(************** Content-type: application/mathematica **************
CreatedBy='Mathematica 5.1'
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[ 31702, 1040]*)
(*NotebookOutlinePosition[ 33111, 1088]*)
(* CellTagsIndexPosition[ 33037, 1082]*)
(*WindowFrame->Normal*)
Notebook[{
Cell[BoxData[
\(<< Graphics`\)], "Input",
InitializationCell->True],
Cell[CellGroupData[{
Cell["Calculus IV Lab 1: Limits and Functions", "Title"],
Cell[CellGroupData[{
Cell["Limits", "Section"],
Cell[TextData[{
"Taking a limit of a function of two variables can be very difficult. ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" can take limits of a function of a single variable relatively easy:"
}], "Text"],
Cell[BoxData[
\(Limit[Sin[\@x]\/x, x \[Rule] 0]\)], "Input"],
Cell[TextData[{
"However, it does not have a built-in command for finding the limit of a \
multi-variable function. This is unfortunate (though not really surprising, \
considering the complications that can arise in 3 dimensions). \n\nFor \
limits of functions of two variables, it can often be useful to graph the \
function around the limit point first. This can give you an idea of whether \
the limit exists or not. If it looks like it doesn't exist, the graph may \
give you some good ideas of what paths to test the limit along to look for \
differing values. If you can find two different paths with two different \
limits, then you're done (the limit does not exist). ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" can also aid you in taking limits along these paths. If it looks like \
the limit does exist, you might be able to use ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" to ease your suffering as you try to prove it really does exist (sadly, \
",
StyleBox["Mathematica",
FontSlant->"Italic"],
" won't prove it for you...).\n\nAs an example, let's examine ",
Cell[BoxData[
\(TraditionalForm\`\(\(Limit\)\(\ \)\)\+\(\((x, y)\) \[Rule] \((0, 0)\)\
\)\ \(x\^3 + \ y\^2\)\/\(x\^2 + y\^2\)\)]],
":"
}], "Text"],
Cell[BoxData[
\(Plot3D[\(x\^3\ + y\^2\)\/\(x\^2 + y\^2\), {x, \(-0.05\),
0.05}, {y, \(-0.05\), 0.05}, PlotPoints \[Rule] 40]\)], "Input"],
Cell["\<\
It can also be very useful to look at a contour plot over the same region:\
\>", "Text"],
Cell[BoxData[
\(ContourPlot[\(x\^3\ + y\^2\)\/\(x\^2 + y\^2\), {x, \(-0.05\),
0.05}, {y, \(-0.05\), 0.05}, PlotPoints \[Rule] 100]\)], "Input"],
Cell["\<\
Although you can't really tell for certain here, it looks like the graph may \
approach different limits, depending upon what path you approach it on. \
\>", "Text"],
Cell["\<\
Explain how the contour plot shows you the limit probably doesn't exist.\
\>", "Text",
FontWeight->"Bold",
CellTags->"Problem"],
Cell[TextData[{
"Now, let's test this on paths of the form ",
Cell[BoxData[
\(TraditionalForm\`y = m\ x\)]],
":"
}], "Text"],
Cell[BoxData[
\(Limit[\(x\^3\ + \((m\ x)\)\^2\)\/\(x\^2 + \((m\ x)\)\^2\),
x \[Rule] 0]\)], "Input"],
Cell["\<\
A fancier way to do this would be using the \"ReplaceAll\" operator:\
\>", "Text"],
Cell[BoxData[
\(Limit[\(x\^3\ + y\^2\)\/\(x\^2 + y\^2\) /. y \[Rule] m\ x,
x \[Rule] 0]\)], "Input"],
Cell[TextData[{
"Since this depends upon m, the limit cannot exist. On the other hand, \
consider ",
Cell[BoxData[
\(TraditionalForm\`lim\+\(\((x, y)\) \[Rule] \((0, 0)\)\)\(x\ \
y\^2\)\/\(x\^2 + y\^4\)\)]],
":"
}], "Text"],
Cell[BoxData[
\(Plot3D[\(x\ y\^2\)\/\(x\^2 + y\^4\), {x, \(-0.5\), 0.5}, {y, \(-0.5\),
0.5}, PlotPoints \[Rule] 100, Mesh \[Rule] False]\)], "Input"],
Cell[BoxData[
\(ContourPlot[\(x\ y\^2\)\/\(x\^2 + y\^4\), {x, \(-0.2\),
0.2}, {y, \(-0.2\), 0.2}, PlotPoints \[Rule] 100]\)], "Input"],
Cell["\<\
The limit doesn't appear to exist here. Again, let's check all linear paths \
through this point:\
\>", "Text"],
Cell[BoxData[
\(Limit[\(x\ \ y\^2\)\/\(x\^2 + y\^4\) /. y \[Rule] m\ x,
x \[Rule] 0]\)], "Input"],
Cell["\<\
The contour lines here give you a clue: they look (vaguely) parabolic. So, \
let's try a parabolic path through the origin:\
\>", "Text"],
Cell[BoxData[
\(Limit[\(x\ \ y\^2\)\/\(x\^2 + y\^4\) /. y \[Rule] m\ x\^2,
x \[Rule] 0]\)], "Input"],
Cell[TextData[{
"Of course, the contours actually look more like parabolas of the form ",
Cell[BoxData[
\(TraditionalForm\`x = m\ y\^2\)]],
":"
}], "Text"],
Cell[BoxData[
\(Limit[\(x\ \ y\^2\)\/\(x\^2 + y\^4\) /. x \[Rule] m\ y\^2,
x \[Rule] 0]\)], "Input"],
Cell[TextData[{
"This goes to different limits for different values of m, so the original \
limit does not exist. So, sometimes checking all lines isn't good enough.\n\n\
Let's examine one more example: ",
Cell[BoxData[
\(TraditionalForm\`lim\+\(\((x, y)\) \[Rule] \((0, 0)\)\)y\^3\/\(x\^2 + \
y\^2\)\)]]
}], "Text"],
Cell[BoxData[
\(Plot3D[\(\(\ \)\(y\^3\)\)\/\(x\^2 + y\^2\), {x, \(-0.5\),
0.5}, {y, \(-0.5\), 0.5}, PlotPoints \[Rule] 60,
Mesh \[Rule] False]\)], "Input"],
Cell[BoxData[
\(ContourPlot[\(\(\ \)\(y\^3\)\)\/\(x\^2 + y\^2\), {x, \(-0.5\),
0.5}, {y, \(-0.5\), 0.5}, PlotPoints \[Rule] 100]\)], "Input"],
Cell[TextData[{
"Here, it looks like the limit DOES exist. Notice that this doesn't \
actually prove this; you still have to figure out a way to do that. ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" may or may not help to do this. Hint: for (x,y) close to (0,0), ",
Cell[BoxData[
\(0 \[LessEqual] \(\(\[VerticalSeparator]\)\(y\^3\)\(\
\[VerticalSeparator]\)\)\/\(x\^2 + y\^2\) \[LessEqual] \[VerticalSeparator]
y \[VerticalSeparator] \)]]
}], "Text"],
Cell[TextData[{
"For each of the following, use ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" to decide whether the limit exists or not. Support your decision with \
appropriate graphs. If it doesn't exist, confirm this fact algebraically \
(you can use ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" to do the grunt work on that as well)."
}], "Text",
FontWeight->"Bold",
CellTags->"Problem"],
Cell[TextData[{
"1. ",
Cell[BoxData[
\(TraditionalForm\`lim\+\(\((x, y)\) \[Rule] \((0, \
0)\)\)\(ln(x\^2\/y\^6)\)\/\(cos(x\^3 - y\^2)\)\)]],
"\n\nNote: ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" uses the function Log for the natural logarithm (rather than ln)."
}], "Text"],
Cell[TextData[{
"2. ",
Cell[BoxData[
FormBox[
RowBox[{\(lim\+\(\((x, y)\) \[Rule] \((0, 0)\)\)\),
FormBox[\(\(sin(3\ y\^2 + x)\)\/\(tan(2\ x\^2 + y)\)\),
"TraditionalForm"]}], TraditionalForm]]]
}], "Text"],
Cell[TextData[{
"3. ",
Cell[BoxData[
FormBox[
RowBox[{\(lim\+\(\((x, y)\) \[Rule] \((0, 0)\)\)\),
FormBox[\(\(\(cos(2\ x)\)\ \(ln(3\ y\^2)\)\)\/\(\(sin(
6\ x)\)\ \(tan(5\ y)\)\)\),
"TraditionalForm"]}], TraditionalForm]]]
}], "Text"]
}, Open ]],
Cell[CellGroupData[{
Cell["Functions", "Section"],
Cell[CellGroupData[{
Cell["Composition of functions", "Subsection"],
Cell[TextData[{
"There are different ways to define a function of more than one variable in \
",
StyleBox["Mathematica",
FontSlant->"Italic"],
". "
}], "Text"],
Cell[TextData[Cell[BoxData[
\(TraditionalForm\`f[x_, y_, z_,
t_] := \(x\ y\ z\ Sin[2 \[Pi]\ t]\)\/\(x\^2 + y\^2 + z\^2\)\)]]], \
"Text",
Evaluatable->True,
FontWeight->"Bold"],
Cell[TextData[Cell[BoxData[
\(TraditionalForm\`g[x_, y_] := {y, x\^2}\)]]], "Text",
Evaluatable->True,
FontWeight->"Bold"],
Cell[TextData[Cell[BoxData[
\(TraditionalForm\`h[t_] := {Sin[t], Cos[t], t, 2 t}\)]]], "Text",
Evaluatable->True,
FontWeight->"Bold"],
Cell["\<\
Taking the composition of two functions is relatively easy (don't forget to \
evaluate the functions above first):\
\>", "Text"],
Cell[BoxData[
\(h[f[x, y, z, t]]\)], "Input"],
Cell["However, try:", "Text"],
Cell[BoxData[
\(g[g[x, y]]\)], "Input"],
Cell["\<\
This doesn't work. It SHOULD work, but it doesn't. To get around this \
problem, we will often define functions of more than one variable in the \
following way:\
\>", "Text"],
Cell[BoxData[
\(g[{x_, y_}] := {y, x\^2}\)], "Input"],
Cell["Now:", "Text"],
Cell[BoxData[
\(g[g[x, y]]\)], "Input"],
Cell[TextData[{
"Will ",
Cell[BoxData[
\(TraditionalForm\`f[h[t]]\)]],
" work with the above definitions? Should it? If so, modify the \
definitions so it does."
}], "Text",
FontWeight->"Bold",
CellTags->"Problem"]
}, Open ]],
Cell[CellGroupData[{
Cell[TextData[{
"Functions as arguments (",
StyleBox["Operators",
FontSlant->"Italic"],
")"
}], "Subsection"],
Cell[TextData[{
"Notice that if you have a function of a single variable, ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" knows what you mean by:"
}], "Text"],
Cell[BoxData[
\(\(h'\)[t]\)], "Input"],
Cell["Partial derivatives are also pretty straightforward:", "Text"],
Cell[BoxData[
\(\[PartialD]\_x\ g[x, y]\)], "Input"],
Cell[TextData[{
"Sometimes, it is useful to define a function that operates on ",
StyleBox["other",
FontSlant->"Italic"],
" functions. So, for example, I could define a function to find the \
derivative matrix for functions from ",
Cell[BoxData[
\(TraditionalForm\`\[DoubleStruckCapitalR]\^2 \[Rule] \
\[DoubleStruckCapitalR]\^2\)]],
":"
}], "Text"],
Cell[BoxData[
\(deriv2By2[
expression_] := \({\[PartialD]\_x\ expression, \[PartialD]\_y\
expression} // Transpose\) // MatrixForm\)], "Input"],
Cell[BoxData[
\(deriv2By2[{x\ Sin[y], x\ Cos[y]}]\)], "Input"],
Cell[BoxData[
\(deriv2By2[g[x, y]]\)], "Input"],
Cell["\<\
(Notice that I needed to transpose the matrix to get the rows/columns to work \
out like we want. I used MatrixForm just because it looks cool.) However, \
you have to be really careful with these. For example, if I just make one \
minor little change when calling it:\
\>", "Text"],
Cell[BoxData[
\(deriv2By2[{u\ Cos[v], u\ Sin[v]}]\)], "Input"],
Cell["\<\
The problem is that, when we defined our function, we assumed that our \
variables would be called x and y, so any other choice of variables gets \
interpreted as a constant. One way to fix this would be to explicitly \
specify your independent variables in the definition:\
\>", "Text"],
Cell[BoxData[
\(deriv2By2b[expression_, var1_,
var2_] := \({\[PartialD]\_var1\ expression, \[PartialD]\_var2\
expression} // Transpose\) // MatrixForm\)], "Input"],
Cell[BoxData[
\(deriv2By2b[g[u, v], u, v]\)], "Input"],
Cell["\<\
This now works, though at the cost of a bit of redundancy in calling the \
function. (There are fancier tricks we could use to generalize this, but \
this is a good starting point.)
If you need to access one of the components of a vector, you can use the \
notation:\
\>", "Text"],
Cell[BoxData[
\(\(g[x, y]\)[\([1]\)]\)], "Input"],
Cell[BoxData[
\(\(g[x, y]\)[\([2]\)]\)], "Input"],
Cell[TextData[{
"Define your own functions to compute the gradient (call it myGrad) and \
divergence (call it myDiv) of an arbitrary function of 3 variables. (You may \
",
StyleBox["not",
FontSlant->"Italic"],
" use any of the built-in functions that handle these.) Demonstrate that \
each of these actually work for a few different functions."
}], "Text",
FontWeight->"Bold",
CellTags->"Problem"]
}, Open ]],
Cell[CellGroupData[{
Cell["ParametricPlot3D with spherical and cylindrical coordinates", \
"Subsection"],
Cell[TextData[{
StyleBox["Mathematica",
FontSlant->"Italic"],
" has special built-in functions for graphing cylindrical and polar \
coordinates (CylinderPlot3D and SphericalPlot3D). Unfortunately, these \
aren't really as versatile as we might wish. For example, they wouldn't be \
capable of plotting something as simple as ",
Cell[BoxData[
\(TraditionalForm\`\[Phi] = \[Pi]\/6\)]],
". Both of these commands are based on a much more flexible command, \
ParametricPlot3D.\n\nParametricPlot3D requires a function from either ",
Cell[BoxData[
\(TraditionalForm\`\(\(\[DoubleStruckCapitalR]\)\(\[Rule]\)\(\
\[DoubleStruckCapitalR]\^3\)\(\ \)\)\)]],
"or ",
Cell[BoxData[
\(TraditionalForm\`\(\(\[DoubleStruckCapitalR]\^2\)\(\[Rule]\)\(\
\[DoubleStruckCapitalR]\^3\)\(\ \)\)\)]],
"as an input. It will then graph the ",
StyleBox["range",
FontSlant->"Italic"],
" of the function. Thus:"
}], "Text"],
Cell[BoxData[
\(curve[t_] := {t, Sin[t], Cos[2 t]}\)], "Input"],
Cell[BoxData[
\(ParametricPlot3D[curve[t], {t, 0, 3 \[Pi]}]\)], "Input"],
Cell["If you like, you can use ParametricPlot3D to draw a surface:", "Text"],
Cell[BoxData[
\(surface[u_, v_] := {u\ Sin[v], u\ Cos[v], u\^2}\)], "Input"],
Cell[BoxData[
\(ParametricPlot3D[
surface[u, v], {u, \(-1\), 1}, {v, 0, 2 \[Pi]}]\)], "Input"],
Cell["\<\
You can even use ParametricPlot3D to graph a function of 2 variables:\
\>", "Text"],
Cell[BoxData[
\(f[x_, y_] := x\^2 + y\^2\)], "Input"],
Cell[BoxData[
\(ParametricPlot3D[{x, y, f[x, y]}, {x, \(-1\), 1}, {y, \(-1\),
1}]\)], "Input"],
Cell["\<\
(If you had used the Plot3D function instead, it would have looked a little \
nicer...)\
\>", "Text"],
Cell["\<\
These two graphs look suspiciously alike. Show that they are really the same \
surface. Why do they look so different?\
\>", "Text",
FontWeight->"Bold",
CellTags->"Problem"],
Cell["\<\
In order to use ParametricPlot3D to graph things in spherical and cylindrical \
coordinates, you must first develop a \"change of variable\" function. For \
example, a change of variable function for polar coordinates might look \
something like:\
\>", "Text"],
Cell[BoxData[
\(polarToRect[{r_, \[Theta]_}] := {r\ Cos[\[Theta]],
r\ Sin[\[Theta]]}\)], "Input"],
Cell[BoxData[
\(rectToPolar[{x_, y_}] := {\@\(x\^2 + y\^2\), ArcTan[y\/x]}\)], "Input"],
Cell[BoxData[
\(polarToRect[{2, \[Pi]\/6}]\)], "Input"],
Cell[BoxData[
\(rectToPolar[{\@3, 1}]\)], "Input"],
Cell[BoxData[
\(rectToPolar[polarToRect[{2, \[Pi]\/6}]]\)], "Input"],
Cell["Warning:", "Text"],
Cell[BoxData[
\(rectToPolar[{\(-\@3\), 1}]\)], "Input"],
Cell["What is wrong with this and why?", "Text",
FontWeight->"Bold",
CellTags->"Problem"],
Cell["\<\
Fortunately, we are mainly interested in polarToRect (actually the \
equivalents for cylindrical and spherical coordinates).\
\>", "Text"],
Cell[TextData[{
"Create 2 new functions: cylinderToRect (accepts points in the form ",
Cell[BoxData[
\(TraditionalForm\`{r, \[Theta], z}\)]],
") and sphereToRect (accepts points in the form ",
Cell[BoxData[
\(TraditionalForm\`{\[Rho], \[Theta], \[Phi]}\)]],
") to make the appropriate conversions. Notice that both of these \
functions are from ",
Cell[BoxData[
\(TraditionalForm\`\[DoubleStruckCapitalR]\^3 \[Rule] \
\[DoubleStruckCapitalR]\^3\)]],
"."
}], "Text",
FontWeight->"Bold",
CellTags->"Problem"],
Cell[TextData[{
"You can use these new functions in conjunction with ParametricPlot3D to \
graph most equations in cylindrical and spherical coordinates. (You can even \
use it to graph cylindrical or spherical \"parametric equations,\" something \
you don't see in many textbooks...)\n\nFor example, to graph something like \
",
Cell[BoxData[
\(TraditionalForm\`\[Rho] = Sin[\[Theta]] Cos[\[Phi]]\)]],
", you would do something like:"
}], "Text"],
Cell[BoxData[
\(\[Rho] = Sin[\[Theta]] Cos[\[Phi]]\)], "Input"],
Cell[BoxData[
\(ParametricPlot3D[
sphereToRect[{\[Rho], \[Theta], \[Phi]}], {\[Theta], 0,
2 \[Pi]}, {\[Phi], 0, 2 \[Pi]}]\)], "Input"],
Cell[TextData[{
"(Notice that you can only have 2 independent variables inside \
ParametricPlot3D, \[Theta] and \[Phi] in this case.)\n\nOf course, the \
built-in SphericalPlot3D function could have done this (with less effort). \
However, you can also use your new functions to plot ",
Cell[BoxData[
\(TraditionalForm\`\[Theta] = \[Pi]\/4\)]],
":"
}], "Text"],
Cell[BoxData[
\(ParametricPlot3D[
sphereToRect[{\[Rho], \[Pi]\/4, \[Phi]}], {\[Rho], 0, 5}, {\[Phi],
0, \[Pi]}]\)], "Input"],
Cell["\<\
Use the functions you developed above to graph the following (carefully \
choose what regions to graph over):\
\>", "Text",
FontWeight->"Bold",
CellTags->"Problem"],
Cell[TextData[{
"1. ",
Cell[BoxData[
\(TraditionalForm\`r = z\ \(cos(2 \[Theta])\)\)]]
}], "Text",
FontWeight->"Bold"],
Cell[TextData[{
"2. ",
Cell[BoxData[
\(TraditionalForm\`\[Phi] = \[Rho]\ \(sin(\[Theta]\/2)\)\)]]
}], "Text",
FontWeight->"Bold"],
Cell[TextData[{
"3. ",
Cell[BoxData[
\(TraditionalForm\`r = \(sin(u)\) \(cos(v)\), \ \[Theta] = sin(u\ v), \
z = cos(u + v)\)]]
}], "Text",
FontWeight->"Bold"]
}, Open ]],
Cell[CellGroupData[{
Cell["\<\
Graphing the Ungraphable (Or: Making Molehills out of Mountains)\
\>", "Subsection"],
Cell[TextData[{
"As we have discussed in class, we often run into functions that require \
more dimensions to graph than we actually have available to us. This is \
really an even bigger problem on a computer, since we are technically limited \
to 2 dimensions instead of our usual 3. (Well, as you have seen above, we \
fake our way around that...) We can use different tricks to visualize these \
sorts of functions anyway. Here are a few techniques that you could use to \
display information in different ways; by combining these (along with other \
things you may think of), we can often work around these limitations. One \
warning: Just because an idea is cool doesn't mean it's a good idea. The \
method we choose depends to a large extent on ",
StyleBox["what",
FontSlant->"Italic"],
" we are trying to model."
}], "Text"],
Cell[CellGroupData[{
Cell["Animation - Bending time to your will", "Subsubsection"],
Cell[TextData[{
"There are several different commands in ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" you can use to animate objects. Personally, I prefer to use the ",
StyleBox["Table",
FontWeight->"Bold"],
" command; I find it to be the most flexible. Basically, it works like \
this:\n\n",
StyleBox["Table[ ",
FontWeight->"Bold"],
"stuff to do , {counter, start value, stop value, step size} ",
StyleBox["]\n\n",
FontWeight->"Bold"],
"So, for example, to animate a sin curve with an amplitude that varies from \
-6 to 6, counting by 2's, you could do:"
}], "Text"],
Cell[BoxData[
\(Table[
Plot[k\ Sin[x], {x, \(-2\) \[Pi], 2 \[Pi]}], {k, \(-6\), 6,
2}]\)], "Input"],
Cell[TextData[{
"Notice a couple of things about this: \n\nWhen you run the command, it \
generates a bunch of separate graphs; these are the \"frames\" of your \
animation. To see it \"run\", double-click on the first frame. (If you \
don't want to see all the individual frames, double-click on the bracket to \
the right of the picture that contains all the frames - the second from the \
left.)\n\nMore disturbingly, the amplitude doesn't actually seem to change. \
Actually, if you look carefully, you can see it does, but ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" automatically rescales all the pictures to show the graph as large as \
possible, so they all look the same. To fix this, you need to use the ",
StyleBox["PlotRange",
FontWeight->"Bold"],
" option to tell ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" exactly what viewing window to use for all your frames:"
}], "Text"],
Cell[BoxData[
\(Table[
Plot[k\ Sin[x], {x, \(-2\) \[Pi], 2 \[Pi]},
PlotRange \[Rule] {\(-6\), 6}], {k, \(-6\), 6, 2}]\)], "Input"],
Cell[TextData[{
"A very handy trick you can also use is to give the ",
StyleBox["Table",
FontWeight->"Bold"],
" a name and then ",
StyleBox["Show",
FontWeight->"Bold"],
" the table, drawing all the \"frames\" together on a single graph:"
}], "Text"],
Cell[BoxData[
\(fred =
Table[Plot[k\ Sin[x], {x, \(-2\) \[Pi], 2 \[Pi]},
PlotRange \[Rule] {\(-6\), 6}], {k, \(-6\), 6, 2}]\)], "Input"],
Cell[BoxData[
\(Show[fred]\)], "Input"],
Cell[TextData[{
"The ",
StyleBox["Table",
FontWeight->"Bold"],
" command can be used for a lot of other things as well (including nesting \
tables within tables). The \"counter\" variable (",
StyleBox["k",
FontSlant->"Italic"],
" in my example) can be thought of as time in this usage, however."
}], "Text"]
}, Open ]],
Cell[CellGroupData[{
Cell["Color - Which way is up?", "Subsubsection"],
Cell[TextData[{
"Another important method for encoding data is by color. Of course, unlike \
time where order is usually obvious, color presents a real problem of \
interpretation. Which color is \"first\" or \"smallest\"? If you use \
color, you have to make this clear. If you want to look this up in the ",
StyleBox["Help",
FontSlant->"Italic"],
" browser, you can learn about this in detail, but here is a relatively \
simple way to assign a color to a variable in some types of graphs. (I have \
chosen to use Grayscale rather than color actually, since it becomes \
relatively easy to assign an obvious order to those. Feel free to experiment \
with other options, if you enjoy that sort of thing...)\n\nIn some cases, ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" uses colors automatically:"
}], "Text"],
Cell[BoxData[
\(ContourPlot[x\^2 + y\^2, {x, \(-10\), 10}, {y, \(-10\), 10}]\)], "Input"],
Cell[TextData[{
"In ",
StyleBox["Plot3D ",
FontWeight->"Bold"],
"and ",
StyleBox["ParametricPlot3D",
FontWeight->"Bold"],
", you can specify an extra list element (like an extra dimension to the \
range vector) with a color specification. One important catch here is that \
you can only specify GrayLevel values between 0 and 1, so you have to be sure \
you scale that \"variable\" accordingly. (This is a pain, since it varies \
with the domain, but not really a serious restriction in displaying your \
data.)"
}], "Text"],
Cell[BoxData[
\(Plot3D[{Sin[x\ y],
GrayLevel[
Sin[x + y]\^2]}, {x, \(-\[Pi]\), \[Pi]}, {y, \(-\[Pi]\), \[Pi]},
PlotPoints \[Rule] 50]\)], "Input"],
Cell[TextData[{
"So, in this case, the color depends on ",
Cell[BoxData[
\(Sin[x + y]\^2\)], "Input"],
". In a parametric graph (curve or surface), you can just list a fourth \
component to your range vector:"
}], "Text"],
Cell[BoxData[
\(ParametricPlot3D[{t, Sin[t], Cos[t], GrayLevel[t/\((4 \[Pi])\)]}, {t,
0, 4 \[Pi]}, Lighting \[Rule] False,
Background \[Rule] SkyBlue]\)], "Input"],
Cell[BoxData[
\(joe =
ParametricPlot3D[{u\ Sin[v], \(-u\)\ Cos[v], u,
GrayLevel[1 - \ v\^2/\[Pi]\^2]}, {v, \(-\[Pi]\), \[Pi]}, {u, 0, 5},
Lighting \[Rule] False]\)], "Input"],
Cell[TextData[{
"Two important notes about this:\n\nIn ",
StyleBox["ParametricPlot3D",
FontWeight->"Bold"],
", it is important to set ",
StyleBox["Lighting\[Rule]False",
FontWeight->"Bold"],
" to show the colors properly. (Oddly enough, you must ",
StyleBox["not",
FontSlant->"Italic"],
" do that in ",
StyleBox["Plot3D",
FontWeight->"Bold"],
".)\n\nUnfortunately, there is ",
StyleBox["still",
FontSlant->"Italic"],
" a bug in the ",
StyleBox["RealTime3D",
FontWeight->"Bold"],
" module that will not pass on color information properly, so to make this \
work, you must not have ",
StyleBox["RealTime3D",
FontWeight->"Bold"],
" loaded. (If it is loaded already, you can unload it by ",
StyleBox["<"Bold"],
")"
}], "Text"]
}, Open ]],
Cell[CellGroupData[{
Cell["Vectors", "Subsubsection"],
Cell[TextData[{
"Nothing all that new here, but the ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" commands for plotting vector fields are ",
StyleBox["PlotVectorField",
FontWeight->"Bold"],
" and ",
StyleBox["PlotVectorField3D",
FontWeight->"Bold"],
". "
}], "Text"],
Cell[BoxData[
\(PlotVectorField[{u, u + v}, {u, \(-5\), 5}, {v, \(-5\), 5},
Axes \[Rule] True]\)], "Input"],
Cell[BoxData[
\(PlotVectorField3D[{u, v, w}, {u, \(-5\), 5}, {v, \(-5\),
5}, {w, \(-5\), 5}]\)], "Input"],
Cell[TextData[{
"There doesn't appear to be any easy way to add arrows to 3-D vectors in ",
StyleBox["Mathematica",
FontSlant->"Italic"],
"..."
}], "Text"]
}, Open ]],
Cell[CellGroupData[{
Cell["Deformations and Distortions", "Subsubsection"],
Cell["\<\
Sometimes, it makes sense to see what a function does to curves or surfaces \
from the domain space. So, for example:\
\>", "Text"],
Cell[BoxData[
\(polarTransform[{u_, v_}] := {u\ Sin[v], u\ Cos[v]}\)], "Input"],
Cell[BoxData[
\(domainCurveU = {t, \[Pi]\/6}; domainCurveV = {1, t};\)], "Input"],
Cell[TextData[{
"This graphs these two lines in the domain space (the green one holds ",
StyleBox["u",
FontSlant->"Italic"],
" constant and varies ",
StyleBox["v",
FontSlant->"Italic"],
", while the red one reverses this)."
}], "Text"],
Cell[BoxData[
\(domainCurves =
ParametricPlot[{domainCurveU, domainCurveV}, {t, \(-5\), 5},
PlotStyle \[Rule] {Red, Green},
AspectRatio \[Rule] Automatic]\)], "Input"],
Cell["Our function transforms these two curves as follows:", "Text"],
Cell[BoxData[
\(polarTransform[domainCurveU]\)], "Input"],
Cell[BoxData[
\(polarTransform[domainCurveV]\)], "Input"],
Cell[BoxData[
\(rangeCurves =
ParametricPlot[
Evaluate[{polarTransform[domainCurveU],
polarTransform[domainCurveV]}], {t, \(-5\), 5},
AspectRatio \[Rule] Automatic, PlotStyle \[Rule] {Red, Green},
PlotRange \[Rule] {{\(-5\), 5}, {\(-5\), 5}}]\)], "Input"],
Cell["\<\
(With a little more work, you could construct a grid of these and see how it \
transforms in general.) Here's another example with a less common \
function:\
\>", "Text"],
Cell[BoxData[
\(fTransform[{u_, v_}] := {u + v, u\^2/v\^2}\)], "Input"],
Cell[BoxData[
\(domainCurveU = {t, 1}; domainCurveV = {1, t};\)], "Input"],
Cell[BoxData[
\(domainCurves =
ParametricPlot[{domainCurveU, domainCurveV}, {t, \(-5\), 5},
PlotStyle \[Rule] {Red, Green},
AspectRatio \[Rule] Automatic]\)], "Input"],
Cell[BoxData[
\(fTransform[domainCurveU]\)], "Input"],
Cell[BoxData[
\(fTransform[domainCurveV]\)], "Input"],
Cell[BoxData[
\(rangeCurves =
ParametricPlot[
Evaluate[{fTransform[domainCurveU],
fTransform[domainCurveV]}], {t, \(-5\), 5},
AspectRatio \[Rule] Automatic, PlotStyle \[Rule] {Red, Green},
PlotRange \[Rule] {{\(-5\), 5}, {\(-5\), 5}}]\)], "Input"],
Cell[TextData[{
"Problems:\n",
StyleBox["For each of the following functions, decide upon a suitable \
method to display the graph (using the techniques mentioned above or other \
appropriate methods) and use ",
FontWeight->"Plain"],
StyleBox["Mathematica",
FontWeight->"Plain",
FontSlant->"Italic"],
StyleBox[" to show it. Warning: The fanciest method is definitely ",
FontWeight->"Plain"],
StyleBox["not",
FontWeight->"Plain",
FontSlant->"Italic"],
StyleBox[" always the best choice. ",
FontWeight->"Plain"],
"Choose ANY THREE",
StyleBox[" of these to do.",
FontWeight->"Plain"]
}], "Text",
FontWeight->"Bold",
CellTags->"Problem"],
Cell[TextData[{
StyleBox["1. ",
FontWeight->"Bold"],
Cell[BoxData[
FormBox[
RowBox[{\(T(x, y, t)\), "=",
StyleBox[\(30\/\(1 + x\^2 + \(y\^2\) sin\ \[Pi]\ t\)\),
FontSize->14]}], TraditionalForm]],
FontWeight->"Bold"],
StyleBox[" ",
FontWeight->"Bold"],
"\n",
StyleBox["T",
FontSlant->"Italic"],
" - The temperature (in \[Degree]C) on the surface of a flat plate ",
StyleBox["t",
FontSlant->"Italic"],
" hours after midnight at the point ",
Cell[BoxData[
\(TraditionalForm\`\((x, y)\)\)]],
" (both measured in inches from the center)."
}], "Text"],
Cell[TextData[{
StyleBox["2. ",
FontWeight->"Bold"],
Cell[BoxData[
FormBox[
RowBox[{
RowBox[{\(L \((x, y)\)\), "=",
RowBox[{"<",
StyleBox[\(\(1 + \ cos(\ 2 x\^2)\)\/\(1 + x\^2 + y\^2\)\),
FontSize->16]}]}],
",", \(\(20 \(\( sin\^2\)(x\ y)\)\)\(>\)\)}], TraditionalForm]]],
"\n",
StyleBox["L",
FontSlant->"Italic"],
" - The surface mass density (first coordinate of the range, in ",
Cell[BoxData[
\(TraditionalForm\`kg/m\^2\)]],
") and temperature (second coordinate of the range, in \[Degree]C) at a \
point ",
Cell[BoxData[
\(TraditionalForm\`\((x, y)\)\)]],
" on a plane."
}], "Text"],
Cell[TextData[{
StyleBox["3. ",
FontWeight->"Bold"],
Cell[BoxData[
\(TraditionalForm\`\(\[Del]\& \[Rule] \
\)\(\(\[CenterDot]\)\(polarTransform(u, v)\)\)\)],
FontWeight->"Bold"],
"\nThis is the same polarTransform function I defined in the explanatory \
text (above)."
}], "Text"],
Cell[TextData[{
StyleBox["4. ",
FontWeight->"Bold"],
Cell[BoxData[
\(TraditionalForm\`Cy(u, v,
w) = \(\(<\)\(\(-u\)\ cos\ v\)\), \(-u\)\ sin\ v, \(\(w\)\(>\)\)\)],
FontWeight->"Bold"],
"\nDo this one twice. Once, consider that this gives the velocity vector \
field of a fluid. Now, consider it as a transformation (or \"change of \
coordinates\") and graph it."
}], "Text"],
Cell[TextData[{
StyleBox["5. ",
FontWeight->"Bold"],
Cell[BoxData[
\(TraditionalForm\`D(u, v,
t) = \(\(<\)\(u\ \((cos\ v)\)\ \((1 +
cos\ t)\)\)\), \(\(u\ \((sin\ v)\) \((1 + \
sin\ t)\)\)\(>\)\)\)],
FontWeight->"Bold"],
"\nThis is a change of coordinates that is time-dependent. "
}], "Text"]
}, Open ]]
}, Open ]]
}, Open ]]
}, Open ]]
},
FrontEndVersion->"5.1 for Macintosh",
ScreenRectangle->{{35, 1680}, {0, 1028}},
AutoGeneratedPackage->None,
CellGrouping->Manual,
WindowSize->{834, 749},
WindowMargins->{{69, Automatic}, {Automatic, 24}},
CellLabelAutoDelete->True,
ShowCellTags->True
]
(*******************************************************************
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->{
"Problem"->{
Cell[4131, 117, 141, 4, 71, "Text",
CellTags->"Problem"],
Cell[7236, 218, 426, 12, 152, "Text",
CellTags->"Problem"],
Cell[9903, 324, 232, 8, 98, "Text",
CellTags->"Problem"],
Cell[12642, 422, 413, 10, 152, "Text",
CellTags->"Problem"],
Cell[14926, 495, 189, 5, 98, "Text",
CellTags->"Problem"],
Cell[15881, 530, 93, 2, 71, "Text",
CellTags->"Problem"],
Cell[16128, 539, 543, 15, 152, "Text",
CellTags->"Problem"],
Cell[17885, 590, 178, 5, 98, "Text",
CellTags->"Problem"],
Cell[28543, 930, 687, 21, 206, "Text",
CellTags->"Problem"]}
}
*)
(*CellTagsIndex
CellTagsIndex->{
{"Problem", 32386, 1059}
}
*)
(*NotebookFileOutline
Notebook[{
Cell[1754, 51, 73, 2, 46, "Input",
InitializationCell->True],
Cell[CellGroupData[{
Cell[1852, 57, 56, 0, 236, "Title"],
Cell[CellGroupData[{
Cell[1933, 61, 25, 0, 121, "Section"],
Cell[1961, 63, 228, 5, 78, "Text"],
Cell[2192, 70, 64, 1, 87, "Input"],
Cell[2259, 73, 1275, 25, 449, "Text"],
Cell[3537, 100, 151, 2, 119, "Input"],
Cell[3691, 104, 98, 2, 51, "Text"],
Cell[3792, 108, 157, 2, 119, "Input"],
Cell[3952, 112, 176, 3, 78, "Text"],
Cell[4131, 117, 141, 4, 71, "Text",
CellTags->"Problem"],
Cell[4275, 123, 136, 5, 51, "Text"],
Cell[4414, 130, 112, 2, 82, "Input"],
Cell[4529, 134, 92, 2, 51, "Text"],
Cell[4624, 138, 112, 2, 82, "Input"],
Cell[4739, 142, 236, 7, 93, "Text"],
Cell[4978, 151, 162, 2, 119, "Input"],
Cell[5143, 155, 147, 2, 119, "Input"],
Cell[5293, 159, 122, 3, 78, "Text"],
Cell[5418, 164, 108, 2, 82, "Input"],
Cell[5529, 168, 149, 3, 78, "Text"],
Cell[5681, 173, 111, 2, 82, "Input"],
Cell[5795, 177, 167, 5, 51, "Text"],
Cell[5965, 184, 111, 2, 82, "Input"],
Cell[6079, 188, 328, 7, 147, "Text"],
Cell[6410, 197, 175, 3, 119, "Input"],
Cell[6588, 202, 154, 2, 119, "Input"],
Cell[6745, 206, 488, 10, 121, "Text"],
Cell[7236, 218, 426, 12, 152, "Text",
CellTags->"Problem"],
Cell[7665, 232, 304, 9, 167, "Text"],
Cell[7972, 243, 248, 7, 69, "Text"],
Cell[8223, 252, 306, 9, 69, "Text"]
}, Open ]],
Cell[CellGroupData[{
Cell[8566, 266, 28, 0, 121, "Section"],
Cell[CellGroupData[{
Cell[8619, 270, 46, 0, 62, "Subsection"],
Cell[8668, 272, 169, 6, 78, "Text"],
Cell[8840, 280, 193, 5, 64, "Text",
Evaluatable->True],
Cell[9036, 287, 130, 3, 48, "Text",
Evaluatable->True],
Cell[9169, 292, 142, 3, 45, "Text",
Evaluatable->True],
Cell[9314, 297, 138, 3, 78, "Text"],
Cell[9455, 302, 49, 1, 46, "Input"],
Cell[9507, 305, 29, 0, 51, "Text"],
Cell[9539, 307, 43, 1, 46, "Input"],
Cell[9585, 310, 186, 4, 105, "Text"],
Cell[9774, 316, 57, 1, 49, "Input"],
Cell[9834, 319, 20, 0, 51, "Text"],
Cell[9857, 321, 43, 1, 46, "Input"],
Cell[9903, 324, 232, 8, 98, "Text",
CellTags->"Problem"]
}, Open ]],
Cell[CellGroupData[{
Cell[10172, 337, 119, 5, 62, "Subsection"],
Cell[10294, 344, 171, 5, 78, "Text"],
Cell[10468, 351, 42, 1, 46, "Input"],
Cell[10513, 354, 68, 0, 51, "Text"],
Cell[10584, 356, 56, 1, 46, "Input"],
Cell[10643, 359, 370, 10, 105, "Text"],
Cell[11016, 371, 170, 3, 100, "Input"],
Cell[11189, 376, 66, 1, 46, "Input"],
Cell[11258, 379, 51, 1, 46, "Input"],
Cell[11312, 382, 295, 5, 132, "Text"],
Cell[11610, 389, 66, 1, 46, "Input"],
Cell[11679, 392, 298, 5, 132, "Text"],
Cell[11980, 399, 191, 3, 98, "Input"],
Cell[12174, 404, 58, 1, 46, "Input"],
Cell[12235, 407, 292, 7, 186, "Text"],
Cell[12530, 416, 53, 1, 46, "Input"],
Cell[12586, 419, 53, 1, 46, "Input"],
Cell[12642, 422, 413, 10, 152, "Text",
CellTags->"Problem"]
}, Open ]],
Cell[CellGroupData[{
Cell[13092, 437, 83, 1, 89, "Subsection"],
Cell[13178, 440, 944, 22, 244, "Text"],
Cell[14125, 464, 68, 1, 46, "Input"],
Cell[14196, 467, 77, 1, 46, "Input"],
Cell[14276, 470, 76, 0, 51, "Text"],
Cell[14355, 472, 80, 1, 49, "Input"],
Cell[14438, 475, 105, 2, 72, "Input"],
Cell[14546, 479, 93, 2, 51, "Text"],
Cell[14642, 483, 57, 1, 49, "Input"],
Cell[14702, 486, 107, 2, 72, "Input"],
Cell[14812, 490, 111, 3, 78, "Text"],
Cell[14926, 495, 189, 5, 98, "Text",
CellTags->"Problem"],
Cell[15118, 502, 270, 5, 132, "Text"],
Cell[15391, 509, 110, 2, 46, "Input"],
Cell[15504, 513, 91, 1, 69, "Input"],
Cell[15598, 516, 59, 1, 69, "Input"],
Cell[15660, 519, 54, 1, 57, "Input"],
Cell[15717, 522, 72, 1, 69, "Input"],
Cell[15792, 525, 24, 0, 51, "Text"],
Cell[15819, 527, 59, 1, 57, "Input"],
Cell[15881, 530, 93, 2, 71, "Text",
CellTags->"Problem"],
Cell[15977, 534, 148, 3, 78, "Text"],
Cell[16128, 539, 543, 15, 152, "Text",
CellTags->"Problem"],
Cell[16674, 556, 459, 9, 213, "Text"],
Cell[17136, 567, 67, 1, 46, "Input"],
Cell[17206, 570, 155, 3, 72, "Input"],
Cell[17364, 575, 372, 8, 163, "Text"],
Cell[17739, 585, 143, 3, 104, "Input"],
Cell[17885, 590, 178, 5, 98, "Text",
CellTags->"Problem"],
Cell[18066, 597, 131, 5, 51, "Text"],
Cell[18200, 604, 141, 5, 59, "Text"],
Cell[18344, 611, 178, 6, 51, "Text"]
}, Open ]],
Cell[CellGroupData[{
Cell[18559, 622, 95, 2, 89, "Subsection"],
Cell[18657, 626, 848, 14, 294, "Text"],
Cell[CellGroupData[{
Cell[19530, 644, 62, 0, 44, "Subsubsection"],
Cell[19595, 646, 609, 16, 240, "Text"],
Cell[20207, 664, 119, 3, 46, "Input"],
Cell[20329, 669, 935, 18, 375, "Text"],
Cell[21267, 689, 150, 3, 72, "Input"],
Cell[21420, 694, 267, 8, 78, "Text"],
Cell[21690, 704, 159, 3, 98, "Input"],
Cell[21852, 709, 43, 1, 46, "Input"],
Cell[21898, 712, 326, 9, 105, "Text"]
}, Open ]],
Cell[CellGroupData[{
Cell[22261, 726, 49, 0, 44, "Subsubsection"],
Cell[22313, 728, 840, 15, 321, "Text"],
Cell[23156, 745, 93, 1, 49, "Input"],
Cell[23252, 748, 544, 13, 186, "Text"],
Cell[23799, 763, 176, 4, 76, "Input"],
Cell[23978, 769, 234, 6, 78, "Text"],
Cell[24215, 777, 185, 3, 98, "Input"],
Cell[24403, 782, 205, 4, 102, "Input"],
Cell[24611, 788, 816, 27, 267, "Text"]
}, Open ]],
Cell[CellGroupData[{
Cell[25464, 820, 32, 0, 44, "Subsubsection"],
Cell[25499, 822, 298, 11, 78, "Text"],
Cell[25800, 835, 118, 2, 72, "Input"],
Cell[25921, 839, 118, 2, 72, "Input"],
Cell[26042, 843, 165, 5, 78, "Text"]
}, Open ]],
Cell[CellGroupData[{
Cell[26244, 853, 53, 0, 44, "Subsubsection"],
Cell[26300, 855, 142, 3, 78, "Text"],
Cell[26445, 860, 83, 1, 46, "Input"],
Cell[26531, 863, 85, 1, 97, "Input"],
Cell[26619, 866, 253, 8, 78, "Text"],
Cell[26875, 876, 196, 4, 124, "Input"],
Cell[27074, 882, 68, 0, 51, "Text"],
Cell[27145, 884, 61, 1, 46, "Input"],
Cell[27209, 887, 61, 1, 46, "Input"],
Cell[27273, 890, 305, 6, 202, "Input"],
Cell[27581, 898, 181, 4, 78, "Text"],
Cell[27765, 904, 75, 1, 49, "Input"],
Cell[27843, 907, 78, 1, 46, "Input"],
Cell[27924, 910, 196, 4, 124, "Input"],
Cell[28123, 916, 57, 1, 46, "Input"],
Cell[28183, 919, 57, 1, 46, "Input"],
Cell[28243, 922, 297, 6, 202, "Input"],
Cell[28543, 930, 687, 21, 206, "Text",
CellTags->"Problem"],
Cell[29233, 953, 630, 21, 118, "Text"],
Cell[29866, 976, 705, 22, 154, "Text"],
Cell[30574, 1000, 301, 9, 115, "Text"],
Cell[30878, 1011, 413, 11, 132, "Text"],
Cell[31294, 1024, 356, 10, 78, "Text"]
}, Open ]]
}, Open ]]
}, Open ]]
}, Open ]]
}
]
*)
(*******************************************************************
End of Mathematica Notebook file.
*******************************************************************)