(************** Content-type: application/mathematica **************
CreatedBy='Mathematica 5.0'
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[ 113969, 3537]*)
(*NotebookOutlinePosition[ 114757, 3566]*)
(* CellTagsIndexPosition[ 114686, 3560]*)
(*WindowFrame->Normal*)
Notebook[{
Cell[CellGroupData[{
Cell["Chapter 2: Plotting", "Title",
CellTags->"Top"],
Cell[TextData[{
StyleBox["Mathematica",
FontSlant->"Italic"],
" ",
StyleBox["is a great tool for making plots. An in-depth introduction to \
the subject can be found in\n\tHelp Browser:\t ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontWeight->"Bold",
FontSlant->"Italic"],
StyleBox[" ",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["Book",
FontFamily->"Times New Roman",
FontWeight->"Bold",
FontSlant->"Italic"],
StyleBox[" ",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["\[Rule]",
FontWeight->"Bold"],
StyleBox[" A Practical Introduction ",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["\[Rule]",
FontWeight->"Bold"],
StyleBox[" Graphics and Sound",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" \nTo look up options more quickly, go to \n\tHelp Browser: ",
FontFamily->"Times New Roman"],
StyleBox["Built-in Functions ",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["\[Rule]",
FontWeight->"Bold"],
StyleBox[" Graphics and Sound",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["\n\t\t ",
FontFamily->"Times New Roman"],
StyleBox["\[Rule]",
FontWeight->"Bold"],
StyleBox[" Basic Options",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" or ",
FontFamily->"Times New Roman"],
StyleBox["\[Rule]",
FontWeight->"Bold"],
StyleBox[" Graphics Primitives",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["\n\nIn this chapter we will learn how to make plots and then use \
them to review some important mathematical ideas that are important in \
physics.",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[CellGroupData[{
Cell["Making x-y plots", "Subtitle"],
Cell[TextData[{
StyleBox["The simplest kind of plot is the 2-d, or x-y, plot and ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontSlant->"Italic"],
" ",
StyleBox["does them with ease. ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontSlant->"Italic"],
" ",
StyleBox["will plot both functions and expressions, but the syntax is \
different for each of these two data types. Here's a plot of the rational \
expression ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(\(x + 1\)\/\(x - 1\)\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[" from ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`x = \(-5\)\)]],
" to ",
Cell[BoxData[
\(TraditionalForm\`x = 0\)]],
". ",
StyleBox[" ",
FontFamily->"Times New Roman",
FontVariations->{"CompatibilityType"->"Subscript"}],
StyleBox["First we assign the rational expression to the variable ",
FontFamily->"Times New Roman"],
StyleBox["g",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[", then plot ",
FontFamily->"Times New Roman"],
StyleBox["g",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[". Note that g is an expression, not a function, so you can't use \
the notation ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`g(x)\)]],
StyleBox[" to plot it. ",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[{
\(g = \(x + 1\)\/\(x - 1\)\), "\[IndentingNewLine]",
\(Plot[\ g, \ {x, \(-5\), 0}\ ]\)}], "Input"],
Cell[TextData[{
"Note: you can change the size of the plot by dragging one of the little \
squares on the borders of the graph.\nThe coordinates of any point are shown \
on the left hand side of the status bar at the bottom of the ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" window if you hold \[ControlKey] while left-clicking you mouse at the \
point."
}], "Text"],
Cell[TextData[{
StyleBox["This same plot can be obtained using ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontSlant->"Italic"],
" ",
StyleBox["'s function notation, like this (I have purposely made the \
function have two arguments so you can see how to plot such a function)",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[
\(f[x_, y_] := \(x + y\)\/\(x - y\)\)], "Input"],
Cell[TextData[{
StyleBox["To make a plot in ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`x\)]],
StyleBox[" just give ",
FontFamily->"Times New Roman"],
StyleBox["y",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" a value through the argument list ",
FontFamily->"Times New Roman"],
StyleBox["(",
FontFamily->"Courier",
FontSize->10],
StyleBox[" ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`y = 1\)]],
" ",
StyleBox["reproduces the previous plot) and plot in ",
FontFamily->"Times New Roman"],
StyleBox["x",
FontFamily->"Times New Roman",
FontSlant->"Italic"]
}], "Text"],
Cell[BoxData[
\(\(\(\(Plot[\
f[x, 1], \ {x, \(-5\),
0}\ ]\) \)\(;\)\(\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \)\( \
(*\ Note\ the\ ; \ ending\ *) \)\(\ \)\)\)], "Input"],
Cell[TextData[{
StyleBox["OK, now let's plot this same function over a larger range. \
Notice that you can just put the expression in the Plot ",
FontFamily->"Times New Roman"],
"function",
StyleBox[" line and skip the assignment of it to a variable if you want.",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[
\(\(Plot[\ \(x + 1\)\/\(x - 1\), \ {x, \(-5\), 5}\ ];\)\)], "Input"],
Cell[TextData[{
StyleBox["Well, it's a plot, but perhaps not the one we wanted. The \
problem is that our function is singular at ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`x = 1\)]],
StyleBox[", so ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" tried to give us its rather large vertical range. We would \
probably rather not try to visualize infinity, so we would like to limit the \
vertical range. This is easy too.",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[
\(\(Plot[\ \(x + 1\)\/\(x - 1\), \ {x, \(-5\), 5}, \
PlotRange \[Rule] {\(-5\), 5}\ \ ];\)\)], "Input"],
Cell[TextData[{
StyleBox["There are many options you can specify and to become an expert \
plotter you have to be able to look them up and use them. A quick way to \
find them is by using ",
FontFamily->"Times New Roman"],
StyleBox["?PlotStyle", "Input",
FontFamily->"Times New Roman"],
StyleBox[", then click on ",
FontFamily->"Times New Roman"],
StyleBox["More...", "Input",
FontFamily->"Times New Roman"],
StyleBox[" , which brings you to \n\tHelp Browser:\t ",
FontFamily->"Times New Roman"],
StyleBox["Built-in Functions ",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["\[Rule]",
FontWeight->"Bold"],
StyleBox[" Graphics and Sound ",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["\[Rule]",
FontWeight->"Bold"],
StyleBox[" Basic Options",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["\nMore detailed information can be found in\n\tHelp Browser:\t ",
FontFamily->"Times New Roman"],
StyleBox["Built-in Functions ",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["\[Rule]",
FontWeight->"Bold"],
StyleBox[" Graphics and Sound ",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["\[Rule]",
FontWeight->"Bold"],
StyleBox[" Graphics Primitives",
FontFamily->"Times New Roman",
FontWeight->"Bold"]
}], "Text"],
Cell[BoxData[
\(\(?PlotStyle\)\)], "Input"],
Cell[TextData[{
"One thing you may have noticed is that all these plots looked squashed. \
This is because the default ",
StyleBox["AspectRatio", "Input"],
" value is ",
StyleBox["1/GoldenRatio", "Input"],
". If you wish to plot in absolute ",
StyleBox["x",
FontSlant->"Italic"],
" and ",
StyleBox["y",
FontSlant->"Italic"],
" coordinates, set \n\t ",
StyleBox["AspectRatio", "Input"],
" ",
StyleBox["\[Rule]",
FontWeight->"Bold"],
StyleBox[" Automatic", "Input"],
"."
}], "Text"],
Cell[BoxData[
RowBox[{
RowBox[{"Plot", "[", " ",
RowBox[{\(\(x + 1\)\/\(x - 1\)\), ",", " ", \({x, \(-5\), 5}\), ",",
" ", \(PlotRange \[Rule] {\(-5\), 5}\), ",", " ",
RowBox[{
StyleBox["AspectRatio",
"Input"], " ", "\[Rule]",
StyleBox[
RowBox[{" ",
StyleBox[" ",
"Input"]}]],
StyleBox["Automatic",
"Input"]}]}], " ", "]"}], ";"}]], "Input"],
Cell[TextData[{
"Now, it is a nuisance to have to set ",
StyleBox["AspectRatio", "Input"],
" ",
StyleBox["\[Rule]",
FontWeight->"Bold"],
StyleBox[" Automatic", "Input"],
" every time you plot. Fortunately, you can use the ",
StyleBox["SetOptions", "Input"],
" function to set any option to hold for the entire session, like this"
}], "Text"],
Cell[BoxData[
\(SetOptions[Plot, AspectRatio\ \[Rule] \ Automatic]\)], "Input"],
Cell["Let's see if it works:", "Text"],
Cell[BoxData[
\(\(Plot[\ \(x + 1\)\/\(x - 1\), \ {x, \(-5\), 5}, \
PlotRange \[Rule] {\(-5\), 5}\ ];\)\)], "Input"],
Cell[TextData[{
StyleBox["Now let's try something a little fancier; let's put two plots on \
the same frame and specify the two different colors we want to use to tell \
them apart. In ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" colors can be specified using one of 4 functions: ",
FontFamily->"Times New Roman"],
StyleBox["GrayLevel", "Input",
FontFamily->"Times New Roman"],
StyleBox[", ",
FontFamily->"Times New Roman"],
StyleBox["RGBColor", "Input",
FontFamily->"Times New Roman"],
StyleBox[", ",
FontFamily->"Times New Roman"],
StyleBox["Hue", "Input",
FontFamily->"Times New Roman"],
StyleBox[", and ",
FontFamily->"Times New Roman"],
StyleBox["CMYKColor", "Input",
FontFamily->"Times New Roman"],
StyleBox[". For convenience, we shall use only the ",
FontFamily->"Times New Roman"],
StyleBox["RGBColor", "Input",
FontFamily->"Times New Roman"],
StyleBox[" function. ",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[
\(\(?RGBColor\)\)], "Input"],
Cell[TextData[StyleBox["Let's use the colors red and blue, and also thicken \
the lines to make the colors stand out. (You might want to use thicker lines \
like this on a plot so that it would be of publication quality.)",
FontFamily->"Times New Roman"]], "Text"],
Cell[BoxData[
RowBox[{
RowBox[{"Plot", "[", " ",
RowBox[{\({\ \(x + 1\)\/\(x - 1\), Cos[x]\ }\), ",",
" ", \({x, \(-5\), 5}\), ",",
" ", \(PlotRange \[Rule] {\(-5\), 5}\), ",", " ",
"\[IndentingNewLine]", "\t\t",
StyleBox[\(PlotStyle \[Rule] {\ {RGBColor[1, 0, 0], \
Thickness[0.01]}, \n\t\t\t\ \ \t\t{RGBColor[0, 0, 1], \
Thickness[0.001]}\ }\),
"Input"]}],
StyleBox[" ",
"Input"],
StyleBox["]",
"Input"]}],
StyleBox[";",
"Input"]}]], "Input"],
Cell[TextData[{
StyleBox["As you can see, the two functions are placed in a ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" list, which is a list of things separated by commas and \
contained within curly brackets. Any options that apply separately to each \
plot are also specified in lists, as you can see in the ",
FontFamily->"Times New Roman"],
StyleBox["PlotStyle", "Input",
FontFamily->"Times New Roman"],
StyleBox[" option.",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[TextData[{
StyleBox["I'll give you one more sample plot and then you will be off to \
the exercises. Suppose you wanted to make a plot of the motion of a damped \
harmonic oscillator, given by the formula ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`e\^\(\(-t\)\ /\ 100\)\ cos\ t\)]],
" ",
StyleBox["from ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`t = 0\)]],
StyleBox[" to ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`t = 600\)]],
StyleBox[". Since you now know how to plot you would just use",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[
\(Plot[\ \[ExponentialE]\^\(\(-t\)/100\)\ Cos[t], \ {t, 0,
600}\ ]\)], "Input"],
Cell[TextData[{
"What's wrong? AspectRatio! The problem arises because we tried to plot \
on absolute scale a function ",
StyleBox["f",
FontSlant->"Italic"],
" with",
" ",
Cell[BoxData[
\(TraditionalForm\`\(\(|\)\(f(t)\)\(|\)\(\(\[LessEqual]\)\(1\)\)\)\)]],
" against ",
Cell[BoxData[
\(TraditionalForm\`t \[Element] \([0, 600]\)\)]],
". The remedy is obvious: "
}], "Text"],
Cell[BoxData[
\(Plot[\ \[ExponentialE]\^\(\(-t\)/100\)\ Cos[t], \ {t, 0, 600},
AspectRatio \[Rule] 1\ ]\)], "Input"],
Cell["Obviously, our view was chopped. To get the full view:", "Text"],
Cell[BoxData[
\(Plot[\ \[ExponentialE]\^\(\(-t\)/100\)\ Cos[t], \ {t, 0, 600}, \
PlotRange \[Rule] {\(-1\), 1}, AspectRatio \[Rule] 1\ ]\)], "Input"],
Cell["\<\
To improve the quality of the graphics, increase the number of points \
plotted:\
\>", "Text"],
Cell[BoxData[
\(Plot[\ \[ExponentialE]\^\(\(-t\)/100\)\ Cos[t], \ {t, 0, 600}, \
AspectRatio \[Rule] 1, \ PlotPoints \[Rule] 5000\ ]\)], "Input"],
Cell[TextData[StyleBox["One last, but very important, thing; you will often \
want to define your own expressions to plot, like this:",
FontFamily->"Times New Roman"]], "Text"],
Cell[BoxData[
\(f = Cos[\[Omega]\ t]\^3\)], "Input"],
Cell[TextData[{
StyleBox["Since it clearly depends on ",
FontFamily->"Times New Roman"],
StyleBox["t",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" ",
FontFamily->"Times New Roman"],
StyleBox["we should be able to plot it",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[
\(Plot[\ f, \ {t, 0, 20}\ ]\)], "Input"],
Cell[TextData[{
StyleBox["Ooops! The problem is that \[Omega] doesn't have a value yet, so \
there is no way ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" could plot it. But how are you supposed to know this? Try \
giving ",
FontFamily->"Times New Roman"],
StyleBox["t",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" a value and evaluating ",
FontFamily->"Times New Roman"],
StyleBox["f",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[".",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[
\(f\ /. \ t \[Rule] 7\)], "Input"],
Cell["\<\
The \[Omega] still sitting there is your clue; it needs a value. So let's \
assign it a value and try again.\
\>", "Text"],
Cell[BoxData[
\(Plot[\ f /. \[Omega] \[Rule] 1, \ {t, 0, 20}\ ]\)], "Input"],
Cell[TextData[{
"Now, you know why the default is not ",
StyleBox["AspectRatio \[Rule] Automatic", "Input"],
". So, we set"
}], "Text"],
Cell[BoxData[
RowBox[{
RowBox[{"SetOptions", "[",
RowBox[{"Plot", ",",
StyleBox[\(AspectRatio \[Rule] 1\),
"Input"]}], "]"}], ";"}]], "Input"],
Cell["Note, a semicolon at the end suppresses output.", "Text"],
Cell[BoxData[
RowBox[{"Plot", "[", " ", \(f /. \[Omega] \[Rule] 1, \ {t, 0, 20}\),
StyleBox[" ",
"Input"], "]"}]], "Input"],
Cell[TextData[{
StyleBox["Before we leave the introduction let's look at one more thing you \
will want to know so that you can make your plots look nice: lettering. To \
put labels on the axes of a plot you can use the labels option, like this: \n\
\t",
FontFamily->"Times New Roman"],
StyleBox["AxesLabel \[Rule] { \"x\", \"y\" }", "Input",
FontFamily->"Times New Roman"],
StyleBox[" \nTo put a title on use\n\t",
FontFamily->"Times New Roman"],
StyleBox["PlotLabel \[Rule] \" This is the title \"", "Input",
FontFamily->"Times New Roman"],
StyleBox[" \nAnd if you want to put text in the figure somewhere, look up ",
FontFamily->"Times New Roman"],
StyleBox["Text", "Input",
FontFamily->"Times New Roman"],
StyleBox[" in online help. Here's a plot illustrating these options.",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[
\(Plot[\ Sin[x\^2], \ {x, 0, 2 \[Pi]}, \
AxesLabel \[Rule] {"\", "\"}, \
PlotLabel \[Rule] \ \*"\"\\""\ ]\)], "Input"],
Cell[TextData[StyleBox["Ok, off to the exercises in the subsections below. \
Along the way you will learn some more plotting tricks.",
FontFamily->"Times New Roman"]], "Text"],
Cell[TextData[ButtonBox["Go to top of section",
ButtonData:>"Top",
ButtonStyle->"Hyperlink"]], "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell["Basic function review", "Subtitle"],
Cell[TextData[StyleBox["In this section we will review the basic functions of \
mathematical physics by making plots.",
FontFamily->"Times New Roman"]], "Text"],
Cell[CellGroupData[{
Cell["Problem 2.1", "Subsection"],
Cell[TextData[{
StyleBox["Using a horizontal range of ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\(-2\) \[Pi]\)]],
" ",
StyleBox["to ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`2 \[Pi]\)]],
StyleBox[" and a vertical range of ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\(-2\)\)]],
StyleBox[" to 2, plot the functions ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`sin\ x\)]],
StyleBox[", ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`cos\ x\)]],
StyleBox[", and ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`tan\ x\)]],
StyleBox[". Plot all three on the same plot by putting these three \
expressions in a list in the plot ",
FontFamily->"Times New Roman"],
"function",
StyleBox[" line. Choose special colors for each one.",
FontFamily->"Times New Roman"]
}], "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell["Problem 2.2", "Subsection"],
Cell[TextData[{
StyleBox["Using a horizontal range of ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\(-3\)\)]],
StyleBox[" to 3 and a vertical range of ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\(-3\)\)]],
StyleBox[" to 3, plot the functions ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`sinh\ x\)]],
StyleBox[", ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(\(1\/2\) e\^x\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[", and ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(\(-\(1\/2\)\) e\^\(-x\)\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[". Choose special colors for each one and study the plot carefully \
so that you can remember how they relate. Now on another picture plot the \
functions ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(\(1\/2\) e\^x\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[", and ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(\(1\/2\) e\^\(-x\)\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[" together with ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`cosh\ x\)]],
StyleBox[". Finally, plot the functions ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`sinh\ x\)]],
StyleBox[", ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`cosh\ x\)]],
StyleBox[", and ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`tanh\ x\)]],
StyleBox[" on the same picture and stare at them until you are sure you \
will remember what they look like.",
FontFamily->"Times New Roman"]
}], "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell["Problem 2.3", "Subsection"],
Cell[TextData[{
"Verify by drawing the appropriate graphs that the following identities are \
true. (This is not the same as a proof, of course, but if you are a person \
who thinks visually, a graph is worth a thousand lemmas.)\n\t",
Cell[BoxData[
\(TraditionalForm\`e\^x\ e\^\(2 x\) = e\^\(3 x\)\)]],
"\t\t",
Cell[BoxData[
\(TraditionalForm\`ln\ x + ln\ 2\ x = ln\ 2\ x\^2\)]],
"\t\t",
Cell[BoxData[
\(TraditionalForm\`5\ ln\ x = ln\ x\^5\)]],
"\n",
StyleBox["To avoid taking the logarithm of negative numbers make the plot \
only over positive values of ",
FontFamily->"Times New Roman"],
StyleBox["x",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[". Note: it will be easier to see that the two expressions are \
graphically equivalent if you plot them with different colors and thicknesses \
by using this option line in your plot ",
FontFamily->"Times New Roman"],
"function",
StyleBox[":\n\t",
FontFamily->"Times New Roman"],
StyleBox["PlotStyle \[Rule] { {RGBColor[1,0,0], Thickness[0.01]},\n\t\t\t \
\t {RGBColor[0,0,1], Thickness[0.001]} }", "Input"]
}], "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell["Problem 2.4", "Subsection"],
Cell[TextData[{
StyleBox["Show by doing graphical experiments that the exponential function \
grows faster than any power of ",
FontFamily->"Times New Roman"],
StyleBox["x",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" and that the natural log function grows more slowly than any \
fractional power of ",
FontFamily->"Times New Roman"],
StyleBox["x",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[". Do this by choosing several fixed powers of ",
FontFamily->"Times New Roman"],
StyleBox["x",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" and then making plots over appropriately sized windows. Recall \
that if you leave the vertical scale out of the plot ",
FontFamily->"Times New Roman"],
"function",
StyleBox[", ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" will choose it appropriately. Note: when you do the exponential \
function you will probably run into a floating point error because you are \
trying to plot numbers that are too big. The standard way to avoid this \
problem is to plot the log of the functions instead. It is easier to tell \
how big the numbers are if you use the function ",
FontFamily->"Times New Roman"],
StyleBox["Log[10,x]", "Input",
FontFamily->"Times New Roman"],
StyleBox[". Second note: when you do the fractional power comparison you \
will have to use such big values of ",
FontFamily->"Times New Roman"],
StyleBox["x",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" that ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" will complain. So in place of ",
FontFamily->"Times New Roman"],
StyleBox["x",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" use ",
FontFamily->"Times New Roman"],
StyleBox["Log[10,x]", "Input",
FontFamily->"Times New Roman"],
StyleBox[", i.e., use ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(x = 10\^t\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[" and make the plots versus ",
FontFamily->"Times New Roman"],
StyleBox["t",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" instead of ",
FontFamily->"Times New Roman"],
StyleBox["x",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[".",
FontFamily->"Times New Roman"]
}], "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell["Problem 2.5", "Subsection"],
Cell[TextData[{
StyleBox["Graphically verify the following trigonometric identities. \
Instead of overlaying two plots, plot the left-hand side minus the right-hand \
side. Comment on why you don't really get zero.\n\t",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`sin\ 2\ x = 2 sin\ x\ cos\ x\)]],
"\t\t\t",
Cell[BoxData[
\(TraditionalForm\`cos\ 2 x = \(cos\^2\) x - \(sin\^2\) x\)]],
"\n\t",
Cell[BoxData[
FormBox[
StyleBox[\(\(sin\^2\) x\/2 = \(1\ - \ cos\ x\)\/2\),
"DisplayFormula"], TraditionalForm]]],
"\t\t\t",
Cell[BoxData[
FormBox[
StyleBox[\(cos\^2\ x\/2 = \(1\ + \ cos\ x\)\/2\),
"DisplayFormula"], TraditionalForm]]]
}], "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell["Problem 2.6", "Subsection"],
Cell[TextData[{
StyleBox[" Show graphically that when you add ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`sin\ x\)]],
" ",
StyleBox["and ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`cos\ x\)]],
StyleBox[" together you just get another sinusoidal function with a new \
amplitude and phase shift. Make the plot by assigning the sum of these two \
functions to a ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" function ",
FontFamily->"Times New Roman"],
StyleBox["f",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" and then plotting ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`f(x)\)]],
StyleBox[". From your graph find the new amplitude and the phase shift \
relative to the cosine function, i.e., find a formula for the addition of \
sine and cosine in the form ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`A\ \(cos(x - \[Phi])\)\)]],
"."
}], "Text"],
Cell[TextData[ButtonBox["Go to top of section",
ButtonData:>"Top",
ButtonStyle->"Hyperlink"]], "Text"]
}, Closed]]
}, Closed]],
Cell[CellGroupData[{
Cell["Fourier analysis", "Subtitle"],
Cell[TextData[{
StyleBox["Later on you will learn some powerful techniques for solving \
partial differential equations using a technique called ",
FontFamily->"Times New Roman"],
StyleBox["Fourier analysis",
FontFamily->"Times New Roman",
FontSlant->"Italic",
FontColor->GrayLevel[0]],
StyleBox[", which is based on this powerful idea: you can make complicated \
functions by using infinite sums of simple ones. In the previous section you \
saw an example of this when you added cosine and sine to get a phase-shifted \
cosine. Here's another simple example that is important in physics. Add two \
cosine functions, but with different frequencies:",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[{
\(Clear[\ "\"]\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (*\
This\ removes\ all\ user\ defined\ symbols\ *) \), \
"\[IndentingNewLine]",
\(f[t_] := Cos[t] + Cos[1.1 t]\)}], "Input"],
Cell[BoxData[
\(Plot[\ f[t], \ {t, 0, 200 \[Pi]}, \
PlotPoints \[Rule] 1000\ ]\)], "Input"],
Cell[TextData[StyleBox["You have probably experienced this plot. Remember \
what the trumpets in junior high band sounded like: wah-wah-wah-wah. The \
annoying flutter of two inexperienced musicians trying to play the same note, \
but not quite succeeding, is called beats, and they are clearly illustrated \
by the plot above. The rapid oscillation is the note and the successive \
amplitude changes are the flutter.",
FontFamily->"Times New Roman"]], "Text"],
Cell[CellGroupData[{
Cell["Problem 2.7", "Subsection"],
Cell[TextData[{
StyleBox["Play with the graph of beats above and find the relation of the \
difference between the two frequencies (",
FontFamily->"Times New Roman"],
StyleBox[" ",
FontFamily->"Courier",
FontSize->10],
Cell[BoxData[
\(TraditionalForm\`\[Omega]\_1 = 1\)]],
" ",
StyleBox["and ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\[Omega]\_2 = 1.1\)]],
" ",
StyleBox["in the example above) to the wah-wah frequency, defined by ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(f = 1\/Tbeat\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[", where ",
FontFamily->"Times New Roman"],
StyleBox["Tbeat",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" is the time between successive loud portions of the sound. ",
FontFamily->"Times New Roman"]
}], "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell["\<\
\t---------------------------------------------------------------------------\
----\
\>", "Subsubtitle"],
Cell[TextData[{
StyleBox["Now let's illustrate Fourier's theorem. He showed that any \
periodic function could be represented by an infinite sum of sines and \
cosines having the same period as the function. In these sums the sines and \
cosine functions are multiplied by coefficients that usually get small as the \
sum index gets big. For instance, here's a sum of cosine functions with \
coefficients that fall off like ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`1\/n\)]],
StyleBox[" coded using ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" 's ",
FontFamily->"Times New Roman"],
StyleBox["Sum", "Input",
FontFamily->"Times New Roman"],
StyleBox[" ",
FontFamily->"Times New Roman"],
"function",
StyleBox[" ( use \[EscapeKey]",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
FrameBox["s",
BoxMargins->{{0.2, 0.2}, {0.4, 0.4}}], TraditionalForm]]],
Cell[BoxData[
FormBox[
FrameBox["u",
BoxMargins->{{0.2, 0.2}, {0.4, 0.4}}], TraditionalForm]]],
Cell[BoxData[
FormBox[
FrameBox["m",
BoxMargins->{{0.2, 0.2}, {0.4, 0.4}}], TraditionalForm]]],
Cell[BoxData[
FormBox[
FrameBox["t",
BoxMargins->{{0.2, 0.2}, {0.4, 0.4}}], TraditionalForm]]],
StyleBox["\[EscapeKey] to enter ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(\[Sum]\+\(\[Placeholder] = \
\[Placeholder]\)\%\[Placeholder] \[Placeholder]\),
"DisplayFormula"], TraditionalForm]]],
" ) :"
}], "Text"],
Cell[BoxData[{
\(Clear["\"]\), "\[IndentingNewLine]",
\(g[x_] := \[Sum]\+\(n = 1\)\%100 Cos[n\ x]\/n\)}], "Input"],
Cell[TextData[{
StyleBox["There isn't any way you can get any insight into what this \
function looks like by staring at this sum, but ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox["'s plotting capability can show you exactly what is going on",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[
\(Plot[\ g[x], \ {x, 0, 6 \[Pi]}\ ]\)], "Input"],
Cell[TextData[StyleBox["Notice (i) that the function is periodic and (ii) \
that you probably couldn't have guessed that it was going to look like this. \
You can do some more examples in the problem below.",
FontFamily->"Times New Roman"]], "Text"],
Cell[CellGroupData[{
Cell["Problem 2.8", "Subsection"],
Cell[TextData[{
StyleBox["Consider the Fourier sum ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(\[Sum]\+\(n = 1\)\%100\(\(\((-)\)\^n\) cos\ \((2 n - 1)\) \
t\)\/\(2 n - 1\)\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[". Plot it from ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`t = 0\)]],
StyleBox[" to ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`t = 2 \[Pi]\)]],
StyleBox[" by assigning this sum to a ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" function. Now modify the sum so the factor in the denominator \
is squared, switch cosine to sine, and plot it again. Then change the factor \
in the denominator to be cubed and plot again. Then switch to the 4th power \
and plot again. This sequence illustrates a property of Fourier series which \
isn't in most math books. Functions which are discontinuous have Fourier \
series in which the terms go to zero like ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(1\/n\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[". (And at the discontinuities they have nasty wiggly features \
called the Gibbs phenomenon, which has someone's name attached to it because \
it had to be discovered the hard way, ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" plots having not yet been invented.) Functions which have \
discontinuous first derivatives fall off like ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(1\/n\^2\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[". Functions which have discontinuous second derivatives fall off \
like ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(1\/n\^3\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[", etc.. And functions which have no discontinuities or \
discontinuous derivatives of any order have to fall off faster than any power \
of ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(1\/n\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[", which means they have to fall off exponentially in ",
FontFamily->"Times New Roman"],
StyleBox["n",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[", like ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`e\^\(-n\)\)]],
StyleBox[", ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(1\/\(cosh\ n\)\),
"DisplayFormula"], TraditionalForm]]],
", ",
StyleBox["etc.. You will see Fourier series that fall off like this in \
Physics 441.",
FontFamily->"Times New Roman"]
}], "Text"]
}, Closed]]
}, Closed]]
}, Closed]],
Cell[CellGroupData[{
Cell["Advanced topic: wave packets", "Subtitle"],
Cell[TextData[StyleBox["Finally, we can use the idea of Fourier analysis to \
build wave packets and to examine the uncertainty principle. You probably \
think of the uncertainty principle only in terms of quantum mechanics, but it \
is really a result of Fourier analysis. But since Fourier analysis underlies \
all of quantum mechanics, it should be no surprise that this important \
physical principle turns out to be a mathematical result. ",
FontFamily->"Times New Roman"]], "Text"],
Cell[TextData[StyleBox["To build a wave packet we sum a whole bunch of \
cosines or sines with frequencies closely spaced around some central \
frequency. The result is a wave at the central frequency but it lives inside \
an envelope caused by the destructive interference of the neighboring waves. \
Here, I'll show you.",
FontFamily->"Times New Roman"]], "Text"],
Cell[TextData[{
StyleBox["We'll use a Gaussian centered at ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\[Omega] = 4\)]],
StyleBox[" as the distribution of frequencies in the packet",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[
\(a[\[Omega]_] := \[ExponentialE]\^\(\(-20\) \((\[Omega] - 4)\)\^2\)\)], \
"Input"],
Cell[TextData[StyleBox["Let's plot it so you can see the distribution of \
frequencies",
FontFamily->"Times New Roman"]], "Text"],
Cell[BoxData[
\(Plot[\ a[\[Omega]], \ {\[Omega], 0, 5}\ , \
AxesLabel \[Rule] {"\<\[Omega]\>", "\"}]\)], "Input"],
Cell[TextData[{
"Well, this is one of those moments at which your respect for ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" drops dramatically.\nSince the maximum of ",
StyleBox["a",
FontSlant->"Italic"],
" is obviously ",
Cell[BoxData[
\(TraditionalForm\`a(4) = 1\)]],
", we plot again"
}], "Text"],
Cell[BoxData[
\(Plot[\ a[\[Omega]], \ {\[Omega], 0, 5}\ , \ PlotRange \[Rule] {0, 1}, \
AxesLabel \[Rule] {"\<\[Omega]\>", "\"}]\)], "Input"],
Cell[TextData[{
StyleBox["It is important to have a way of describing how wide this \
distribution is. A common term that you may have learned before is the Full \
Width at Half Maximum, or FWHM for short. This is the width in \[Omega] \
between the two points in the distribution ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`a(\[Omega])\)]],
StyleBox[" where ",
FontFamily->"Times New Roman"],
StyleBox["a",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" is one-half of its maximum. Look at the graph and roughly \
verify that the FWHM is given by ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(\[CapitalDelta]\[Omega] = 2 \@\(\( ln\ 2\)\/20\)\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[" . Then do a little math and see that this formula is correct.",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[TextData[{
StyleBox["Now we will build a function of time which is made up of a \
superposition of waves with frequencies between ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\[Omega] = 3.5\)]],
StyleBox[" and ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\[Omega] = 4.5\)]],
StyleBox[" (frequencies outside of this range don't have enough amplitude \
to matter very much, according to the graph above).",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[
\(f[t_] := \[Sum]\+\(n = 0\)\%100\
a[3.5 + n\/100]\ \ Cos[\((3.5 + n\/100)\) t]\)], "Input"],
Cell[TextData[{
StyleBox["Note that as ",
FontFamily->"Times New Roman"],
StyleBox["n",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" ranges from 0 to 100, the quantity ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(3.5 + n\/100\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[" ranges from 3.5 to 4.5, just as desired for \[Omega]. Now we \
can plot the time signal and see what time function ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`f(t)\)]],
StyleBox[" is produced by the frequency function ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`a(\[Omega])\)]],
StyleBox[".",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[
\(Plot[\ f[t], \ {t, \(-50\), 50}\ ]\)], "Input"],
Cell[TextData[{
"Once again, ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" disappoints. Since we are not sure what the range of ",
Cell[BoxData[
\(TraditionalForm\`f(t)\)]],
" is, we apply the remedy like this"
}], "Text"],
Cell[BoxData[
\(Plot[\ f[t], \ {t, \(-50\), 50}, \ PlotRange \[Rule] All\ ]\)], "Input"],
Cell["The rather shabby look can be improved like this", "Text"],
Cell[BoxData[
\(Plot[\ f[t], \ {t, \(-50\), 50}, \ PlotRange \[Rule] All, \
PlotPoints \[Rule] 1000\ ]\)], "Input"],
Cell[TextData[{
StyleBox["So we see that a finite-width distribution of amplitudes in \
frequency space (\[Omega]) makes a finite-width distribution in time, which \
is exactly what a wave packet is. Now comes the uncertainty principle. This \
theorem says that the product of the width of the amplitude function ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`a(\[Omega])\)]],
StyleBox[", which we call ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\[CapitalDelta]\[Omega]\)]],
StyleBox[", and the width of the time signal ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\[CapitalDelta]\ t\)]],
StyleBox[" (the width of the wave packet plotted above) is no smaller than \
a number of order unity. In practice it is usually about equal to 5.5 if we \
measure the widths using the full-width at half-maximum. Or in symbols ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`5.5 \[LessEqual] \[CapitalDelta]\[Omega]\ \
\[CapitalDelta]\ t\)]],
"."
}], "Text"],
Cell[CellGroupData[{
Cell["Problem 2.9", "Subsection"],
Cell[TextData[{
StyleBox["Verify the uncertainty principle given above for the graphs \
displayed. Then change the width of the amplitude function ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`a(\[Omega])\)]],
StyleBox[" by changing the parameter 20 in the definition of ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`a(\[Omega])\)]],
StyleBox[" to something else and making a new set of plots. Verify that \
the uncertainty relation holds for the new plots.",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[TextData[ButtonBox["Go to top of section",
ButtonData:>"Top",
ButtonStyle->"Hyperlink"]], "Text"]
}, Closed]]
}, Closed]],
Cell[CellGroupData[{
Cell["Plotting data", "Subtitle"],
Cell[TextData[{
StyleBox["Mathematica",
FontSlant->"Italic"],
" ",
StyleBox["is not really a very good way to do data analysis. You have \
learned, or will learn, some powerful ways to do data analysis when you study \
Labview in your physics lab courses or when you study Matlab in Physics 330. \
But you might want to import some data into ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontSlant->"Italic"],
" ",
StyleBox["sometime and compare it with a formula that you have coded in ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontSlant->"Italic"],
StyleBox[", so here's what you need to know.",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[TextData[{
StyleBox["Mathematica",
FontSlant->"Italic"],
" ",
StyleBox["stores and plots data in matrix form. Data can be read in using \
either the ",
FontFamily->"Times New Roman"],
StyleBox["Import", "Input",
FontFamily->"Times New Roman"],
StyleBox[" or the ",
FontFamily->"Times New Roman"],
StyleBox["ReadList",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" ",
FontFamily->"Times New Roman"],
StyleBox["function. In the following, we shall try to read in 2 columns of \
data\n0 1.0\n1 1.5\n2 1.9\n3 2.6\n4 3.7\n5 5.4\n\
6 7.3\n7 10.4\n8 14.2\n9 20.0\n10 29.0\nwhich are stored in \
the file ",
FontFamily->"Times New Roman"],
StyleBox["datafile.txt ",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["in the same directory as this file.",
FontFamily->"Times New Roman"]
}], "Text"],
Cell["\<\
Before importing the file, you can use the !! operator to examine its \
content, like this:\
\>", "Text"],
Cell[BoxData[
\(\(!! "\"\)\)], "Input"],
Cell[TextData[{
StyleBox["Chances are, ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" cannot find your file. This shows where ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" does its search:",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[
RowBox[{"$Path", " ",
StyleBox[\( (*\ this\ gives\ you\ the\ current\ setting\ *) \),
FontColor->GrayLevel[0.500008]]}]], "Input"],
Cell[TextData[{
"There are 2 ways to remedy the problem. The 1st is to supply ",
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" ",
FontFamily->"Times New Roman"],
"with the full path of the file, like this ( put in the actual path on your \
computer ) :"
}], "Text"],
Cell[BoxData[
\(\(!! "\"\)\)], "Input"],
Cell[TextData[{
"Now, dragging such a long file name around is a pain. So you may opt for \
the 2nd way by setting the current directory known to ",
StyleBox["Mathematica",
FontSlant->"Italic"],
", like this:"
}], "Text"],
Cell[BoxData[{
RowBox[{\(Directory[]\), " ",
StyleBox[\( (*\ check\ on\ current\ directory\ setting\ *) \),
FontColor->GrayLevel[
0.500008]]}], "\[IndentingNewLine]", \(SetDirectory[\ \
"\"\ ]\), "\[IndentingNewLine]", \
\(Directory[]\)}], "Input"],
Cell["Check:", "Text"],
Cell[BoxData[
\(\(!! "\"\)\)], "Input"],
Cell["\<\
Since this is indeed what we want, we can import it like this\
\>", "Text"],
Cell[BoxData[
\(dat = Import["\", "\"]\)], "Input"],
Cell[TextData[{
"The data are now stored in the array ",
StyleBox["dat",
FontSlant->"Italic"],
"."
}], "Text"],
Cell[BoxData[
\(dat\ // TableForm\)], "Input"],
Cell[TextData[{
"Here is another way to do it (",
StyleBox[" the option ",
FontFamily->"Times New Roman"],
StyleBox["Table[Number,{2}]", "Input",
FontFamily->"Times New Roman"],
StyleBox[" tabulizes 2 columns of numbers ",
FontFamily->"Times New Roman"],
"):"
}], "Text"],
Cell[BoxData[{
\(\(ReadList["\", \ Table[Number, {2}]\ ];\)\), "\n",
\(%\ // TableForm\)}], "Input"],
Cell[TextData[{
StyleBox["Now that the data is stored as a matrix ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontSlant->"Italic"],
" ",
StyleBox["can plot it using the ",
FontFamily->"Times New Roman"],
StyleBox["ListPlot",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" function, like this:",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[
\(ListPlot[dat]\)], "Input"],
Cell[TextData[{
StyleBox["Now suppose we want to see how well this data is fit by the \
formula ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`e\^\(\(\ \)\(x/3\)\)\)]],
StyleBox[". We simply assign the point plot to one variable name and the \
formula plot to another, then display them together, like this ( the option ",
FontFamily->"Times New Roman"],
StyleBox["DisplayFunction \[Rule]Identity",
FontWeight->"Bold"],
" is used to suppress output, while ",
StyleBox["DisplayFunction \[Rule] $DisplayFunction ",
FontWeight->"Bold"],
"does the opposite",
StyleBox[" ",
FontWeight->"Bold"],
StyleBox[") :",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[{
\(\(p1 = ListPlot[dat, \ DisplayFunction \[Rule] Identity];\)\), "\n",
\(\(p2 =
Plot[\ \[ExponentialE]\^\(x/3\), \ {x, 0, 10}, \
DisplayFunction \[Rule] Identity\ ];\)\), "\n",
\(\(Show[\ p1, p2, \
DisplayFunction \[Rule] $DisplayFunction\ ];\)\)}], "Input"],
Cell[TextData[{
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox["'s statistics package does similar things, and will even do some \
fitting.",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[TextData[ButtonBox["Go to top of section",
ButtonData:>"Top",
ButtonStyle->"Hyperlink"]], "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell["Parametric plots", "Subtitle"],
Cell[TextData[{
StyleBox["One of the best ways to make complicated plots is with a \
parametric representation. Consider, for example, the humble circle. The \
formula for it that you remember best is probably this one\n\t",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`x\^2 + y\^2 = R\^2\)]],
"\n",
StyleBox["but if you try to graph a circle with this formula you have to do \
it this way\n\t",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`y(x) = \@\(R\^2 - x\^2\)\)]],
"\t\t",
Cell[BoxData[
\(TraditionalForm\`y(x) = \(-\@\(R\^2 - x\^2\)\)\)]],
"\n",
StyleBox["which requires two separate plots and the functions have infinite \
derivatives at ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`x = \(\[PlusMinus]R\)\)]],
StyleBox["; it's just messy. But look how pretty the formulas for ",
FontFamily->"Times New Roman"],
StyleBox["x",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" and ",
FontFamily->"Times New Roman"],
StyleBox["y",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" on a circle look if you use a parametric representation:",
FontFamily->"Times New Roman"],
"\n\t",
Cell[BoxData[
FormBox[
RowBox[{\(x(s)\), "=",
RowBox[{"R", " ", "cos", " ", "s", Cell[""]}]}],
TraditionalForm]]],
"\t\t",
Cell[BoxData[
\(TraditionalForm\`y(s) = R\ sin\ s\)]],
"\t\twith\t",
Cell[BoxData[
\(TraditionalForm\`s = \(0\ ... \)\ 2 \[Pi]\)]]
}], "Text"],
Cell[TextData[{
StyleBox["Here are the ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" plot ",
FontFamily->"Times New Roman"],
"function",
StyleBox["s to do the plot of a circle both the ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`y(x)\)]],
StyleBox[" way and the parametric way, with the parametric one at a smaller \
radius so you can see them both :",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[{
\(\(p1 =
Plot[\ {\ \@\(1 - x\^2\), \ \(-\@\(1 - x\^2\)\)\ }, \ {x, \(-1\),
1}\ , \[IndentingNewLine]\t\t\ PlotStyle \[Rule] {\
RGBColor[1, 0, 0], \
RGBColor[0, 0,
1]\ }, \[IndentingNewLine]\t\tAspectRatio \[Rule]
Automatic, \
DisplayFunction \[Rule] Identity\ ];\)\), "\[IndentingNewLine]",
\(\(p2 =
ParametricPlot[\ {\ 0.8 Cos[s], 0.8\ Sin[s]\ }, \ {s, 0,
2 \[Pi]}\ , \[IndentingNewLine]\t\ AspectRatio \[Rule]
Automatic, \
DisplayFunction \[Rule] Identity\ ];\)\), "\[IndentingNewLine]",
\(\(Show[\ p1, p2,
DisplayFunction \[Rule] $DisplayFunction\ ];\)\)}], "Input"],
Cell[TextData[StyleBox["You can explore some more ways of doing parametric \
plots in the problems below.",
FontFamily->"Times New Roman"]], "Text"],
Cell[TextData[ButtonBox["Go to top of section",
ButtonData:>"Top",
ButtonStyle->"Hyperlink"]], "Text"],
Cell[CellGroupData[{
Cell["Problem 2.10", "Subsection"],
Cell[TextData[{
StyleBox["The classic conic sections all have parametric forms. Use the \
parametric plot ",
FontFamily->"Times New Roman"],
"function",
StyleBox[" to sketch each of these curves using constrained scaling. ",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[TextData[{
StyleBox["Ellipse:\t \t",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`x(s) = 3 cos\ s\)]],
"\t\t",
Cell[BoxData[
\(TraditionalForm\`y(s) = 1.3 sin\ s\)]],
"\t\twith ",
Cell[BoxData[
\(TraditionalForm\`s = \(0\ ... \)\ \ 2 \[Pi]\)]],
"\nHyperbola:\t",
Cell[BoxData[
\(TraditionalForm\`x(s) = 3 cosh\ s\)]],
"\t\t",
Cell[BoxData[
\(TraditionalForm\`y(s) = 1.3 sinh\ s\)]],
"\twith ",
Cell[BoxData[
FormBox[
StyleBox[\(s = \(\(-\(\[Pi]\/2\)\) ... \)\ \ \[Pi]\/2\),
"DisplayFormula"], TraditionalForm]]],
"\n",
StyleBox["(Once you draw this, figure out how to get the missing half of \
the picture.)",
FontFamily->"Times New Roman",
FontVariations->{"CompatibilityType"->"Subscript"}],
"\nParabola (rotated):\t",
Cell[BoxData[
\(TraditionalForm\`x(s) = s\ cos\ \[Phi] - \(s\^2\) sin\ \[Phi]\)]],
"\t",
Cell[BoxData[
\(TraditionalForm\`y(s) = s\^2\ cos\ \[Phi] + s\ sin\ \[Phi]\)]],
"\twith ",
Cell[BoxData[
\(TraditionalForm\`s = \(\(-\[Pi]\)\ ... \)\ \ \[Pi]\)]]
}], "Text"],
Cell[TextData[{
StyleBox["Try plotting this for several different angles. If you want to \
go a little crazy, try drawing a rotated parabola using the ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`y(x)\)]],
StyleBox[" form.",
FontFamily->"Times New Roman"]
}], "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell["Problem 2.11", "Subsection"],
Cell[TextData[{
StyleBox[" It is also possible to draw curves in polar coordinates. A \
simple example is the ellipse again, but this time with the origin at one \
focus of the ellipse. To make sense of this we need some relations from \
ellipse geometry. Suppose that the ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\((x, y)\)\)]],
StyleBox[" form of the ellipse is as given above, \n\t",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`x(s) = a\ cos\ s\)]],
"\t\t",
Cell[BoxData[
\(TraditionalForm\`y(s) = b\ sin\ s\)]],
"\t\twith ",
Cell[BoxData[
\(TraditionalForm\`b < a\)]],
StyleBox["\nThen the distance ",
FontFamily->"Times New Roman"],
StyleBox["a",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" is called the semi-major axis and the distance ",
FontFamily->"Times New Roman"],
StyleBox["b",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" is called the semi-minor axis. The eccentricity of the ellipse \
is defined to be ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`e = \@\(1 - b\^2\/a\^2\)\)]],
StyleBox[" . It is zero for a circle and as it gets smaller the ellipse \
gets more and more squashed. The ellipse has two foci, one focus to the left \
of center along the long (semi-major) axis and the other to the right of \
center. The distance from the center of the ellipse to either focus is ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`f = e\ a\)]],
StyleBox[". (Wait a sec \[LongDash] how come I am dragging you through \
this? What has this got to do with physics? Well, this is the language you \
will use in Physics 321 to describe the motion of planets around the sun, so \
stay with me, this is important.) ",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[TextData[{
StyleBox["Draw an ellipse using an ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\((x, y)\)\)]],
StyleBox[" parametrization which has the origin of coordinates at the right \
focus of the ellipse with ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`a = 2\)]],
StyleBox[" and ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`b = 1\)]],
StyleBox[". (Use the standard parametrization given above, but subtract ",
FontFamily->"Times New Roman"],
StyleBox["f",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" from ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`x(s)\)]],
StyleBox[" to shift it over.",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[TextData[{
StyleBox["Now, here's the point of this exercise. The parametric form of \
an ellipse with the origin of coordinates at the right focus in polar \
coordinates (like you will use in course Classical Mechanics) is given by\n\t\
",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(r(\[Phi]) = \(a\ \((\ 1\ - \ e\^2\ )\)\)\/\(1\ + \ e\ \
cos\ \[Phi]\)\),
"DisplayFormula"], TraditionalForm]]],
"\n",
StyleBox["Lay this polar coordinate graph on top of the ",
FontFamily->"Times New Roman"],
StyleBox["xy",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" graph of the ellipse you just did and verify that they match. ",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[TextData[{
"Hint: to plot in polar coordinates, you need the function ",
StyleBox["PolarPlot ",
FontWeight->"Bold"],
"in the ",
"Graphics package",
". It can be loaded like this:"
}], "Text"],
Cell[BoxData[
\(<< Graphics`\)], "Input"],
Cell[BoxData[
\(\(?PolarPlot\)\)], "Input"],
Cell[TextData[{
"For example, ",
StyleBox["a spiral ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(r(\[Phi]) = \[Phi]\/10\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[" can be plotted like this",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[
\(\(PolarPlot[\ \[Phi]\/10, \ {\[Phi], 0, 16 \[Pi]}\ ];\)\)], "Input"],
Cell[TextData[{
StyleBox["Once you get the plots to agree you are finished; but try to \
remember that the form for an ellipse with long dimension 2",
FontFamily->"Times New Roman"],
StyleBox["a",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[", eccentricity ",
FontFamily->"Times New Roman"],
StyleBox["e",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[", and with the origin at one focus in cylindrical coordinates is\n\
\t ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(r(\[Phi]) = \(a\ \((\ 1\ - \ e\^2\ )\)\)\/\(1\ + \ e\ \
cos\ \[Phi]\)\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[" \nOk-you won't remember this. But remember that you can come \
back here as a review when you get to planetary motion in the course \
Classical Mechanics.",
FontFamily->"Times New Roman"]
}], "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell["Problem 2.12", "Subsection"],
Cell[TextData[{
StyleBox["Well, that was pretty bad. Here's one that's just for fun. In \
the polar plot ",
FontFamily->"Times New Roman"],
"function",
StyleBox[" given below treat two numbers as adjustable, ",
FontFamily->"Times New Roman"],
StyleBox["j",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" and ",
FontFamily->"Times New Roman"],
StyleBox["k",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[", and just see what kinds of different pictures you can make. \
Fractional values of ",
FontFamily->"Times New Roman"],
StyleBox["j",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" are interesting if you use large values of ",
FontFamily->"Times New Roman"],
StyleBox["k",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[".",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[{
\(j = 3; \ k = 2\), "\[IndentingNewLine]",
\(\(PolarPlot[\ Cos[j\ \[Phi]], \ {\[Phi], 0, k\ \[Pi]}\ , \
Axes \[Rule] False];\)\)}], "Input"],
Cell[TextData[ButtonBox["Go to top of section",
ButtonData:>"Top",
ButtonStyle->"Hyperlink"]], "Text"]
}, Closed]]
}, Closed]],
Cell[CellGroupData[{
Cell["Special functions", "Subtitle"],
Cell[TextData[{
StyleBox["There are a bunch of functions you haven't encountered yet that \
are called ",
FontFamily->"Times New Roman"],
StyleBox["special functions",
FontFamily->"Times New Roman",
FontSlant->"Italic",
FontColor->GrayLevel[0]],
StyleBox[", meaning they are not like the simple sines, cosines, \
exponentials, logs, powers, and hyperbolic functions you can find on hand \
calculators. These are functions that arise in more advanced work in \
mathematical physics and you will work with them in courses like Mathematical \
Physics, Electricity and Magnetism, Optics, Quantum Physics, Atomic Physics, \
etc. A discussion of the subject can be found in\n\tHelp Browser: \t",
FontFamily->"Times New Roman"],
StyleBox["The ",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontWeight->"Bold",
FontSlant->"Italic"],
StyleBox[" Book ",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["\[Rule] ",
FontWeight->"Bold"],
StyleBox["Advanced Mathematics \n\t\t\t",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["\[Rule]",
FontWeight->"Bold"],
StyleBox[" Mathematical Functions ",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["\[Rule]",
FontWeight->"Bold"],
StyleBox[" Special Functions",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["\nLet's get a head start on these functions by using ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontSlant->"Italic"],
" ",
StyleBox["graphs to at least see what they look like. Each problem below \
introduces you to a different special function and asks you to get a feel for \
its properties by making graphs.",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[CellGroupData[{
Cell["Problem 2.13: Legendre polynomials", "Subsection"],
Cell[TextData[{
StyleBox["These functions show up when we do electrical and quantum \
mechanical problems in spherical coordinates. The conventional mathematical \
symbol for them is ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\(P\_n\)(x)\)]],
", but in ",
StyleBox[" ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
", they are denoted as",
StyleBox[" ",
FontFamily->"Times New Roman"],
StyleBox["LegendreP[ ", "Input",
FontFamily->"Times New Roman"],
StyleBox["n", "Input",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[", ", "Input",
FontFamily->"Times New Roman"],
StyleBox["x ", "Input",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox["]", "Input",
FontFamily->"Times New Roman"],
StyleBox[". Basically, they are simply polynomials in ",
FontFamily->"Times New Roman"],
StyleBox["x",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[". But they have very special properties on the interval ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\([\(-1\), 1]\)\)]],
":",
StyleBox[" \n(i) For odd values of the integer index ",
FontFamily->"Times New Roman"],
StyleBox["n ",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox["they are odd and for ",
FontFamily->"Times New Roman"],
StyleBox["n ",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox["even they are even.\n(ii) ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\(P\_n\)(\(\[PlusMinus]1\)) = \
\((\(\[PlusMinus]1\))\)\^n\)]],
" for all ",
StyleBox["n.",
FontSlant->"Italic"],
"\n",
StyleBox["(iii) They wiggle a lot, more and more as ",
FontFamily->"Times New Roman"],
StyleBox["n",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" gets bigger and bigger, but their magnitudes are always smaller \
than 1 inside the interval ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\([\(-1\), 1]\)\)]],
StyleBox[".",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[TextData[{
StyleBox["I have given you below a plot ",
FontFamily->"Times New Roman"],
"function",
StyleBox[" that plots the first two on top of each other. Modify this ",
FontFamily->"Times New Roman"],
"function",
StyleBox[" so that it plots the first 8 Legendre polynomials on top of each \
other. ( The plot for ",
FontFamily->"Times New Roman"],
StyleBox["c",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" is to identify the color assigned to ",
FontFamily->"Times New Roman"],
StyleBox["n",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" ).",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[{
\(s = Table[\ LegendreP[n, x], \ {n, 0, 2}\ ]\), "\n",
\(co = Table[\ Hue[n/3], \ {n, 0, 2}\ ]\), "\n",
\(c = Table[\ n, \ {n, 0, 2}\ ]\), "\n",
\(\(Plot[\ Evaluate[s], \ {x, \(-1\), 1}, \
PlotStyle \[Rule] co\ ];\)\), "\n",
\(\(Plot[\ Evaluate[c], \ {x, \(-1\), 1}, \
PlotStyle \[Rule] co\ ];\)\)}], "Input"],
Cell[TextData[ButtonBox["Go to top of section",
ButtonData:>"Top",
ButtonStyle->"Hyperlink"]], "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell["Problem 2.14: Bessel functions", "Subsection"],
Cell[TextData[{
StyleBox["These functions show up when we do electricity and thermal \
conduction problems in cylindrical geometry. There are 4 of them that are \
most commonly used: ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\(J\_n\)(x)\)]],
", ",
Cell[BoxData[
\(TraditionalForm\`\(Y\_n\)(x)\)]],
", ",
Cell[BoxData[
\(TraditionalForm\`\(I\_n\)(x)\)]],
", and ",
Cell[BoxData[
\(TraditionalForm\`\(K\_n\)(x)\)]],
". In ",
StyleBox["Mathematica",
FontSlant->"Italic"],
", they are represented as ",
StyleBox["BesselJ[ ",
FontWeight->"Bold"],
StyleBox["n",
FontWeight->"Bold",
FontSlant->"Italic"],
StyleBox[", ",
FontWeight->"Bold"],
StyleBox["x",
FontWeight->"Bold",
FontSlant->"Italic"],
StyleBox[" ]",
FontWeight->"Bold"],
", ",
StyleBox["BesselY[ ",
FontWeight->"Bold"],
StyleBox["n",
FontWeight->"Bold",
FontSlant->"Italic"],
StyleBox[", ",
FontWeight->"Bold"],
StyleBox["x",
FontWeight->"Bold",
FontSlant->"Italic"],
StyleBox[" ]",
FontWeight->"Bold"],
", ",
StyleBox["BesselI[ ",
FontWeight->"Bold"],
StyleBox["n",
FontWeight->"Bold",
FontSlant->"Italic"],
StyleBox[", ",
FontWeight->"Bold"],
StyleBox["x",
FontWeight->"Bold",
FontSlant->"Italic"],
StyleBox[" ]",
FontWeight->"Bold"],
", and ",
StyleBox["BesselK[ ",
FontWeight->"Bold"],
StyleBox["n",
FontWeight->"Bold",
FontSlant->"Italic"],
StyleBox[", ",
FontWeight->"Bold"],
StyleBox["x",
FontWeight->"Bold",
FontSlant->"Italic"],
StyleBox[" ]",
FontWeight->"Bold"],
", respectively. ",
StyleBox["The ",
FontFamily->"Times New Roman"],
StyleBox["J ",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox["'s and ",
FontFamily->"Times New Roman"],
StyleBox["Y ",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox["'s are sort of like cylindrical sines and cosines while the ",
FontFamily->"Times New Roman"],
StyleBox["I ",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox["'s and ",
FontFamily->"Times New Roman"],
StyleBox["K ",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox["'s are like cylindrical growing and dying exponentials. You also \
need to know that the ",
FontFamily->"Times New Roman"],
StyleBox["Y ",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox["'s and the ",
FontFamily->"Times New Roman"],
StyleBox["K ",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox["'s are singular at ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`x = 0\)]],
StyleBox[" so you have to be careful when making plots of them. You can \
control singularities by choosing the vertical range of the plot to be \
finite. The ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" ",
FontFamily->"Times New Roman"],
"function",
StyleBox[" below plots the first two ",
FontFamily->"Times New Roman"],
StyleBox["J ",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox["'s. I want you make the following plots: \n(a) Plot ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\(J\_0\)(x)\)]],
StyleBox[" and ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\(Y\_0\)(x)\)]],
StyleBox[" on one plot frame from ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`x = 0\)]],
StyleBox[" to ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`x = 30\)]],
StyleBox[". Set ",
FontFamily->"Times New Roman"],
StyleBox["PlotPoints",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" large enough that you can see the logarithmic singularity of ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\(Y\_0\)(x)\)]],
StyleBox[" near ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`x = 0\)]],
StyleBox[". \n(b) Plot ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\(J\_n\)(x)\)]],
" and ",
Cell[BoxData[
\(TraditionalForm\`\(Y\_n\)(x)\)]],
StyleBox[" for ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`n = \(1\ ... \)\ \ 4\)]],
StyleBox[" with the ",
FontFamily->"Times New Roman"],
StyleBox["J ",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox["'s on one plot frame and the ",
FontFamily->"Times New Roman"],
StyleBox["Y ",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox["'s on another. Plot them from ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`x = 0\)]],
StyleBox[" to ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`x = 30\)]],
StyleBox[". The ",
FontFamily->"Times New Roman"],
StyleBox["Table",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" ",
FontFamily->"Times New Roman"],
"function",
StyleBox[" will help you here. \n(c) Plot ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\(I\_n\)(x)\)]],
StyleBox[" for ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`n = \(1\ ... \)\ \ 4\)]],
StyleBox[" all on one plot frame. Do it from ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`x = 0\)]],
StyleBox[" to ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`x = 30\)]],
StyleBox[". \n(d) Plot ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\(K\_n\)(x)\)]],
StyleBox[" for ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`n = \(1\ ... \)\ \ 4\)]],
StyleBox[", all on one plot frame. Do it from ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`x = 0\)]],
StyleBox[" to ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`x = 10\)]],
StyleBox[". Take a good look at these functions; they will show up later.",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[
\(\(Plot[\ {BesselJ[0, x], BesselJ[1, x]}, \ {x, 0,
50}, \[IndentingNewLine]\t\t\ PlotStyle \[Rule] {\
RGBColor[1, 0, 0], RGBColor[0, 0, 1]}\ ];\)\)], "Input"],
Cell[TextData[StyleBox["Now use your graphs to answer the following \
questions.",
FontFamily->"Times New Roman"]], "Text"],
Cell[TextData[{
StyleBox["1. (a) The ",
FontFamily->"Times New Roman"],
StyleBox["J",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox["- and ",
FontFamily->"Times New Roman"],
StyleBox["Y",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox["-Bessel functions look like sines and cosines after about ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`x = 10\)]],
StyleBox["; what is the period of these almost periodic functions? (b) You \
will notice that their amplitudes are falling off at large ",
FontFamily->"Times New Roman"],
StyleBox["x",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[". The fall off factor is a power law, i.e., ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(A\/x\^p\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[". Find the value of ",
FontFamily->"Times New Roman"],
StyleBox["p",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" by plotting ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\(J\_0\)(x)\)]],
StyleBox[" and ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(A\/x\^p\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[" on the same plot and by adjusting ",
FontFamily->"Times New Roman"],
StyleBox["A",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" and ",
FontFamily->"Times New Roman"],
StyleBox["p",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" until the second function lines up with the top of the Bessel \
function wiggles.",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[TextData[{
StyleBox["2. The ",
FontFamily->"Times New Roman"],
StyleBox["I",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox["- and ",
FontFamily->"Times New Roman"],
StyleBox["K",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox["-Bessel functions look like exponentials ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`e\^\(\(\ \)\(a\ x\)\)\)]],
StyleBox[" after about ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`x = 10\)]],
StyleBox[". Find the approximate exponential function that fits them out \
there. You will have trouble doing this because in addition to the ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`e\^\(\(\ \)\(a\ x\)\)\)]],
StyleBox["-behavior these functions also have the same power-law drop-off \
factor ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(A\/x\^p\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[" as the ",
FontFamily->"Times New Roman"],
StyleBox["J ",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox["'s and ",
FontFamily->"Times New Roman"],
StyleBox["Y ",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox["'s. So when you look for the exponential function that comes \
close to describing what they do, make your comparison plots between \
exponentials and ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\(\(I\_n\)(x)\)\ x\^p\)]],
StyleBox[" and ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\(\(K\_n\)(x)\)\ x\^p\)]],
StyleBox[". You will also find it helpful to plot the logarithms of these \
functions instead of the functions themselves to handle their huge variation \
in magnitude. All you want to see is that the logarithms of the ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\(\(I\_n\)(x)\)\ x\^p\)]],
StyleBox[" functions are parallel to each other and also parallel to the \
line ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`y = a\ x\)]],
StyleBox[" for the appropriate choice of ",
FontFamily->"Times New Roman"],
StyleBox["a",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" ; then do the same thing for the functions ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\(\(K\_n\)(x)\)\ x\^p\)]],
StyleBox[" .",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[TextData[ButtonBox["Go to top of section",
ButtonData:>"Top",
ButtonStyle->"Hyperlink"]], "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell["Problem 2.15: The Gamma function", "Subsection"],
Cell[TextData[{
StyleBox["The Gamma function is the analytic continuation onto the real \
number line of the factorial function for integers. The connection is\n\t ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\[CapitalGamma](n + 1) = \(n!\)\)]],
"\n",
StyleBox["This function shows up in all kinds of places and it has rather \
surprising properties for negative values of its argument. All I want you to \
do is to plot it ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`from\)]],
" ",
Cell[BoxData[
\(TraditionalForm\`\(\(-5\)\ ... \)\ 5\)]],
StyleBox[" and verify that it has the correct values at positive integers, \
and then to marvel that a function that seems so simple on the positive half \
of the number line could be so messed up on the negative side. ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica ",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox["'s name for it is ",
FontFamily->"Times New Roman"],
StyleBox["Gamma[x]",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[".",
FontFamily->"Times New Roman"]
}], "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell["Problem 2.16: Complete elliptic integrals", "Subsection"],
Cell[TextData[{
StyleBox["The complete elliptic integral functions ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`K(k)\)]],
StyleBox[" and ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`E(k)\)]],
StyleBox[" are defined by the definite integrals\n\t",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`K(
k) = \[Integral]\_0\%\(\[Pi]/2\)\(1\/\@\(1\ - \ k\^2\ \(sin\^2\) \
\[Phi]\)\) \[DifferentialD]\[Phi]\)]],
"\t\t",
Cell[BoxData[
FormBox[
StyleBox[\(E(
k) = \[Integral]\_0\%\(\[Pi]/2\)\(\@\(1\ - \
k\^2\ \(sin\^2\) \[Phi]\)\) \[DifferentialD]\[Phi]\),
"DisplayFormula"], TraditionalForm]]]
}], "Text"],
Cell[TextData[{
StyleBox["The ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" names for these functions are ",
FontFamily->"Times New Roman"],
StyleBox["EllipticK[ ",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["k ",
FontFamily->"Times New Roman",
FontWeight->"Bold",
FontSlant->"Italic"],
StyleBox["]",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" and ",
FontFamily->"Times New Roman"],
StyleBox["EllipticK[ ",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["k ",
FontFamily->"Times New Roman",
FontWeight->"Bold",
FontSlant->"Italic"],
StyleBox["]",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[".",
FontFamily->"Times New Roman"],
StyleBox[" ",
FontFamily->"Times New Roman"],
StyleBox[" ",
FontFamily->"Times New Roman",
FontWeight->"Bold",
FontColor->RGBColor[0, 0.501961, 0]],
StyleBox["These functions are usually used with ",
FontFamily->"Times New Roman"],
StyleBox["k",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" in the range 0...1, but they can be analytically continued into \
the entire complex plane. Both ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`K(k)\)]],
StyleBox[" and ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`E(k)\)]],
StyleBox[" are ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(\[Pi]\/2\),
"DisplayFormula"], TraditionalForm]]],
" ",
StyleBox["for ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`k = 0\)]],
StyleBox[". At the other end, ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`k = 1\)]],
StyleBox[", ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`K(k)\)]],
StyleBox[" is logarithmically singular and ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`E(k)\)]],
StyleBox[" is 1. Plot both functions on the same plot over this range \
using ",
FontFamily->"Times New Roman"],
StyleBox["PlotPoints",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" of 200",
FontFamily->"Times New Roman"],
StyleBox[" and 1000; I want you to see how weak a logarithmic singularity \
is. You should find that almost nothing happens as ",
FontFamily->"Times New Roman"],
StyleBox["PlotPoints",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" is changed, except that the vertical plotting range changes a \
little. To see why this plot behavior indicates a weak singularity, here's \
what such a pair of plots looks like for a strong singularity:",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[{
\(\(Plot[1\/\(1 - x\), \ {x, 0, 1}, \
PlotPoints \[Rule] 200\ ];\)\), "\[IndentingNewLine]",
\(\(Plot[1\/\(1 - x\), \ {x, 0, 1}, \
PlotPoints \[Rule] 1000\ ];\)\)}], "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell["Problem 2.17: The error function", "Subsection"],
Cell[TextData[{
StyleBox["The error function ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`erf(x)\)]],
StyleBox[" shows up all the time in probability theory and ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" calls it ",
FontFamily->"Times New Roman"],
StyleBox["Erf[ x ]",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[". If you have a Gaussian probability distribution, proportional \
to ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`e\^\(-x\^2\)\)]],
StyleBox[", then the probability that the variable ",
FontFamily->"Times New Roman"],
StyleBox["x",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" lies between ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\(-\[Infinity]\)\)]],
StyleBox[" and ",
FontFamily->"Times New Roman"],
StyleBox["z",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" is\n\t",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(\[Integral]\_\(\(\ \)\(-\[Infinity]\)\)\%z\(
e\^\(-x\^2\)\) \[DifferentialD]x\),
"DisplayFormula"], TraditionalForm]]],
StyleBox["\nwhich is just what the error function ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`erf(x)\)]],
StyleBox[" involves. But for some reason a long time ago someone decided \
that the basic function erf should be defined as an integral starting at 0 \
instead of at, so they defined it this way:",
FontFamily->"Times New Roman"],
"\n\t",
Cell[BoxData[
FormBox[
StyleBox[\(erf(
z) = \(2\/\@\[Pi]\) \(\[Integral]\_\(\(\ \)\(0\)\)\%z\(
e\^\(-x\^2\)\) \[DifferentialD]x\)\),
"DisplayFormula"], TraditionalForm]]]
}], "Text"],
Cell[TextData[{
StyleBox["The probability that a Gaussian variable lies between ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\(-\[Infinity]\)\)]],
StyleBox[" and ",
FontFamily->"Times New Roman"],
StyleBox["z",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" is given by ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(\(1\/2\)[\ 1 + erf(z)\ ]\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[". Plot both erf(",
FontFamily->"Times New Roman"],
StyleBox["x",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[") and ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(\(1\/2\)[\ 1 + erf(z)\ ]\),
"DisplayFormula"], TraditionalForm]]],
" ",
StyleBox["in the range ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\(\(-3\)\ ... \)\ 3\)]],
StyleBox[".",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[TextData[ButtonBox["Go to top of section",
ButtonData:>"Top",
ButtonStyle->"Hyperlink"]], "Text"]
}, Closed]]
}, Closed]],
Cell[CellGroupData[{
Cell["Animations", "Subtitle"],
Cell[TextData[{
StyleBox["Perhaps the coolest plots ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" can make are animations. Let's start with two simple wave \
examples. The formula for a traveling wave is ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`y(x, t) = A\ \(sin(\ k\ x - \[Omega]\ t\ )\)\)]],
StyleBox[". There are many ways ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" can show you that this formula travels. For an introduction of \
the subject, see\n\tHelp Browser: ",
FontFamily->"Times New Roman"],
StyleBox["The ",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["Mathematica ",
FontFamily->"Times New Roman",
FontWeight->"Bold",
FontSlant->"Italic"],
StyleBox["Book ",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["\[Rule]",
FontWeight->"Bold"],
StyleBox[" A Practical Introduction\n\t\t",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["\[Rule]",
FontWeight->"Bold"],
StyleBox[" Graphics and Sound ",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["\[Rule]",
FontWeight->"Bold"],
StyleBox[" Special Topic: Animation",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["\nHere, we shall make use of only the ",
FontFamily->"Times New Roman"],
StyleBox["Animate",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" function. This requires loading the ",
FontFamily->"Times New Roman"],
StyleBox["Animation",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" package",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[
\(<< Graphics`Animation`\)], "Input"],
Cell[BoxData[
\(\(?Animate\)\)], "Input"],
Cell[TextData[{
StyleBox["Next, we give ",
FontFamily->"Times New Roman"],
StyleBox["A",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[", ",
FontFamily->"Times New Roman"],
StyleBox["k",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" and \[Omega]",
FontFamily->"Times New Roman"],
StyleBox[" numerical values, then invoke the ",
FontFamily->"Times New Roman"],
StyleBox["Animate",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" ",
FontFamily->"Times New Roman"],
StyleBox["function.",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[{
\(a = 1.5; \
k = 3\ \[Pi]/2; \ \ \[Omega] = \[Pi]/2;\), "\[IndentingNewLine]",
\(Animate[\
Plot[\ a\ Sin[\ k\ x - \[Omega]\ t], \ {x, 0, 20}, \
Axes \[Rule] False\ ], \ {t, 0, 5, 1}\ \ ]\)}], "Input"],
Cell[TextData[{
StyleBox["When you execute the cell, you will see a series of stationary \
plots. To make them move, just double-click on any plot. Animation will \
start on the most visible plot. Player controls will also appear on the left \
hand side of the status bar at the bottom of the ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" window. When they come up, take a minute and check out what \
each one does.",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[CellGroupData[{
Cell["Problem 2.18", "Subsection"],
Cell[TextData[{
StyleBox["Modify the ",
FontFamily->"Times New Roman"],
StyleBox["Animate",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" function above so that the function runs smoother in time. \
Show, using your animation, that the velocity at which the wavetops move \
(this velocity is called the ",
FontFamily->"Times New Roman"],
StyleBox["phase velocity)",
FontFamily->"Times New Roman",
FontSlant->"Italic",
FontColor->GrayLevel[0]],
StyleBox[" is given by ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(v\_\[Phi] = \[Omega]\/k\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[" . Also show that changing the sign of ",
FontFamily->"Times New Roman"],
StyleBox["k",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" changes the direction the wave moves. ",
FontFamily->"Times New Roman"]
}], "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell["Problem 2.19", "Subsection"],
Cell[TextData[{
StyleBox["Modify the animation above so that it plots a standing wave \
instead: ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`y(x, t) = A\ sin\ k\ x\ sin\ \[Omega]\ t\)]],
StyleBox[". Use a range in ",
FontFamily->"Times New Roman"],
StyleBox["x",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" so that the standing wave has 3 zeros between the endpoints and \
fixed ends as well.",
FontFamily->"Times New Roman"]
}], "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell["Problem 2.20", "Subsection"],
Cell[TextData[StyleBox["Show by making an animation that the sum of two waves \
of equal amplitude traveling in opposite directions is a standing wave.",
FontFamily->"Times New Roman"]], "Text"]
}, Closed]]
}, Closed]],
Cell[CellGroupData[{
Cell["Advanced topic: wave packets", "Subtitle"],
Cell[TextData[{
StyleBox["In addition to elementary wave properties, animation can also \
illustrate the more complex behavior of wave packets, including the concepts \
of group velocity and wave packet diffusion. The way to make a wave packet \
is to take a whole bunch of waves of the form ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`A\ \(sin(k\ x - \[Omega]\ t)\)\)]],
StyleBox[" with different ",
FontFamily->"Times New Roman"],
StyleBox["k ",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox["'s and add them together, as we did in the section of Fourier \
analysis when we discussed the uncertainty principle. We can do exactly the \
same thing here with ",
FontFamily->"Times New Roman"],
StyleBox["k",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[", using an amplitude function ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`A(\[Omega])\)]],
StyleBox[" centered at ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`k\_0\)]],
StyleBox[" with width ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\[CapitalDelta]\ k\)]],
StyleBox[" to make a wave packet in space with wavelength ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(\(2 \[Pi]\)\/k\_0\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[" and width ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\[CapitalDelta]\ x\)]],
StyleBox[". But the new feature is that this packet moves, and in weird \
and strange ways. Its behavior is determined by the dispersion relation ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\[Omega] = \[Omega](k)\)]],
StyleBox[" of the waves that are being added together. We will start with \
the simplest case and work our way up to some strange ones that are more than \
just mathematical curiosities. Every effect that will be shown in this \
section is physically realized in some kind of electromagnetic wave found in \
the plasmas that surround the sun and the planets of our solar system.",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[TextData[{
StyleBox["Suppose the dispersion relation is just the standard \
non-dispersive one that governs light and sound: ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\[Omega] = k\ v\)]],
StyleBox[", where ",
FontFamily->"Times New Roman"],
StyleBox["v",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" is the phase velocity of the waves. In this case every wave of \
the superposition moves at exactly the same speed, so every part of the wave \
packet moves at speed ",
FontFamily->"Times New Roman"],
StyleBox["v",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[", as shown in the example below.",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[TextData[StyleBox["Define the dispersion relation ( some previously \
defined symbols were removed to avoid possible conflicts ) :",
FontFamily->"Times New Roman"]], "Text"],
Cell[BoxData[{
\(Clear[\ "\"]\ \), "\n",
\(v = 1; \ \ \[Omega][k_] := k\ v\)}], "Input"],
Cell[TextData[{
"Define the spectrum in ",
StyleBox["k",
FontSlant->"Italic"],
" :"
}], "Text"],
Cell[BoxData[
\(k0 =
1; \ \ a[k_] := \[ExponentialE]\^\(\(-40\) \((k - k0)\)\^2\)\)], "Input"],
Cell[TextData[{
StyleBox["Now we will look at the wave packet at time ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`t = 0\)]]
}], "Text"],
Cell[BoxData[
\(f[x_,
t_] := \[Sum]\+\(n = 0\)\%40 a[
k0 - 1\/2 +
n\/40]\ Sin[\ \((k0 - 1\/2 + n\/40)\)
x - \[Omega][k0 - 1\/2 + n\/40]\ t\ ]\)], "Input"],
Cell[BoxData[
\(Plot[\ f[x, 0], \ {x, \(-60\), 60}, \
PlotRange \[Rule] All\ ]\)], "Input"],
Cell[TextData[{
StyleBox["Now we are ready to make it move by using ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" 's ",
FontFamily->"Times New Roman"],
StyleBox["Animate",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" function.",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[
\(Animate[\
Plot[\ f[x, t], \ {x, \(-60\), 60}, \
PlotRange \[Rule] {\(-12\), 12}\ ], \ {t, 0, 180, 10}\ \ ]\)], "Input"],
Cell[CellGroupData[{
Cell["Problem 2.21", "Subsection"],
Cell[TextData[{
StyleBox["If the dispersion relation is not just the linear function ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\[Omega] = k\ v\)]],
StyleBox[", then more interesting things can happen. The first of these is \
that the waves in the packet and the packet as a whole no longer move at the \
same velocity. Let's try a new dispersion relation using the form\n\t ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(\[Omega] = k\ v\ \((\ 1 + \(a\ k\)\/k\_0\ )\)\),
"DisplayFormula"], TraditionalForm]]],
"\n",
StyleBox["When you study Fourier analysis in more detail you will learn how \
to show that while the wave crests move at the phase velocity given by ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(v\_phase = \[Omega]\/k\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[" , the packet as a whole moves at the group velocity given by ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(v\_group = \(d\ \[Omega]\)\/\(d\ k\)\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[". \n(a) Find the phase and group velocities for the dispersion \
relation given in the introduction to this problem (",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" can help). Choose ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`k = k\_0\)]],
StyleBox[" and obtain ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`v\_\[Phi]\)]],
StyleBox[" and ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`v\_g\)]],
StyleBox[" (the standard phase and group velocity notations) as functions \
of the parameter ",
FontFamily->"Times New Roman"],
StyleBox["a",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[". Modify the dispersion relation in the ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" execution cells given in the first part of the problem and run \
it again with ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`a = 1\)]],
StyleBox[". Try to see the wave crests moving slower than the wave packet \
as a whole (you will see wavecrests moving backwards through the packet \
because the group velocity is bigger than the phase velocity). To see this \
you will have to slow the animation down using the controls on the toolbar. \
You may also want to put it into continuous play mode and adjust the \
simulation time so that it runs just long enough that the group velocity \
covers the distance from ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`x = 0\)]],
StyleBox[" to ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`x = 60\)]],
StyleBox[". Warning: this takes a while, so be patient. \n(b) Now for \
something really weird; choose ",
FontFamily->"Times New Roman"],
StyleBox["a",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" so that the group velocity is zero and run the animation again. \
The packet should sit still while the wave crests move through it.",
FontFamily->"Times New Roman"]
}], "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell["Problem 2.22", "Subsection"],
Cell[TextData[{
StyleBox["You may have noticed in part (b) of Problem 2.21 that although \
the packet didn't move much, it did change shape a little. The reason for \
this is that wave packets can also broaden in time via diffusion, just like a \
tiny hot spot in a piece of metal spreads out through thermal diffusion. The \
diffusion coefficient for wave packet broadening is proportional to the \
magnitude of the second derivative of the dispersion relation (with respect \
to ",
FontFamily->"Times New Roman"],
StyleBox["k",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox["). This means that if the dispersion relation has a non-zero \
second derivative, then the wave packet will spread in time. But to really \
see it you will need to run the simulation long enough that the effect starts \
to really matter. This run time is on the order of a few times the absolute \
value of ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(1\/\(\[Omega]''\ \[CapitalDelta]\ k\^2\)\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[" in this problem, where ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\[CapitalDelta]\ k\)]],
StyleBox[" is the width of ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`A(k)\)]],
" ",
StyleBox["(use FWHM). Calculate ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`\[Omega]''\)]],
StyleBox[" and verify that it is non-zero, then run the simulation for \
Problem 2.21 long enough that you can see the spreading.",
FontFamily->"Times New Roman"]
}], "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell["Problem 2.23", "Subsection"],
Cell[TextData[StyleBox["Invent a dispersion relation that has a positive \
phase velocity and a negative group velocity and verify that it works by \
modifying and running an animation.",
FontFamily->"Times New Roman"]], "Text"],
Cell[TextData[ButtonBox["Go to top of section",
ButtonData:>"Top",
ButtonStyle->"Hyperlink"]], "Text"]
}, Closed]]
}, Closed]],
Cell[CellGroupData[{
Cell["Visualizing vector fields", "Subtitle"],
Cell[TextData[{
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" 's ",
FontFamily->"Times New Roman"],
StyleBox["PlotVectorField",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" ",
FontFamily->"Times New Roman"],
StyleBox["function ( in package ",
FontFamily->"Times New Roman"],
StyleBox["Graphics`PlotField`",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" ) ",
FontFamily->"Times New Roman"],
StyleBox["allows you to visualize vector fields in two dimensions. \
Suppose, for instance, that you have a magnetic field given by the formulas ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(B\_x = \(B\_0\/a\) y\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[" ",
FontFamily->"Times New Roman",
FontVariations->{"CompatibilityType"->"Superscript"}],
StyleBox["and ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(B\_y = \(B\_0\/a\) x\),
"DisplayFormula"], TraditionalForm]]],
StyleBox[". To visualize the field lines we would do this (setting ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`B\_0 = 1\)]],
StyleBox[" and ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`a = 1\)]],
StyleBox[" to make the numbers easy) :",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[
\(\(\( (*\
This\ reads\ in\ package\ ONLY\ if\ not\ already\ loaded\ *) \)\(\
\[IndentingNewLine]\)\(Needs[\ "\"]\[IndentingNewLine]
\(?PlotVectorField\)\)\)\)], "Input"],
Cell[BoxData[
\(\(PlotVectorField[\ {\ y, x\ }, \ {x, \(-1\), 1}, \ {y, \(-1\), 1}\ , \
ColorFunction \[Rule] Hue\ ];\)\)], "Input"],
Cell[TextData[{
StyleBox["There is also a ",
FontFamily->"Times New Roman"],
StyleBox["PlotVectorField3D",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" function ( in package ",
FontFamily->"Times New Roman"],
StyleBox["Graphics`PlotField3D`",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" ) which works similarly in three dimensions; you can find out \
how it works ( ? doesn't work without loading the package) in\n\tHelp \
Browser: \t",
FontFamily->"Times New Roman"],
StyleBox["Add-ons & Links ",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["\[Rule]",
FontWeight->"Bold"],
StyleBox[" Standard Packages\n\t\t",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["\[Rule]",
FontWeight->"Bold"],
StyleBox[" Graphics ",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox["\[Rule]",
FontWeight->"Bold"],
StyleBox[" PlotField3D",
FontFamily->"Times New Roman",
FontWeight->"Bold"]
}], "Text"],
Cell[CellGroupData[{
Cell["Problem 2.24", "Subsection"],
Cell[TextData[{
StyleBox["(a) Use ",
FontFamily->"Times New Roman"],
StyleBox["PlotVectorField",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" t",
FontFamily->"Times New Roman"],
StyleBox["o visualize the electric field of a line charge, given by ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[
FractionBox[
RowBox[{"\[Lambda]", " ",
RowBox[{"(", " ",
RowBox[{
RowBox[{"x", " ",
StyleBox["i",
FontWeight->"Bold",
FontSlant->"Plain"]}],
StyleBox[" ",
FontWeight->"Plain"],
StyleBox["+",
FontWeight->"Plain"],
StyleBox[" ",
FontWeight->"Plain"],
RowBox[{
StyleBox["y",
FontWeight->"Plain"],
StyleBox[" ",
FontWeight->"Plain"],
StyleBox["j",
FontWeight->"Bold",
FontSlant->"Plain"]}]}],
StyleBox[" ",
FontWeight->"Plain"],
StyleBox[")",
FontWeight->"Plain"]}]}], \(2 \[Pi]\ \((\
x\^2\ + \ y\^2\ )\)\)],
"DisplayFormula"], TraditionalForm]]],
StyleBox[" where ",
FontFamily->"Times New Roman"],
StyleBox["i",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" and ",
FontFamily->"Times New Roman"],
StyleBox["j",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" are the ",
FontFamily->"Times New Roman"],
StyleBox["x",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" and ",
FontFamily->"Times New Roman"],
StyleBox["y",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" unit vectors. \n(b) Use ",
FontFamily->"Times New Roman"],
StyleBox["PlotVectorField",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" ",
FontFamily->"Times New Roman"],
StyleBox["to visualize the magnetic field of a long wire, given by ",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[
FractionBox[
RowBox[{\(\[Mu]\_0\), " ", "I", " ",
RowBox[{"(", " ",
RowBox[{
RowBox[{\(-y\), " ",
StyleBox["i",
FontWeight->"Bold",
FontSlant->"Plain"]}],
StyleBox[" ",
FontWeight->"Bold",
FontSlant->"Plain"], "+", " ",
RowBox[{"x", " ",
StyleBox["j",
FontWeight->"Bold",
FontSlant->"Plain"]}]}], " ", ")"}]}], \(2 \[Pi]\ \((\
x\^2\ + \ y\^2\ )\)\)],
"DisplayFormula"], TraditionalForm]]],
StyleBox[" . Experiment with different ",
FontFamily->"Times New Roman"],
StyleBox["PlotPoints",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" and choices for the other options. Note: don't use big numbers \
in the ",
FontFamily->"Times New Roman"],
StyleBox["PlotPoints",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[". If you do, ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" will take forever and when it finishes you will be looking at a \
solid wall of color without any discernible arrows. I don't usually go above \
30.",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[TextData[ButtonBox["Go to top of section",
ButtonData:>"Top",
ButtonStyle->"Hyperlink"]], "Text"]
}, Closed]]
}, Closed]],
Cell[CellGroupData[{
Cell["3D-surface plots and contour plots", "Subtitle"],
Cell[TextData[{
StyleBox["To visualize 2-dimensional data in the form of a function ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`f(x, y)\)]],
StyleBox[" ",
FontFamily->"Times New Roman"],
StyleBox["Mathematica",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" gives you two choices: \n(1) plot the function values as the \
height of a surface above the ",
FontFamily->"Times New Roman"],
StyleBox["xy",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" plane or \n(2) draw contours of constant ",
FontFamily->"Times New Roman"],
Cell[BoxData[
\(TraditionalForm\`f(x, y)\)]],
StyleBox[" in the ",
FontFamily->"Times New Roman"],
StyleBox["xy",
FontFamily->"Times New Roman",
FontSlant->"Italic"],
StyleBox[" plane. \nWhich does a better job depends on the problem and on \
your tastes. Here is an example done both ways. ",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[TextData[{
StyleBox["Consider the function\n\t",
FontFamily->"Times New Roman"],
Cell[BoxData[
FormBox[
StyleBox[\(f(x, y) =
e\^\(-\(\(|\)\(\ \)\(x\ - \ sin\ y\)\(\ \)\(|\)\)\)\ \((\
1 + \ 0.2\ cos\ x\/2\ )\)\ \((\
1 + \ 0.4\/\(0.3\ + \ y\^2\)\ )\)\),
"DisplayFormula"], TraditionalForm]]],
"\nwhich shall be called t",
StyleBox["he \"mountain range\" function. (Don't worry about where this \
function came from. I just made it up because it looks cool, like a mountain \
range.) A three-dimensional surface plot is done with ",
FontFamily->"Times New Roman"],
StyleBox["Plot3D",
FontFamily->"Times New Roman",
FontWeight->"Bold"],
StyleBox[" like this",
FontFamily->"Times New Roman"]
}], "Text"],
Cell[BoxData[{\(Clear["\"]\), "\[IndentingNewLine]",
RowBox[{"f", "=",
FormBox[\(Exp[\ \(-Abs[x - Sin[y]]\)\ ]\ \((1 +
0.2\ Cos[x\/2])\)\ \((1 + 0.4\/\(0.3 + y\^2\))\)\),
"TraditionalForm"]}], "\[IndentingNewLine]", \(Plot3D[\
f, \ {x, \(-6\), 6}, \ {y, \(-6\), 6}\ ];\)}], "Input"],
Cell[TextData[{
"If you want another viewpoint, open an input cell and enter \" ",
StyleBox["Show[ % , ",
FontWeight->"Bold"],
"\", leave the cursor there, then enter\n\t",
StyleBox[" \[ShiftKey]",
FontWeight->"Bold"],
"-\[ControlKey]-",
Cell[BoxData[
FormBox[
FrameBox["v",
BoxMargins->{{0.2, 0.2}, {0.4, 0.4}}], TraditionalForm]]],
" to open the 3-D ViewPoint Selector dialog\nDrag the cube around to the \
desired viewpoint, click on ",
StyleBox["Paste",
FontWeight->"Bold"],
".\nThe viewpoint coordinates, e.g., ",
StyleBox["ViewPoint \[Rule] {-1.684, -1.397, -2.581}",
FontWeight->"Bold"],
" will be pasted to where your cursor had been.\nThe cell immediately \
below was entered in this manner: "
}], "Text"],
Cell[BoxData[
\(\(Show[%, \
ViewPoint \[Rule] \ {\(-1.684\), \ \(-1.397\), \ \(-2.581\)}];\)\)], \
"Input"],
Cell[TextData[{
"If you find this tiresome, welcome to the club. [ BTW, you may find ",
StyleBox["Maple",
FontWeight->"Bold"],
" much more agreeable ]."
}], "Text"],
Cell[TextData[StyleBox["Well, all this looks rather interesting, but the \
detail is too crude to really see what is going on? No problem:",
FontFamily->"Times New Roman"]], "Text"],
Cell[BoxData[
\(\(Plot3D[\ f, \ {x, \(-6\), 6}, \ {y, \(-6\), 6}, \
PlotPoints \[Rule] 100\ ];\)\)], "Input"],
Cell["\<\
Some other useful options are illustrated in the following example:\
\>", "Text"],
Cell[BoxData[
\(\(Plot3D[\ f, \ {x, \(-6\), 6}, \ {y, \(-6\), 6},
Mesh \[Rule] False\ , \[IndentingNewLine]\ PlotPoints \[Rule] 100, \
Boxed \[Rule] False, \ Axes \[Rule] False\ , \
HiddenSurface \[Rule] False];\)\)], "Input"],
Cell[TextData[ButtonBox["Go to top of section",
ButtonData:>"Top",
ButtonStyle->"Hyperlink"]], "Text"]
}, Closed]]
}, Closed]]
},
FrontEndVersion->"5.0 for Microsoft Windows",
ScreenRectangle->{{0, 1024}, {0, 713}},
WindowSize->{1016, 681},
WindowMargins->{{0, Automatic}, {Automatic, 0}},
StyleDefinitions -> "TutorialBook.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->{
"Top"->{
Cell[1776, 53, 55, 1, 109, "Title",
CellTags->"Top"]}
}
*)
(*CellTagsIndex
CellTagsIndex->{
{"Top", 114596, 3553}
}
*)
(*NotebookFileOutline
Notebook[{
Cell[CellGroupData[{
Cell[1776, 53, 55, 1, 109, "Title",
CellTags->"Top"],
Cell[1834, 56, 1849, 59, 316, "Text"],
Cell[CellGroupData[{
Cell[3708, 119, 36, 0, 49, "Subtitle"],
Cell[3747, 121, 1512, 47, 142, "Text"],
Cell[5262, 170, 122, 2, 108, "Input"],
Cell[5387, 174, 384, 8, 111, "Text"],
Cell[5774, 184, 356, 9, 70, "Text"],
Cell[6133, 195, 66, 1, 73, "Input"],
Cell[6202, 198, 711, 25, 41, "Text"],
Cell[6916, 225, 199, 4, 80, "Input"],
Cell[7118, 231, 322, 7, 70, "Text"],
Cell[7443, 240, 86, 1, 72, "Input"],
Cell[7532, 243, 605, 15, 99, "Text"],
Cell[8140, 260, 130, 2, 72, "Input"],
Cell[8273, 264, 1402, 41, 198, "Text"],
Cell[9678, 307, 47, 1, 46, "Input"],
Cell[9728, 310, 523, 19, 120, "Text"],
Cell[10254, 331, 498, 13, 113, "Input"],
Cell[10755, 346, 363, 10, 82, "Text"],
Cell[11121, 358, 84, 1, 46, "Input"],
Cell[11208, 361, 38, 0, 41, "Text"],
Cell[11249, 363, 128, 2, 72, "Input"],
Cell[11380, 367, 1083, 30, 138, "Text"],
Cell[12466, 399, 46, 1, 46, "Input"],
Cell[12515, 402, 267, 3, 70, "Text"],
Cell[12785, 407, 621, 17, 146, "Input"],
Cell[13409, 426, 586, 14, 104, "Text"],
Cell[13998, 442, 666, 18, 99, "Text"],
Cell[14667, 462, 106, 2, 47, "Input"],
Cell[14776, 466, 410, 13, 70, "Text"],
Cell[15189, 481, 127, 2, 47, "Input"],
Cell[15319, 485, 71, 0, 41, "Text"],
Cell[15393, 487, 160, 2, 81, "Input"],
Cell[15556, 491, 104, 3, 41, "Text"],
Cell[15663, 496, 156, 2, 81, "Input"],
Cell[15822, 500, 178, 2, 41, "Text"],
Cell[16003, 504, 56, 1, 47, "Input"],
Cell[16062, 507, 313, 10, 41, "Text"],
Cell[16378, 519, 58, 1, 46, "Input"],
Cell[16439, 522, 651, 20, 70, "Text"],
Cell[17093, 544, 53, 1, 46, "Input"],
Cell[17149, 547, 133, 3, 41, "Text"],
Cell[17285, 552, 80, 1, 46, "Input"],
Cell[17368, 555, 143, 4, 47, "Text"],
Cell[17514, 561, 184, 5, 46, "Input"],
Cell[17701, 568, 63, 0, 41, "Text"],
Cell[17767, 570, 142, 3, 46, "Input"],
Cell[17912, 575, 872, 19, 266, "Text"],
Cell[18787, 596, 213, 4, 82, "Input"],
Cell[19003, 602, 178, 2, 41, "Text"],
Cell[19184, 606, 106, 2, 41, "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell[19327, 613, 41, 0, 49, "Subtitle"],
Cell[19371, 615, 162, 2, 41, "Text"],
Cell[CellGroupData[{
Cell[19558, 621, 33, 0, 65, "Subsection"],
Cell[19594, 623, 1009, 32, 99, "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell[20640, 660, 33, 0, 65, "Subsection"],
Cell[20676, 662, 1898, 58, 154, "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell[22611, 725, 33, 0, 65, "Subsection"],
Cell[22647, 727, 1160, 28, 301, "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell[23844, 760, 33, 0, 65, "Subsection"],
Cell[23880, 762, 2611, 73, 283, "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell[26528, 840, 33, 0, 65, "Subsection"],
Cell[26564, 842, 748, 20, 158, "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell[27349, 867, 33, 0, 65, "Subsection"],
Cell[27385, 869, 1131, 33, 128, "Text"],
Cell[28519, 904, 106, 2, 41, "Text"]
}, Closed]]
}, Closed]],
Cell[CellGroupData[{
Cell[28674, 912, 36, 0, 49, "Subtitle"],
Cell[28713, 914, 724, 14, 157, "Text"],
Cell[29440, 930, 222, 4, 114, "Input"],
Cell[29665, 936, 103, 2, 46, "Input"],
Cell[29771, 940, 465, 6, 128, "Text"],
Cell[CellGroupData[{
Cell[30261, 950, 33, 0, 65, "Subsection"],
Cell[30297, 952, 917, 28, 112, "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell[31251, 985, 115, 3, 47, "Subsubtitle"],
Cell[31369, 990, 1684, 48, 195, "Text"],
Cell[33056, 1040, 134, 2, 130, "Input"],
Cell[33193, 1044, 384, 9, 70, "Text"],
Cell[33580, 1055, 67, 1, 46, "Input"],
Cell[33650, 1058, 252, 3, 70, "Text"],
Cell[CellGroupData[{
Cell[33927, 1065, 33, 0, 65, "Subsection"],
Cell[33963, 1067, 2987, 80, 431, "Text"]
}, Closed]]
}, Closed]]
}, Closed]],
Cell[CellGroupData[{
Cell[37011, 1154, 48, 0, 49, "Subtitle"],
Cell[37062, 1156, 492, 6, 128, "Text"],
Cell[37557, 1164, 369, 5, 99, "Text"],
Cell[37929, 1171, 269, 7, 41, "Text"],
Cell[38201, 1180, 101, 2, 52, "Input"],
Cell[38305, 1184, 131, 2, 41, "Text"],
Cell[38439, 1188, 128, 2, 46, "Input"],
Cell[38570, 1192, 332, 11, 82, "Text"],
Cell[38905, 1205, 156, 2, 80, "Input"],
Cell[39064, 1209, 944, 23, 161, "Text"],
Cell[40011, 1234, 532, 13, 99, "Text"],
Cell[40546, 1249, 119, 2, 91, "Input"],
Cell[40668, 1253, 788, 23, 79, "Text"],
Cell[41459, 1278, 67, 1, 46, "Input"],
Cell[41529, 1281, 248, 8, 70, "Text"],
Cell[41780, 1291, 92, 1, 46, "Input"],
Cell[41875, 1294, 64, 0, 41, "Text"],
Cell[41942, 1296, 126, 2, 46, "Input"],
Cell[42071, 1300, 1097, 24, 157, "Text"],
Cell[CellGroupData[{
Cell[43193, 1328, 33, 0, 65, "Subsection"],
Cell[43229, 1330, 582, 13, 99, "Text"],
Cell[43814, 1345, 106, 2, 41, "Text"]
}, Closed]]
}, Closed]],
Cell[CellGroupData[{
Cell[43969, 1353, 33, 0, 49, "Subtitle"],
Cell[44005, 1355, 712, 18, 128, "Text"],
Cell[44720, 1375, 933, 26, 567, "Text"],
Cell[45656, 1403, 115, 3, 41, "Text"],
Cell[45774, 1408, 58, 1, 46, "Input"],
Cell[45835, 1411, 425, 13, 41, "Text"],
Cell[46263, 1426, 185, 3, 46, "Input"],
Cell[46451, 1431, 328, 9, 70, "Text"],
Cell[46782, 1442, 85, 1, 46, "Input"],
Cell[46870, 1445, 232, 6, 70, "Text"],
Cell[47105, 1453, 313, 6, 114, "Input"],
Cell[47421, 1461, 22, 0, 41, "Text"],
Cell[47446, 1463, 58, 1, 46, "Input"],
Cell[47507, 1466, 85, 2, 41, "Text"],
Cell[47595, 1470, 78, 1, 46, "Input"],
Cell[47676, 1473, 120, 5, 41, "Text"],
Cell[47799, 1480, 51, 1, 46, "Input"],
Cell[47853, 1483, 293, 9, 46, "Text"],
Cell[48149, 1494, 125, 2, 80, "Input"],
Cell[48277, 1498, 404, 13, 42, "Text"],
Cell[48684, 1513, 46, 1, 46, "Input"],
Cell[48733, 1516, 725, 20, 130, "Text"],
Cell[49461, 1538, 316, 6, 115, "Input"],
Cell[49780, 1546, 239, 7, 41, "Text"],
Cell[50022, 1555, 106, 2, 41, "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell[50165, 1562, 36, 0, 49, "Subtitle"],
Cell[50204, 1564, 1599, 46, 304, "Text"],
Cell[51806, 1612, 540, 16, 70, "Text"],
Cell[52349, 1630, 748, 15, 265, "Input"],
Cell[53100, 1647, 150, 2, 41, "Text"],
Cell[53253, 1651, 106, 2, 41, "Text"],
Cell[CellGroupData[{
Cell[53384, 1657, 34, 0, 65, "Subsection"],
Cell[53421, 1659, 282, 7, 70, "Text"],
Cell[53706, 1668, 1142, 36, 184, "Text"],
Cell[54851, 1706, 311, 8, 70, "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell[55199, 1719, 34, 0, 65, "Subsection"],
Cell[55236, 1721, 1920, 45, 388, "Text"],
Cell[57159, 1768, 832, 25, 99, "Text"],
Cell[57994, 1795, 765, 19, 162, "Text"],
Cell[58762, 1816, 212, 7, 71, "Text"],
Cell[58977, 1825, 45, 1, 46, "Input"],
Cell[59025, 1828, 47, 1, 46, "Input"],
Cell[59075, 1831, 306, 10, 54, "Text"],
Cell[59384, 1843, 89, 1, 72, "Input"],
Cell[59476, 1846, 924, 24, 191, "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell[60437, 1875, 34, 0, 65, "Subsection"],
Cell[60474, 1877, 917, 28, 99, "Text"],
Cell[61394, 1907, 173, 3, 80, "Input"],
Cell[61570, 1912, 106, 2, 41, "Text"]
}, Closed]]
}, Closed]],
Cell[CellGroupData[{
Cell[61725, 1920, 37, 0, 49, "Subtitle"],
Cell[61765, 1922, 1862, 49, 339, "Text"],
Cell[CellGroupData[{
Cell[63652, 1975, 57, 0, 65, "Subsection"],
Cell[63712, 1977, 2246, 69, 265, "Text"],
Cell[65961, 2048, 685, 20, 100, "Text"],
Cell[66649, 2070, 366, 7, 182, "Input"],
Cell[67018, 2079, 106, 2, 41, "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell[67161, 2086, 53, 0, 65, "Subsection"],
Cell[67217, 2088, 6418, 223, 468, "Text"],
Cell[73638, 2313, 201, 3, 80, "Input"],
Cell[73842, 2318, 125, 2, 41, "Text"],
Cell[73970, 2322, 1789, 55, 141, "Text"],
Cell[75762, 2379, 2616, 73, 257, "Text"],
Cell[78381, 2454, 106, 2, 41, "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell[78524, 2461, 55, 0, 65, "Subsection"],
Cell[78582, 2463, 1194, 30, 240, "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell[79813, 2498, 64, 0, 65, "Subsection"],
Cell[79880, 2500, 779, 22, 95, "Text"],
Cell[80662, 2524, 2949, 93, 227, "Text"],
Cell[83614, 2619, 216, 4, 137, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[83867, 2628, 55, 0, 65, "Subsection"],
Cell[83925, 2630, 1973, 56, 280, "Text"],
Cell[85901, 2688, 1037, 34, 96, "Text"],
Cell[86941, 2724, 106, 2, 41, "Text"]
}, Closed]]
}, Closed]],
Cell[CellGroupData[{
Cell[87096, 2732, 30, 0, 49, "Subtitle"],
Cell[87129, 2734, 1871, 56, 223, "Text"],
Cell[89003, 2792, 55, 1, 46, "Input"],
Cell[89061, 2795, 45, 1, 46, "Input"],
Cell[89109, 2798, 643, 22, 42, "Text"],
Cell[89755, 2822, 245, 5, 114, "Input"],
Cell[90003, 2829, 563, 12, 128, "Text"],
Cell[CellGroupData[{
Cell[90591, 2845, 34, 0, 65, "Subsection"],
Cell[90628, 2847, 956, 27, 109, "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell[91621, 2879, 34, 0, 65, "Subsection"],
Cell[91658, 2881, 519, 14, 70, "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell[92214, 2900, 34, 0, 65, "Subsection"],
Cell[92251, 2902, 196, 2, 70, "Text"]
}, Closed]]
}, Closed]],
Cell[CellGroupData[{
Cell[92496, 2910, 48, 0, 49, "Subtitle"],
Cell[92547, 2912, 2266, 53, 319, "Text"],
Cell[94816, 2967, 758, 20, 99, "Text"],
Cell[95577, 2989, 180, 2, 41, "Text"],
Cell[95760, 2993, 108, 2, 80, "Input"],
Cell[95871, 2997, 105, 5, 41, "Text"],
Cell[95979, 3004, 105, 2, 52, "Input"],
Cell[96087, 3008, 173, 5, 41, "Text"],
Cell[96263, 3015, 211, 5, 130, "Input"],
Cell[96477, 3022, 102, 2, 46, "Input"],
Cell[96582, 3026, 404, 13, 42, "Text"],
Cell[96989, 3041, 155, 3, 80, "Input"],
Cell[CellGroupData[{
Cell[97169, 3048, 34, 0, 65, "Subsection"],
Cell[97206, 3050, 3460, 84, 622, "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell[100703, 3139, 34, 0, 65, "Subsection"],
Cell[100740, 3141, 1682, 38, 287, "Text"]
}, Closed]],
Cell[CellGroupData[{
Cell[102459, 3184, 34, 0, 65, "Subsection"],
Cell[102496, 3186, 230, 3, 70, "Text"],
Cell[102729, 3191, 106, 2, 41, "Text"]
}, Closed]]
}, Closed]],
Cell[CellGroupData[{
Cell[102884, 3199, 45, 0, 49, "Subtitle"],
Cell[102932, 3201, 1485, 45, 156, "Text"],
Cell[104420, 3248, 221, 4, 114, "Input"],
Cell[104644, 3254, 145, 2, 80, "Input"],
Cell[104792, 3258, 1057, 33, 154, "Text"],
Cell[CellGroupData[{
Cell[105874, 3295, 34, 0, 65, "Subsection"],
Cell[105911, 3297, 3796, 110, 228, "Text"],
Cell[109710, 3409, 106, 2, 41, "Text"]
}, Closed]]
}, Closed]],
Cell[CellGroupData[{
Cell[109865, 3417, 54, 0, 49, "Subtitle"],
Cell[109922, 3419, 1005, 28, 164, "Text"],
Cell[110930, 3449, 811, 20, 192, "Text"],
Cell[111744, 3471, 337, 5, 151, "Input"],
Cell[112084, 3478, 780, 21, 235, "Text"],
Cell[112867, 3501, 120, 3, 46, "Input"],
Cell[112990, 3506, 175, 5, 42, "Text"],
Cell[113168, 3513, 185, 2, 41, "Text"],
Cell[113356, 3517, 122, 2, 46, "Input"],
Cell[113481, 3521, 91, 2, 41, "Text"],
Cell[113575, 3525, 257, 4, 114, "Input"],
Cell[113835, 3531, 106, 2, 41, "Text"]
}, Closed]]
}, Closed]]
}
]
*)
(*******************************************************************
End of Mathematica Notebook file.
*******************************************************************)