(*^ ::[ Information = "This is a Mathematica Notebook file. It contains ASCII text, and can be transferred by email, ftp, or other text-file transfer utility. It should be read or edited using a copy of Mathematica or MathReader. If you received this as email, use your mail application or copy/paste to save everything from the line containing (*^ down to the line containing ^*) into a plain text file. On some systems you may have to give the file a name ending with ".ma" to allow Mathematica to recognize it as a Notebook. The line below identifies what version of Mathematica created this file, but it can be opened using any other version as well."; FrontEndVersion = "Macintosh Mathematica Notebook Front End Version 2.2"; MacintoshStandardFontEncoding; fontset = title, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, e8, 24, "Times"; fontset = subtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, e6, 18, "Times"; fontset = subsubtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, italic, e6, 14, "Times"; fontset = section, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, grayBox, M22, bold, a20, 18, "Times"; fontset = subsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, blackBox, M19, bold, a15, 14, "Times"; fontset = subsubsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, whiteBox, M18, bold, a12, 12, "Times"; fontset = text, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 14, "Times"; fontset = smalltext, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 10, "Times"; fontset = input, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeInput, M42, N23, bold, L-5, 12, "Courier"; fontset = output, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-5, 12, "Courier"; fontset = message, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, R65535, L-5, 12, "Courier"; fontset = print, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-5, 12, "Courier"; fontset = info, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, B65535, L-5, 12, "Courier"; fontset = postscript, PostScript, formatAsPostScript, output, inactive, noPageBreakInGroup, nowordwrap, groupLikeGraphics, M7, l48, o6, w400, h145, 12, "Courier"; fontset = name, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, italic, 10, "Geneva"; fontset = header, inactive, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; fontset = leftheader, inactive, L2, 12, "Times"; fontset = footer, inactive, noKeepOnOnePage, preserveAspect, center, M7, 12, "Times"; fontset = leftfooter, inactive, L2, 12, "Times"; fontset = help, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 10, "Times"; fontset = clipboard, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; fontset = completions, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; fontset = special1, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; fontset = special2, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; fontset = special3, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; fontset = special4, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; fontset = special5, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; paletteColors = 128; currentKernel; ] :[font = section; inactive; Cclosed; noPageBreakInGroup; preserveAspect; cellOutline; backColorRed = 58981; backColorGreen = 58981; backColorBlue = 58981; startGroup] Setup: :[font = input; preserveAspect; endGroup] Clear["Global`*"]; Off[ General::spell ]; Off[ General::spell1]; Off[Clear::wrsym]; :[font = section; inactive; Cclosed; noPageBreakInGroup; preserveAspect; cellOutline; backColorRed = 58981; backColorGreen = 58981; backColorBlue = 58981; startGroup] Load Packages: :[font = input; preserveAspect; endGroup] Needs["LinearAlgebra`Orthogonalization`"] Needs["Calculus`VectorAnalysis`"] Needs["Graphics`PlotField`"] Needs["Graphics`PlotField3D`"] :[font = section; inactive; Cclosed; noPageBreakInGroup; preserveAspect; cellOutline; backColorRed = 58981; backColorGreen = 58981; backColorBlue = 58981; startGroup] Initialization: Define Home-made: VectorPlot, VectorPlot3D VectorLength :[font = input; preserveAspect] Unprotect[{VectorPlot,VectorPlot3D,VectorLength}]; :[font = input; preserveAspect] VectorPlot[list__List?VectorQ]:= VectorPlot[{list}]; VectorPlot[list_List?MatrixQ]:= Module[{length,totList}, length=Length[list]; totList=Table[{{0,0},list[[i]]} ,{i,1,length}]; Return[ Show[Graphics[{Thickness[0.015],Line /@ totList } ,{GridLines->Automatic ,Axes->True ,AspectRatio->1}]] ] ]; :[font = input; preserveAspect] VectorPlot3D[list__List?VectorQ]:= VectorPlot3D[{list}]; VectorPlot3D[list_List?MatrixQ]:= Module[{length,totList}, length=Length[list]; totList=Table[{{0,0,0},list[[i]]} ,{i,1,length}]; Return[ Show[Graphics3D[{Thickness[0.015],Line /@ totList} ,{ FaceGrids->{{0,0,-1},{0,1,0},{-1,0,0}} ,BoxRatios->{1,1,1} ,Axes->True}]] ] ]; :[font = input; preserveAspect] VectorLength[vector_List?VectorQ]:=Sqrt[vector.vector] :[font = input; preserveAspect; endGroup] Protect[{VectorPlot,VectorPlot3D,VectorLength}]; :[font = section; inactive; Cclosed; noPageBreakInGroup; preserveAspect; cellOutline; backColorRed = 58981; backColorGreen = 58981; backColorBlue = 58981; startGroup] Example 1: Plotting and adding vectors :[font = text; inactive; preserveAspect] This is a simple exercise to help the student see the relationship between the graphical and analytic representation of vectors. The exercise is to plot {a,b,c}, and estimate the result BEFORE plotting {d}. :[font = input; preserveAspect] Clear["Global`*"] :[font = input; preserveAspect] a= 3 {Cos[ 30 Degree],Sin[ 30 Degree]} //N b= 5 {Cos[ 50 Degree],Sin[ 50 Degree]} //N c= 7 {Cos[170 Degree],Sin[170 Degree]} //N VectorLength /@ {a,b,c} :[font = input; preserveAspect] d=a+b+c :[font = input; preserveAspect; endGroup] VectorPlot[a,b,c,d]; :[font = section; inactive; Cclosed; noPageBreakInGroup; preserveAspect; cellOutline; backColorRed = 58981; backColorGreen = 58981; backColorBlue = 58981; startGroup] Example 2: Dot and Cross products of vectors :[font = text; inactive; preserveAspect] This is a simple exercise in computing vector products, both scalar and vector. :[font = input; preserveAspect] Clear["Global`*"] :[font = text; inactive; preserveAspect] Given the following vectors, we compute requested quantities. :[font = input; preserveAspect] a={3,2,-1}; b={1,2, 3}; c={1,0, 1}; :[font = subsection; inactive; noPageBreakInGroup; preserveAspect] Part a) :[font = input; preserveAspect] {a.b, a.c, b.c} :[font = subsection; inactive; noPageBreakInGroup; preserveAspect] Part b) :[font = input; preserveAspect] {CrossProduct[a,b] ,CrossProduct[a,c] ,CrossProduct[b,c] } :[font = input; preserveAspect] {CrossProduct[b,a] ,CrossProduct[c,a] ,CrossProduct[c,b] } :[font = subsection; inactive; noPageBreakInGroup; preserveAspect] Part c) :[font = input; preserveAspect] ArcCos[a.b /(VectorLength[a] VectorLength[b]) ]/Degree //N :[font = input; preserveAspect] ArcCos[b.c /(VectorLength[b] VectorLength[c]) ]/Degree //N :[font = input; preserveAspect] ArcCos[a.c /(VectorLength[a] VectorLength[c]) ]/Degree //N :[font = subsection; inactive; noPageBreakInGroup; preserveAspect] Part d) :[font = input; preserveAspect] (a+b).c :[font = subsection; inactive; noPageBreakInGroup; preserveAspect] Part e) :[font = input; preserveAspect] {a.CrossProduct[b,c] ,b.CrossProduct[c,a] ,c.CrossProduct[a,b] } :[font = subsection; inactive; noPageBreakInGroup; preserveAspect] Part f) :[font = input; preserveAspect; endGroup] {CrossProduct[a,CrossProduct[b,c] ] ,CrossProduct[b,CrossProduct[c,a] ] ,CrossProduct[c,CrossProduct[a,b] ] } :[font = section; inactive; Cclosed; noPageBreakInGroup; preserveAspect; cellOutline; backColorRed = 58981; backColorGreen = 58981; backColorBlue = 58981; startGroup] Example 3: Gradient of a scalar field :[font = text; inactive; preserveAspect] This exercise shows the students the relationship between a scalar function and the gradient. :[font = input; preserveAspect] Clear["Global`*"] :[font = input; preserveAspect] phi= -( x^2+y^2 ); :[font = input; preserveAspect] Plot3D[ phi ,{x,-1,1} ,{y,-1,1} ,BoxRatios->{1,1,1} ]; :[font = input; preserveAspect] ContourPlot[ phi ,{x,-1,1} ,{y,-1,1} ]; :[font = input; preserveAspect] PlotGradientField[ phi ,{x,-1,1} ,{y,-1,1} ,VectorHeads->True ,PlotPoints->8 ,Axes->True ]; :[font = text; inactive; preserveAspect] Having seen the picture of the gradient field, we compute the analytic result, and compare with the figure. :[font = input; preserveAspect] Grad[phi] :[font = input; preserveAspect] Grad[phi][[{1,2}]] :[font = input; preserveAspect] PlotVectorField[ Grad[phi][[{1,2}]] //Evaluate ,{x,-1,1} ,{y,-1,1} ,VectorHeads->True ,PlotPoints->8 ,Axes->True ]; :[font = text; inactive; preserveAspect] Here is a 3-D version. :[font = input; preserveAspect] phi= -( x^2+y^2+z^2 ); :[font = input; preserveAspect; endGroup] PlotGradientField3D[ phi ,{x,0,1} ,{y,0,1} ,{z,0,1} ,VectorHeads->True ,PlotPoints->4 ,Axes->True ]; :[font = section; inactive; Cclosed; noPageBreakInGroup; preserveAspect; cellOutline; backColorRed = 58981; backColorGreen = 58981; backColorBlue = 58981; startGroup] Example 4: Divergence of a vector field I :[font = text; inactive; preserveAspect] This is a function that has a non-zero divergence. Again, this allows the students to gain an intuitive feeling for the vector calculus operations. :[font = input; preserveAspect] Clear["Global`*"] :[font = input; preserveAspect] v={x,0}; :[font = input; preserveAspect] Div[{x,0,0}] (* needs to be 3-D for Mathematica *) ;[s] 3:0,0;37,1;48,0;52,-1; 2:2,12,10,Courier,1,12,0,0,0;1,12,10,Courier,3,12,0,0,0; :[font = input; preserveAspect; endGroup] PlotVectorField[v ,{x,-1,1} ,{y,-1,1} ,PlotPoints->8 ]; :[font = section; inactive; Cclosed; noPageBreakInGroup; preserveAspect; cellOutline; backColorRed = 58981; backColorGreen = 58981; backColorBlue = 58981; startGroup] Example 5: Divergence of a vector field II :[font = text; inactive; preserveAspect] In contrast to the above, this is a function that has a zero divergence. Again, this allows the students to gain an intuitive feeling for the vector calculus operations. :[font = input; preserveAspect] Clear["Global`*"] :[font = input; preserveAspect] v={1,2}; :[font = input; preserveAspect] Div[{1,2,0}] (* needs to be 3-D for Mathematica *) ;[s] 3:0,0;37,1;48,0;52,-1; 2:2,12,10,Courier,1,12,0,0,0;1,12,10,Courier,3,12,0,0,0; :[font = input; preserveAspect; endGroup] PlotVectorField[v ,{x,-1,1} ,{y,-1,1} ,PlotPoints->8 ]; :[font = section; inactive; Cclosed; noPageBreakInGroup; preserveAspect; cellOutline; backColorRed = 58981; backColorGreen = 58981; backColorBlue = 58981; startGroup] Example 6: {Div,Curl}={0,-2} :[font = text; inactive; preserveAspect] Here is a function that has a non-zero curl and zero divergence. :[font = input; preserveAspect] Clear["Global`*"] :[font = input; preserveAspect] v={y,-x,0}; :[font = input; preserveAspect] Div[v] :[font = input; preserveAspect] Curl[v] :[font = input; preserveAspect] PlotVectorField[v[[{1,2}]] ,{x,-1,1} ,{y,-1,1} ,PlotPoints->8 ]; :[font = text; inactive; preserveAspect] Here is a 3-D rendering. :[font = input; preserveAspect; endGroup] PlotVectorField3D[v ,{x,-1,1} ,{y,-1,1} ,{z,-1,1} ,PlotPoints->3 ,VectorHeads->True ,ViewPoint->{1,2,4} ]; :[font = section; inactive; Cclosed; noPageBreakInGroup; preserveAspect; cellOutline; backColorRed = 58981; backColorGreen = 58981; backColorBlue = 58981; startGroup] Example 7: {Div,Curl}={2,0} :[font = text; inactive; preserveAspect] Here is a function that has a zero curl and non-zero divergence. :[font = input; preserveAspect] Clear["Global`*"] :[font = input; preserveAspect] v={x,y,0}; :[font = input; preserveAspect] Div[v] :[font = input; preserveAspect] Curl[v] :[font = input; preserveAspect] PlotVectorField[v[[{1,2}]] ,{x,-1,1} ,{y,-1,1} ,PlotPoints->8 ]; :[font = text; inactive; preserveAspect] Here is a 3-D rendering. :[font = input; preserveAspect; endGroup] PlotVectorField3D[v ,{x,-1,1} ,{y,-1,1} ,{z,-1,1} ,PlotPoints->3 ,VectorHeads->True ,ViewPoint->{1,2,4} ]; :[font = section; inactive; noPageBreakInGroup; preserveAspect; cellOutline; backColorRed = 58981; backColorGreen = 58981; backColorBlue = 58981; startGroup] Problem 8: {Div,Curl}={2,1} :[font = text; inactive; Cclosed; preserveAspect; fontColorRed = 65535; startGroup] Can you find a function that has a zero curl and non-zero divergence. :[font = input; preserveAspect] Clear["Global`*"] :[font = input; preserveAspect] v={0,0,0}; :[font = input; preserveAspect] Div[v] :[font = input; preserveAspect] Curl[v] :[font = input; preserveAspect] PlotVectorField[v[[{1,2}]] ,{x,-1,1} ,{y,-1,1} ,PlotPoints->8 ]; :[font = text; inactive; preserveAspect] Here is a 3-D rendering. :[font = input; preserveAspect; endGroup; endGroup] PlotVectorField3D[v ,{x,-1,1} ,{y,-1,1} ,{z,-1,1} ,PlotPoints->3 ,VectorHeads->True ,ViewPoint->{1,2,4} ]; ^*)