notebook giving examples of line...

8
Notebook giving examples of Line Integrals Mathematica 9 Version If you are using Mathematica 8 or earlier, you will need to load in the VectorAnalysis package. In Mathe- matica 9, vector analysis is part of the default kernel but the format for various expressions has changed. If you look at the help page for VectorAnalysis it has in detail what has changed. If you want to run old code (such as this notebook), you can still load in the package and Mathematica will give you a warning but will let all the old formating work. This notebook is written in Mathematica 9 format. See the other notebook for Mathematica 8 or earlier’s format. Sec. 6.8 #5 --- example of line integral Here's the vector F: ff = 8x^2y, - xy^2<; field1 = VectorPlot@ff, 8x, - 1, 5<, 8y, - 1, 3<, VectorScale .25D -2 0 2 4 6 -2 -1 0 1 2 3 4 The first path for the line integral: linea = 81, 1< + s 83, 1< 81 + 3s,1 + s< Slope (here constant) D@linea, sD 83, 1<

Upload: others

Post on 16-Oct-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Notebook giving examples of Line Integralscourses.washington.edu/ph227814/227/A13/notes/LineIntegralsMath9.nb.pdfNotebook giving examples of Line Integrals Mathematica 9 Version If

Notebook giving examples of Line Integrals

Mathematica 9 Version

If you are using Mathematica 8 or earlier, you will need to load in the VectorAnalysis package. In Mathe-

matica 9, vector analysis is part of the default kernel but the format for various expressions has

changed. If you look at the help page for VectorAnalysis it has in detail what has changed. If you want

to run old code (such as this notebook), you can still load in the package and Mathematica will give you

a warning but will let all the old formating work. This notebook is written in Mathematica 9 format. See

the other notebook for Mathematica 8 or earlier’s format.

Sec. 6.8 #5 --- example of line integral

Here's the vector F:

ff = 8x^2 y, -x y^2<;

field1 = VectorPlot@ff, 8x, -1, 5<, 8y, -1, 3<, VectorScale ® .25D

-2 0 2 4 6

-2

-1

0

1

2

3

4

The first path for the line integral:

linea = 81, 1< + s 83, 1<81 + 3 s, 1 + s<

Slope (here constant)

D@linea, sD83, 1<

Page 2: Notebook giving examples of Line Integralscourses.washington.edu/ph227814/227/A13/notes/LineIntegralsMath9.nb.pdfNotebook giving examples of Line Integrals Mathematica 9 Version If

Here's a general and compact way of doing the line integral:

[email protected]@linea, sD �. 8x ® linea@@1DD, y ® linea@@2DD<, 8s, 0, 1<D86

3

This is the path that we have integrated along

Show@field1, Graphics@8Red, Arrow@881, 1<, 84, 2<<D<DD

-2 0 2 4 6

-2

-1

0

1

2

3

4

Second path (in three segments)

lineb1 = 81, y<;[email protected]@lineb1, yD �. x ® 1, 8y, 1, 0<D1

3

lineb2 = 8x, 0<;[email protected]@lineb2, xD �. y ® 0, 8x, 1, 4<D0

lineb3 = 84, y<;[email protected]@lineb3, yD �. x ® 4, 8y, 0, 2<D

-

32

3

Sum leads to a different result than first path:

2 LineIntegralsMath9.nb

Page 3: Notebook giving examples of Line Integralscourses.washington.edu/ph227814/227/A13/notes/LineIntegralsMath9.nb.pdfNotebook giving examples of Line Integrals Mathematica 9 Version If

1 � 3 - 32 � 3

-

31

3

Show@field1, Graphics@8Red, Arrow@881, 1<, 81, 0<, 84, 0<, 84, 2<<D<DD

-2 0 2 4 6

-2

-1

0

1

2

3

4

Evaluate curl F

The format of Curl in

ff3d = 8x^2 y, -x y^2, 0<; Curl@ff3d, 8x, y, z<D90, 0, -x

2- y

2=

Since it does not vanish, work depends on path.

VectorPlot3D@8x^2 y, -x y^2, 0<, 8x, -10, 10<,8y, -10, 10<, 8z, -10, 10<, AxesLabel ® 8x, y, z<D

LineIntegralsMath9.nb 3

Page 4: Notebook giving examples of Line Integralscourses.washington.edu/ph227814/227/A13/notes/LineIntegralsMath9.nb.pdfNotebook giving examples of Line Integrals Mathematica 9 Version If

-10

0

10

x

-10

0

10

y

-10

0

10

z

When you see the vector lines seem to be “swirling” in the same direction, this is a sign of having a non-

zero curl.

Sec. 6.10 #6

Do by brute force:

vv = 8Hx^3 - x^2L y, Hy^3 - 2 y^2 + yL x, z^2 - 1<;

Result agrees with evaluation done in lecture notes using divergence theorem and surface integral:

Integrate@Div@vv, 8x, y, z<D, 8x, 0, 1<, 8y, 0, 1<, 8z, 0, 1<D1

4 LineIntegralsMath9.nb

Page 5: Notebook giving examples of Line Integralscourses.washington.edu/ph227814/227/A13/notes/LineIntegralsMath9.nb.pdfNotebook giving examples of Line Integrals Mathematica 9 Version If

VectorPlot3D@vv, 8x, 0, 1<, 8y, 0, 1<, 8z, 0, 1<, AxesLabel ® 8x, y, z<D

0.0

0.5

1.0

x

0.0

0.5

1.0

y

0.0

0.5

1.0

z

Sec. 6.11 #18

Here's B, which is indeed divergenceless:

bb = 8x^2 - y z + y, x - 2 y z, z^2 - 2 z x + x + y<;

Div@bb, 8x, y, z<D0

LineIntegralsMath9.nb 5

Page 6: Notebook giving examples of Line Integralscourses.washington.edu/ph227814/227/A13/notes/LineIntegralsMath9.nb.pdfNotebook giving examples of Line Integrals Mathematica 9 Version If

VectorPlot3D@bb, 8x, -10, 10<, 8y, -10, 10<, 8z, -10, 10<, AxesLabel ® 8x, y, z<D

-10

0

10

x-10

0

10

y

-10

0

10

z

Checking the answer found in lecture notes:

aa = 80, x z^2 - z x^2 + x^2 � 2 + x y, -x^2 � 2 + 2 x y z - y^2 z � 2 + y^2 � 2<;

6 LineIntegralsMath9.nb

Page 7: Notebook giving examples of Line Integralscourses.washington.edu/ph227814/227/A13/notes/LineIntegralsMath9.nb.pdfNotebook giving examples of Line Integrals Mathematica 9 Version If

VectorPlot3D@aa, 8x, -10, 10<, 8y, -10, 10<, 8z, -10, 10<, AxesLabel ® 8x, y, z<D-10

0

10

x

-10

0

10

y

-10

0

10

z

Curl@aa, 8x, y, z<D9x2 + y - y z, x - 2 y z, x + y - 2 x z + z

2=

Remember that to plot this correctly we need to use Evaluate[ ] on the Curl function, otherwise Mathe-

matica will try to take the curl with respect to numerical values.

LineIntegralsMath9.nb 7

Page 8: Notebook giving examples of Line Integralscourses.washington.edu/ph227814/227/A13/notes/LineIntegralsMath9.nb.pdfNotebook giving examples of Line Integrals Mathematica 9 Version If

VectorPlot3D@Evaluate@Curl@aa, 8x, y, z<DD,8x, -10, 10<, 8y, -10, 10<, 8z, -10, 10<, AxesLabel ® 8x, y, z<D

-10

0

10

x

-10

0

10

y

-10

0

10

z

Curl@aa, 8x, y, z<D - bb

80, 0, 0<

8 LineIntegralsMath9.nb