(************** 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[ 13407, 457]*) (*NotebookOutlinePosition[ 14099, 481]*) (* CellTagsIndexPosition[ 14055, 477]*) (*WindowFrame->Normal*) Notebook[{ Cell["\<\ To open the sections, Doubleclick on the vertical bars with a \ little arrow at the bottom that are on the right side of the section \ titles.\ \>", "Text"], Cell[CellGroupData[{ Cell[TextData[StyleBox["Some Very Basic Mathematica Usage", FontFamily->"Bitstream charter"]], "Section"], Cell[CellGroupData[{ Cell["Shift-Enter. Shift-Enter. Have I told you about Shift-Enter?", \ "Subsection"], Cell[TextData[{ "The most important thing to know is how to evaluate a cell. When you've \ typed in some stuff you want ", StyleBox["Mathematica", FontSlant->"Italic"], " to do for you, hit Shift-Enter, or the Enter on the numeric keypad. Just \ regular \"enter\" won't do it. Whoever made this user interface decision is \ responsible for an enormous amount of profanity that has been directed at the \ computer screens of novice ", StyleBox["Mathematica", FontSlant->"Italic"], " users.\n\nThe first lab for the IT multivariable calculus course (2374) \ has a good introduction to ", StyleBox["Mathematica", FontSlant->"Italic"], ". You can get it from ", StyleBox["http://www.math.umn.edu/math2374/ ", FontFamily->"Courier"], ". Download Lab 1A. It's quite useful. If you're looking for stuff on doing \ calculus with ", StyleBox["Mathematica", FontSlant->"Italic"], ", you should definitely check out those labs. They have lots of stuff, and \ if you can figure out Jon's code, you can do quite a lot in ", StyleBox["Mathematica", FontSlant->"Italic"], ".\n\nAlso, this program is very narcississtic and italicizes its name \ automatically when you type it." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["\<\ Like capital letters and square brackets? You'll LOVE \ Mathematica.\ \>", "Subsection"], Cell["\<\ Functions and constants generally use capital letters and square \ brackets:\ \>", "Text"], Cell[BoxData[ \(Sin[Pi/E]\)], "Input"], Cell[BoxData[ \(PartitionsP[13]\)], "Input"], Cell[BoxData[ \(HermiteH[3, x]\)], "Input"], Cell["\<\ Lots of functions are of the form Function[ blah , {options}]. For \ instance:\ \>", "Text"], Cell[BoxData[ \(Integrate[Sin[x^2], \ {x, 0, Pi}]\)], "Input"], Cell[BoxData[ \(Sum[1/n, \ {n, 1, 5}]\)], "Input"], Cell[BoxData[ \(Product[\(\((3 j\ + 1)\)!\)/\(\((5 + j)\)!\), {j, 0, 4}]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Defining your own functions", "Subsection"], Cell["\<\ Everyone wants to define their own functions and variables. \ Variables are easy:\ \>", "Text"], Cell[BoxData[ \(a\ = \ 12\)], "Input"], Cell[BoxData[ \(b\ = \ x*y\)], "Input"], Cell[BoxData[ \(stegasaurus\ = \ Plot[x\ *\ Sin[x - 1], \ {x, 0, 1}]\)], "Input"], Cell[TextData[{ "As you see, you can use entire words for variables. ", StyleBox["Mathematica", FontSlant->"Italic"], " distinguishes between words-as-variables and letters put next to each \ other to mean \"multiplication\" with spaces. Sometimes spaces are hard to \ see, so it's best to use asterisks to eliminate confusion." }], "Text"], Cell[BoxData[ \(a\ b\)], "Input"], Cell[BoxData[ \(ab\)], "Input"], Cell["\<\ For functions, the key is to use underscores on the left-hand side \ of the function.For example,\ \>", "Text"], Cell[BoxData[ \(f[x_, \ y_, \ z_]\ = \ x\ + \ y\ + \ z\ + \ 2\)], "Input"], Cell[TextData[{ "On the left side,you use \"x_\" to signify one of the variables or \ parameters.On the right-hand side,just use that variable as normal. When you \ don't use an underscore, ", StyleBox["Mathematica", FontSlant->"Italic"], " assumes you're defining the function for a ", StyleBox["particular", FontSlant->"Italic"], " value. If the variable doesn't have a particular value, weird things \ happen." }], "Text"], Cell[BoxData[ \(NumASMs[n_]\ = \ Product[\(\((3 j\ + 1)\)!\)/\(\((n + j)\)!\), {j, 0, n - 1}]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Recursive functions", "Subsection"], Cell["\<\ The example that absolutely everybody uses every single time \ recursive functions are brought up. First, give it the initial \ conditions:\ \>", "Text"], Cell[BoxData[ \(f[1]\ = \ 1\)], "Input"], Cell["And now the general definition:", "Text"], Cell[BoxData[ \(f[n_]\ := \ n\ *\ f[n - 1]\)], "Input"], Cell["Okay, let's see if it works:", "Text"], Cell[BoxData[ \(f[5]\)], "Input"], Cell[TextData[{ "The := is key. It tells ", StyleBox["Mathematica", FontSlant->"Italic"], " to not try and evaluate the right-hand side until you actually ask for \ the left-hand side. When we actually ask for f[5], it keeps recursing until \ it hits f[1], which it knows equals 1.\n\nIf you're doing heavy-duty \ computations, you may want your recursive function to remember values it has \ computed. The way you tell ", StyleBox["Mathematica", FontSlant->"Italic"], " to do that is like so:" }], "Text"], Cell[BoxData[{ \(g[1]\ = \ 1\), "\[IndentingNewLine]", \(g[x_]\ := \ \(g[x]\ = \ x\ g[x - 1]\)\)}], "Input"], Cell[TextData[{ "Note that I did both those commands in one cell by hitting Enter after the \ first one, and only hitting Shift-Enter when I wanted the whole thing \ evaluated.\n\nWe can ask for a value and then use ? to see what ", StyleBox["Mathematica", FontSlant->"Italic"], " thinks of this function." }], "Text"], Cell[BoxData[ \(g[4]\)], "Input"], Cell[BoxData[ \(\(?g\)\)], "Input"], Cell["\<\ Let's do general orthogonal polynomials. We know they always \ satisfy a three-term recurrence, for suitable values of b and lambda:\ \>", \ "Text"], Cell[BoxData[{ \(p[\(-1\), x_]\ = \ 0\), "\[IndentingNewLine]", \(p[0, x_]\ = \ 1\), "\[IndentingNewLine]", \(p[n_, x_]\ := \ \(p[n, x]\ = \((x\ - \ b[n - 1])\)\ p[n - 1, x]\ - \ l[n - 1]\ p[n - 2, x]\)\)}], "Input"], Cell["\<\ As defined this way, we just need to define the b and l functions \ and we'll get a particular OPS. For instance, if b[n] = 0 and l[n-1] = n, you \ get Hermite polynomials.\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Other useful functions", "Subsection"], Cell["\<\ Factor, Expand, and Simplify do mostly what you expect. There's two \ ways to use them:\ \>", "Text"], Cell[BoxData[ \(Factor[x^2\ + \ 2\ xy\ + \ y^2]\)], "Input"], Cell[BoxData[ \(x^2\ + \ 2\ x\ y\ + \ y^2\ // Factor\)], "Input"], Cell["\<\ The \"//Command\" syntax means \"apply Command to all the stuff \ before //\". You can't use this for commands with more than one parameter. There's also FullSimplify. FullSimplify works much harder than Simplify and \ sometimes yields much better results. Sometimes not. Expand...expands an expression. Collect gathers up the powers of the variable \ you specify:\ \>", "Text"], Cell[BoxData[ \(JacobiP[3, a, b, x]\)], "Input"], Cell[BoxData[ \(Expand[JacobiP[3, a, b, x]]\)], "Input"], Cell[BoxData[ \(Collect[Expand[JacobiP[3, a, b, x]], a]\)], "Input"], Cell["\<\ Expanding functions in a series is great when you're working with \ generating functions. The syntax for the \"{x, 0, 6}\" is {variable, \ expand_about_this_point, degree}\ \>", "Text"], Cell[BoxData[ \(Series[\((1 - Sqrt[1 - 4\ x])\)/\((2 x)\), \ {x, 0, 6}]\)], "Input"], Cell["\<\ If the 'H' key on your keyboard doesn't work, you can find Hermite \ polynomials using the generating function. ere's te fift ermite polynomial:\ \ \>", "Text"], Cell[BoxData[ \(\(5!\)*Coefficient[Series[Exp[x\ t\ + \ t^2/2], \ {t, 0, 5}], t^5] // Expand\)], "Input"], Cell["\<\ The Coefficient command just picks out the specified coefficient -- \ t^5 in this case. If you're checking to see if your formula agrees with a known result, you can \ use Table to work out a bunch of cases. Say we have a formula for \ Hermite-polynomials-as-matchings, which we derived combinatorially:\ \>", \ "Text"], Cell[BoxData[ \(hermitehmatching[n_, x_]\ = Sum[Binomial[n, 2\ k]\ \(\((2 k - 1)\)!!\)\ x^\((n - 2 k)\), {k, 0, Floor[n/2]}]\)], "Input"], Cell["\<\ and we want to compare that with a specialization of the usual \ Hermites:\ \>", "Text"], Cell[BoxData[ \(hermitehmatching2[n_, x_]\ = \ 2^\((\(-n\)/2)\)\ HermiteH[n, x*Sqrt[\(-1\)/2]]* Which[FractionalPart[n/4] \[Equal] 0, 1, \[IndentingNewLine]FractionalPart[ n/4]\ \[Equal] .25, \(-Sqrt[\(-1\)]\), \ \[IndentingNewLine]FractionalPart[ n/4]\ \[Equal] \ .5, \ \(-1\), \ \[IndentingNewLine]FractionalPart[n/4]\ \[Equal] \ .75, Sqrt[\(-1\)]]\)], "Input"], Cell["\<\ We can divide one by the other, factor it, and see if we get one. \ Let's do the first ten to see if they match (ha!) up:\ \>", "Text"], Cell[BoxData[ \(Table[ hermitehmatching[n, x]/hermitehmatching2[n, x] // Factor, {n, 0, 10}]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Making notes to yourself", "Subsection"], Cell["\<\ Both Mathematica and Maple fancy themselves as complete math-aware \ word processors. They have this notebook idea going on, which when used \ properly is quite nice (look at some of the 2374 labs sometime). It's nice to \ make notes to yourself, which you can do with the Format menu: if you've got \ some text, go to Format -> Style -> Text and it turn it into text like this \ right here.\ \>", "Text"], Cell[BoxData[ \(Regular\ prose\ gets\ formatted\ funny\ when\ Mathematica\ thinks\ you' re\ typing\ some\ kind\ of\ \(\(formula\)\(.\)\)\)], "Input"], Cell["\<\ There's also collapsible sections and subsections, which aren't too \ hard to figure out.\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell[TextData[{ "Jane, stop this crazy thing (dealing with the ", StyleBox["Mathematica", FontSlant->"Italic"], " kernel)" }], "Subsection"], Cell[TextData[{ "If you've been working for a while and want to start over, you can reset \ ", StyleBox["Mathematica", FontSlant->"Italic"], " without quitting. Go to Kernel -> Quit Kernel -> Local. It will ask if \ you really want to do that. Hit yes if you want all your definitions and \ variables to be forgotten.\n\nYou can clear the value of a particular \ variable or function with Clear:" }], "Text"], Cell[BoxData[ \(a\ = \ 5\)], "Input"], Cell[BoxData[ \(a\)], "Input"], Cell[BoxData[ \(Clear[a]\)], "Input"], Cell[BoxData[ \(a\)], "Input"], Cell[TextData[{ "If you evaluated a cell and it's taking too long, you can stop ", StyleBox["Mathematica", FontSlant->"Italic"], " by going to Kernel -> Abort Evaluation.\n\nFinally, if you want to clear \ out all the gobbledygook that has been output to the screen, use Kernel -> \ Delete All Output. It only removes output; variable definitions are \ remembered. This is useful when emailing files, since it reduces the size of \ the notebook.\n\nCongratulations if you recognized the Jetsons reference of \ the title." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Getting help", "Subsection"], Cell[TextData[{ "The help browser is fairly nice. Go to Help -> Help Browser and you'll get \ a window with a search box. Type in what you're looking for and it will look \ up things in its database. Together with Google, it's not too difficult to \ figure things out in ", StyleBox["Mathematica", FontSlant->"Italic"], ".\n\nNow let's switch to Maple and see what happens when Canadians are \ running the show" }], "Text"], Cell["\<\ Dan Drake drake@math.umn.edu\ \>", "Text", TextAlignment->Right] }, Closed]] }, Open ]] }, FrontEndVersion->"5.0 for X", ScreenRectangle->{{0, 1280}, {0, 1024}}, ScreenStyleEnvironment->"Working", WindowSize->{715, 839}, WindowMargins->{{108, Automatic}, {0, Automatic}}, CellLabelAutoDelete->True ] (******************************************************************* Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. *******************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[1754, 51, 166, 4, 50, "Text"], Cell[CellGroupData[{ Cell[1945, 59, 107, 1, 74, "Section"], Cell[CellGroupData[{ Cell[2077, 64, 84, 1, 38, "Subsection"], Cell[2164, 67, 1225, 28, 212, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[3426, 100, 98, 3, 30, "Subsection"], Cell[3527, 105, 100, 3, 32, "Text"], Cell[3630, 110, 42, 1, 27, "Input"], Cell[3675, 113, 48, 1, 27, "Input"], Cell[3726, 116, 47, 1, 27, "Input"], Cell[3776, 119, 102, 3, 32, "Text"], Cell[3881, 124, 66, 1, 27, "Input"], Cell[3950, 127, 54, 1, 27, "Input"], Cell[4007, 130, 91, 1, 27, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[4135, 136, 49, 0, 30, "Subsection"], Cell[4187, 138, 105, 3, 32, "Text"], Cell[4295, 143, 43, 1, 27, "Input"], Cell[4341, 146, 44, 1, 27, "Input"], Cell[4388, 149, 86, 1, 27, "Input"], Cell[4477, 152, 350, 7, 68, "Text"], Cell[4830, 161, 37, 1, 27, "Input"], Cell[4870, 164, 35, 1, 27, "Input"], Cell[4908, 167, 121, 3, 32, "Text"], Cell[5032, 172, 82, 1, 27, "Input"], Cell[5117, 175, 443, 11, 68, "Text"], Cell[5563, 188, 131, 3, 27, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[5731, 196, 41, 0, 30, "Subsection"], Cell[5775, 198, 163, 4, 50, "Text"], Cell[5941, 204, 45, 1, 27, "Input"], Cell[5989, 207, 47, 0, 32, "Text"], Cell[6039, 209, 60, 1, 27, "Input"], Cell[6102, 212, 44, 0, 32, "Text"], Cell[6149, 214, 37, 1, 27, "Input"], Cell[6189, 217, 526, 12, 104, "Text"], Cell[6718, 231, 120, 2, 43, "Input"], Cell[6841, 235, 328, 7, 86, "Text"], Cell[7172, 244, 37, 1, 27, "Input"], Cell[7212, 247, 39, 1, 27, "Input"], Cell[7254, 250, 158, 4, 50, "Text"], Cell[7415, 256, 256, 5, 59, "Input"], Cell[7674, 263, 196, 4, 50, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[7907, 272, 44, 0, 30, "Subsection"], Cell[7954, 274, 111, 3, 32, "Text"], Cell[8068, 279, 66, 1, 27, "Input"], Cell[8137, 282, 72, 1, 27, "Input"], Cell[8212, 285, 390, 9, 140, "Text"], Cell[8605, 296, 52, 1, 27, "Input"], Cell[8660, 299, 60, 1, 27, "Input"], Cell[8723, 302, 72, 1, 27, "Input"], Cell[8798, 305, 197, 4, 50, "Text"], Cell[8998, 311, 89, 1, 27, "Input"], Cell[9090, 314, 170, 4, 50, "Text"], Cell[9263, 320, 117, 2, 27, "Input"], Cell[9383, 324, 330, 8, 86, "Text"], Cell[9716, 334, 162, 3, 43, "Input"], Cell[9881, 339, 98, 3, 32, "Text"], Cell[9982, 344, 439, 9, 107, "Input"], Cell[10424, 355, 145, 3, 32, "Text"], Cell[10572, 360, 124, 3, 27, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[10733, 368, 46, 0, 30, "Subsection"], Cell[10782, 370, 415, 7, 86, "Text"], Cell[11200, 379, 160, 2, 43, "Input"], Cell[11363, 383, 113, 3, 32, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[11513, 391, 150, 5, 30, "Subsection"], Cell[11666, 398, 418, 9, 104, "Text"], Cell[12087, 409, 42, 1, 27, "Input"], Cell[12132, 412, 34, 1, 27, "Input"], Cell[12169, 415, 41, 1, 27, "Input"], Cell[12213, 418, 34, 1, 27, "Input"], Cell[12250, 421, 543, 10, 140, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[12830, 436, 34, 0, 30, "Subsection"], Cell[12867, 438, 433, 9, 104, "Text"], Cell[13303, 449, 76, 4, 50, "Text"] }, Closed]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)