(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 5.2' Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. *******************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 40972, 1336]*) (*NotebookOutlinePosition[ 43356, 1411]*) (* CellTagsIndexPosition[ 43102, 1399]*) (*WindowFrame->Normal*) Notebook[{ Cell[TextData[{ "Introduction to ", StyleBox["Mathematica \[MathematicaIcon]", FontSlant->"Italic"] }], "Title"], Cell["4. Data, Statistics, Optimization", "Subtitle"], Cell["\<\ P. S. Cally, School of Mathematical Sciences, Monash \ University\ \>", "Author"], Cell[CellGroupData[{ Cell["Fitting Data", "Section"], Cell["Here is some noisy data generated from a quadratic.", "Text"], Cell[BoxData[ \(data = Table[{x, \((1 - 3 x + x\^2)\) + Random[Real, {\(-10\), 10}]}, {x, 0.1, 10, .1}]\)], "Input"], Cell["Plot it with ListPlot.", "Text"], Cell[BoxData[ \(\(lp = ListPlot[data];\)\)], "Input"], Cell["\<\ The basic utility Fit takes a linear combination of any set of \ given functions (not necessarily powers) and obtains a least-squares \ fit.\ \>", "Text"], Cell[BoxData[ \(f[x_] = Fit[data, {1, x, x\^2}, x]\)], "Input"], Cell["\<\ Especially if you want to do high-degree polynomial fitting, it is \ better to use PolynomialFit from the standard package \ NumericalMath`PolynomialFit`. This saves having to list the expansion \ functions, and uses superior algorithms specifically designed for polynomial \ fitting that are more numerically stable. First read in the package:\ \>", \ "Text"], Cell[BoxData[ \(<< NumericalMath`PolynomialFit`\)], "Input"], Cell["\<\ Then, PolynomialFit gives the least-sqaures best fit, as a \ PolynomialFit object\ \>", "Text"], Cell[BoxData[ \(p = PolynomialFit[data, 2]\)], "Input"], Cell["which can be evaluated anywhere.", "Text"], Cell[BoxData[ \(p[2.37]\)], "Input"], Cell["If you want to actually see what that polynomial is,", "Text"], Cell[BoxData[ \(Expand[p[x]]\)], "Input"], Cell["\<\ which of course is the same as before. However, for numerical \ purposes, it is better to leave it in PolynomialFit form, which calculates it \ a little differently:\ \>", "Text"], Cell[BoxData[ \(p[x]\)], "Input"], Cell["\<\ Similarly, there are packages for spline and trigonometric fitting. \ Look up StandardPackage>NumericalMath in Help.\ \>", "Text"], Cell[TextData[{ StyleBox["Mathematica", FontSlant->"Italic"], " also has a utility for nonlinear fitting. For example, let's fit a simple \ rational function to the same data:" }], "Text"], Cell[BoxData[ \(ff[x_] = \(a + b\ x\)\/\(1 + c\ x\) /. FindFit[data, \(a + b\ x\)\/\(1 + c\ x\), {a, b, c}, x]\)], "Input"], Cell["Plot the two and compare:", "Text"], Cell[BoxData[ \(\(fplts = Plot[{f[x], ff[x]}, {x, 0, 10}, PlotStyle \[Rule] {{Red}, {Blue}}, DisplayFunction \[Rule] Identity];\)\)], "Input"], Cell["\<\ (The DisplayFunction\[Rule]Identity option just stops the graph \ from displaying, though it is created and stored in fplts.)\ \>", "Text"], Cell[BoxData[ \(\(Show[lp, fplts];\)\)], "Input"], Cell[BoxData[ \(Clear[data, f, ff, fplts, lp]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Interpolating Data", "Section"], Cell["\<\ We must distinguish between fitting data and interpolating it. \ Interpolation returns a curve (often a spline) which passes through all the \ data points, whereas fitting generally finds the \"best\" fit of a particular \ form, where the number of free parameters is (much) less than the number of \ points, so in general it is not possible to exactly fit the data points. Let's make a table of data:\ \>", "Text"], Cell[BoxData[ \(f[x_] := Cos[x + x\^2]\/\(1 + x\)\)], "Input"], Cell[BoxData[ \(tb = Table[{x, f[x]}, {x, 0, 4, .2}]\)], "Input"], Cell[BoxData[ \(\(pts = ListPlot[tb, PlotStyle \[Rule] {Red, PointSize[ .018]}];\)\)], "Input"], Cell["Interpolating tb is trivial:", "Text"], Cell[BoxData[ \(F = Interpolation[tb]\)], "Input"], Cell[BoxData[ \(\(Plot[F[x], {x, 0, 4}, Epilog \[Rule] First[pts]];\)\)], "Input"], Cell["Note that Interpolation takes a couple of options:", "Text"], Cell[BoxData[ \(Options[Interpolation]\)], "Input"], Cell["\<\ By default, Interpolation gives cubic splines, but we can force any \ other order, e.g., piecewise constant or piecewise linear.\ \>", "Text"], Cell[BoxData[ \(\(F0 = Interpolation[tb, InterpolationOrder \[Rule] 0];\)\)], "Input"], Cell[BoxData[ \(\(F1 = Interpolation[tb, InterpolationOrder \[Rule] 1];\)\)], "Input"], Cell[BoxData[ \(\(Plot[{F0[x], F1[x]}, {x, 0, 4}, PlotStyle \[Rule] {{}, {Green}}, Epilog \[Rule] First[pts], PlotPoints \[Rule] 1000];\)\)], "Input"], Cell[TextData[{ "Alternatively, you may actually have a function f rather than a set of \ data that you might want to fit a spline to, perhaps because f is expensive \ to evaluate and you will need to do so many times, or because f is already a \ combination of InterpolatingFunction objects you wish to simplify to just \ one. ", StyleBox["Mathematica", FontSlant->"Italic"], " can use FunctionInterpolation to do this:" }], "Text"], Cell[BoxData[ \(FF = FunctionInterpolation[f[x], {x, 0, 4}]\)], "Input"], Cell[BoxData[ \(\(Fplt = Plot[{F[x], FF[x]}, {x, 0, 4}, PlotStyle \[Rule] {{Green}, {Blue, Dashing[{ .03, .02}]}}, Epilog \[Rule] First[pts], ImageSize \[Rule] 450];\)\)], "Input"], Cell[BoxData[ \(Clear[F, tb, f, F0, F1, FF, Fplt]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Basic Statistics", "Section"], Cell[TextData[{ "The following basic statistical functions are built into ", StyleBox["Mathematica", FontSlant->"Italic"], ". \n", Cell[BoxData[ FormBox[GridBox[{ {Cell[TextData[{ StyleBox["Mean[", "MR"], StyleBox["data", "TI"], StyleBox["]", "MR"], " " }]], Cell["mean (average value) "]}, {Cell[TextData[{ StyleBox["Median[", "MR"], StyleBox["data", "TI"], StyleBox["]", "MR"], " " }]], Cell["median (central value) "]}, {Cell[TextData[{ StyleBox["Variance[", "MR"], StyleBox["data", "TI"], StyleBox["]", "MR"], " " }]], Cell["variance "]}, {Cell[TextData[{ StyleBox["StandardDeviation[", "MR"], StyleBox["data", "TI"], StyleBox["]", "MR"], " " }]], Cell["standard deviation "]}, {Cell[TextData[{ StyleBox["Quantile[", "MR"], StyleBox["data", "TI"], StyleBox[",", "MR"], " ", StyleBox["q", "TI"], StyleBox["]", "MR"], " " }]], Cell[TextData[{ StyleBox["q", "TI"], Cell[BoxData[ \(TraditionalForm\`\[Null]\^th\)], "InlineFormula"], " quantile " }]]}, {Cell[TextData[{ StyleBox["Total[", "MR"], StyleBox["data", "TI"], StyleBox["]", "MR"], " " }]], Cell["total of values "]} }, ColumnAlignments->{Right, Left}], TraditionalForm]], GridBoxOptions->{RowSpacings->0.4, RowLines->False}] }], "Text"], Cell["For example, if", "Text"], Cell["data = {4.3, 7.2, 8.4, 5.8, 9.2, 3.9}", "Input", CellTags->"S1.6.7"], Cell["then the mean is given by", "Text"], Cell["Mean[data]", "Input", CellTags->"S1.6.7"], Cell["and variance my", "Text"], Cell["Variance[data]", "Input", CellTags->"S1.6.7"], Cell["\<\ Pretty basic! However, do not despair. There are several powerful \ packages.\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Standard Statistical Packages", "Section"], Cell[TextData[{ "There are many standard statistical package in ", StyleBox["Mathematica.", FontSlant->"Italic"], " Let's load them all at once." }], "Text"], Cell[BoxData[ \(<< Statistics`\)], "Input"], Cell["and here they are", "Text"], Cell[BoxData[ \(Partition[Contexts["\"], 2] // TableForm\)], "Input"], Cell["\<\ Statisticians are advised to check out some of these in the help \ facility. (Don't worry about the `Common` ones; they just provide common \ utilities for the others, and are automatically loaded by them.)\ \>", "Text"], Cell["\<\ As an example, here's something that uses ANOVA package, which \ performs univariate Analysis of Variance. In this data set, the first element \ in each pair gives the value of the factor and the second element gives the \ response. There are four levels of the factor, each having five responses. \ \ \>", "Text"], Cell["\<\ onewaydata = {{1,7.0}, {1,5.3}, {1,5.9}, {1,6.6}, {1,4.9}, {2,4.4}, \ {2,6.8}, {2,7.7}, {2,8.3}, {2,6.6}, {3,8.1}, {3,10.4}, {3,8.0}, {3,6.8}, \ {3,9.2}, {4,5.7}, {4,3.9}, {4,6.2}, {4,5.5}, {4,6.2}};\ \>", "Input", CellTags->"S5.95.1"], Cell["ANOVA[onewaydata]", "Input", CellTags->"S5.95.1"] }, Closed]], Cell[CellGroupData[{ Cell["Import and Export", "Section"], Cell[CellGroupData[{ Cell["Graphics", "Subsection"], Cell[TextData[{ "We have seen how to make graphics, and even animations in ", StyleBox["Mathematica", FontSlant->"Italic"], ". But how do we get them off the screen and into a page or file? For \ single frames, the easiest method involves saving as an encapsulated \ postscript file (.eps). These are readily incorporated into ", Cell[BoxData[ StyleBox[ RowBox[{"L", StyleBox[ AdjustmentBox["A", BoxMargins->{{-0.36, -0.1}, {0, -0}}, BoxBaselineShift->-0.2], FontSize->Smaller], "T", AdjustmentBox["E", BoxMargins->{{-0.075, -0.085}, {0, 0}}, BoxBaselineShift->0.5], "X"}]]]], " documents. Saving as eps is most conveniently done from the Edit>Save \ Selection As>EPS... menu item. Give it a try; save this as peanut.eps:" }], "Text"], Cell[BoxData[ \(\(peanut[a_, opts___] := ParametricPlot3D[\(\((a + 2 Cos[\[Theta]]\^2)\)\/\(2 + a\)\) {Sin[\[Theta]] Cos[\[Phi]], Sin[\[Theta]] Sin[\[Phi]], Cos[\[Theta]]}, {\[Theta], 0, \[Pi]}, {\[Phi], 0, 2 \[Pi]}, opts, ViewPoint \[Rule] { .5, 2.3, 0}, AxesLabel \[Rule] {x, y, z}, PlotLabel -> "\" <> ToString[a]];\)\)], "Input"], Cell[BoxData[ \(\(pnt = peanut[1];\)\)], "Input"], Cell[TextData[{ "However, we may also save with a ", StyleBox["Mathematica", FontSlant->"Italic"], " command:" }], "Text"], Cell[BoxData[ \(\(Export["\", pnt];\)\)], "Input"], Cell["\<\ There are very many available formats: eps, pdf, gif, jpeg, png, \ tiff, fits, \[Ellipsis]. See Help for details on Export and its available \ formats, or do this to see what's available on your system (may vary between \ platforms):\ \>", "Text"], Cell[BoxData[ \($ExportFormats\)], "Input"], Cell["Of course, we can also Import.", "Text"], Cell[BoxData[ \(\(pn = Import["\"];\)\)], "Input"], Cell[BoxData[ \(\(Show[pn];\)\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Animations", "Subsection"], Cell["\<\ There are even formats for exporting animations (AVI and animated \ GIFs). Animated GIFs are good for putting on web pages.\ \>", "Text"], Cell[BoxData[ \(\(peanuts = Table[peanut[10\^n, Boxed \[Rule] False, Axes \[Rule] False, PlotRange \[Rule] {{\(-1\), 1}, {\(-1\), 1}, {\(-1\), 1}}], {n, \(-1.5\), 1.5, .1}];\)\)], "Input"], Cell["Export as an animated gif (slow):", "Text"], Cell[BoxData[ \(Export["\", peanuts]\)], "Input"], Cell["And as an avi:", "Text"], Cell[BoxData[ \(Export["\", peanuts]\)], "Input"], Cell["\<\ Check them out using your favourite viewer (xanim, animate, xine, \ \[Ellipsis]). For gifs, you can use mozilla, netscape, etc if you like. Export takes a vast array of options as well, through ConversionOptions, \ mostly taylored to the specific format. For example, for gif we could do \ this:\ \>", "Text"], Cell[BoxData[ \(\(Export["\", peanuts, ConversionOptions \[Rule] {"\" \[Rule] .1, \ "\" \[Rule] True}];\)\)], "Input"], Cell[TextData[{ "AnimationDisplayTime inserts extra time between frame to slow down the \ rate at which it plays. This is handy with some viewers which don't have \ speed control (e.g., web browsers). The equivalent for avi files is \ \"FrameRate\"\[Rule]", StyleBox["n", FontSlant->"Italic"], ", where ", StyleBox["n", FontSlant->"Italic"], " is the number of frames per second.\n", "\"Loop\"\[Rule]True tells it to loop indefinitily, whereas \ \"Loop\"\[Rule]", StyleBox["n", FontSlant->"Italic"], " says loop just ", StyleBox["n", FontSlant->"Italic"], " times. However, most viewers don't listen to this instruction, they just \ loop forever." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Data", "Subsection"], Cell["Here is how we can export data. First make a table.", "Text"], Cell[BoxData[ \(tb = Table[N[{x, Sin[x\ Degree]}], {x, 0, 90, 5}]\)], "Input"], Cell["Then simply", "Text"], Cell[BoxData[ \(Export["\", tb]\)], "Input"], Cell["Have a look at it. Now try this instead; see the difference?", "Text"], Cell[BoxData[ \(Export["\", tb, "\", ConversionOptions -> {"\" \[Rule] {{}, {"\", \ "\"}}, "\" \[Rule] Right, "\" \[Rule] \((PaddedForm[#, {6, 5}] &)\)}]\)], "Input"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["Optimization", "Section"], Cell[TextData[{ StyleBox["Mathematica", FontSlant->"Italic"], " has several different optimization routines. " }], "Text"], Cell[TextData[{ "Minimize (and Maximize) use exact methods (including exact linear \ programming methods for linear cases, and cylindrical algebraic decomposition \ for polynomials). It returns both the minimum and the point at which it is \ found. For linear and polynomial functions and constraints, exact ", StyleBox["global", FontSlant->"Italic"], " minima are found.\n", "\[FilledSmallSquare] ", StyleBox["Minimize[", "MR"], StyleBox["f", "TI"], StyleBox[",", "MR"], " ", StyleBox["{", "MR"], StyleBox["x", "TI"], StyleBox[",", "MR"], " ", StyleBox["y", "TI"], StyleBox[",", "MR"], " \[Ellipsis] ", StyleBox["}]", "MR"], " minimizes ", StyleBox["f", "TI"], " with respect to ", StyleBox["x", "TI"], ", ", StyleBox["y", "TI"], ", \[Ellipsis] . \n\[FilledSmallSquare] ", StyleBox["Minimize[{", "MR"], StyleBox["f", "TI"], StyleBox[",", "MR"], " ", StyleBox["cons", "TI"], StyleBox["},", "MR"], " ", StyleBox["{", "MR"], StyleBox["x", "TI"], StyleBox[",", "MR"], " ", StyleBox["y", "TI"], StyleBox[",", "MR"], " \[Ellipsis] ", StyleBox["}]", "MR"], " minimizes ", StyleBox["f", "TI"], " subject to the constraints ", StyleBox["cons", "TI"], ". " }], "Text"], Cell[BoxData[ \(Minimize[{\[ExponentialE]\ x\^2 - \[Pi]\ y, x\^2 + \@2\ y\^2 \[LessEqual] \[Pi]}, {x, y}]\)], "Input", CellTags->"Minimize"], Cell[BoxData[ \(% // N\)], "Input"], Cell[BoxData[ \(Minimize[{\(-2\) a + 7 b + c + 9 d, 6 a - b + c \[LessEqual] 10, a + 5 b \[LessEqual] 4, a + 5 b + d == 5, a \[GreaterEqual] 0, b \[GreaterEqual] 0, c \[GreaterEqual] 0, d \[GreaterEqual] 0}, {a, b, c, d}]\)], "Input", CellTags->"Minimize"], Cell[BoxData[ \(Minimize[{\[ExponentialE]\^x + 7.8\/x, 1 \[LessEqual] x \[LessEqual] 2}, x]\)], "Input", CellTags->"Minimize"], Cell["\<\ NMinimize (and NMaximize) are similar, but proceed numerically. \[FilledSmallSquare]NMinimize[f, {x, y, \[Ellipsis] }]minimizesfnumerically \ with respect tox,y,\[Ellipsis] . \[FilledSmallSquare]NMinimize[{f, cons}, {x, y, \[Ellipsis] \ }]minimizesfnumerically subject to the constraintscons.\ \>", "Text"], Cell[BoxData[ \(NMinimize[{\[ExponentialE]\ x\^2 - \[Pi]\ y, x\^2 + \@2\ y\^2 \[LessEqual] \[Pi]}, {x, y}]\)], "Input", CellTags->"Minimize"], Cell[TextData[{ "Again, NMinimize and NMaximize look for ", StyleBox["global", FontSlant->"Italic"], " extrema." }], "Text"], Cell[TextData[{ "FindMinimum and FindMaximum are similar to FindRoot, and only find ", StyleBox["local", FontSlant->"Italic"], " extrema. \n", "\[FilledSmallSquare] ", StyleBox["FindMinimum[", "MR"], StyleBox["f", "TI"], StyleBox[",", "MR"], " ", StyleBox["{", "MR"], StyleBox["x", "TI"], StyleBox[",", "MR"], " ", Cell[BoxData[ FormBox[ SubscriptBox[ StyleBox["x", "TI"], "0"], TraditionalForm]], "InlineFormula"], StyleBox["}]", "MR"], " searches for a local minimum in ", StyleBox["f", "TI"], ", starting from the point ", StyleBox["x", "TI"], StyleBox["=", "MR"], Cell[BoxData[ FormBox[ SubscriptBox[ StyleBox["x", "TI"], "0"], TraditionalForm]], "InlineFormula"], ". \n\[FilledSmallSquare] ", StyleBox["FindMinimum[", "MR"], StyleBox["f", "TI"], StyleBox[",", "MR"], " ", StyleBox["{{", "MR"], StyleBox["x", "TI"], StyleBox[",", "MR"], " ", Cell[BoxData[ FormBox[ SubscriptBox[ StyleBox["x", "TI"], "0"], TraditionalForm]], "InlineFormula"], StyleBox["},", "MR"], " ", StyleBox["{", "MR"], StyleBox["y", "TI"], StyleBox[",", "MR"], " ", Cell[BoxData[ FormBox[ SubscriptBox[ StyleBox["y", "TI"], "0"], TraditionalForm]], "InlineFormula"], StyleBox["},", "MR"], " \[Ellipsis] ", StyleBox["}]", "MR"], " searches for a local minimum in a function of several variables. ", "\nHere is a simple example with two local minima." }], "Text"], Cell[BoxData[ \(f[x_] := \(-7\)\ x - x\^2\/2 + \(4\ x\^3\)\/3 + x\^4\/4\)], "Input"], Cell[BoxData[ \(\(Plot[f[x], {x, \(-6\), 3}];\)\)], "Input"], Cell["\<\ Depending on our starting guess, we may or may not find the global \ minimum.\ \>", "Text"], Cell[BoxData[ \(FindMinimum[f[x], {x, \(-2\)}]\)], "Input"], Cell[BoxData[ \(FindMinimum[f[x], {x, 0}]\)], "Input"], Cell[TextData[{ "However, NMinimize finds the ", StyleBox["global", FontSlant->"Italic"], " minimum." }], "Text"], Cell[BoxData[ \(NMinimize[f[x], x]\)], "Input"], Cell["\<\ Each of these extremization utilities can be used in multiple \ dimensions.NMinimize is particularly powerful.\ \>", "Text"], Cell[BoxData[{ \(\(Clear[rainbow];\)\), "\n", \(rainbow[a_] := Hue[0.75\ a, \ .5, 1]\), "\n", \(\(ContourPlot[ If[x\^2 + y\^2 \[LessEqual] 1, 100\ \((y - x\^2)\)\^2 + \((1 - x)\)\^2, 150], {x, \(-1\), 1}, {y, \(-1\), 1}, Contours \[Rule] \[ExponentialE]\^Range[\(-1\), 5, 0.333], ColorFunction \[Rule] rainbow, PlotPoints \[Rule] 250];\)\)}], "Input",\ CellTags->{"NMinimize:Contents", "NMinimize"}], Cell[BoxData[ \(NMinimize[{100 \((y - x\^2)\)\^2 + \((1 - x)\)\^2, \ x\^2 + y\^2 \[LessEqual] 1}, {x, y}]\)], "Input", CellTags->{"NMinimize:Contents", "NMinimize"}], Cell[BoxData[ \(\@\(x\^2 + y\^2\) /. %\[LeftDoubleBracket]2\[RightDoubleBracket]\)], \ "Input"], Cell["\<\ The minimum occurred on the boundary in this case. Try the exact \ routine. It returns an answer (albeit after some time), since the function \ and constraints are polynomial.\ \>", "Text"], Cell[BoxData[ \(Minimize[{100 \((y - x\^2)\)\^2 + \((1 - x)\)\^2, \ x\^2 + y\^2 \[LessEqual] 1}, {x, y}]\)], "Input", CellTags->{"NMinimize:Contents", "NMinimize"}], Cell["This is the same as before:", "Text"], Cell[BoxData[ \(% // N\)], "Input"], Cell["\<\ NMinimize takes many options, most importantly Method. If you don't \ specify a method (i.e., Method\[Rule]Automatic), NMinimize will choose one \ itself, based on the problem you give it. However, sometimes you should \ enforce a particular Method: see the Advanced Documentation for NMinimize in \ Help.\ \>", "Text"], Cell[BoxData[ \(Clear[f]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Example: Triangularization", "Section"], Cell["\<\ We may want to set up a triangularization of a plane given a set of \ nodes. For example, this is important when carrying out a finite element \ discretization of a computational domain. One common algorithm is the \ Delaunay triangularization, which gives in some sense an optimal solution. We read in a standard package.\ \>", "Text"], Cell[BoxData[ \(<< DiscreteMath`ComputationalGeometry`\)], "Input"], Cell["Here is a collection of points in the plane", "Text"], Cell["\<\ data2D = {{4.4, 14}, {6.7, 15.25}, {6.9, 12.8}, {2.1, 11.1}, {9.5, 14.9}, {13.2, 11.9}, {10.3, 12.3}, {6.8, 9.5}, {3.3, 7.7}, {0.6, 5.1}, {5.3, 2.4}, {8.45, 4.7}, {11.5, 9.6}, {13.8, 7.3}, {12.9, 3.1}, {11, 1.1}};\ \>", "Input", CellTags->"S5.19.1"], Cell["Look at them", "Text"], Cell[BoxData[ \(\(pts = Show[Graphics[PointSize[ .018]], Graphics[Hue[0]], Graphics[Point /@ data2D], AspectRatio \[Rule] Automatic];\)\)], "Input"], Cell["\<\ Now plot the Voronoi diagram, which shows the polygons consisting \ of points nearest to each of the points in data2D.\ \>", "Text"], Cell[BoxData[ \(\(vor = DiagramPlot[data2D, TextStyle \[Rule] {"\" \[Rule] 18}, DefaultColor \[Rule] Cyan, AspectRatio \[Rule] Automatic];\)\)], "Input"], Cell["Overlay:", "Text"], Cell[BoxData[ \(\(Show[vor, pts];\)\)], "Input"], Cell["\<\ The Delaunay triangularization connects points only if they are \ associated with Voronoi cells which have a common side. We see that point 1 \ is connected to points 4, 2, and 3; point 2 to 1,3, and 5, etc.\ \>", "Text"], Cell[BoxData[ \(delval = DelaunayTriangulation[data2D]\)], "Input"], Cell["Here's what it looks like:", "Text"], Cell[BoxData[ \(\(delplt = PlanarGraphPlot[data2D, LabelPoints \[Rule] False];\)\)], "Input"], Cell["\<\ Overlay the points, Voronoi diagram, and Delaunay \ triangularization.\ \>", "Text"], Cell[BoxData[ \(\(Show[vor, pts, Graphics[GrayLevel[0]], delplt, AspectRatio \[Rule] Automatic, ImageSize \[Rule] 400, Background \[Rule] GrayLevel[ .6]];\)\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Example: Mesh generation (3rd party packages)", "Section"], Cell[TextData[{ "Triangularization is only one part of finite elements mesh generation. The \ more difficult part is deciding where to put the nodes in the first place. \ There are many methods, but none are currently built into ", StyleBox["Mathematica", FontSlant->"Italic"], " or a Standard Package. But there are literally thousands of third party \ ", StyleBox["Mathematica", FontSlant->"Italic"], " packages out there, many at the Wolfram Information Center (", StyleBox["http://library.wolfram.com/", FontFamily->"Courier"], "). Others may be found using a web search engine. Here we will use one of \ these, meshgenerator (", StyleBox["http://library.wolfram.com/infocenter/MathSource/5475/ ", FontFamily->"Courier"], ") written by Zhe Hu of the ", StyleBox["Illinois Institute of Technology", FontSlant->"Italic"], ". Assuming meshgenerator.m is sitting in your default directory, we read \ it in like this:" }], "Text"], Cell[BoxData[ \(<< meshgenerator`\)], "Input"], Cell["This adds several new utilities:", "Text"], Cell[BoxData[ \(\(?MeshGenerator`*\)\)], "Input"], Cell["\<\ We define the shape of the 2D region we want to model using \ ddiff:\ \>", "Text"], Cell[BoxData[ \(\(?ddiff\)\)], "Input"], Cell["A circle of radius 1 cut out of another of radius 4.", "Text"], Cell[BoxData[{ \(\(d[{x_, y_}] := ddiff[dcircle[{x, y}, {0, 0, 4}], dcircle[{x, y}, {0, 2, 1}]];\)\), "\[IndentingNewLine]", \(\(h[{x_, y_}] := 0.1 + 0.4 \@\( x\^2 + \((y - 2)\)\^2\);\)\)}], "Input"], Cell["\<\ This routine generates the nodal points based on d[{x,y}], and on \ h[{x,y}] which specifies a nonuniform approximate spacing, allowing us to \ place more points near the small hole.\ \>", "Text"], Cell[BoxData[ \(\(p2 = generateMesh[d, h, 0.1, {\(-4\), \(-4\), 4, 4}];\)\)], "Input"], Cell["Here are the nodal points.", "Text"], Cell[BoxData[ \(\(ListPlot[p2, AspectRatio \[Rule] Automatic, Epilog \[Rule] {Hue[0], Circle[{0, 0}, 4], Circle[{0, 2}, 1]}];\)\)], "Input"], Cell["Now we can triangularize", "Text"], Cell[BoxData[ \(\(delp2 = DelaunayTriangulation[p2];\)\)], "Input"], Cell["and plot", "Text"], Cell[BoxData[ \(\(PlanarGraphPlot[p2, delp2, LabelPoints \[Rule] False, Epilog \[Rule] {Hue[0], Circle[{0, 0}, 4], Circle[{0, 2}, 1]}];\)\)], "Input"], Cell["\<\ We have a problem. Some elements are inside the small cutout! Let's \ remove them.\ \>", "Text"], Cell[BoxData[ \(meshbar[t_] := Union[Sort /@ \((\(Thread[List[Sequence @@ #]] &\) /@ t // Flatten[#, 1] &)\)]\)], "Input"], Cell[BoxData[ \(\(bars = meshbar[delp2];\)\)], "Input"], Cell[BoxData[ \(meshbarPlot[p_, bar_List] := Show[Graphics[Line /@ \((\(Part[p, #] &\) /@ bar)\)], AspectRatio \[Rule] Automatic]\)], "Input"], Cell[BoxData[ \(middlepoint[p_, {a_, b_}] := \(p[\([a]\)] + p[\([b]\)]\)\/2\)], "Input"], Cell["\<\ This selects only those bars whose midpoints are in the \ computational domain.\ \>", "Text"], Cell[BoxData[ \(\(bars0 = Select[bars, d[middlepoint[p2, #]] < 0 &];\)\)], "Input"], Cell[BoxData[ \(\(mbp = meshbarPlot[p2, bars0];\)\)], "Input"], Cell["So, here's our final mesh.", "Text"], Cell[BoxData[ \(\(Show[mbp, Graphics[{Hue[0], Circle[{0, 0}, 4], Circle[{0, 2}, 1]}]];\)\)], "Input"], Cell[TextData[{ "Just one example of using ", StyleBox["Mathematica", FontSlant->"Italic"], " packages available off the net. Don't reinvent the wheel; you can \ sometimes find what you want with a little bit of searching." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Exercises", "ExerciseMain"], Cell["\<\ Do not look at the solution until you have completed the \ exercise!\ \>", "Text", TextAlignment->Center, FontFamily->"Helvetica", FontSize->18, FontWeight->"Bold", FontColor->RGBColor[1, 0, 0]], Cell[CellGroupData[{ Cell["Fitting Data", "Exercise"], Cell[TextData[{ "Find the best fit of the form ", Cell[BoxData[ FormBox[ RowBox[{ StyleBox["y", "TI"], "=", \(\[Theta]\_1\), \(\[Theta]\_3\), SubscriptBox[ StyleBox["x", "TI"], "1"], "/", RowBox[{"(", RowBox[{"1", "+", \(\[Theta]\_1\), SubscriptBox[ StyleBox["x", "TI"], "1"], "+", \(\[Theta]\_2\), SubscriptBox[ StyleBox["x", "TI"], "2"]}], ")"}]}], TraditionalForm]], GridBoxOptions->{ColumnWidths->Automatic}], " to this data, where each point represents ", Cell[BoxData[ \(TraditionalForm\`\(\({x\_1, x\_2, y}\)\(.\)\)\)]] }], "Text"], Cell["\<\ data = {{1.0, 1.0, .126}, {2.0, 1.0, .219}, {1.0, 2.0, .076}, {2.0, 2.0, .126}, {.1, .0, .186}};\ \>", "Input", CellTags->"S6.7.1"], Cell["\<\ Plot the resulting fitting function, and calculate the deviation \ between it and the data for all points.\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Solution", "Subsubsection"], Cell[BoxData[ \(ff = FindFit[data, \(\[Theta]\_1\) \(\[Theta]\_3\) x\_1/\((1 + \[Theta]\_1\ x\_1 + \(\[Theta]\_2\) x\_2)\), \ {\[Theta]\_1, \[Theta]\_2, \[Theta]\_3}, {x\_1, x\_2}]\)], "Input"], Cell[BoxData[ \(\(pplt = Show[Graphics3D[{PointSize[ .025], Red, Point /@ data}], AspectRatio \[Rule] Automatic, DisplayFunction \[Rule] Identity];\)\)], "Input"], Cell[BoxData[ \(\(srf = Plot3D[Evaluate[\(\[Theta]\_1\) \(\[Theta]\_3\) x\_1/\((1 + \[Theta]\_1\ x\_1 + \(\[Theta]\_2\) x\_2)\) /. ff], {x\_1, 0, 2}, {x\_2, 0, 2}, ViewPoint \[Rule] {1.3`, 2.4`, 2.`}, AxesLabel \[Rule] {\*"\"\<\!\(x\_1\)\>\"", \*"\"\<\!\(x\_2\)\>\"", \ "\"}, DisplayFunction \[Rule] Identity];\)\)], "Input"], Cell[BoxData[ \(\(Show[srf, pplt, DisplayFunction \[Rule] $DisplayFunction];\)\)], "Input"], Cell[BoxData[ \(\(Show[%, ViewPoint \[Rule] {1.3`, 2.4`, \(-2.`\)}];\)\)], "Input"], Cell[BoxData[ \(\((\(\[Theta]\_1\) \[Theta]\_3\ #\[LeftDoubleBracket]1\ \[RightDoubleBracket]/\((1 + \[Theta]\_1\ #\[LeftDoubleBracket]1\ \[RightDoubleBracket] + \[Theta]\_2\ #\[LeftDoubleBracket]2\ \[RightDoubleBracket])\) - #\[LeftDoubleBracket]3\[RightDoubleBracket] /. ff &)\) /@ data\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Interpolation Functions", "Exercise"], Cell[TextData[{ "Use NDSolve to solve the differential equation system u''+u=v, v''+x v=u' \ with initial conditions u(0)=u'(0)=v(0)=0, v'(0)=1 on 0\[LessEqual]x\ \[LessEqual]6. This will return solutions in the form of \ InterpolatingFunction objects. Defining ", "F(x)=u v'-v u'", ", time (using Timing[]) the plotting of F over (0,6) ", "using \"PlotPoints\[Rule]5000\"", ". Now find a ", StyleBox["single", FontWeight->"Bold"], " InterpolatingFunction object for F(x)=u v'-v u', and repeat the plotting \ (with timing). Compare.\nBy plotting ever higher derivatives of u over (2,4) \ say, determine the interpolating order of the InterpolatingFunction solutions \ NDSolve gave you" }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Solution", "Subsubsection"], Cell[BoxData[ \(sol = First[NDSolve[{\(u''\)[x] + u[x] \[Equal] v[x], \(v''\)[x] + x\ v[x] \[Equal] \(u'\)[x], u[0] \[Equal] 0, \(u'\)[0] \[Equal] 0, v[0] \[Equal] 0, \(v'\)[0] \[Equal] 1}, {u, v}, {x, 0, 6}]]\)], "Input"], Cell[BoxData[ \(\(Plot[Evaluate[{u[x], v[x]} /. sol], {x, 0, 6}, PlotStyle \[Rule] {{}, {Red}}];\)\)], "Input"], Cell[BoxData[ \(F[x_] = u[x] \(v'\)[x] - v[x] \(u'\)[x] /. sol\)], "Input"], Cell[BoxData[ \(Timing[\(Plot[F[x], {x, 0, 6}, PlotPoints \[Rule] 5000, PlotLabel -> "\"];\)]\)], \ "Input"], Cell[BoxData[ \(FI = FunctionInterpolation[F[x], {x, 0, 6}]\)], "Input"], Cell[BoxData[ \(Timing[\(Plot[FI[x], {x, 0, 6}, PlotPoints \[Rule] 5000, PlotLabel -> "\"];\)]\)], "Input"], Cell["\<\ Much faster! What order are the InterpolatingFunction objects?\ \>", "Text"], Cell[BoxData[ \(\(Plot[Evaluate[\(u'\)[x] /. sol], {x, 2, 4}];\)\)], "Input"], Cell[BoxData[ \(\(Plot[Evaluate[\(u''\)[x] /. sol], {x, 2, 4}];\)\)], "Input"], Cell[BoxData[ \(\(Plot[Evaluate[\(u'''\)[x] /. sol], {x, 2, 4}];\)\)], "Input"], Cell[BoxData[ \(\(Plot[Evaluate[\(u''''\)[x] /. sol], {x, 2, 4}];\)\)], "Input"], Cell[BoxData[ \(\(Plot[Evaluate[\(u'''''\)[x] /. sol], {x, 2, 4}];\)\)], "Input"], Cell[TextData[{ "Clearly, the InterpolatingFunction for u is a ", Cell[BoxData[ FormBox[ SuperscriptBox[ StyleBox["C", FontFamily->"Chancery l"], "4"], TraditionalForm]]], "function ", StyleBox["in this case", FontWeight->"Bold"], ", i.e., it has continuous 4th derivative, but discontinuous 5th \ derivative." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Exporting Graphics", "Exercise"], Cell[TextData[{ "Here is a ", StyleBox["Mathematica", FontSlant->"Italic"], " program (see Chapter 5) which numerically integrates the 3-body problem \ in the plane for three gravitationally interacting point masses. It's \ arguments are the time duration of the integration T, the gravitational \ constant G, the three masses, M1, M2, and M3, the initial x- and y-positions \ of the three points Xs and Ys, and the initial velocities Us (x-components) \ and Ys (y-components). The default values hardwired into this definition \ correspond to the strange ", StyleBox["choreographic solution ", FontSlant->"Italic"], " recently discovered for three equal masses." }], "Text"], Cell[BoxData[ \(threeBody[T_, G_: 1, M1_: 1, M2_: 1, M3_: 1, \[IndentingNewLine]Xs_: {0.97000436, \(-0.97000436\), 0}, \[IndentingNewLine]Ys_: {\(-0.24308753\), 0.24308753, 0}, \[IndentingNewLine]Us_: {0.93240737/2, 0.93240737/ 2, \(-0.93240737\)}, \[IndentingNewLine]Vs_: {0.86473146/2, 0.86473146/ 2, \(-0.86473146\)}] := \[IndentingNewLine]Module[{sol, D12, D13, D23}, \[IndentingNewLine]{x1s, x2s, x3s} = Xs; \[IndentingNewLine]{y1s, y2s, y3s} = Ys; \[IndentingNewLine]{u1s, u2s, u3s} = Us; \[IndentingNewLine]{v1s, v2s, v3s} = Vs; \[IndentingNewLine]sol = NDSolve[\[IndentingNewLine]D12[ t_] = \@\(\((x1[t] - x2[t])\)\^2 + \((y1[t] - y2[t])\)\^2\); D13[t_] = \@\(\((x1[t] - x3[t])\)\^2 + \((y1[t] - y3[t])\)\^2\); \ \[IndentingNewLine]D23[ t_] = \@\(\((x2[t] - x3[t])\)\^2 + \((y2[t] - y3[t])\)\^2\); \ \[IndentingNewLine]{\(x1''\)[ t] \[Equal] \(-G\)\ \((\(M2 \((x1[t] - \ x2[t])\)\)\/D12[t]\^3 + \(M3 \((x1[t] - x3[t])\)\)\/D13[t]\^3)\), \ \[IndentingNewLine]\(x2''\)[ t] \[Equal] \(-G\)\ \((\(M1 \((x2[t] - \ x1[t])\)\)\/D12[t]\^3 + \(M3 \((x2[t] - x3[t])\)\)\/D23[t]\^3)\), \ \[IndentingNewLine]\(x3''\)[ t] == \(-G\)\ \((\(M1 \((x3[t] - x1[t])\)\)\/D13[t]\^3 + \ \(M2 \((x3[t] - x2[t])\)\)\/D23[t]\^3)\), \[IndentingNewLine]\(y1''\)[ t] \[Equal] \(-G\)\ \((\(M2 \((y1[t] - \ y2[t])\)\)\/D12[t]\^3 + \(M3 \((y1[t] - y3[t])\)\)\/D13[t]\^3)\), \ \[IndentingNewLine]\(y2''\)[ t] \[Equal] \(-G\)\ \((\(M1 \((y2[t] - \ y1[t])\)\)\/D12[t]\^3 + \(M3 \((y2[t] - y3[t])\)\)\/D23[t]\^3)\), \ \[IndentingNewLine]\(y3''\)[ t] == \(-G\)\ \((\(M1 \((y3[t] - y1[t])\)\)\/D13[t]\^3 + \ \(M2 \((y3[t] - y2[t])\)\)\/D23[t]\^3)\), \[IndentingNewLine]x1[0] \[Equal] x1s, y1[0] \[Equal] y1s, \(x1'\)[0] \[Equal] u1s, \(y1'\)[0] \[Equal] v1s, \[IndentingNewLine]x2[0] \[Equal] x2s, y2[0] \[Equal] y2s, \(x2'\)[0] \[Equal] u2s, \(y2'\)[0] \[Equal] v2s, \[IndentingNewLine]x3[0] \[Equal] x3s, y3[0] \[Equal] y3s, \(x3'\)[0] \[Equal] u3s, \(y3'\)[0] \[Equal] v3s}, {x1, y1, x2, y2, x3, y3}, {t, 0, T}]; First[sol]]\)], "Input"], Cell[TextData[{ "Integrate the choreographic solution for T=10 and make a movie. Save that \ movie as an animated gif, and view it using a web browser to make sure it \ would work properly on a web page. [Your movie should display time ", StyleBox["t ", FontSlant->"Italic"], "on each frame. It should also have a fixed frame size, so that it is not \ zooming in and out as the points move. Colour each of the three points \ differently, and place them on a black background.] Also make a \ ParametricPlot of the motion of the three points, with the curves similarly \ colour-coded, and save this as an encapsulated postscript file.", "\nRepeat the exercise for the case where M3 is changed to 0.9, but \ everything else stays the same.\n[Note: threeBody is a fairly unsophisticated \ implementation. Higher accuracy could be achieved by, for example, choosing \ to conserve certain invariants such as energy and angular momentum. ", StyleBox["Mathematica", FontSlant->"Italic"], "'s Projection method allows us to do this inside NDSolve.]" }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Solution", "Subsubsection"], Cell[BoxData[ \(solchor = threeBody[10]\)], "Input"], Cell[BoxData[ \(sol = threeBody[10, 1, 1, 1, .9]\)], "Input"], Cell[BoxData[ \(Clear[p]\)], "Input"], Cell[BoxData[ \(p[sol_, t_, PR_: {{\(-1.50001\), 1.5}, {\(-1.50001\), 1.5}}] := Show[Graphics[{PointSize[ .025], Red, Point[{x1[t], y1[t]} /. sol]}], Graphics[{PointSize[ .025], Blue, Point[{x2[t], y2[t]} /. sol]}], Graphics[{PointSize[ .025], Green, Point[{x3[t], y3[t]} /. sol]}], Frame \[Rule] True, FrameLabel \[Rule] {"\", "\"}, PlotRange \[Rule] PR, AspectRatio \[Rule] Automatic, Background \[Rule] Black, PlotLabel -> "\" <> ToString[PaddedForm[t, {4, 2}]]]\)], "Input"], Cell[BoxData[ \(\(ParametricPlot[ Evaluate[{{x1[t], y1[t]}, {x2[t], y2[t]}, {x3[t], y3[t]}} /. solchor], {t, 0, 10}, PlotStyle \[Rule] {{Red}, {Blue}, {Green}}, Frame \[Rule] True];\)\)], "Input"], Cell[BoxData[ \(\(anim3BobyChor = Table[p[solchor, t], {t, 0, 10, .1}];\)\)], "Input"], Cell[BoxData[ \(\(Export["\", anim3BobyChor, ConversionOptions \[Rule] {"\" \[Rule] .1, \ "\" \[Rule] True}];\)\)], "Input"], Cell[BoxData[ \(\(ParametricPlot[ Evaluate[{{x1[t], y1[t]}, {x2[t], y2[t]}, {x3[t], y3[t]}} /. sol], {t, 0, 10}, PlotStyle \[Rule] {{Red}, {Blue}, {Green}}, Frame \[Rule] True];\)\)], "Input"], Cell[BoxData[ \(\(anim3Body = Table[p[sol, t, {{\(-2.5\), 2.5}, {\(-2.5\), 2.5}}], {t, 0, 10, .1}];\)\)], "Input"], Cell[BoxData[ \(\(Export["\<3Body.gif\>", anim3Body, ConversionOptions \[Rule] {"\" \[Rule] .1, \ "\" \[Rule] True}];\)\)], "Input"], Cell[BoxData[ \(Clear[sol, solchor, anim3BobyChor, anim3Body, p]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Optimization", "Exercise"], Cell["Plot the function", "Text"], Cell[BoxData[ \(\(f[x_, y_] = \[ExponentialE]\^Sin[50\ x] + Sin[60\ \[ExponentialE]\^y] + Sin[70\ Sin[x]] + Sin[Sin[80\ y]] - Sin[10\ \((x + y)\)] + 1\/4\ \((x\^2 + y\^2)\);\)\)], "Input"], Cell[TextData[{ "over -1\[LessEqual]x\[LessEqual]1, -1\[LessEqual]y\[LessEqual]1. Wow! \ Find the global minimum of ", StyleBox["f", FontSlant->"Italic"], ", correct to 10 decimal places. [Hint: try a genetic algorithm, and use at \ least 32 for WorkingPrecision. See the options of NMinimize.]" }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Solution", "Subsubsection"], Cell[BoxData[ \(\(Plot3D[Evaluate[f[x, y]], {x, \(-1\), 1}, {y, \(-1\), 1}, PlotPoints \[Rule] 500, Mesh \[Rule] False];\)\)], "Input"], Cell[BoxData[ \(\(Show[ContourGraphics[%]];\)\)], "Input"], Cell[BoxData[ \(N[NMinimize[f[x, y], \ {x, y}, \ Method -> "\", \ WorkingPrecision \[Rule] 32], 10]\)], "Input"] }, Closed]] }, Open ]] }, FrontEndVersion->"5.2 for X", ScreenRectangle->{{0, 1280}, {0, 1024}}, WindowSize->{791, 944}, WindowMargins->{{0, Automatic}, {Automatic, 0}}, ShowSelection->True, Magnification->1, StyleDefinitions -> "Classroom.nb" ] (******************************************************************* Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. *******************************************************************) (*CellTagsOutline CellTagsIndex->{ "S1.6.7"->{ Cell[9075, 301, 76, 1, 47, "Input", CellTags->"S1.6.7"], Cell[9198, 306, 49, 1, 47, "Input", CellTags->"S1.6.7"], Cell[9284, 311, 53, 1, 47, "Input", CellTags->"S1.6.7"]}, "S5.95.1"->{ Cell[10435, 353, 247, 5, 77, "Input", CellTags->"S5.95.1"], Cell[10685, 360, 57, 1, 47, "Input", CellTags->"S5.95.1"]}, "Minimize"->{ Cell[16939, 581, 155, 3, 53, "Input", CellTags->"Minimize"], Cell[17139, 589, 294, 5, 63, "Input", CellTags->"Minimize"], Cell[17436, 596, 141, 3, 64, "Input", CellTags->"Minimize"], Cell[17899, 609, 156, 3, 53, "Input", CellTags->"Minimize"]}, "NMinimize:Contents"->{ Cell[20473, 715, 465, 10, 105, "Input", CellTags->{"NMinimize:Contents", "NMinimize"}], Cell[20941, 727, 180, 3, 52, "Input", CellTags->{"NMinimize:Contents", "NMinimize"}], Cell[21428, 742, 179, 3, 52, "Input", CellTags->{"NMinimize:Contents", "NMinimize"}]}, "NMinimize"->{ Cell[20473, 715, 465, 10, 105, "Input", CellTags->{"NMinimize:Contents", "NMinimize"}], Cell[20941, 727, 180, 3, 52, "Input", CellTags->{"NMinimize:Contents", "NMinimize"}], Cell[21428, 742, 179, 3, 52, "Input", CellTags->{"NMinimize:Contents", "NMinimize"}]}, "S5.19.1"->{ Cell[22641, 781, 266, 8, 122, "Input", CellTags->"S5.19.1"]}, "S6.7.1"->{ Cell[29194, 1011, 143, 4, 62, "Input", CellTags->"S6.7.1"]} } *) (*CellTagsIndex CellTagsIndex->{ {"S1.6.7", 41622, 1354}, {"S5.95.1", 41839, 1361}, {"Minimize", 41995, 1366}, {"NMinimize:Contents", 42306, 1375}, {"NMinimize", 42614, 1382}, {"S5.19.1", 42920, 1389}, {"S6.7.1", 43006, 1392} } *) (*NotebookFileOutline Notebook[{ Cell[1754, 51, 122, 4, 70, "Title"], Cell[1879, 57, 53, 0, 41, "Subtitle"], Cell[1935, 59, 91, 3, 39, "Author"], Cell[CellGroupData[{ Cell[2051, 66, 31, 0, 64, "Section"], Cell[2085, 68, 67, 0, 28, "Text"], Cell[2155, 70, 140, 3, 51, "Input"], Cell[2298, 75, 38, 0, 28, "Text"], Cell[2339, 77, 57, 1, 47, "Input"], Cell[2399, 80, 164, 4, 46, "Text"], Cell[2566, 86, 67, 1, 51, "Input"], Cell[2636, 89, 370, 7, 64, "Text"], Cell[3009, 98, 64, 1, 47, "Input"], Cell[3076, 101, 105, 3, 28, "Text"], Cell[3184, 106, 59, 1, 47, "Input"], Cell[3246, 109, 48, 0, 28, "Text"], Cell[3297, 111, 40, 1, 47, "Input"], Cell[3340, 114, 68, 0, 28, "Text"], Cell[3411, 116, 45, 1, 47, "Input"], Cell[3459, 119, 189, 4, 46, "Text"], Cell[3651, 125, 37, 1, 47, "Input"], Cell[3691, 128, 140, 3, 28, "Text"], Cell[3834, 133, 196, 5, 28, "Text"], Cell[4033, 140, 136, 2, 64, "Input"], Cell[4172, 144, 41, 0, 28, "Text"], Cell[4216, 146, 166, 3, 63, "Input"], Cell[4385, 151, 149, 3, 28, "Text"], Cell[4537, 156, 53, 1, 47, "Input"], Cell[4593, 159, 62, 1, 47, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[4692, 165, 37, 0, 44, "Section"], Cell[4732, 167, 425, 7, 112, "Text"], Cell[5160, 176, 66, 1, 66, "Input"], Cell[5229, 179, 70, 1, 47, "Input"], Cell[5302, 182, 108, 2, 47, "Input"], Cell[5413, 186, 44, 0, 28, "Text"], Cell[5460, 188, 54, 1, 47, "Input"], Cell[5517, 191, 86, 1, 47, "Input"], Cell[5606, 194, 66, 0, 28, "Text"], Cell[5675, 196, 55, 1, 47, "Input"], Cell[5733, 199, 152, 3, 46, "Text"], Cell[5888, 204, 90, 1, 47, "Input"], Cell[5981, 207, 90, 1, 47, "Input"], Cell[6074, 210, 163, 2, 63, "Input"], Cell[6240, 214, 443, 9, 82, "Text"], Cell[6686, 225, 76, 1, 47, "Input"], Cell[6765, 228, 216, 4, 79, "Input"], Cell[6984, 234, 66, 1, 47, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[7087, 240, 35, 0, 44, "Section"], Cell[7125, 242, 1913, 55, 163, "Text"], Cell[9041, 299, 31, 0, 28, "Text"], Cell[9075, 301, 76, 1, 47, "Input", CellTags->"S1.6.7"], Cell[9154, 304, 41, 0, 28, "Text"], Cell[9198, 306, 49, 1, 47, "Input", CellTags->"S1.6.7"], Cell[9250, 309, 31, 0, 28, "Text"], Cell[9284, 311, 53, 1, 47, "Input", CellTags->"S1.6.7"], Cell[9340, 314, 101, 3, 28, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[9478, 322, 48, 0, 44, "Section"], Cell[9529, 324, 167, 5, 28, "Text"], Cell[9699, 331, 47, 1, 47, "Input"], Cell[9749, 334, 33, 0, 28, "Text"], Cell[9785, 336, 87, 1, 47, "Input"], Cell[9875, 339, 230, 4, 46, "Text"], Cell[10108, 345, 324, 6, 64, "Text"], Cell[10435, 353, 247, 5, 77, "Input", CellTags->"S5.95.1"], Cell[10685, 360, 57, 1, 47, "Input", CellTags->"S5.95.1"] }, Closed]], Cell[CellGroupData[{ Cell[10779, 366, 36, 0, 44, "Section"], Cell[CellGroupData[{ Cell[10840, 370, 30, 0, 53, "Subsection"], Cell[10873, 372, 861, 20, 82, "Text"], Cell[11737, 394, 424, 7, 103, "Input"], Cell[12164, 403, 53, 1, 47, "Input"], Cell[12220, 406, 132, 5, 28, "Text"], Cell[12355, 413, 67, 1, 47, "Input"], Cell[12425, 416, 257, 5, 46, "Text"], Cell[12685, 423, 47, 1, 47, "Input"], Cell[12735, 426, 46, 0, 28, "Text"], Cell[12784, 428, 67, 1, 47, "Input"], Cell[12854, 431, 46, 1, 47, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[12937, 437, 32, 0, 37, "Subsection"], Cell[12972, 439, 147, 3, 28, "Text"], Cell[13122, 444, 234, 4, 63, "Input"], Cell[13359, 450, 49, 0, 28, "Text"], Cell[13411, 452, 67, 1, 47, "Input"], Cell[13481, 455, 30, 0, 28, "Text"], Cell[13514, 457, 67, 1, 47, "Input"], Cell[13584, 460, 319, 6, 76, "Text"], Cell[13906, 468, 176, 3, 47, "Input"], Cell[14085, 473, 695, 20, 94, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[14817, 498, 26, 0, 37, "Subsection"], Cell[14846, 500, 67, 0, 28, "Text"], Cell[14916, 502, 82, 1, 47, "Input"], Cell[15001, 505, 27, 0, 28, "Text"], Cell[15031, 507, 58, 1, 47, "Input"], Cell[15092, 510, 76, 0, 28, "Text"], Cell[15171, 512, 300, 5, 79, "Input"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[15520, 523, 31, 0, 44, "Section"], Cell[15554, 525, 130, 4, 28, "Text"], Cell[15687, 531, 1249, 48, 124, "Text"], Cell[16939, 581, 155, 3, 53, "Input", CellTags->"Minimize"], Cell[17097, 586, 39, 1, 47, "Input"], Cell[17139, 589, 294, 5, 63, "Input", CellTags->"Minimize"], Cell[17436, 596, 141, 3, 64, "Input", CellTags->"Minimize"], Cell[17580, 601, 316, 6, 88, "Text"], Cell[17899, 609, 156, 3, 53, "Input", CellTags->"Minimize"], Cell[18058, 614, 134, 5, 28, "Text"], Cell[18195, 621, 1569, 60, 118, "Text"], Cell[19767, 683, 88, 1, 66, "Input"], Cell[19858, 686, 64, 1, 47, "Input"], Cell[19925, 689, 101, 3, 28, "Text"], Cell[20029, 694, 63, 1, 47, "Input"], Cell[20095, 697, 58, 1, 47, "Input"], Cell[20156, 700, 123, 5, 28, "Text"], Cell[20282, 707, 51, 1, 47, "Input"], Cell[20336, 710, 134, 3, 28, "Text"], Cell[20473, 715, 465, 10, 105, "Input", CellTags->{"NMinimize:Contents", "NMinimize"}], Cell[20941, 727, 180, 3, 52, "Input", CellTags->{"NMinimize:Contents", "NMinimize"}], Cell[21124, 732, 99, 2, 56, "Input"], Cell[21226, 736, 199, 4, 46, "Text"], Cell[21428, 742, 179, 3, 52, "Input", CellTags->{"NMinimize:Contents", "NMinimize"}], Cell[21610, 747, 43, 0, 28, "Text"], Cell[21656, 749, 39, 1, 47, "Input"], Cell[21698, 752, 329, 6, 64, "Text"], Cell[22030, 760, 41, 1, 47, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[22108, 766, 45, 0, 44, "Section"], Cell[22156, 768, 346, 6, 94, "Text"], Cell[22505, 776, 71, 1, 47, "Input"], Cell[22579, 779, 59, 0, 28, "Text"], Cell[22641, 781, 266, 8, 122, "Input", CellTags->"S5.19.1"], Cell[22910, 791, 28, 0, 28, "Text"], Cell[22941, 793, 183, 4, 63, "Input"], Cell[23127, 799, 142, 3, 28, "Text"], Cell[23272, 804, 199, 4, 63, "Input"], Cell[23474, 810, 24, 0, 28, "Text"], Cell[23501, 812, 52, 1, 47, "Input"], Cell[23556, 815, 231, 4, 46, "Text"], Cell[23790, 821, 71, 1, 47, "Input"], Cell[23864, 824, 42, 0, 28, "Text"], Cell[23909, 826, 106, 2, 47, "Input"], Cell[24018, 830, 94, 3, 28, "Text"], Cell[24115, 835, 191, 3, 63, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[24343, 843, 64, 0, 44, "Section"], Cell[24410, 845, 971, 22, 100, "Text"], Cell[25384, 869, 50, 1, 47, "Input"], Cell[25437, 872, 48, 0, 28, "Text"], Cell[25488, 874, 53, 1, 47, "Input"], Cell[25544, 877, 92, 3, 28, "Text"], Cell[25639, 882, 43, 1, 47, "Input"], Cell[25685, 885, 68, 0, 28, "Text"], Cell[25756, 887, 228, 4, 72, "Input"], Cell[25987, 893, 206, 4, 28, "Text"], Cell[26196, 899, 90, 1, 47, "Input"], Cell[26289, 902, 42, 0, 28, "Text"], Cell[26334, 904, 166, 3, 47, "Input"], Cell[26503, 909, 40, 0, 28, "Text"], Cell[26546, 911, 71, 1, 47, "Input"], Cell[26620, 914, 24, 0, 28, "Text"], Cell[26647, 916, 176, 3, 47, "Input"], Cell[26826, 921, 106, 3, 28, "Text"], Cell[26935, 926, 148, 3, 47, "Input"], Cell[27086, 931, 59, 1, 47, "Input"], Cell[27148, 934, 162, 3, 47, "Input"], Cell[27313, 939, 92, 1, 64, "Input"], Cell[27408, 942, 103, 3, 28, "Text"], Cell[27514, 947, 87, 1, 47, "Input"], Cell[27604, 950, 66, 1, 47, "Input"], Cell[27673, 953, 42, 0, 28, "Text"], Cell[27718, 955, 127, 3, 47, "Input"], Cell[27848, 960, 245, 6, 28, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[28130, 971, 33, 0, 46, "ExerciseMain"], Cell[28166, 973, 214, 8, 35, "Text"], Cell[CellGroupData[{ Cell[28405, 985, 32, 0, 48, "Exercise"], Cell[28440, 987, 751, 22, 28, "Text"], Cell[29194, 1011, 143, 4, 62, "Input", CellTags->"S6.7.1"], Cell[29340, 1017, 130, 3, 28, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[29507, 1025, 33, 0, 48, "Subsubsection"], Cell[29543, 1027, 245, 5, 47, "Input"], Cell[29791, 1034, 197, 4, 47, "Input"], Cell[29991, 1040, 396, 7, 63, "Input"], Cell[30390, 1049, 104, 2, 47, "Input"], Cell[30497, 1053, 87, 1, 47, "Input"], Cell[30587, 1056, 318, 5, 47, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[30942, 1066, 43, 0, 34, "Exercise"], Cell[30988, 1068, 715, 15, 112, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[31740, 1088, 33, 0, 48, "Subsubsection"], Cell[31776, 1090, 287, 6, 63, "Input"], Cell[32066, 1098, 124, 2, 47, "Input"], Cell[32193, 1102, 79, 1, 47, "Input"], Cell[32275, 1105, 164, 3, 47, "Input"], Cell[32442, 1110, 76, 1, 47, "Input"], Cell[32521, 1113, 146, 2, 47, "Input"], Cell[32670, 1117, 86, 3, 58, "Text"], Cell[32759, 1122, 81, 1, 47, "Input"], Cell[32843, 1125, 82, 1, 47, "Input"], Cell[32928, 1128, 83, 1, 47, "Input"], Cell[33014, 1131, 84, 1, 47, "Input"], Cell[33101, 1134, 85, 1, 47, "Input"], Cell[33189, 1137, 372, 12, 28, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[33598, 1154, 38, 0, 34, "Exercise"], Cell[33639, 1156, 693, 14, 82, "Text"], Cell[34335, 1172, 2474, 44, 577, "Input"], Cell[36812, 1218, 1072, 18, 160, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[37921, 1241, 33, 0, 48, "Subsubsection"], Cell[37957, 1243, 56, 1, 47, "Input"], Cell[38016, 1246, 66, 1, 47, "Input"], Cell[38085, 1249, 41, 1, 47, "Input"], Cell[38129, 1252, 571, 9, 127, "Input"], Cell[38703, 1263, 230, 4, 63, "Input"], Cell[38936, 1269, 91, 1, 47, "Input"], Cell[39030, 1272, 188, 3, 63, "Input"], Cell[39221, 1277, 226, 4, 63, "Input"], Cell[39450, 1283, 141, 3, 47, "Input"], Cell[39594, 1288, 176, 3, 47, "Input"], Cell[39773, 1293, 81, 1, 47, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[39891, 1299, 32, 0, 34, "Exercise"], Cell[39926, 1301, 33, 0, 28, "Text"], Cell[39962, 1303, 214, 3, 64, "Input"], Cell[40179, 1308, 318, 7, 46, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[40534, 1320, 33, 0, 48, "Subsubsection"], Cell[40570, 1322, 148, 2, 47, "Input"], Cell[40721, 1326, 62, 1, 47, "Input"], Cell[40786, 1329, 158, 3, 63, "Input"] }, Closed]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)