(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 7.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 76445, 1924] NotebookOptionsPosition[ 69319, 1737] NotebookOutlinePosition[ 72401, 1815] CellTagsIndexPosition[ 71802, 1800] WindowTitle->Lecture 16 MIT 3.016 (Fall 2009) \251 W. Craig Carter \ 2003--2009 WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[TextData[{ "Generalizations of the Fundamental Theorem of Calculus (Part II)\n", StyleBox["(note: some of the symbolic integrations in this notebook will \ take a long time to evaluate)", FontSize->18, FontColor->GrayLevel[0.666667]] }], "Title", CellTags->"mmtag:16:divergence_theorem"], Cell[CellGroupData[{ Cell[TextData[{ "Using Divergence theorem to find Hamaker Field (here modeled as \ point-wise", Cell[BoxData[ FormBox[ FractionBox["1", SuperscriptBox["r", "6"]], TraditionalForm]]], ") for a Finite Body" }], "Subtitle", CellChangeTimes->{{3.401203802085453*^9, 3.4012038226742573`*^9}}], Cell[TextData[{ "The induced dipole\[LongDash]dipole interaction goes as -1/", Cell[BoxData[ FormBox[ SuperscriptBox["r", "6"], TraditionalForm]]], ", and it is this term which shows up in the Lennard-Jones potential. This \ dipole-dipole interaction gives rise to the Hamaker forces between two \ bodies. As a first approximation to the interaction between two bodies, one \ must intergrate 1/", Cell[BoxData[ FormBox[ SuperscriptBox["r", "6"], TraditionalForm]]], " from a single point in the first body to all points in the second body. \ The net interaction energy is the sum over all such points and therefore this \ energy produces a six-dimensional integration. There are a few cases, such a \ two spheres, a sphere and a seminfinite half-space, that can be worked out \ exactly. However, to model the interaction energy of more complex shapes, \ there are no closed-form solutions and one must resort to numerical \ integration.\n\nNumerical integration is a cpu-time-consuming numerical \ procedure\[LongDash]a six dimensional integration can be very expensive (time \ is money). If there is a way to reduce the dimensionality of the \ integration, then we can reap rewards for our cleverness. One trick is to \ use the divergence theorem to push the integration over a volume, to an \ integration over a surface. For example, we could use the divergence theorem:\ \n\[Integral]\[Integral]\[Integral]", Cell[BoxData[ FormBox[ SubscriptBox[" ", "volume"], TraditionalForm]]], " \[Del]\[CenterDot] ", Cell[BoxData[ FormBox[ OverscriptBox["P", "\[RightVector]"], TraditionalForm]]], " dV = \[Integral]\[Integral]", Cell[BoxData[ FormBox[ SubscriptBox[" ", "surface"], TraditionalForm]]], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{ OverscriptBox["P", "\[RightVector]"], "\[CenterDot]", "d"}], OverscriptBox["A", "\[RightVector]"]}], TraditionalForm]]], "\nWe will work out such an example for a cylindrical volume interacting \ with a point in space, in other words, the London Interaction Potential for a \ finite cylinder. We will perform as many exact integrals as possible and \ reduce the cost of the numerical integration. To do this, we must find a \ vector potential ", Cell[BoxData[ FormBox[ OverscriptBox["P", "\[RightVector]"], TraditionalForm]]], " such that \[Del]\[CenterDot] ", Cell[BoxData[ FormBox[ OverscriptBox["P", "\[RightVector]"], TraditionalForm]]], " = -1/|", Cell[BoxData[ FormBox[ RowBox[{ RowBox[{ OverscriptBox["r", "\[RightVector]"], "-", OverscriptBox["x", "\[RightVector]"]}], SuperscriptBox["|", "6"]}], TraditionalForm]]], " where ", Cell[BoxData[ FormBox[ OverscriptBox["r", "\[RightVector]"], TraditionalForm]]], " is a position in the integrated volume and ", Cell[BoxData[ FormBox[ OverscriptBox["x", "\[RightVector]"], TraditionalForm]]], " is a point at which the potential is measured. (A fairly general method \ to do this and similar problems can be found in ", StyleBox["Argento C; Jagota A; Carter WC", FontSize->12], StyleBox[" ``", FontSize->12, FontWeight->"Bold"], StyleBox["Surface formulation for molecular interactions of macroscopic \ bodies'' J.Mech. Physics Solids 1997, pp 1161-1183 .", FontSize->12] }], "Text", CellChangeTimes->{{3.401101033924312*^9, 3.4011013057166777`*^9}, { 3.40110150288204*^9, 3.4011017534761763`*^9}, {3.4011018430699043`*^9, 3.401101951564242*^9}, {3.4011020282457848`*^9, 3.4011022694496613`*^9}, { 3.401102305062665*^9, 3.401102653909244*^9}, {3.4018013105330353`*^9, 3.401801324631115*^9}}], Cell["\<\ The following is a ``guess'' at the vector potential; it will be verified as \ the correct one by checking its divergence. We use (CX,CY,CZ) to represent \ points in the cylinder and (X,Y,Z) to be points in space\ \>", "Text", CellChangeTimes->{{3.401102658292955*^9, 3.4011026967723513`*^9}}], Cell[BoxData[ RowBox[{"PVecLondon", " ", "=", " ", RowBox[{ FractionBox["1", RowBox[{"3", SuperscriptBox[ RowBox[{"(", RowBox[{ SuperscriptBox[ RowBox[{"(", RowBox[{"CX", "-", "X"}], ")"}], "2"], " ", "+", SuperscriptBox[ RowBox[{"(", RowBox[{"CY", "-", "Y"}], ")"}], "2"], " ", "+", " ", SuperscriptBox[ RowBox[{"(", RowBox[{"CZ", "-", "Z"}], ")"}], "2"]}], ")"}], "3"]}]], RowBox[{"{", RowBox[{ RowBox[{"CX", "-", "X"}], ",", " ", RowBox[{"CY", "-", "Y"}], ",", " ", RowBox[{"CZ", "-", "Z"}]}], "}"}]}]}]], "Input", CellChangeTimes->{{3.4004212194146967`*^9, 3.400421224326539*^9}, { 3.4004934203858643`*^9, 3.40049342667204*^9}, {3.401102704550758*^9, 3.401102745878992*^9}, 3.40110279695992*^9}, CellTags->"mmtag:16:London_interaction__vector_potential"], Cell[BoxData[ RowBox[{"Needs", "[", "\"\\"", "]"}]], "Input", CellChangeTimes->{{3.400158911341324*^9, 3.400158921523077*^9}, 3.400159673820537*^9}], Cell["\<\ The following verifies that the correct vector potential is obtained, the \ divergence must be taked with respect to the coodinates of the integration:\ \>", "Text", CellChangeTimes->{{3.401102751788986*^9, 3.4011027723163443`*^9}}], Cell[BoxData[ RowBox[{"FullSimplify", "[", RowBox[{"Div", "[", RowBox[{"PVecLondon", ",", RowBox[{"Cartesian", "[", RowBox[{"CX", ",", "CY", ",", "CZ"}], "]"}]}], "]"}], "]"}]], "Input", CellTags->"mmtag:16:Div[]"], Cell["\<\ We will integrate over a cylinder of radius R and length L along the z-axis, \ with its middle at the origin. First, let's use the radius of the cylinder \ to scale all the length variables: Let (X,Y,Z)/R = (x,y,z); (CX,CY,CZ)/R = \ (cx,cy,cz), and L/R = \[Lambda] (the cylinder's aspect ratio).\ \>", "Text", CellChangeTimes->{{3.4011048847127037`*^9, 3.401104930188787*^9}, { 3.4011049783727627`*^9, 3.401105082223508*^9}, {3.401105380294722*^9, 3.401105420437128*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"ScaleRules", "=", RowBox[{"{", RowBox[{ RowBox[{"X", "\[Rule]", RowBox[{"x", " ", "R"}]}], ",", " ", RowBox[{"Y", "\[Rule]", " ", RowBox[{"y", " ", "R"}]}], ",", " ", RowBox[{"Z", "\[Rule]", " ", RowBox[{"z", " ", "R"}]}], ",", " ", RowBox[{"CX", "\[Rule]", " ", RowBox[{"cx", " ", "R"}]}], ",", " ", RowBox[{"CY", "\[Rule]", " ", RowBox[{"cy", " ", "R"}]}], ",", " ", RowBox[{"CZ", "\[Rule]", " ", RowBox[{"cz", " ", "R"}]}]}], "}"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"PvecR5", " ", "=", " ", RowBox[{"FullSimplify", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"R", "^", "5"}], " ", "PVecLondon"}], "/.", "ScaleRules"}], ",", RowBox[{"Assumptions", "->", RowBox[{"R", ">", " ", "0"}]}]}], "]"}]}]}], "Input", CellChangeTimes->{{3.401105111479703*^9, 3.40110519904066*^9}, { 3.4011052332317038`*^9, 3.401105360968697*^9}}], Cell[TextData[{ "Therefore, \[Phi](", Cell[BoxData[ FormBox[ OverscriptBox["x", "\[RightVector]"], TraditionalForm]]], ") = \[Integral]\[Integral]\[Integral]", Cell[BoxData[ FormBox[ SubscriptBox[" ", "volume"], TraditionalForm]]], " ", Cell[BoxData[ FormBox[ FractionBox[ RowBox[{"-", "1"}], SuperscriptBox[ RowBox[{"(", RowBox[{ OverscriptBox["r", "\[Rule]"], "-", OverscriptBox["x", "\[Rule]"]}], ")"}], "6"]], TraditionalForm]]], " dV = \[Integral]\[Integral]", Cell[BoxData[ FormBox[ SubscriptBox[" ", "surface"], TraditionalForm]]], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{ OverscriptBox["PVecLondon", "\[RightVector]"], "\[CenterDot]", "d"}], OverscriptBox["A", "\[RightVector]"]}], TraditionalForm]]], " = (\[Integral]\[Integral]", Cell[BoxData[ FormBox[ SubscriptBox[" ", RowBox[{"cylinder", "\[IndentingNewLine]", "surface"}]], TraditionalForm]]], Cell[BoxData[ FormBox[" ", TraditionalForm]]], Cell[BoxData[ FormBox[ RowBox[{" ", RowBox[{ OverscriptBox["PVecR5", "\[RightVector]"], "\[Bullet]", RowBox[{"\[DifferentialD]", OverscriptBox["A", "\[Rule]"]}]}]}], TraditionalForm]]], " + \[Integral]\[Integral]", Cell[BoxData[ FormBox[ SubscriptBox[" ", RowBox[{"cylinder", "\[IndentingNewLine]", "ends"}]], TraditionalForm]]], Cell[BoxData[ FormBox[" ", TraditionalForm]]], " ", Cell[BoxData[ FormBox[ RowBox[{ FormBox[" ", TraditionalForm], RowBox[{ OverscriptBox["PVecR5", "\[RightVector]"], "\[Bullet]", RowBox[{"\[DifferentialD]", OverscriptBox["A", "\[Rule]"]}]}]}], TraditionalForm]]], ")/", Cell[BoxData[ FormBox[ SuperscriptBox["R", "5"], TraditionalForm]]], "\n is the total interaction between a point an a cylinder. We can exploit \ the symmetry of the cylinder: we know that the potential will be indendent of \ the angular coordinate in cylindrical coordinates; it will be a function of \ \[Rho] = ", Cell[BoxData[ FormBox[ SqrtBox[ RowBox[{ RowBox[{"x", "^", "2"}], "+", " ", RowBox[{"y", "^", "2"}]}]], TraditionalForm]]], "and z.\n " }], "Text", CellChangeTimes->{{3.400494950332245*^9, 3.400495363469721*^9}, { 3.4011048607327013`*^9, 3.4011048710024776`*^9}, {3.4011054577152433`*^9, 3.401105655784357*^9}, {3.401105725396999*^9, 3.40110587034892*^9}}], Cell[TextData[{ "We will do three integrals over the cylindrical surfaces using this \ expression to define the cylinder: (cx,cy,cz) = (Cos[\[Theta]], \ Sin[\[Theta]], cz):\nThe cylindrical surface is the domain \[Theta] \ \[Element] (0, 2\[Pi]), cz \[Element] (-", Cell[BoxData[ FormBox[ FractionBox["\[Lambda]", "2"], TraditionalForm]]], " , ", Cell[BoxData[ FormBox[ FractionBox["\[Lambda]", "2"], TraditionalForm]]], ")\nThe two caps r \[Element] (0,1), \[Theta] \[Element] (0, 2\[Pi]), cz=\ \[PlusMinus]", Cell[BoxData[ FormBox[ FractionBox["\[Lambda]", "2"], TraditionalForm]]] }], "Text", CellChangeTimes->{{3.400495371790447*^9, 3.4004954381664743`*^9}, { 3.401105879600021*^9, 3.4011059941422787`*^9}, {3.401106026584442*^9, 3.4011060631711187`*^9}}, CellTags->"mmtag:16:integral__over_cylinder"] }, Open ]], Cell[CellGroupData[{ Cell["Cylinder Surface Normals and Integrands", "Subtitle", CellChangeTimes->{{3.401802160809857*^9, 3.401802166035767*^9}}], Cell["\<\ The following is a parametric representation of a cylinder surface that is \ coaxial with the z-axis (the cylinder ends will be included later)\ \>", "Text"], Cell[BoxData[ RowBox[{"CylSurf", " ", "=", " ", RowBox[{"{", " ", RowBox[{ RowBox[{"Cos", "[", "\[Theta]", "]"}], ",", " ", RowBox[{"Sin", "[", "\[Theta]", "]"}], ",", "cz"}], "}"}]}]], "Input", CellChangeTimes->{{3.40015908743699*^9, 3.400159095289452*^9}, { 3.40042109103236*^9, 3.4004210928935537`*^9}, {3.400421165712181*^9, 3.400421166485668*^9}, {3.400493409641685*^9, 3.400493438506864*^9}, { 3.4011060800323553`*^9, 3.401106088105014*^9}}], Cell[TextData[{ "The infinitessimal surface vectors ", Cell[BoxData[ FormBox[ OverscriptBox[ SubscriptBox["R", "u"], "\[RightVector]"], TraditionalForm]]], " and ", Cell[BoxData[ FormBox[ OverscriptBox[ SubscriptBox["R", "v"], "\[RightVector]"], TraditionalForm]]], " for the cylinder surface are obtained by differentiation; they will be \ used to find the surface patch d", Cell[BoxData[ FormBox[ OverscriptBox["A", "\[Rule]"], TraditionalForm]]], "." }], "Text"], Cell[BoxData[{ RowBox[{"CylSurfR\[Theta]", " ", "=", " ", RowBox[{"D", "[", RowBox[{"CylSurf", ",", "\[Theta]"}], "]"}]}], "\[IndentingNewLine]", RowBox[{"CylSurfRcz", " ", "=", " ", RowBox[{"D", "[", RowBox[{"CylSurf", ",", "cz"}], "]"}]}], "\[IndentingNewLine]"}], "Input", CellChangeTimes->{{3.4001591023879642`*^9, 3.400159105003772*^9}, { 3.4001594619733553`*^9, 3.400159507875945*^9}, 3.4004210980939617`*^9, { 3.400421171933857*^9, 3.400421173901873*^9}, 3.400493406577574*^9, { 3.400493440767088*^9, 3.4004934420310087`*^9}, {3.401106099462508*^9, 3.401106103750139*^9}}], Cell[TextData[{ "The surface normal given by ", Cell[BoxData[ FormBox[ OverscriptBox[ SubscriptBox["R", "u"], "\[RightVector]"], TraditionalForm]]], " \[Times] ", Cell[BoxData[ FormBox[ OverscriptBox[ SubscriptBox["R", "v"], "\[RightVector]"], TraditionalForm]]], " for the cylinder surface, there for the following (multiplied by d\[Theta] \ dz) is the infinitessimal oriented surface patch d", Cell[BoxData[ FormBox[ OverscriptBox["A", "\[Rule]"], TraditionalForm]]], "." }], "Text", CellTags->"mmtag:16:surface_normal__example"], Cell[BoxData[ RowBox[{"NormalVecCylSurf", " ", "=", " ", RowBox[{"Cross", "[", RowBox[{"CylSurfR\[Theta]", ",", "CylSurfRcz"}], "]"}]}]], "Input", CellChangeTimes->{{3.400159514934654*^9, 3.400159527398931*^9}, { 3.401106124111902*^9, 3.401106124838097*^9}}, CellTags->"mmtag:16:Cross[]"], Cell["\<\ The integrand to be evaluated over the cylinder surface is the vector \ potential, dotted into the normal vector. Because of the cylindrical \ symmetry of this model, we can convert to cylindrical coordinates. One set \ of coordinates is for the cylinder surface (\[Xi] \[Rule] R Cos[\[Theta]], \ \[Eta] \[Rule] R Sin[\[Theta]]) for fixed radius R (which is a model \ parameter) and another set of coordinates for where we will be testing the \ potential (x \[Rule] \[Rho] Cos[\[Alpha]], y \[Rule] \[Rho] Sin[\[Alpha]]). \ Because the potential must be independent of \[Alpha], we might as well set \ it to zero.\ \>", "Text", CellChangeTimes->{{3.400493133999982*^9, 3.400493229829688*^9}, { 3.4004933143818417`*^9, 3.400493390175346*^9}, {3.4008402935949802`*^9, 3.400840352338468*^9}}], Cell[BoxData[ RowBox[{"CylinderIntegrandd\[Theta]d\[Zeta]", " ", "=", " ", RowBox[{"FullSimplify", "[", RowBox[{ RowBox[{"(", RowBox[{"PvecR5", "/.", RowBox[{"{", RowBox[{ RowBox[{"cx", "\[Rule]", RowBox[{"Cos", "[", "\[Theta]", "]"}]}], ",", " ", RowBox[{"cy", "\[Rule]", " ", RowBox[{"Sin", "[", "\[Theta]", "]"}]}], ",", RowBox[{"x", "\[Rule]", " ", "\[Rho]"}], " ", ",", RowBox[{"y", "\[Rule]", "0"}]}], "}"}]}], ")"}], ".", "NormalVecCylSurf"}], "]"}]}]], "Input", CellChangeTimes->{{3.400159114372514*^9, 3.400159124268149*^9}, { 3.400421110438608*^9, 3.4004211128225107`*^9}, {3.4004237052849903`*^9, 3.400423738850863*^9}, {3.4004934537850447`*^9, 3.4004934846166162`*^9}, { 3.400497373562804*^9, 3.4004973834656487`*^9}, {3.400840361390383*^9, 3.400840365724996*^9}, {3.4011061438881617`*^9, 3.401106214399485*^9}}], Cell[TextData[{ "We have a choice whether to integrate over cz \[Element] (-", Cell[BoxData[ FormBox[ FractionBox["\[Lambda]", "2"], TraditionalForm]]], " , ", Cell[BoxData[ FormBox[ FractionBox["\[Lambda]", "2"], TraditionalForm]]], ") or \[Theta] \[Element] (0, 2\[Pi]) first. If we can a closed form for \ the cylinder surface over cz and then the cylinder end over r, then we can \ integrate the sum of these over \[Theta] together." }], "Text", CellChangeTimes->{{3.401106266914538*^9, 3.401106415404826*^9}}], Cell[TextData[{ "Try and see if we can do one of the two integrals---we have a choice of \ integrating over \[Theta] or (\[Zeta] for the cylinder sides, and R) for the \ cylinder ends. We find a closed form for integrating \[Zeta] for the sides \ and R for the top, and then subsequently numerically integrate \[Theta] for \ (0,2 \[Pi]).\n\n\n", StyleBox["This will take a while to finish, even on a very fast machine (as \ of 2007, one minute to do the integral and about 6 hours minutes to simplify \ the expression).", FontColor->RGBColor[1, 0, 0]], "\nFor this reason, I' ve set up an option to read the result over the web, \ instead of having each of your computers spend time on a previously computed \ result:\n", StyleBox["(NOTE: As of ", FontColor->RGBColor[0., 0.5019607843137255, 0.]], StyleBox["Mathematica", FontSlant->"Italic", FontColor->RGBColor[0., 0.5019607843137255, 0.]], StyleBox[" 6.01 Oct. 2007, If we first try the definite integral over \ \[Theta] \[Element] (0, 2 \[Pi]) , we get ZERO which is an incorrect result \ (I will include a discussion of why it is incorrect in the future))", FontColor->RGBColor[0., 0.5019607843137255, 0.]] }], "Text", CellChangeTimes->{{3.4002319995735292`*^9, 3.400232043499716*^9}, { 3.400233469148468*^9, 3.400233495812017*^9}, {3.4002415669434013`*^9, 3.400241578205146*^9}, 3.400249142551711*^9, {3.400495707824164*^9, 3.4004958706059723`*^9}, {3.400496146521645*^9, 3.400496148415059*^9}, { 3.4005008868415527`*^9, 3.400500925495022*^9}, {3.400501158303357*^9, 3.4005011857273607`*^9}, {3.400683103216076*^9, 3.400683139174238*^9}, { 3.400683326736738*^9, 3.400683328846416*^9}, {3.400683363796349*^9, 3.400683492806395*^9}, {3.400683525351635*^9, 3.400683568497197*^9}, 3.401106437400935*^9, {3.401106722286653*^9, 3.4011067458691263`*^9}, { 3.401106805318446*^9, 3.4011068153413258`*^9}, 3.4011104433056593`*^9, 3.4016438984934473`*^9}] }, Open ]], Cell[CellGroupData[{ Cell["Integrating over the Cylinder's Surface", "Subtitle", CellChangeTimes->{{3.401802160809857*^9, 3.401802166035767*^9}, { 3.4018026260486517`*^9, 3.40180265199116*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"UpperPlane", "=", RowBox[{"{", RowBox[{ RowBox[{"\[Lambda]", ">", " ", "0"}], ",", RowBox[{"\[Rho]", ">", "0"}], ",", " ", RowBox[{"z", ">", "0"}], " ", ",", RowBox[{"0", " ", "<", " ", "\[Theta]", "<", " ", RowBox[{"2", " ", "\[Pi]"}]}]}], "}"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{"CylinderIntegrandUpperZd\[Theta]", "=", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"ChoiceDialog", "[", RowBox[{ "\"\\"", ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"\"\\"", "\[Rule]", "True"}], ",", RowBox[{"\"\\"", "\[Rule]", "False"}]}], "}"}]}], "]"}], ",", RowBox[{ "Import", "[", "\"\\ \"", "]"}], ",", RowBox[{"FullSimplify", "[", RowBox[{ RowBox[{"Integrate", "[", RowBox[{"CylinderIntegrandd\[Theta]d\[Zeta]", ",", RowBox[{"{", RowBox[{"cz", ",", RowBox[{ RowBox[{"-", "\[Lambda]"}], "/", "2"}], ",", RowBox[{"\[Lambda]", "/", "2"}]}], "}"}], " ", ",", " ", RowBox[{"Assumptions", "\[Rule]", "UpperPlane"}]}], "]"}], ",", RowBox[{"Assumptions", "\[Rule]", "UpperPlane"}]}], "]"}]}], "]"}]}]}], "Input"], Cell["\<\ Here we restrict z to the upper half-space. We will treat z=0 below.\ \>", "Text", CellChangeTimes->{{3.400680870436802*^9, 3.400680896653792*^9}}], Cell["\<\ Here is the limit of the integral for z> 0 (CylinderIntegrandd\[Theta]) in \ the limit as z \[Rule] 0.\ \>", "Text", CellChangeTimes->{{3.400680930487515*^9, 3.40068098507955*^9}}], Cell[BoxData[ RowBox[{"CylinderIntegrandd\[Theta]ZeroLimit", " ", "=", RowBox[{"FullSimplify", "[", RowBox[{"Limit", "[", RowBox[{"CylinderIntegrandUpperZd\[Theta]", ",", RowBox[{"z", "\[Rule]", " ", "0"}]}], "]"}], "]"}], " "}]], "Input", CellChangeTimes->{{3.400673018962929*^9, 3.4006730197976027`*^9}, { 3.4006753513600893`*^9, 3.400675363557886*^9}, {3.400675406791761*^9, 3.400675420727447*^9}, {3.400676226610018*^9, 3.400676231487054*^9}, { 3.401190892340507*^9, 3.401190911891436*^9}, {3.401191189810955*^9, 3.40119119051336*^9}, {3.40170947756847*^9, 3.401709487368327*^9}, 3.401725015608736*^9}], Cell[TextData[{ "Here is the limit of the integral z=0, it is not obvious that the limit \ and its value at z=0 are the same. ", StyleBox["(the following evaluation will take about 10-20 seconds)", FontColor->RGBColor[1, 0, 0]] }], "Text", CellChangeTimes->{{3.400680930487515*^9, 3.40068098507955*^9}, { 3.400681029255867*^9, 3.400681062870034*^9}, {3.401191218626625*^9, 3.401191233471918*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"FewerAssumptions", "=", " ", RowBox[{"{", " ", RowBox[{ RowBox[{"R", " ", ">", " ", "0"}], " ", ",", " ", RowBox[{"\[Lambda]", ">", " ", "0"}], ",", RowBox[{"\[Rho]", ">", " ", "0"}], ",", " ", RowBox[{"0", "<", " ", "\[Theta]", " ", "<", " ", RowBox[{"2", " ", "\[Pi]"}]}]}], "}"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{"CylinderIntegrandAtZerod\[Theta]", "=", RowBox[{"Integrate", "[", RowBox[{ RowBox[{"Evaluate", "[", RowBox[{"CylinderIntegrandd\[Theta]d\[Zeta]", "/.", RowBox[{"z", "\[Rule]", "0"}]}], "]"}], ",", RowBox[{"{", RowBox[{"cz", ",", RowBox[{ RowBox[{"-", "\[Lambda]"}], "/", "2"}], ",", RowBox[{"\[Lambda]", "/", "2"}]}], "}"}], " ", ",", " ", RowBox[{"Assumptions", "\[Rule]", "FewerAssumptions"}]}], "]"}]}]}], "Input"], Cell["\<\ The limit as z -> 0 and the integrand at z = 0 are the same, so we can use a \ single integrand\ \>", "Text", CellChangeTimes->{{3.401191322729905*^9, 3.401191355390726*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"CylinderIntegrandd\[Theta]", "[", RowBox[{"dist_", ",", "height_", ",", " ", "AspectRat_"}], "]"}], ":=", " ", RowBox[{"Evaluate", "[", RowBox[{"CylinderIntegrandUpperZd\[Theta]", "/.", RowBox[{"{", RowBox[{ RowBox[{"\[Rho]", "\[Rule]", "dist"}], ",", " ", RowBox[{"z", " ", "\[Rule]", " ", "height"}], ",", RowBox[{"\[Lambda]", "\[Rule]", " ", "AspectRat"}]}], "}"}]}], "]"}]}], "\[IndentingNewLine]", RowBox[{"?", "CylinderIntegrandd\[Theta]"}]}], "Input", CellChangeTimes->{{3.401191386937792*^9, 3.4011914015067253`*^9}, { 3.4011915799987183`*^9, 3.401191652742219*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"CylinderContribution", "[", RowBox[{"dist_", ",", " ", "height_", ",", " ", "AspectRat_"}], "]"}], " ", ":=", " ", RowBox[{"NIntegrate", "[", RowBox[{ RowBox[{"CylinderIntegrandd\[Theta]", "[", RowBox[{"dist", ",", "height", ",", " ", "AspectRat"}], "]"}], ",", RowBox[{"{", RowBox[{"\[Theta]", ",", "0", ",", RowBox[{"2", " ", "\[Pi]"}]}], "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.401199521731165*^9, 3.4011995907309847`*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Integrating over the Cylinder Top", "Subtitle", CellChangeTimes->{{3.401802160809857*^9, 3.401802166035767*^9}, { 3.4018026260486517`*^9, 3.40180265199116*^9}, {3.4018029648009653`*^9, 3.401802967430705*^9}, {3.401803696121348*^9, 3.40180369677477*^9}}], Cell["Now, perform the integral for the top and bottom surfaces", "Text", CellChangeTimes->{{3.400683813452029*^9, 3.4006838355032473`*^9}}], Cell[BoxData[ RowBox[{"TopSurf", " ", "=", " ", RowBox[{"{", RowBox[{ RowBox[{"r", " ", RowBox[{"Cos", "[", "\[Theta]", "]"}]}], ",", RowBox[{"r", " ", RowBox[{"Sin", "[", "\[Theta]", "]"}]}], ",", FractionBox["\[Lambda]", "2"]}], "}"}]}]], "Input", CellChangeTimes->{{3.400683845231966*^9, 3.400683861255547*^9}, { 3.400684752488249*^9, 3.400684756303905*^9}, {3.401191848843525*^9, 3.401191852457437*^9}}], Cell[BoxData[{ RowBox[{"TopSurfR\[Theta]", " ", "=", " ", RowBox[{"D", "[", RowBox[{"TopSurf", ",", "\[Theta]"}], "]"}]}], "\[IndentingNewLine]", RowBox[{"TopSurfRr", " ", "=", " ", RowBox[{"D", "[", RowBox[{"TopSurf", ",", "r"}], "]"}]}]}], "Input", CellChangeTimes->{{3.40068391627991*^9, 3.400683922423478*^9}, { 3.400683953319654*^9, 3.400683960127989*^9}, {3.400684759959578*^9, 3.400684761719825*^9}, 3.401725008119852*^9}], Cell[BoxData[ StyleBox[ RowBox[{ "Now", " ", "weThe", " ", "oriented", " ", "surface", " ", "patch", " ", "d", OverscriptBox["A", "\[Rule]"], " ", "for", " ", "the", " ", "top", " ", "surface", " ", "is", " ", "the", " ", "following", " ", RowBox[{"(", RowBox[{"multiplied", " ", "by", " ", "dr", " ", "d\[Theta]"}], ")"}]}], "Text"]], "Text", CellChangeTimes->{{3.400683306249537*^9, 3.40068330863997*^9}}], Cell[BoxData[ RowBox[{"NormalVecTopSurf", " ", "=", " ", RowBox[{"FullSimplify", "[", RowBox[{"Cross", "[", RowBox[{"TopSurfRr", ",", "TopSurfR\[Theta]"}], "]"}], "]"}]}]], "Input", CellChangeTimes->{{3.400683970919464*^9, 3.400683976350341*^9}, 3.400684765901328*^9}], Cell[BoxData[{ RowBox[{ RowBox[{"EndAssumptions", "=", RowBox[{"{", RowBox[{ RowBox[{"\[Lambda]", ">", " ", "0"}], ",", RowBox[{"\[Rho]", ">", "0"}], " ", ",", RowBox[{"z", " ", ">", " ", "0"}], ",", " ", RowBox[{ RowBox[{"-", "1"}], " ", "\[LessEqual]", " ", RowBox[{"Cos", "[", "\[Theta]", "]"}], "<", "1"}]}], "}"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"TopIntegrandd\[Theta]dr", " ", "=", " ", RowBox[{"FullSimplify", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"PvecR5", "/.", RowBox[{"{", RowBox[{ RowBox[{"cx", "\[Rule]", RowBox[{"r", " ", RowBox[{"Cos", "[", "\[Theta]", "]"}]}]}], ",", " ", RowBox[{"cy", "\[Rule]", " ", RowBox[{"r", " ", RowBox[{"Sin", "[", "\[Theta]", "]"}]}]}], ",", RowBox[{"cz", "\[Rule]", " ", RowBox[{"\[Lambda]", "/", "2"}]}], ",", RowBox[{"x", "\[Rule]", " ", "\[Rho]"}], ",", RowBox[{"y", "\[Rule]", "0"}]}], "}"}]}], ")"}], ".", "NormalVecTopSurf"}], ",", RowBox[{"Assumptions", "\[Rule]", "EndAssumptions"}]}], "]"}], " ", RowBox[{"(*", " ", RowBox[{"5", " ", "seconds"}], " ", "*)"}]}]}], "Input", CellChangeTimes->{{3.400683895446083*^9, 3.400683896966948*^9}, { 3.400684024276202*^9, 3.400684040733185*^9}, {3.400684099084272*^9, 3.400684139924491*^9}, {3.400684632545586*^9, 3.400684656595299*^9}, { 3.400684774411106*^9, 3.400684786533215*^9}, {3.400686427228059*^9, 3.4006864362141247`*^9}, {3.400686611363339*^9, 3.400686660706965*^9}, { 3.400688236837749*^9, 3.400688237881295*^9}, {3.400688851173627*^9, 3.4006888555716343`*^9}, {3.401191882862027*^9, 3.401192097470881*^9}, 3.401192203039178*^9, {3.40119386588645*^9, 3.4011938874362307`*^9}, { 3.401709569610252*^9, 3.401709579399674*^9}, 3.401725004071206*^9}], Cell[BoxData[{ RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"ChoiceDialog", "[", RowBox[{ "\"\\"", ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"\"\\"", "\[Rule]", "True"}], ",", RowBox[{"\"\\"", "\[Rule]", "False"}]}], "}"}]}], "]"}], ",", RowBox[{ "Import", "[", "\"\\"", "]"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"TopIntegrandInsideAbovedr", " ", "=", RowBox[{"Integrate", "[", RowBox[{"TopIntegrandd\[Theta]dr", ",", RowBox[{"{", RowBox[{"\[Theta]", ",", "0", ",", " ", RowBox[{"2", " ", "\[Pi]"}]}], "}"}], ",", " ", RowBox[{"Assumptions", "\[Rule]", RowBox[{"{", " ", RowBox[{ RowBox[{"0", " ", "<", " ", "r", " ", "<", " ", "1"}], ",", RowBox[{"\[Lambda]", ">", " ", "0"}], ",", RowBox[{"\[Rho]", "<", "1"}], " ", ",", RowBox[{"z", " ", ">", " ", RowBox[{"\[Lambda]", "/", "2"}]}]}], "}"}]}]}], " ", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"TopIntegrandInsideBelowdr", " ", "=", RowBox[{"Integrate", "[", RowBox[{"TopIntegrandd\[Theta]dr", ",", RowBox[{"{", RowBox[{"\[Theta]", ",", "0", ",", " ", RowBox[{"2", " ", "\[Pi]"}]}], "}"}], ",", " ", RowBox[{"Assumptions", "\[Rule]", RowBox[{"{", " ", RowBox[{ RowBox[{"0", " ", "<", " ", "r", " ", "<", " ", "1"}], ",", RowBox[{"\[Lambda]", ">", " ", "0"}], ",", RowBox[{"\[Rho]", "<", "1"}], " ", ",", RowBox[{"z", " ", "<", " ", RowBox[{"\[Lambda]", "/", "2"}]}]}], "}"}]}]}], " ", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"TopIntegrandOutsideAbovedr", "=", RowBox[{"Integrate", "[", RowBox[{"TopIntegrandd\[Theta]dr", ",", RowBox[{"{", RowBox[{"\[Theta]", ",", "0", ",", " ", RowBox[{"2", " ", "\[Pi]"}]}], "}"}], ",", " ", RowBox[{"Assumptions", "\[Rule]", RowBox[{"{", " ", RowBox[{ RowBox[{"0", " ", "<", " ", "r", " ", "<", " ", "1"}], ",", RowBox[{"\[Lambda]", ">", " ", "0"}], ",", RowBox[{"\[Rho]", ">", "1"}], " ", ",", RowBox[{"z", " ", ">", " ", RowBox[{"\[Lambda]", "/", "2"}]}]}], "}"}]}]}], " ", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"TopIntegrandOutsideBelowdr", "=", RowBox[{"Integrate", "[", RowBox[{"TopIntegrandd\[Theta]dr", ",", RowBox[{"{", RowBox[{"\[Theta]", ",", "0", ",", " ", RowBox[{"2", " ", "\[Pi]"}]}], "}"}], ",", " ", RowBox[{"Assumptions", "\[Rule]", RowBox[{"{", " ", RowBox[{ RowBox[{"0", " ", "<", " ", "r", " ", "<", " ", "1"}], ",", RowBox[{"\[Lambda]", ">", " ", "0"}], ",", RowBox[{"\[Rho]", ">", "1"}], " ", ",", RowBox[{"z", " ", "<", " ", RowBox[{"\[Lambda]", "/", "2"}]}]}], "}"}]}]}], " ", "]"}]}]}]}], "]"}], ";"}], "\[IndentingNewLine]", RowBox[{"Grid", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ "TopIntegrandInsideAbovedr", ",", "\[IndentingNewLine]", "TopIntegrandInsideBelowdr"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ "TopIntegrandOutsideAbovedr", ",", "\[IndentingNewLine]", "TopIntegrandOutsideBelowdr"}], "}"}]}], "}"}], "]"}]}], "Input", CellChangeTimes->{{3.4011972911069603`*^9, 3.4011973036815643`*^9}, { 3.401197709512063*^9, 3.4011977371534443`*^9}, {3.401197778699394*^9, 3.4011978355886374`*^9}, 3.401198011936205*^9, 3.401198064414604*^9, 3.401198249292626*^9, {3.401198553265246*^9, 3.4011985586941557`*^9}, { 3.4011988428396063`*^9, 3.401198901579131*^9}, {3.4011994093373957`*^9, 3.401199410635499*^9}, {3.4011996862919283`*^9, 3.401199709555398*^9}, { 3.401199980296548*^9, 3.40120011129774*^9}, {3.401201306937398*^9, 3.4012013110029297`*^9}, {3.401644054098349*^9, 3.401644075453052*^9}, { 3.401709690525919*^9, 3.401709711797089*^9}, {3.401709860865757*^9, 3.401709865394434*^9}, {3.401709898770052*^9, 3.401709935263488*^9}, { 3.401724007527396*^9, 3.4017240777600803`*^9}, 3.4017242116472673`*^9, { 3.401724998289534*^9, 3.401724999316421*^9}}], Cell[BoxData[ RowBox[{"TopIntegranddr", "=", "TopIntegrandInsideAbovedr"}]], "Input", CellChangeTimes->{{3.4012025989574823`*^9, 3.401202620692786*^9}}], Cell[BoxData[ RowBox[{"TopPart", "=", RowBox[{"If", "[", RowBox[{ RowBox[{"ChoiceDialog", "[", RowBox[{ "\"\\"", ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"\"\\"", "\[Rule]", "True"}], ",", RowBox[{"\"\\"", "\[Rule]", "False"}]}], "}"}]}], "]"}], ",", RowBox[{ "Import", "[", "\"\\"", "]"}], ",", RowBox[{"Integrate", "[", RowBox[{"TopIntegranddr", ",", RowBox[{"{", RowBox[{"r", ",", "0", ",", "1"}], "}"}], ",", RowBox[{"Assumptions", "\[Rule]", RowBox[{"{", " ", RowBox[{ RowBox[{"\[Lambda]", ">", " ", "0"}], ",", RowBox[{"\[Rho]", ">", "0"}], " ", ",", RowBox[{"z", " ", ">", " ", "0"}], ",", " ", RowBox[{"z", " ", "\[NotEqual]", RowBox[{"\[Lambda]", "/", "2"}]}]}], "}"}]}]}], "]"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.401201298968014*^9, 3.401201372859255*^9}, { 3.401201442612801*^9, 3.401201459616783*^9}, 3.4012026291026993`*^9, { 3.401710283643136*^9, 3.40171030735773*^9}, {3.4017107587399693`*^9, 3.401710859143347*^9}, 3.401724293201078*^9, 3.4017249847574263`*^9}], Cell[BoxData[{ RowBox[{ RowBox[{"TopContribution", "[", RowBox[{"dist_", ",", "height_", ",", " ", "AspectRat_"}], "]"}], ":=", " ", RowBox[{"Evaluate", "[", RowBox[{"TopPart", "/.", RowBox[{"{", RowBox[{ RowBox[{"\[Rho]", "\[Rule]", "dist"}], ",", " ", RowBox[{"z", " ", "\[Rule]", " ", "height"}], ",", RowBox[{"\[Lambda]", "\[Rule]", " ", "AspectRat"}]}], "}"}]}], "]"}]}], "\[IndentingNewLine]", RowBox[{"?", "TopContribution"}]}], "Input", CellChangeTimes->{{3.401201509604989*^9, 3.401201529331757*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Integrating over the Cylinder Bottom", "Subtitle", CellChangeTimes->{{3.401802160809857*^9, 3.401802166035767*^9}, { 3.4018026260486517`*^9, 3.40180265199116*^9}, {3.4018029648009653`*^9, 3.401802967430705*^9}, {3.401803696121348*^9, 3.401803709566804*^9}}], Cell[BoxData[ RowBox[{"BotSurf", " ", "=", " ", RowBox[{"{", RowBox[{ RowBox[{"r", " ", RowBox[{"Cos", "[", "\[Theta]", "]"}]}], ",", RowBox[{"r", " ", RowBox[{"Sin", "[", "\[Theta]", "]"}]}], ",", FractionBox[ RowBox[{"-", "\[Lambda]"}], "2"]}], "}"}]}]], "Input", CellChangeTimes->{{3.4006887484649563`*^9, 3.400688755248267*^9}, { 3.401201656265069*^9, 3.401201658523061*^9}}], Cell[BoxData[{ RowBox[{"BotSurfR\[Theta]", " ", "=", " ", RowBox[{"D", "[", RowBox[{"BotSurf", ",", "\[Theta]"}], "]"}]}], "\[IndentingNewLine]", RowBox[{"BotSurfRr", " ", "=", " ", RowBox[{"D", "[", RowBox[{"BotSurf", ",", "r"}], "]"}]}], "\[IndentingNewLine]"}], "Input", CellChangeTimes->{{3.400688758632321*^9, 3.400688763664671*^9}}], Cell[BoxData[ StyleBox[ RowBox[{"The", " ", "oriented", " ", "surface", " ", "patch", " ", "d", OverscriptBox["A", "\[Rule]"], " ", "for", " ", "the", " ", "bottom", " ", "surface", " ", "is", " ", "the", " ", "following", " ", RowBox[{"(", RowBox[{"multiplied", " ", "by", " ", "dr", " ", "d\[Theta]"}], ")"}]}], "Text"]], "Text"], Cell[BoxData[ RowBox[{"NormalVecBotSurf", " ", "=", " ", RowBox[{"FullSimplify", "[", RowBox[{"Cross", "[", RowBox[{"BotSurfR\[Theta]", ",", "BotSurfRr"}], "]"}], "]"}]}]], "Input", CellChangeTimes->{{3.4006887693589907`*^9, 3.40068877071279*^9}}], Cell[BoxData[ RowBox[{"BotIntegrandd\[Theta]dr", " ", "=", " ", RowBox[{"FullSimplify", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"PvecR5", "/.", RowBox[{"{", RowBox[{ RowBox[{"cx", "\[Rule]", RowBox[{"r", " ", RowBox[{"Cos", "[", "\[Theta]", "]"}]}]}], ",", " ", RowBox[{"cy", "\[Rule]", " ", RowBox[{"r", " ", RowBox[{"Sin", "[", "\[Theta]", "]"}]}]}], ",", RowBox[{"cz", "\[Rule]", " ", RowBox[{ RowBox[{"-", "\[Lambda]"}], "/", "2"}]}], ",", RowBox[{"x", "\[Rule]", " ", "\[Rho]"}], ",", RowBox[{"y", "\[Rule]", "0"}]}], "}"}]}], ")"}], ".", "NormalVecBotSurf"}], ",", RowBox[{"Assumptions", "\[Rule]", "EndAssumptions"}]}], "]"}]}]], "Input",\ CellChangeTimes->{{3.400688792309556*^9, 3.4006887968432407`*^9}, { 3.400688909439829*^9, 3.4006889139490623`*^9}, 3.400690430082363*^9, 3.400690463963717*^9, {3.401201678101283*^9, 3.401201704464499*^9}, { 3.401201794400606*^9, 3.4012018156924133`*^9}, {3.401202239752707*^9, 3.401202244197874*^9}, 3.401202310425761*^9}], Cell[BoxData[{ RowBox[{"If", "[", RowBox[{ RowBox[{"ChoiceDialog", "[", RowBox[{ "\"\\"", ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"\"\\"", "\[Rule]", "True"}], ",", RowBox[{"\"\\"", "\[Rule]", "False"}]}], "}"}]}], "]"}], ",", RowBox[{ "Import", "[", "\"\\"", "]"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"BotIntegrandInsidedr", "=", RowBox[{"Simplify", "[", RowBox[{ RowBox[{"Integrate", "[", RowBox[{"BotIntegrandd\[Theta]dr", ",", RowBox[{"{", RowBox[{"\[Theta]", ",", "0", ",", " ", RowBox[{"2", " ", "\[Pi]"}]}], "}"}], ",", " ", RowBox[{"Assumptions", "\[Rule]", RowBox[{"{", " ", RowBox[{ RowBox[{"0", " ", "<", " ", "r", " ", "<", " ", "1"}], ",", RowBox[{"\[Lambda]", ">", " ", "0"}], ",", RowBox[{"\[Rho]", "<", "1"}], " ", ",", RowBox[{"z", " ", ">", " ", "0"}]}], "}"}]}]}], " ", "]"}], ",", RowBox[{"Assumptions", "\[Rule]", RowBox[{"{", " ", RowBox[{ RowBox[{"0", " ", "<", " ", "r", " ", "<", " ", "1"}], ",", RowBox[{"\[Lambda]", ">", " ", "0"}], ",", RowBox[{"\[Rho]", "<", "1"}], " ", ",", RowBox[{"z", " ", ">", " ", "0"}]}], "}"}]}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"BotIntegrandOutsidedr", "=", RowBox[{"Simplify", "[", RowBox[{ RowBox[{"Integrate", "[", RowBox[{"BotIntegrandd\[Theta]dr", ",", RowBox[{"{", RowBox[{"\[Theta]", ",", "0", ",", " ", RowBox[{"2", " ", "\[Pi]"}]}], "}"}], ",", " ", RowBox[{"Assumptions", "\[Rule]", RowBox[{"{", " ", RowBox[{ RowBox[{"0", " ", "<", " ", "r", " ", "<", " ", "1"}], ",", RowBox[{"\[Lambda]", ">", " ", "0"}], ",", RowBox[{"\[Rho]", ">", "1"}], " ", ",", RowBox[{"z", " ", ">", "0"}]}], "}"}]}]}], " ", "]"}], ",", RowBox[{"Assumptions", "\[Rule]", RowBox[{"{", " ", RowBox[{ RowBox[{"0", " ", "<", " ", "r", " ", "<", " ", "1"}], ",", RowBox[{"\[Lambda]", ">", " ", "0"}], ",", RowBox[{"\[Rho]", ">", "1"}], " ", ",", RowBox[{"z", " ", ">", "0"}]}], "}"}]}]}], " ", "]"}]}], ";"}]}], "]"}], "\[IndentingNewLine]", RowBox[{"Column", "[", RowBox[{"{", RowBox[{"BotIntegrandInsidedr", ",", "BotIntegrandOutsidedr"}], "}"}], "]"}]}], "Input", CellChangeTimes->{{3.401201558058045*^9, 3.401201607010149*^9}, { 3.401201713635366*^9, 3.401201720820652*^9}, {3.401202009819375*^9, 3.401202046350812*^9}, {3.401710936738285*^9, 3.401710957089608*^9}, { 3.4017109902667837`*^9, 3.401711059425235*^9}, {3.401711149848199*^9, 3.401711159511187*^9}, {3.401711228115198*^9, 3.401711333843429*^9}, { 3.4017244325823803`*^9, 3.4017245198502913`*^9}, {3.401724611918975*^9, 3.401724622504665*^9}, {3.401724958827907*^9, 3.401724960009693*^9}}], Cell[BoxData[ RowBox[{"BotIntegranddr", "=", " ", "BotIntegrandOutsidedr"}]], "Input", CellChangeTimes->{{3.401202570563245*^9, 3.401202577284821*^9}}], Cell[TextData[StyleBox["Next evaluation will take about 40 seconds", FontColor->RGBColor[1, 0, 0]]], "Text", CellChangeTimes->{{3.4017114194066677`*^9, 3.401711437011134*^9}}], Cell[BoxData[ RowBox[{"BotPart", "=", " ", RowBox[{"Integrate", "[", RowBox[{"BotIntegranddr", ",", RowBox[{"{", RowBox[{"r", ",", "0", ",", "1"}], "}"}], ",", RowBox[{"Assumptions", "\[Rule]", RowBox[{"{", " ", RowBox[{ RowBox[{"\[Lambda]", ">", " ", "0"}], ",", RowBox[{"\[Rho]", ">", "0"}], " ", ",", RowBox[{"z", " ", ">", " ", "0"}]}], "}"}]}]}], "]"}]}]], "Input", CellChangeTimes->{{3.40120266597781*^9, 3.4012026775278263`*^9}, { 3.401711346457467*^9, 3.401711367941702*^9}, {3.401711451923258*^9, 3.401711463570545*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"BotContribution", "[", RowBox[{"dist_", ",", "height_", ",", " ", "AspectRat_"}], "]"}], ":=", " ", RowBox[{"Evaluate", "[", RowBox[{"BotPart", "/.", RowBox[{"{", RowBox[{ RowBox[{"\[Rho]", "\[Rule]", "dist"}], ",", " ", RowBox[{"z", " ", "\[Rule]", " ", "height"}], ",", RowBox[{"\[Lambda]", "\[Rule]", " ", "AspectRat"}]}], "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.401202741724971*^9, 3.401202747931443*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"LondonCylinderPotential", "[", RowBox[{"dist_", ",", " ", "height_", ",", " ", "AspectRat_"}], "]"}], " ", ":=", RowBox[{ RowBox[{"CylinderContribution", "[", RowBox[{"dist", ",", "height", ",", "AspectRat"}], "]"}], " ", "+", " ", RowBox[{"TopContribution", "[", RowBox[{"dist", ",", "height", ",", "AspectRat"}], "]"}], " ", "+", " ", RowBox[{"BotContribution", "[", RowBox[{"dist", ",", "height", ",", "AspectRat"}], "]"}]}]}]], "Input", CellChangeTimes->{{3.4012027824334393`*^9, 3.401202813951421*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["\<\ Speed and Efficiency: When to Evaluate the Right-Hand-Side during a Function \ Definition\ \>", "Subtitle", CellTags->{ "mmtag:16:Evaluate[]__in_function_definitions", "mmtag:16:defining_functions_from_previously_evaluated_functions", "mmtag:16:functions__definiting_from_previously_defined_expressions_\ without_using_replacement_rules"}], Cell["\<\ Let's set a baseline to check efficiency. Here we check timing to integrate \ something\ \>", "Text", CellChangeTimes->{{3.400249639352862*^9, 3.400249682142026*^9}}], Cell[BoxData[ RowBox[{"Timing", "[", RowBox[{"Integrate", "[", RowBox[{ RowBox[{"Exp", "[", RowBox[{"Tan", "[", "x", "]"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", "c"}], "}"}]}], "]"}], "]"}]], "Input"], Cell[TextData[{ "We check the same thing again, because ", StyleBox["Mathematica", FontSlant->"Italic"], " may have spent some time loading algorithms to integrate" }], "Text", CellChangeTimes->{{3.400249639352862*^9, 3.400249719478221*^9}}], Cell[BoxData[ RowBox[{"Timing", "[", RowBox[{"Integrate", "[", RowBox[{ RowBox[{"Exp", "[", RowBox[{"Tan", "[", "x", "]"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", "c"}], "}"}]}], "]"}], "]"}]], "Input"], Cell["\<\ Here, we time how long it takes to create a function (with delayed \ assignment), but using Evaluate on the rhs.\ \>", "Text", CellChangeTimes->{{3.400249639352862*^9, 3.400249719478221*^9}, { 3.400249767951955*^9, 3.4002498096862164`*^9}}], Cell[BoxData[ RowBox[{"Timing", "[", RowBox[{ RowBox[{"DelayedEvaluated", "[", "c_", "]"}], " ", ":=", " ", RowBox[{"Evaluate", "[", RowBox[{"Integrate", "[", RowBox[{ RowBox[{"Exp", "[", RowBox[{"Tan", "[", "x", "]"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", "c"}], "}"}]}], "]"}], "]"}]}], "]"}]], "Input", CellChangeTimes->{{3.400250112664089*^9, 3.400250119144034*^9}}], Cell["\<\ The following is equivalent to the above (safer) definition---and will work \ so long as c is not assigned to an expression.\ \>", "Text", CellChangeTimes->{{3.400249639352862*^9, 3.400249719478221*^9}, { 3.400249767951955*^9, 3.4002498840942*^9}}], Cell[BoxData[ RowBox[{"Timing", "[", RowBox[{ RowBox[{"Immediate", "[", "c_", "]"}], " ", "=", RowBox[{"Integrate", "[", RowBox[{ RowBox[{"Exp", "[", RowBox[{"Tan", "[", "x", "]"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", "c"}], "}"}]}], "]"}]}], "]"}]], "Input", CellChangeTimes->{{3.400250125055792*^9, 3.4002501270956497`*^9}}], Cell["\<\ The following should take the *least* amount of time to perform, but as we \ shall see is not as efficient in the long run.\ \>", "Text", CellChangeTimes->{{3.4002500112716417`*^9, 3.400250072502329*^9}}], Cell[BoxData[ RowBox[{"Timing", "[", RowBox[{ RowBox[{"FunctionDef", "[", "c_", "]"}], " ", ":=", " ", RowBox[{"Integrate", "[", RowBox[{ RowBox[{"Exp", "[", RowBox[{"Tan", "[", "x", "]"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", "c"}], "}"}]}], "]"}]}], "]"}]], "Input", CellChangeTimes->{{3.400250132775949*^9, 3.40025013663975*^9}}], Cell[BoxData[{ RowBox[{"?", "DelayedEvaluated"}], "\[IndentingNewLine]", RowBox[{"?", "Immediate"}], "\[IndentingNewLine]", RowBox[{"?", "FunctionDef"}]}], "Input", CellChangeTimes->{{3.400250089544847*^9, 3.4002500992721577`*^9}, { 3.4002501478416367`*^9, 3.400250159105145*^9}}], Cell["The following should give a rapid result", "Text", CellChangeTimes->{{3.400250294988844*^9, 3.4002503108556223`*^9}}], Cell[BoxData[{ RowBox[{"Timing", "[", RowBox[{"DelayedEvaluated", "[", "0.5", "]"}], "]"}], "\[IndentingNewLine]", RowBox[{"Timing", "[", RowBox[{"Immediate", "[", "0.5", "]"}], "]"}]}], "Input", CellChangeTimes->{ 3.400250186313654*^9, {3.4002502906924047`*^9, 3.400250291222983*^9}}], Cell["\<\ The following will not be rapid, because it has to do the symbolic \ integration before returning the result.\ \>", "Text", CellChangeTimes->{{3.400250294988844*^9, 3.400250351142198*^9}}], Cell[BoxData[ RowBox[{"Timing", "[", RowBox[{"FunctionDef", "[", "0.5", "]"}], "]"}]], "Input", CellChangeTimes->{3.400250234745476*^9}] }, Open ]], Cell[CellGroupData[{ Cell["\<\ Visualizing the London Dispersion Potential in the Vicinity of Finite \ Cylinder: ContourPlots\ \>", "Subtitle", CellChangeTimes->{{3.401806552954125*^9, 3.4018065572232103`*^9}}], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"LondonCylinderPotential", "[", RowBox[{"x", ",", "0.01", ",", "1"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "0.0", ",", "1.5"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.401202998372345*^9, 3.4012030208751097`*^9}, { 3.4012032380357313`*^9, 3.4012032401464987`*^9}, {3.40120327506038*^9, 3.401203275186536*^9}, {3.401203309725209*^9, 3.401203334240416*^9}, { 3.401203382502523*^9, 3.40120338939499*^9}, {3.401203428726618*^9, 3.4012034811585083`*^9}, {3.401212342789431*^9, 3.401212343443879*^9}, { 3.401212373867997*^9, 3.4012124038432293`*^9}}], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"LondonCylinderPotential", "[", RowBox[{"x", ",", "0.01", ",", "1"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "0.0", ",", "1.5"}], "}"}], ",", RowBox[{"Exclusions", "\[Rule]", " ", RowBox[{"{", "1.0", "}"}]}], ",", " ", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"-", "50"}], ",", "20"}], "}"}]}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{"Thick", ",", "Red"}], "}"}]}], ",", RowBox[{"BaseStyle", "\[Rule]", RowBox[{"{", "Medium", "}"}]}], ",", RowBox[{"ImageSize", "\[Rule]", "Full"}], ",", RowBox[{ "PlotLabel", "\[Rule]", "\"\\""}], ",", RowBox[{"AxesLabel", "\[Rule]", " ", RowBox[{"{", RowBox[{ "\"\<\!\(\*FractionBox[\(distance\\\ from\\\ cylinder\), \(cylinder\\\ \ radius\)]\)\>\"", ",", "\"\\""}], "}"}]}]}], "]"}]], "Input", CellChangeTimes->{{3.401212429349702*^9, 3.401212475659101*^9}, { 3.401212531486446*^9, 3.401212531804784*^9}, {3.401278628019741*^9, 3.4012787061195*^9}, {3.4012787414021807`*^9, 3.401278831079961*^9}}], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"LondonCylinderPotential", "[", RowBox[{"0.0", ",", "h", ",", "1"}], "]"}], ",", RowBox[{"{", RowBox[{"h", ",", "0.0", ",", "1.5"}], "}"}], ",", RowBox[{"Exclusions", "\[Rule]", " ", RowBox[{"{", "0.5", "}"}]}], ",", " ", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"-", "50"}], ",", "20"}], "}"}]}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{"Thick", ",", RowBox[{"Darker", "[", "Blue", "]"}]}], "}"}]}], ",", RowBox[{"BaseStyle", "\[Rule]", RowBox[{"{", "Medium", "}"}]}], ",", RowBox[{"ImageSize", "\[Rule]", "Full"}], ",", RowBox[{ "PlotLabel", "\[Rule]", "\"\\""}], ",", RowBox[{"AxesLabel", "\[Rule]", " ", RowBox[{"{", RowBox[{ "\"\<\!\(\*FractionBox[\(height\\\ above\\\ midplane\), \(cylinder\\\ \ radius\)]\)\>\"", ",", "\"\\""}], "}"}]}]}], "]"}]], "Input", CellChangeTimes->{{3.401213127014586*^9, 3.401213175420912*^9}, { 3.401278839210011*^9, 3.401278916240356*^9}}], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"Log", "[", RowBox[{"Abs", "[", RowBox[{"LondonCylinderPotential", "[", RowBox[{"0.0", ",", "h", ",", "4"}], "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"h", ",", "0", ",", "2.5"}], "}"}], ",", RowBox[{"Exclusions", "\[Rule]", " ", RowBox[{"{", "2.0", "}"}]}], ",", " ", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{"0", ",", "18"}], "}"}]}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{"Thick", ",", RowBox[{"Darker", "[", "Blue", "]"}]}], "}"}]}], ",", RowBox[{"BaseStyle", "\[Rule]", RowBox[{"{", "Medium", "}"}]}], ",", RowBox[{"ImageSize", "\[Rule]", "Large"}], ",", RowBox[{ "PlotLabel", "\[Rule]", "\"\\""}], ",", RowBox[{"AxesLabel", "\[Rule]", " ", RowBox[{"{", RowBox[{ "\"\<\!\(\*FractionBox[\(height\\\ above\\\ midplane\), \(cylinder\\\ \ radius\)]\)\>\"", ",", "\"\\""}], "}"}]}]}], "]"}]], "Input", CellChangeTimes->{{3.401475545596972*^9, 3.401475546233959*^9}, { 3.401475581021949*^9, 3.401475704481638*^9}, {3.401475752230044*^9, 3.4014759087094316`*^9}, {3.401475951147662*^9, 3.401475957098097*^9}, 3.401476090668689*^9, {3.401476131597082*^9, 3.401476148493442*^9}, { 3.4017143004384327`*^9, 3.40171431512035*^9}}], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"Log", "[", RowBox[{"Abs", "[", RowBox[{"LondonCylinderPotential", "[", RowBox[{"x", ",", "0", ",", "1"}], "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "0.0", ",", "1.5"}], "}"}], ",", RowBox[{"Exclusions", "\[Rule]", " ", RowBox[{"{", "1.0", "}"}]}], ",", " ", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{"0", ",", "20"}], "}"}]}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{"Thick", ",", "Red"}], "}"}]}], ",", RowBox[{"BaseStyle", "\[Rule]", RowBox[{"{", "Medium", "}"}]}], ",", RowBox[{"ImageSize", "\[Rule]", "Large"}], ",", RowBox[{ "PlotLabel", "\[Rule]", "\"\\""}], ",", RowBox[{"AxesLabel", "\[Rule]", " ", RowBox[{"{", RowBox[{ "\"\<\!\(\*FractionBox[\(distance\\\ from\\\ cylinder\), \(cylinder\\\ \ radius\)]\)\>\"", ",", "\"\\""}], "}"}]}]}], "]"}]], "Input", CellChangeTimes->{{3.401212429349702*^9, 3.401212475659101*^9}, { 3.401212531486446*^9, 3.401212531804784*^9}, {3.401278628019741*^9, 3.4012787061195*^9}, {3.4012787414021807`*^9, 3.401278831079961*^9}, { 3.401475984381817*^9, 3.4014760040028267`*^9}, 3.401476062099032*^9, { 3.401476095986848*^9, 3.401476117266461*^9}, {3.401714320068418*^9, 3.401714320794469*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"ChoiceDialog", "[", RowBox[{ "\"\\"", ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"\"\\"", "\[Rule]", "True"}], ",", RowBox[{"\"\\"", "\[Rule]", "False"}]}], "}"}]}], "]"}], ",", RowBox[{ "Import", "[", "\"\\"", "]"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"conplotouter", " ", "=", " ", RowBox[{"ContourPlot", "[", RowBox[{ RowBox[{"-", RowBox[{"Log", "[", RowBox[{"Abs", "[", RowBox[{"LondonCylinderPotential", "[", RowBox[{"dist", ",", "h", ",", "4"}], "]"}], "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"dist", ",", "0", ",", "1.5"}], "}"}], ",", RowBox[{"{", RowBox[{"h", ",", "0", ",", "2.5"}], "}"}], ",", RowBox[{"RegionFunction", "\[Rule]", RowBox[{"Function", "[", RowBox[{ RowBox[{"{", RowBox[{"dist", ",", "h"}], "}"}], ",", RowBox[{ RowBox[{"dist", ">", " ", "1.01"}], " ", "||", " ", RowBox[{"h", ">", " ", "2.01"}]}]}], "]"}]}], ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"-", "15"}], ",", "1"}], "}"}]}], ",", RowBox[{"Contours", "\[Rule]", "15"}], ",", " ", RowBox[{"ColorFunction", "\[Rule]", "\"\\""}], ",", RowBox[{"AspectRatio", "\[Rule]", "Automatic"}], ",", RowBox[{"ImageSize", "\[Rule]", "Medium"}], ",", RowBox[{ "PlotLabel", "\[Rule]", "\"\\""}], ",", RowBox[{"BaseStyle", "->", RowBox[{"{", "Medium", "}"}]}], ",", RowBox[{"AxesLabel", "\[Rule]", " ", RowBox[{"{", RowBox[{ "\"\<(distance from cylinder)/radius\>\"", ",", "\"\<(height above midplane)/radius\>\""}], "}"}]}], ",", RowBox[{"AspectRatio", "\[Rule]", "Automatic"}], ",", RowBox[{"Exclusions", "\[Rule]", " ", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"dist", "\[Equal]", "1.0"}], ",", RowBox[{ RowBox[{"Abs", "[", RowBox[{"dist", "-", "1.0"}], "]"}], " ", "<", " ", "0.001"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"h", "\[Equal]", "2.0"}], ",", " ", RowBox[{ RowBox[{"Abs", "[", RowBox[{"h", "-", "2"}], "]"}], " ", "<", " ", "0.001"}]}], "}"}]}], "}"}]}]}], "]"}]}], ";"}]}], "]"}], ";"}], "\[IndentingNewLine]", "conplotouter"}], "Input", CellChangeTimes->{{3.4012126934880657`*^9, 3.401212771292408*^9}, { 3.401212835180669*^9, 3.401212851015547*^9}, {3.401212935760248*^9, 3.401212967383876*^9}, {3.401213225910142*^9, 3.4012133250567007`*^9}, { 3.4012134800639477`*^9, 3.401213525294628*^9}, {3.4012135980197153`*^9, 3.401213606758709*^9}, {3.4012137930286217`*^9, 3.401213793183983*^9}, { 3.401274228031973*^9, 3.401274238758771*^9}, 3.401275650404867*^9, { 3.401277836976006*^9, 3.401277882622883*^9}, {3.401277956189509*^9, 3.4012779697677*^9}, {3.401278035856161*^9, 3.401278043063232*^9}, { 3.4012781060078*^9, 3.401278174016077*^9}, {3.401278228951991*^9, 3.4012783782363*^9}, 3.4012817762819023`*^9, {3.401285562503303*^9, 3.401285586746972*^9}, {3.401285620620224*^9, 3.401285649131536*^9}, { 3.401289045234902*^9, 3.401289056672392*^9}, {3.4012891153735237`*^9, 3.4012891484430304`*^9}, {3.401290714694087*^9, 3.4012907271888447`*^9}, { 3.4012980561401243`*^9, 3.401298098316556*^9}, {3.401442610112898*^9, 3.401442649527699*^9}, {3.401443183982732*^9, 3.401443252007996*^9}, { 3.401443286981463*^9, 3.401443342722206*^9}, {3.401443415460453*^9, 3.4014434331479397`*^9}, {3.401443464062613*^9, 3.4014435452676687`*^9}, { 3.4014439139983892`*^9, 3.401443920553234*^9}, {3.4014439594263268`*^9, 3.401443965504637*^9}, {3.401444525182468*^9, 3.401444551524104*^9}, { 3.4014451065007763`*^9, 3.401445206081257*^9}, {3.401445645604087*^9, 3.401445711361093*^9}, {3.401446304413217*^9, 3.4014463405280848`*^9}, { 3.401450818993183*^9, 3.401450826953063*^9}, {3.401451807052236*^9, 3.401451840953869*^9}, {3.401451921010523*^9, 3.401451921713244*^9}, { 3.401452022661385*^9, 3.401452024009985*^9}, {3.401459587875971*^9, 3.4014596313947783`*^9}, {3.401461065960004*^9, 3.40146109649899*^9}, { 3.401461145900576*^9, 3.4014611561569967`*^9}, {3.401461209132374*^9, 3.4014612098831177`*^9}, {3.401474167326274*^9, 3.401474176708787*^9}, { 3.401474251031353*^9, 3.401474262679029*^9}, {3.4014748020877047`*^9, 3.401474862116352*^9}, {3.401474925153409*^9, 3.401474930973987*^9}, { 3.401475513944173*^9, 3.401475514756689*^9}, {3.401615922073896*^9, 3.401615977846994*^9}, {3.401616011672583*^9, 3.401616082886642*^9}, 3.4016162323465557`*^9, 3.4016166976490297`*^9, {3.401616736909272*^9, 3.401616755727785*^9}, {3.401617080448902*^9, 3.40161717006627*^9}, { 3.4017143570175753`*^9, 3.40171441707365*^9}, {3.4017144748300962`*^9, 3.401714480233646*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"ChoiceDialog", "[", RowBox[{ "\"\\"", ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"\"\\"", "\[Rule]", "True"}], ",", RowBox[{"\"\\"", "\[Rule]", "False"}]}], "}"}]}], "]"}], ",", RowBox[{ "Import", "[", "\"\\"", "]"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"conplotinner", " ", "=", " ", RowBox[{"ContourPlot", "[", RowBox[{ RowBox[{"Log", "[", RowBox[{"LondonCylinderPotential", "[", RowBox[{"dist", ",", "h", ",", "4"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"dist", ",", "0", ",", "1.5"}], "}"}], ",", RowBox[{"{", RowBox[{"h", ",", "0", ",", "2.5"}], "}"}], ",", RowBox[{"RegionFunction", "\[Rule]", RowBox[{"Function", "[", RowBox[{ RowBox[{"{", RowBox[{"dist", ",", "h"}], "}"}], ",", RowBox[{ RowBox[{"dist", "<", " ", "0.99"}], " ", "&&", " ", RowBox[{"h", "<", "1.99"}]}]}], "]"}]}], ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{"0", ",", "15"}], "}"}]}], ",", RowBox[{"Contours", "\[Rule]", "16"}], ",", " ", RowBox[{"ColorFunction", "\[Rule]", "\"\\""}], ",", RowBox[{"AspectRatio", "\[Rule]", "Automatic"}], ",", RowBox[{"ImageSize", "\[Rule]", "Medium"}], ",", RowBox[{ "PlotLabel", "\[Rule]", "\"\\""}], ",", RowBox[{"BaseStyle", "->", RowBox[{"{", "Medium", "}"}]}], ",", RowBox[{"AxesLabel", "\[Rule]", " ", RowBox[{"{", RowBox[{ "\"\<(distance from cylinder)/radius\>\"", ",", "\"\<(height above midplane)/radius\>\""}], "}"}]}], ",", RowBox[{"AspectRatio", "\[Rule]", "Automatic"}]}], "]"}]}], ";"}]}], "]"}], ";"}], "\[IndentingNewLine]", "conplotinner"}], "Input", CellChangeTimes->{{3.4017145189215593`*^9, 3.401714527337455*^9}, { 3.4017145793129663`*^9, 3.40171460868708*^9}, {3.401805269867063*^9, 3.401805270590087*^9}}], Cell[BoxData[ RowBox[{"Show", "[", RowBox[{"conplotinner", ",", "conplotouter"}], "]"}]], "Input", CellChangeTimes->{{3.401450785734633*^9, 3.401450799010827*^9}, 3.4014594192210217`*^9, {3.401806080411182*^9, 3.401806094501951*^9}, { 3.401806210806031*^9, 3.401806218248291*^9}, {3.401806248595667*^9, 3.401806253896173*^9}, 3.401806529376403*^9}] }, Open ]], Cell[CellGroupData[{ Cell["\<\ Visualizing the London Dispersion Potential in the Vicinity of Finite \ Cylinder: Three-Dimensional Graphics\ \>", "Subtitle", CellChangeTimes->{{3.401806552954125*^9, 3.401806581487314*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"plotoutside3D", " ", "=", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"ChoiceDialog", "[", RowBox[{ "\"\\"", ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"\"\\"", "\[Rule]", "True"}], ",", RowBox[{"\"\\"", "\[Rule]", "False"}]}], "}"}]}], "]"}], ",", RowBox[{ "Import", "[", "\"\\"", "]"}], ",", "\[IndentingNewLine]", RowBox[{"Plot3D", "[", RowBox[{ RowBox[{"-", RowBox[{"Log", "[", RowBox[{"Abs", "[", RowBox[{"LondonCylinderPotential", "[", RowBox[{"dist", ",", "h", ",", "4"}], "]"}], "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"dist", ",", "0", ",", "1.5"}], "}"}], ",", RowBox[{"{", RowBox[{"h", ",", "0", ",", "2.5"}], "}"}], ",", RowBox[{"RegionFunction", "\[Rule]", RowBox[{"Function", "[", RowBox[{ RowBox[{"{", RowBox[{"dist", ",", "h"}], "}"}], ",", RowBox[{ RowBox[{"dist", ">", " ", "1.01"}], " ", "||", " ", RowBox[{"h", ">", " ", "2.01"}]}]}], "]"}]}], ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"-", "15"}], ",", "1"}], "}"}]}], ",", RowBox[{"MeshFunctions", "->", RowBox[{"{", RowBox[{"#3", "&"}], "}"}]}], ",", RowBox[{"ColorFunction", "\[Rule]", "\"\\""}], ",", RowBox[{"AspectRatio", "\[Rule]", "Automatic"}], ",", RowBox[{"ImageSize", "\[Rule]", "Large"}], ",", RowBox[{"BaseStyle", "->", RowBox[{"{", "Medium", "}"}]}], ",", RowBox[{"AxesLabel", "\[Rule]", " ", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}]}], ",", RowBox[{"AspectRatio", "\[Rule]", "Automatic"}]}], "]"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", "plotoutside3D"}], "Input", CellChangeTimes->{{3.4012139224324417`*^9, 3.4012139343983383`*^9}, { 3.401213997798606*^9, 3.401214015529002*^9}, {3.4012740982987013`*^9, 3.401274177678678*^9}, {3.4012743813153887`*^9, 3.401274418399473*^9}, { 3.4014427515424843`*^9, 3.401442766029624*^9}, {3.4016234232911453`*^9, 3.401623497948674*^9}, 3.401623562670042*^9, {3.401623662381564*^9, 3.401623671908287*^9}, {3.401623810750548*^9, 3.4016238923463573`*^9}, 3.401623951270021*^9, {3.401624126444757*^9, 3.4016241322843657`*^9}, { 3.401624196613432*^9, 3.401624203913497*^9}, {3.401624282044376*^9, 3.401624307566536*^9}, 3.4016244853882236`*^9, {3.401714672529166*^9, 3.401714709894812*^9}, {3.401714769056452*^9, 3.401714789755992*^9}, { 3.401714822823853*^9, 3.4017148251721*^9}, {3.4017148778550167`*^9, 3.401714889464367*^9}, {3.4017248561127377`*^9, 3.401724858753366*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"plotinside3D", " ", "=", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"ChoiceDialog", "[", RowBox[{ "\"\\"", ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"\"\\"", "\[Rule]", "True"}], ",", RowBox[{"\"\\"", "\[Rule]", "False"}]}], "}"}]}], "]"}], ",", RowBox[{ "Import", "[", "\"\\"", "]"}], ",", "\[IndentingNewLine]", RowBox[{"Plot3D", "[", RowBox[{ RowBox[{"Log", "[", RowBox[{"Abs", "[", RowBox[{"LondonCylinderPotential", "[", RowBox[{"dist", ",", "h", ",", "4"}], "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"dist", ",", "0", ",", "1.5"}], "}"}], ",", RowBox[{"{", RowBox[{"h", ",", "0", ",", "2.5"}], "}"}], ",", RowBox[{"RegionFunction", "\[Rule]", RowBox[{"Function", "[", RowBox[{ RowBox[{"{", RowBox[{"dist", ",", "h"}], "}"}], ",", RowBox[{ RowBox[{"dist", "<", " ", "0.99"}], " ", "&&", " ", RowBox[{"h", "<", " ", "1.99"}]}]}], "]"}]}], ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{"0", ",", "15"}], "}"}]}], ",", RowBox[{"MeshFunctions", "->", RowBox[{"{", RowBox[{"#3", "&"}], "}"}]}], ",", RowBox[{"ColorFunction", "\[Rule]", "\"\\""}], ",", RowBox[{"AspectRatio", "\[Rule]", "Automatic"}], ",", RowBox[{"ImageSize", "\[Rule]", "Large"}], ",", RowBox[{"BaseStyle", "->", RowBox[{"{", "Medium", "}"}]}], ",", RowBox[{"AxesLabel", "\[Rule]", " ", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}]}], ",", RowBox[{"AspectRatio", "\[Rule]", "Automatic"}]}], "]"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", "plotinside3D"}], "Input", CellChangeTimes->{{3.401214037680299*^9, 3.401214055777741*^9}, { 3.4012743867844687`*^9, 3.4012744039266357`*^9}, {3.4016237611941967`*^9, 3.401623762439652*^9}, {3.4016242299775553`*^9, 3.401624264612063*^9}, { 3.40162433553616*^9, 3.4016244078372507`*^9}, {3.401624491979439*^9, 3.401624494608947*^9}, 3.401624538114244*^9, 3.401624642048139*^9, { 3.401626386196662*^9, 3.4016264250643177`*^9}, {3.401714994851328*^9, 3.4017150603374367`*^9}, {3.4017151525757923`*^9, 3.401715153332719*^9}, { 3.401715238238852*^9, 3.401715247099353*^9}, {3.4017248843929996`*^9, 3.401724886219102*^9}}], Cell[BoxData[ RowBox[{"Show", "[", RowBox[{"plotinside3D", ",", "plotoutside3D", ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"-", "15"}], ",", "15"}], "}"}]}]}], "]"}]], "Input", CellChangeTimes->{{3.4016257369136467`*^9, 3.4016257752014723`*^9}}] }, Open ]] }, PrintingStyleEnvironment->"ColorPrintout", CellGrouping->Manual, WindowSize->{1329, 990}, WindowMargins->{{157, Automatic}, {Automatic, 0}}, WindowTitle->"Lecture 16 MIT 3.016 (Fall 2009) \[Copyright] W. Craig Carter \ 2003--2009", PrintingCopies->1, PrintingPageRange->{1, Automatic}, PrintingOptions->{"PaperOrientation"->"Portrait"}, ShowSelection->True, ShowCellLabel->False, CellLabelAutoDelete->True, FrontEndVersion->"7.0 for Mac OS X x86 (32-bit) (November 11, 2008)", StyleDefinitions->"3016-Carter.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{ "mmtag:16:divergence_theorem"->{ Cell[628, 22, 299, 7, 93, "Title", CellTags->"mmtag:16:divergence_theorem"]}, "mmtag:16:London_interaction__vector_potential"->{ Cell[5189, 138, 911, 25, 63, "Input", CellTags->"mmtag:16:London_interaction__vector_potential"]}, "mmtag:16:Div[]"->{ Cell[6524, 176, 234, 6, 37, "Input", CellTags->"mmtag:16:Div[]"]}, "mmtag:16:integral__over_cylinder"->{ Cell[10649, 303, 836, 21, 80, "Text", CellTags->"mmtag:16:integral__over_cylinder"]}, "mmtag:16:surface_normal__example"->{ Cell[13407, 380, 562, 18, 38, "Text", CellTags->"mmtag:16:surface_normal__example"]}, "mmtag:16:Cross[]"->{ Cell[13972, 400, 300, 6, 37, "Input", CellTags->"mmtag:16:Cross[]"]}, "mmtag:16:Evaluate[]__in_function_definitions"->{ Cell[43157, 1104, 360, 8, 107, "Subtitle", CellTags->{ "mmtag:16:Evaluate[]__in_function_definitions", "mmtag:16:defining_functions_from_previously_evaluated_functions", "mmtag:16:functions__definiting_from_previously_defined_expressions_\ without_using_replacement_rules"}]}, "mmtag:16:defining_functions_from_previously_evaluated_functions"->{ Cell[43157, 1104, 360, 8, 107, "Subtitle", CellTags->{ "mmtag:16:Evaluate[]__in_function_definitions", "mmtag:16:defining_functions_from_previously_evaluated_functions", "mmtag:16:functions__definiting_from_previously_defined_expressions_\ without_using_replacement_rules"}]}, "mmtag:16:functions__definiting_from_previously_defined_expressions_without_\ using_replacement_rules"->{ Cell[43157, 1104, 360, 8, 107, "Subtitle", CellTags->{ "mmtag:16:Evaluate[]__in_function_definitions", "mmtag:16:defining_functions_from_previously_evaluated_functions", "mmtag:16:functions__definiting_from_previously_defined_expressions_\ without_using_replacement_rules"}]} } *) (*CellTagsIndex CellTagsIndex->{ {"mmtag:16:divergence_theorem", 69967, 1757}, {"mmtag:16:London_interaction__vector_potential", 70102, 1760}, {"mmtag:16:Div[]", 70227, 1763}, {"mmtag:16:integral__over_cylinder", 70338, 1766}, {"mmtag:16:surface_normal__example", 70468, 1769}, {"mmtag:16:Cross[]", 70582, 1772}, {"mmtag:16:Evaluate[]__in_function_definitions", 70708, 1775}, {"mmtag:16:defining_functions_from_previously_evaluated_functions", 71076, \ 1782}, {"mmtag:16:functions__definiting_from_previously_defined_expressions_without_\ using_replacement_rules", 71481, 1790} } *) (*NotebookFileOutline Notebook[{ Cell[628, 22, 299, 7, 93, "Title", CellTags->"mmtag:16:divergence_theorem"], Cell[CellGroupData[{ Cell[952, 33, 301, 9, 128, "Subtitle"], Cell[1256, 44, 3622, 85, 198, "Text"], Cell[4881, 131, 305, 5, 26, "Text"], Cell[5189, 138, 911, 25, 63, "Input", CellTags->"mmtag:16:London_interaction__vector_potential"], Cell[6103, 165, 172, 3, 37, "Input"], Cell[6278, 170, 243, 4, 26, "Text"], Cell[6524, 176, 234, 6, 37, "Input", CellTags->"mmtag:16:Div[]"], Cell[6761, 184, 488, 8, 41, "Text"], Cell[7252, 194, 985, 26, 53, "Input"], Cell[8240, 222, 2406, 79, 112, "Text"], Cell[10649, 303, 836, 21, 80, "Text", CellTags->"mmtag:16:integral__over_cylinder"] }, Open ]], Cell[CellGroupData[{ Cell[11522, 329, 125, 1, 70, "Subtitle"], Cell[11650, 332, 167, 3, 26, "Text"], Cell[11820, 337, 472, 9, 37, "Input"], Cell[12295, 348, 495, 17, 38, "Text"], Cell[12793, 367, 611, 11, 68, "Input"], Cell[13407, 380, 562, 18, 38, "Text", CellTags->"mmtag:16:surface_normal__example"], Cell[13972, 400, 300, 6, 37, "Input", CellTags->"mmtag:16:Cross[]"], Cell[14275, 408, 807, 13, 56, "Text"], Cell[15085, 423, 928, 19, 37, "Input"], Cell[16016, 444, 534, 13, 38, "Text"], Cell[16553, 459, 1959, 33, 116, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[18549, 497, 175, 2, 70, "Subtitle"], Cell[18727, 501, 1596, 40, 143, "Input"], Cell[20326, 543, 158, 3, 26, "Text"], Cell[20487, 548, 193, 4, 26, "Text"], Cell[20683, 554, 644, 11, 37, "Input"], Cell[21330, 567, 407, 8, 26, "Text"], Cell[21740, 577, 932, 24, 68, "Input"], Cell[22675, 603, 185, 4, 26, "Text"], Cell[22863, 609, 666, 15, 53, "Input"], Cell[23532, 626, 513, 12, 37, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[24082, 643, 265, 3, 70, "Subtitle"], Cell[24350, 648, 141, 1, 26, "Text"], Cell[24494, 651, 447, 11, 56, "Input"], Cell[24944, 664, 456, 9, 53, "Input"], Cell[25403, 675, 437, 10, 36, "Text"], Cell[25843, 687, 286, 6, 37, "Input"], Cell[26132, 695, 1911, 42, 68, "Input"], Cell[28046, 739, 4659, 101, 203, "Input"], Cell[32708, 842, 154, 2, 37, "Input"], Cell[32865, 846, 1444, 33, 113, "Input"], Cell[34312, 881, 566, 14, 53, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[34915, 900, 269, 3, 70, "Subtitle"], Cell[35187, 905, 421, 11, 56, "Input"], Cell[35611, 918, 358, 7, 68, "Input"], Cell[35972, 927, 354, 7, 36, "Text"], Cell[36329, 936, 261, 5, 37, "Input"], Cell[36593, 943, 1158, 27, 37, "Input"], Cell[37754, 972, 3340, 74, 128, "Input"], Cell[41097, 1048, 153, 2, 37, "Input"], Cell[41253, 1052, 177, 2, 26, "Text"], Cell[41433, 1056, 596, 14, 37, "Input"], Cell[42032, 1072, 505, 13, 37, "Input"], Cell[42540, 1087, 580, 12, 53, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[43157, 1104, 360, 8, 107, "Subtitle", CellTags->{ "mmtag:16:Evaluate[]__in_function_definitions", "mmtag:16:defining_functions_from_previously_evaluated_functions", "mmtag:16:functions__definiting_from_previously_defined_expressions_\ without_using_replacement_rules"}], Cell[43520, 1114, 177, 4, 26, "Text"], Cell[43700, 1120, 245, 7, 37, "Input"], Cell[43948, 1129, 247, 6, 26, "Text"], Cell[44198, 1137, 245, 7, 37, "Input"], Cell[44446, 1146, 253, 5, 26, "Text"], Cell[44702, 1153, 441, 12, 37, "Input"], Cell[45146, 1167, 261, 5, 26, "Text"], Cell[45410, 1174, 385, 10, 37, "Input"], Cell[45798, 1186, 215, 4, 26, "Text"], Cell[46016, 1192, 390, 10, 37, "Input"], Cell[46409, 1204, 288, 5, 68, "Input"], Cell[46700, 1211, 124, 1, 26, "Text"], Cell[46827, 1214, 297, 6, 53, "Input"], Cell[47127, 1222, 199, 4, 26, "Text"], Cell[47329, 1228, 141, 3, 37, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[47507, 1236, 191, 4, 107, "Subtitle"], Cell[47701, 1242, 643, 12, 37, "Input"], Cell[48347, 1256, 1300, 32, 103, "Input"], Cell[49650, 1290, 1242, 32, 103, "Input"], Cell[50895, 1324, 1507, 36, 103, "Input"], Cell[52405, 1362, 1518, 36, 103, "Input"], Cell[53926, 1400, 5774, 113, 193, "Input"], Cell[59703, 1515, 2666, 60, 192, "Input"], Cell[62372, 1577, 364, 6, 37, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[62773, 1588, 203, 4, 107, "Subtitle"], Cell[62979, 1594, 3174, 67, 158, "Input"], Cell[66156, 1663, 2848, 62, 158, "Input"], Cell[69007, 1727, 296, 7, 37, "Input"] }, Open ]] } ] *) (* End of internal cache information *)