(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 4.0, MathReader 4.0, or any compatible application. 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[ 28110, 803]*) (*NotebookOutlinePosition[ 29317, 849]*) (* CellTagsIndexPosition[ 29181, 840]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["\<\ Exploring the Mathematics Behind Skateboarding: Analysis of the Directional Derivative \ \>", "Title"], Cell[TextData[StyleBox["Chapter 11, Section 5 ", FontFamily->"Arial", FontSize->16, FontWeight->"Bold"]], "Text"], Cell[CellGroupData[{ Cell["Introduction", "Section"], Cell[TextData[{ "OBJECTIVE: You will see how the directional derivative changes as you \ traverse a path through the domain of a function ", Cell[BoxData[ \(TraditionalForm\`\(z\ = \ f(x, y)\ \)\)]], "." }], "Text"], Cell[TextData[{ "What is a directional derivative and what does it look like? To find out, \ you get to put yourself in the position of a skateboarder and explore skating \ on a flat ramp or inside a bowl. The graphical representation of the dot \ product of the gradient of the surface function and a unit vector in the \ direction of motion will become clearer. You will be able to plot the \ directional derivative as a function of the parameter", StyleBox[" t", FontSlant->"Italic"], "." }], "Text"], Cell[CellGroupData[{ Cell["Technology Guidelines", "Subsection", CellDingbat->"\[LightBulb]"], Cell[TextData[{ StyleBox["NOTE: If you have just finished a module, restart ", CellFrame->True, Background->None], StyleBox["Mathematica", CellFrame->True, FontSlant->"Italic", Background->None], StyleBox[ " before executing a new module.\nTO OPEN CELLS, put your cursor on the \ right cell bracket and double click.", CellFrame->True, Background->None], "\nTO STOP AN EXECUTION\n\tSelect the ", StyleBox["Kernel", FontSlant->"Italic"], " pull-down menu and click on ", StyleBox["Abort Evaluation.\n", FontSlant->"Italic"], "ORDER OF EXECUTION\n\tExecute cells in the order given. Do not skip any \ Input cells within a given notebook.\nSAVING NOTEBOOKS\n\tYou can save \ anytime to any directory you choose, and it is wise to save often.\n\t\ However, before you do your final save, delete all your output by selecting \ the \n\t ", StyleBox["Delete All Output", FontSlant->"Italic"], " selection under the ", StyleBox["Kernel", FontSlant->"Italic"], " pull-down menu.\nEXPERIENCING MAJOR PROBLEMS\n\tSave if appropriate, and \ then shut down ", StyleBox["Mathematica", FontSlant->"Italic"], " and start it up again." }], "Text"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["Part I: Skateboarding on a Flat Horizontal Surface", "Section"], Cell[TextData[{ "Imagine a skateboarder tracing out a figure-8 on a horizontal plane. The \ first set of commands that follow give the parametric equations of the \ skateboarder's path in the ", StyleBox["xy", FontSlant->"Italic"], "-plane. We'll start with the equations in polar form." }], "Text"], Cell[BoxData[{ \(Off[General::spell]\ \), "\n", \(Off[General::spell1]\), "\n", \(Clear[r, \[Theta], t, x, y]\ \), "\n", \(r[t_] := 16 Sin[t]\^2\), "\n", \(\[Theta][t_] := t\)}], "Input"], Cell[TextData[{ "Load the following special graphics package to do polar plots. Be sure to \ read it in BEFORE you try to execute ", StyleBox["PolarPlot", FontWeight->"Bold"], ". " }], "Text"], Cell[BoxData[ \(<< Graphics`Graphics`\)], "Input"], Cell["\<\ The following set of plots shows the progression of the skateboarder. To \ animate this set of plots, select any one of the plots in the sequence, then \ double-click on it. You can slow down the animation while it is playing by \ clicking on the appropriate button that appears in the lower left-hand \ corner. Notice how the skateboarder is tracing out the figure-8.\ \>", "Text"], Cell[BoxData[ ButtonBox[ ButtonBox[ RowBox[{ StyleBox["\[MathematicaIcon]", FontSize->14, FontWeight->"Bold", FontColor->RGBColor[0.792981, 0.777356, 0.144533], FontVariations->{"CompatibilityType"->0}], StyleBox[" ", FontSize->14, FontWeight->"Bold", FontSlant->"Italic"], StyleBox["About", FontSize->14, FontWeight->"Bold", FontColor->RGBColor[0.500008, 0, 0.500008]], StyleBox[" ", FontSize->14, FontWeight->"Bold", FontSlant->"Italic"], StyleBox["Mathematica", FontSize->14, FontWeight->"Bold", FontSlant->"Italic", FontColor->RGBColor[0.500008, 0, 0.500008]]}], ButtonStyle->"Paste"], ButtonData:>"h1", ButtonStyle->"Hyperlink"]], "Input", Evaluatable->False, CellTags->"hb1"], Cell[BoxData[{ \(p[n_] := PolarPlot[r[t], {t, 0, 2 \[Pi]*n}, PlotRange \[Rule] {{\(-7\), 7}, {\(-17\), 17}}, AspectRatio \[Rule] 1, AxesLabel \[Rule] {"\", "\"}]\), "\n", \(\(Do[p[n], {n, 0.1, 1, 0.1}];\)\)}], "Input"], Cell[TextData[{ "When we introduce vector quantities such as velocity and gradient, it is \ convenient to use rectangular coordinates. For this reason we will redefine \ our motion and position, velocity, and unit tangent vectors parametrically in \ ", StyleBox["x", FontSlant->"Italic"], " and ", StyleBox["y", FontSlant->"Italic"], ", using the above parametrizations for r and \[Theta].\n\nTo show the \ direction of movement along the figure-8, we will place a few arrows on the \ graph. Adding arrows to the graph requires loading a graphics arrow package. \ Remember to load the package before you execute a command within the \ package." }], "Text"], Cell[BoxData[ \(<< Graphics`Arrow`\)], "Input"], Cell[BoxData[{ \(\(x1[t_] = r[t] Cos[\[Theta][t]];\)\), "\n", \(\(y1[t_] = r[t] Sin[\[Theta][t]];\)\), "\n", \(\(pp8 = ParametricPlot[{x1[t], y1[t]}, {t, 0, 2 \[Pi]}, AspectRatio -> Automatic, PlotStyle -> RGBColor[1, 0, 0], AxesLabel -> {"\", "\"}, Epilog \[Rule] {Arrow[{x1[1], y1[1]}, {x1[1.1], y1[1.1]}, HeadScaling \[Rule] Absolute], Arrow[{x1[2.5], y1[2.5]}, {x1[2.6], y1[2.6]}, HeadScaling \[Rule] Absolute], Arrow[{x1[4], y1[4]}, {x1[4.1], y1[4.1]}, HeadScaling \[Rule] Absolute], Arrow[{x1[5.5], y1[5.5]}, {x1[5.6], y1[5.6]}, HeadScaling \[Rule] Absolute]}];\)\)}], "Input"], Cell["\<\ In the following Parts as we examine the motion, we will need the unit \ tangent vector, so we now define the quantities we will use.\ \>", "Text"], Cell[BoxData[{ \(\(position[t_] = {x1[t], y1[t]} // Simplify;\)\), "\n", \(\(velocity[t_] = \(position'\)[t] // Simplify;\)\), "\n", \(\(speed[t_] = \@\(velocity[t] . velocity[t] // Simplify\);\)\), "\n", \(\(unittangent[t_] = velocity[t]/speed[t] // Simplify;\)\), "\n", \(Print["\", position[t]]\), "\n", \(Print["\", velocity[t]]\), "\n", \(Print["\", unittangent[t]]\)}], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["You Try It: Part I", "Section"], Cell[TextData[{ "Select and plot your own parametric equations for ", StyleBox["x", FontSlant->"Italic"], " and ", StyleBox["y", FontSlant->"Italic"], ". Replace the ", StyleBox["x2", FontSlant->"Italic"], " and ", StyleBox["y2", FontSlant->"Italic"], " functions in red. Remember that you are laying out a path for a \ skateboarder. You can execute the following example if you wish, and then try \ one of your own." }], "Text"], Cell[BoxData[{ RowBox[{ RowBox[{\(x2[t_]\), "=", StyleBox[\(10 Sin[t - 1]\^2\), FontColor->RGBColor[1, 0, 0]]}], ";", "\n", RowBox[{\(y2[t_]\), "=", StyleBox[\(10 Cos[2 t]\^3\), FontColor->RGBColor[1, 0, 0]]}], ";", "\n", \(pos[t_] = {x2[t], y2[t]} // Simplify\), ";", "\n", \(vel[t_] = \(pos'\)[t] // Simplify\), ";", "\n", \(spd[t_] = \@\(vel[t] . vel[t] // Simplify\)\), ";", "\n", \(unittan[t_] = vel[t]/spd[t] // Simplify\), ";", "\n", \(Print["\", pos[t]]\)}], "\n", \(Print["\", vel[t]]\), "\n", \(Print["\", unittan[t]]\)}], "Input"], Cell[TextData[{ "Look at the graph, and adjust the limits on ", StyleBox["t", FontSlant->"Italic"], " if necessary." }], "Text"], Cell[BoxData[ RowBox[{ RowBox[{"ppnew", "=", RowBox[{"ParametricPlot", "[", RowBox[{\({x2[t], y2[t]}\), ",", RowBox[{"{", RowBox[{ StyleBox["t", FontColor->GrayLevel[0]], StyleBox[",", FontColor->GrayLevel[0]], StyleBox["0", FontColor->RGBColor[1, 0, 0]], StyleBox[",", FontColor->RGBColor[1, 0, 0]], StyleBox["7", FontColor->RGBColor[1, 0, 0]]}], "}"}], ",", \(PlotStyle -> RGBColor[1, 0, 0]\), ",", \(AxesLabel -> {"\", "\"}\)}], "]"}]}], ";"}]], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["\<\ Part II: Skateboarding on a Planar Ramp and Computing and Analyzing the \ Directional Derivative\ \>", "Section"], Cell[TextData[{ "Now we consider a flat, inclined ramp for the skateboarder. The ramp has a \ 10% grade along the ", StyleBox["x", FontSlant->"Italic"], " direction (east-west) and a 20% grade along the ", StyleBox["y", FontSlant->"Italic"], " direction (north-south). Take the figure-8 from Part I as the horizontal \ projection of the skateboarder's path of motion on the inclined plane. If you \ were straight above the skateboarder and were looking down, the skateboarder \ would appear to move along the figure-8 in Part I. You would not see the \ incline of the plane. To visualize the ramp together with the figure-8, we \ produce plots, first in three-space, then projecting the motion onto the \ horizontal ", StyleBox["xy", FontSlant->"Italic"], "-plane." }], "Text"], Cell[BoxData[{ \(Clear[x, y]\), "\n", \(\(ramp[x_, y_] = .1 x + .2 y;\)\), "\n", \(\(p8ramp = ParametricPlot3D[{x1[t], y1[t], ramp[x1[t], y1[t]], RGBColor[1, 0, 0]}, {t, 0, 2 \[Pi]}, AxesLabel -> {x, y, z}, DisplayFunction -> Identity];\)\), "\n", \(\(pramp = Plot3D[ramp[x, y], {x, \(-10\), 10}, {y, \(-20\), 20}, DisplayFunction -> Identity];\)\), "\n", \(\(Show[p8ramp, pramp, DisplayFunction -> $DisplayFunction];\)\), "\n", \(\(ctramp = ContourPlot[ramp[x, y], {x, \(-10\), 10}, {y, \(-20\), 20}, ContourShading -> False, DisplayFunction -> Identity];\)\), "\n", \(\(Show[pp8, ctramp, DisplayFunction -> $DisplayFunction];\)\)}], "Input"], Cell[BoxData[ ButtonBox[ ButtonBox[ RowBox[{ StyleBox["\[MathematicaIcon]", FontWeight->"Bold", FontColor->RGBColor[0.792981, 0.777356, 0.144533], FontVariations->{"CompatibilityType"->0}], StyleBox[" ", FontWeight->"Bold", FontSlant->"Italic"], StyleBox["About", FontWeight->"Bold", FontColor->RGBColor[0.500008, 0, 0.500008]], StyleBox[" ", FontWeight->"Bold", FontSlant->"Italic"], StyleBox["Mathematica", FontWeight->"Bold", FontSlant->"Italic", FontColor->RGBColor[0.500008, 0, 0.500008]]}], ButtonStyle->"Paste"], ButtonData:>"h2", ButtonStyle->"Hyperlink"]], "Input", Evaluatable->False, CellTags->"hb2"], Cell["\<\ Look at the contour plot above. Recall that the gradient of a function of two \ variables is a vector in the domain perpendicular to the contours. If you dot \ the gradient of the ramp into a unit vector in the direction of movement \ around the figure-8 in the plane, can you predict when that dot product will \ be 0 and where it is positive or negative?\ \>", "Text"], Cell[TextData[{ "Let's calculate the directional derivative of the height of the ramp \ relative to the changing positions along the skateboarder's path in the \ domain. Note that we are interested only in the gradient of the ", StyleBox["z", FontSlant->"Italic"], "-function along the path of the figure-8. That is what the ", StyleBox[" /.{x->x1[t],y->y1[t]", FontWeight->"Bold"], " refers to after the standard definition of the gradient.\n\nBefore \ computing the directional derivative, look at both the two- and \ three-dimensional plots. When might you expect the directional derivative to \ be 0? Why? When might you expect it to be a maximum or a minimum? Jot down \ your estimates and see how they compare to the computed results that follow." }], "Text"], Cell[BoxData[{ \(gradient[ z_] := {D[z, x], D[z, y]} /. {x -> x1[t], y -> y1[t]}\), "\n", \(dirderiv[z_, t_] := gradient[z] . unittangent[t]\), "\n", \(ddramp[t_] = dirderiv[ramp[x, y], t]\)}], "Input"], Cell[TextData[{ "Look at your result carefully. What happens to the value of the \ directional derivative when ", StyleBox["t", FontSlant->"Italic"], " is a multiple of \[Pi]?\n\n Let's look at both the left-hand (Direction\ \[Rule]1) and the right-hand (Direction\[Rule]-1) limits for the directional \ derivative as ", StyleBox["t", FontSlant->"Italic"], "\[Rule]\[Pi]." }], "Text"], Cell[BoxData[{ \(Print["\", Limit[ddramp[t], t \[Rule] \[Pi], Direction \[Rule] 1]]\), "\n", \(Print["\", Limit[ddramp[t], t \[Rule] \[Pi], Direction \[Rule] \(-1\)]]\)}], "Input"], Cell[TextData[{ "Uh-oh! What does this tell you about the value of the directional \ derivative at ", Cell[BoxData[ \(TraditionalForm\`t\ = \ \[Pi]\)]], "?" }], "Text"], Cell["\<\ Now consider the plot of this directional derivative as the skateboarder \ traverses the entire figure-8.\ \>", "Text"], Cell[BoxData[ \(\(pdd = Plot[ddramp[t], {t, 0, 7}, PlotStyle -> RGBColor[0, 0, 1], AxesLabel -> {t, "\"}, Ticks -> {{0, \[Pi]/2, \[Pi], 3 \[Pi]/2, 2 \[Pi], 5 \[Pi]/2}, Automatic}];\)\)], "Input"], Cell[TextData[{ "What do the sharp turns in this plot mean? Where are these sharp turns \ occurring? What has caused them? You may want to go back to your figure-8 \ graph and see what happens at ", StyleBox["t", FontSlant->"Italic"], " = \[Pi] and at ", StyleBox["t", FontSlant->"Italic"], " = 2\[Pi]. The vertical segments drawn at ", StyleBox["t", FontSlant->"Italic"], " = \[Pi] and at ", StyleBox["t", FontSlant->"Italic"], " = 2\[Pi] don't really represent the directional derivative, because it \ actually takes a jump at those points. Is there any way that you could adjust \ the path of the skateboarder to make the directional derivative continuous \ and the motion smooth at ", StyleBox["t", FontSlant->"Italic"], " = \[Pi] and at ", StyleBox["t", FontSlant->"Italic"], " = 2\[Pi]?" }], "Text"], Cell[TextData[{ "What does it mean when the directional derivative is 0? We will encounter \ this later in the module on Lagrange multipliers. For later comparison, we go \ ahead and use the ", StyleBox["FindRoot", FontWeight->"Bold"], " command to estimate the places where the directional derivative is 0, \ ignoring the places of discontinuity (", Cell[BoxData[ \(TraditionalForm\`\(\(t = \)\ \)\)]], "\[Pi] or 2\[Pi])" }], "Text"], Cell[BoxData[{ \(\(dd1 = FindRoot[ddramp[t], {t, 1.5}];\)\), "\n", \(\(dd2 = FindRoot[ddramp[t], {t, 2.8}];\)\), "\n", \(\(dd3 = FindRoot[ddramp[t], {t, 4.5}];\)\), "\n", \(\(dd4 = FindRoot[ddramp[t], {t, 6}];\)\), "\n", \(Print["\", ddzero = {dd1, dd2, dd3, dd4}]\)}], "Input"], Cell[BoxData[{ \(Clear[xyzdisplay, xyzset]\), "\n", \(\(xyzset = Table[N[{ddzero[\([i, 1, 2]\)], x1[ddzero[\([i, 1, 2]\)]], y1[ddzero[\([i, 1, 2]\)]], ramp[x1[ddzero[\([i, 1, 2]\)]], y1[ddzero[\([i, 1, 2]\)]]]}], {i, 1, Length[ddzero]}];\)\), "\n", \(xyzdisplay = PrependTo[xyzset, {"\", "\", "\", "\"}] // TableForm\)}], "Input"], Cell["Where are these points on your plots?", "Text"], Cell[CellGroupData[{ Cell["Looking at the Time Derivative", "Subsection"], Cell[TextData[{ "If we assume that the parameter ", StyleBox["t", FontSlant->"Italic"], " represents time and determine the rate of change of the skateboarder's \ height with respect to time, we can multiply the directional derivative by \ the speed in the ", StyleBox["xy", FontSlant->"Italic"], "-plane. Why?" }], "Text"], Cell[BoxData[{ \(\ntimederivramp[t_] := ddramp[t]\ speed[t]\), "\n", \(\(ps = Plot[speed[t], {t, 0, N[2 \[Pi]]}, PlotRange -> All, AxesLabel -> {time, speed}];\)\), "\n", \(\(Plot[timederivramp[t], {t, 0, N[2 \[Pi]]}, AxesLabel -> {time, "\