(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 4.2' Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. *******************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 15311, 522]*) (*NotebookOutlinePosition[ 15947, 544]*) (* CellTagsIndexPosition[ 15903, 540]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["\<\ Although Mathematica is a powerful programming language that can model system \ dynamics once you know the syntax and have a good knowledge of Mathematica \ functions, on a more basic level the software is an excellent graphing \ calculator. In other words, Mathematica is only as complicated as the \ calculations you want to evaluate or the programs you want to write. Let's \ get started!! \ \>", "Subsubtitle"], Cell[CellGroupData[{ Cell["Numbers and General Stuff To Know", "Section"], Cell[CellGroupData[{ Cell["\<\ To evaluate a line of code or a command, simply click within that cell and \ press SHIFT+ENTER..This should create a line of output in most cases. Try \ evaluating this line:\ \>", "Subsection"], Cell[BoxData[ \(3 + 5 \((8)\)\)], "Input"] }, Open ]], Cell["\<\ If for some reason you would like to cut/copy and then paste the previous \ input,3+5(8), to another part of your document simply cut and paste like you \ would in WORD. However, you must wait for the cursor to be horizontal...then \ click and paste (this will create a new cell in which you can paste and/or \ type input). Try to copy and paste the line of code in the previous cell \ into a new cell below.\ \>", "Subsection"], Cell[CellGroupData[{ Cell["\<\ This document is called a notebook because there is text and inputto be \ calculated. To vary the Format of the text, select the blue bracket around \ the cell of text you would like to change by clicking on the blue bracket. \ Then select Format from the Menu, and then under Style there are various \ options. Try changing the format of the following text:\ \>", "Subsection"], Cell[BoxData[ \(Change\ the\ format\ of\ the\ text\ in\ this\ \(\(cell\)\(.\)\)\)], \ "Input"] }, Open ]], Cell["\<\ There are probably going to points in working with Mathematica that you will \ want to save your work. Just like Word, select Save (or Save As)from the \ File menu and give the file a descriptive name.\ \>", "Subsection"], Cell["\<\ To look up a function and its properties, type a ? before the name of the \ function. Use * as a wildcard. Try \"?Table\", \"?*Table\", and \"?Table*\" \ and compare output.\ \>", "Subsection"], Cell["\<\ Another note before we move on...when you open a saved Notebook (or file), if \ you would like to use previous calculations in that file to continue your \ work, you must re-evaluate each cell. The file sort of \"forgets\" what it \ previously computed even though the output lines are still there. Also, each \ time you change an aspect of the input, you must re-evaluate in order to get \ the new output. The output doesn't immediately change as it would in \ Excel.\ \>", "Subsection"] }, Open ]], Cell[CellGroupData[{ Cell["Calculations", "Section"], Cell["\<\ Now let's work with some calculations. Choose the Basic Input pallette from \ Pallettes under the File menu. These tools will help us type in some of the \ input. Notice that there are other pallettes which are more specialized and \ may be of more use to you as you gain proficiency with Mathematica and thus \ choose to evaluate more complicated calculations.\ \>", "Subsection"], Cell["\<\ Find the sum of 1/4 and 1/6. You can write fractions as I did, or you can \ use the pallete. Mathematica gives the most accurate answer it can (in this \ case, not a decimal). If you wanted a decimal answer, add \"//N\" to the end \ of your expression. \ \>", "Subsection"], Cell[CellGroupData[{ Cell["\<\ \"E\" is little e (2.71...) and Log[3] takes the NATURAL log of 3. Notice \ that most Mathematica functions begin in a capital letter (later we will want \ to name our variables in lowercase so that the names don't conflict with \ pre-existing function names). Evaluate:\ \>", "Subsection"], Cell[BoxData[ \(E^1\)], "Input"], Cell[BoxData[ \(Log[4]\)], "Input"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Graphing Functions", "Section"], Cell[CellGroupData[{ Cell["\<\ Graphing functions is a good application for Mathematica. In the following \ steps we will graph a function, x^2+1.\ \>", "Subsection"], Cell["\<\ STEP 1: Clear the function (let's define the function using f[x])\ \>", "Text"], Cell["\<\ STEP 2: Define the function. Don't forget the underscore or the colon!\ \>", "Text"], Cell["\<\ STEP 3: Evaluate the function at 7. Be sure to use square brackets. Symbols \ can also be evaluated...try evaluating \"3z\" as well.\ \>", "Text"], Cell["\<\ STEP 4: For practice, repeat these steps for the function p(t)=100e^0.1t \ (start by clearing p, not f).\ \>", "Text"], Cell["\<\ STEP 5: Use the plot function. The following is how you would plot f[x]. \ \>", "Text"], Cell[BoxData[ \(Plot[f[x], {x, \(-2\), 2}, PlotRange \[Rule] {0, 4}, AspectRatio \[Rule] 1, AxesLabel \[Rule] {"\", "\"}]\)], "Input"], Cell["\<\ Play around with the numbers and other variables and you will discover the \ function of each of the commands within Plot.For example,PlotRange sets the \ range (or y coordinates),the numbers in the first line set the domain over \ which the function is graphed.The AspectRatio changes the proportions of the \ axes,and AxesLabel labels the axes.Now try to plot p[t].You can retype the \ function after Plot or use the symbols p[t].\ \>", "Text"], Cell["\<\ You can plot both functions on the same graph, and give each function its own \ color. Here's how you would do that:\ \>", "Text"], Cell[BoxData[ \(Plot[{f[x], p[x]}, {x, \(-3\), 3}, \[IndentingNewLine]PlotStyle \[Rule] {RGBColor[1, 0, 0], RGBColor[0, 0, 1]}]\)], "Input"], Cell["\<\ The commands are pretty straight-forward, the syntax can be tedious however. \ RGBColor indicates the amount of red, green, and blue. The values for these \ colors are floating point numbers between 0 and 1. f[x] should be red and \ p[t] should be blue. Now define h[x] and add another function to the graph \ making it green.\ \>", "Text"], Cell["\<\ Colors are not the only way you can differentiate among graphed functions. \ Copy the previous code and change the function RGBColor to Thickness. Inside \ the square brackets put a decimal number (this number is a fraction of the \ graph's size)..0.05 is very thick. Evaluate again and observe the output.\ \>", "Text"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Fitting Data", "Section"], Cell[CellGroupData[{ Cell["\<\ Now let's pretend that we have a set of data to which you would like to fit a \ line (or other type of function). We will want to define a list which \ contains the data, plot that data,and then fit the line.\ \>", "Subsection"], Cell[CellGroupData[{ Cell["STEP 1: Define a list.", "Subsubsection"], Cell[BoxData[ \(\(t = {{\(-3\), 2}, {2, 2}, {\(-1\), \(-1\)}, {4, 3}, {0, 0}};\)\)], "Input"], Cell["\<\ The semicolon suspends the output from displaying. Remove the semicolon and \ evaluate, then compare the results.\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["\<\ STEP 2: Plot your data. mydataplotted is the assigned name to the scatter \ plot. The following lines of code will give you a scatter plot. Play with \ the numbers and observe the changes.\ \>", "Subsubsection"], Cell[BoxData[ \(mydataplotted = ListPlot[t, \[IndentingNewLine]AxesLabel \[Rule] {"\", "\"}, \ \[IndentingNewLine]AspectRatio \[Rule] 1, \[IndentingNewLine]PlotRange \[Rule] {\(-5\), 5}]\)], "Input"], Cell["\<\ Now add this line of code to make the points magenta and bigger: PlotStyle\[Rule]{PointSize[0.03],RGBColor[1,0,1]},\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["\<\ STEP 3: Fit the data Using Fit, we can find the least-squares fit to a list of data,t, as a linear \ combination of x and 1. Thus the fit is a linear expression of the form \ ax+b. The following code accomplishes this fit:\ \>", "Subsubsection"], Cell[BoxData[ \(fitline = Fit[t, {x, 1}, x]\)], "Input"], Cell["To plot the equation of this line of best fit:", "Text"], Cell[BoxData[ \(plottedfitline = Plot[fitline, {x, \(-3\), 4}]\)], "Input"], Cell["\<\ Using the function Show, we can display the best fit line and the scatter \ plot of the data in the list on the same coordinate system.\ \>", "Text"], Cell[BoxData[ \(Show[mydataplotted, plottedfitline]\)], "Input"], Cell["\<\ To take this a step further: Fit t to a cubic ax^3+bx^2+cx+d by using the \ Fit command and four terms--x^3,x^2,x,and 1 in braces,{}.\ \>", "Text"], Cell[BoxData[ \(fitline2 = Fit[t, {x^3, x^2, x, 1}, x]\)], "Input"], Cell["This yields the equation of the line of best fit.", "Text"], Cell[BoxData[ \(plottedfitline2 = Plot[{fitline2}, {x, \(-10\), 10}]\)], "Input"], Cell["This plots the best fit equation and names that plot.", "Text"], Cell[BoxData[ \(Show[mydataplotted, plottedfitline2]\)], "Input"], Cell["\<\ This shows the scatter plot of data as well as the line of best fit. \ \>", "Text"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Check this out:", "Section"], Cell[BoxData[ \(3*5*8\)], "Input"], Cell[BoxData[ \(3\ 5\ 8\)], "Input"], Cell["\<\ Turns out you don't need to put the multiplaction signs in, just put spaces \ between the numbers and Mathematica will assume that you want to multiply.\ \>", "Text"], Cell[BoxData[ \(Round[4.5]\)], "Input"], Cell[BoxData[ \(Round[4.501]\)], "Input"], Cell["\<\ This function rounds to the closest integer to the number in brackets.\ \>", "Text"], Cell[BoxData[ \(FactorInteger[567]\)], "Input"], Cell["\<\ This function lists the prime factors of the number in brackets.\ \>", "Text"], Cell[BoxData[ \(Mod[11, 7]\)], "Input"], Cell["\<\ This function takes the first number modulo the second number (remainder on \ division of the first number by the second)\ \>", "Text"], Cell[BoxData[ \(Abs[\(-6\)]\)], "Input"], Cell["\<\ This function takes the absolute value of the number in brackets.\ \>", "Text"], Cell[BoxData[ \(\(25!\)\)], "Input"], Cell["\<\ Wow..Mathematica can do all sorts of stuff...even much more...\ \>", "Text"], Cell[BoxData[ \(Log[10, 7]\)], "Input"], Cell["\<\ This line takes the Log BASE10 of 7. The base is always the first number.\ \>", "Text"], Cell[BoxData[ \(Sqrt[4]\)], "Input"], Cell["\<\ This function takes the square root of the number in brackets.\ \>", "Text"], Cell[BoxData[ \(Sin[3 \[Pi] + 5] // N\)], "Input"], Cell["Wow..even geometric calculations are easily done!", "Text"], Cell[BoxData[ \(ArcTan[\[Pi]] // N\)], "Input"], Cell["For all of you \"arc\" enemies of Bush...", "Text"], Cell[BoxData[ \(%\)], "Input"], Cell["\<\ Typing the percent sign as the input generates the previous output, or the \ last result generated.\ \>", "Text"], Cell[BoxData[ \(%%%\)], "Input"], Cell["That gives me the third previous result.", "Text"], Cell["\<\ In case you startrunning a long calculation and you want to stop the program, \ use alt-comma or control-c (sometimes command-comma depending on your \ machine)\ \>", "Text"], Cell[BoxData[ \(xy + 2 x^2 y + y^2 x^2 - 2 y^2 x^2\)], "Input"], Cell["\<\ Mathematica can will simplify the latter expression (adding like terms), and \ it can expand the following expression by multiplying out products and \ powers, writing the result as a sum of terms.\ \>", "Text"], Cell[BoxData[ \(Expand[\((x + 2 y + 1)\) \((x - 2)\)^2]\)], "Input"], Cell["\<\ Mathematica can also factor algebraic expressions by writing the expression \ as a product of minimal factors:\ \>", "Text"], Cell[BoxData[ \(Factor[x^2 - 9]\)], "Input"], Cell["Now let's use the \"%\" in a clever way:", "Text"], Cell[BoxData[ \(Expand[%]\)], "Input"], Cell["\<\ Simplify is a function which finds the simplest form of the expression by \ applying various standard algebraic transformations...different than \ Factor.\ \>", "Text"], Cell[BoxData[ \(Simplify[x^2 + 2 x + 1]\)], "Input"], Cell["\<\ You can also take derivatives and integrals (definite or indefinite).\ \>", "Text"], Cell[BoxData[ \(D[x^2 - x + 1, x]\)], "Input"], Cell[BoxData[ \(Integrate[x^3, x]\)], "Input"], Cell[BoxData[ \(Integrate[x^3, {x, 0, 5}]\)], "Input"], Cell["\<\ Sum x^2 with respect to x with the min being 1 and the max being 5.\ \>", "Text"], Cell[BoxData[ \(Sum[x^2, {x, 1, 5}]\)], "Input"], Cell["We can take it to the limit...one more time.", "Text"], Cell[BoxData[ \(Limit[x^3 - x + 11, x \[Rule] 5]\)], "Input"], Cell[BoxData[ \(Limit[x^3 - x + 11, x \[Rule] 0]\)], "Input"], Cell[BoxData[ \(Limit[x^3 - x + 11, x \[Rule] \(-Infinity\)]\)], "Input"], Cell["\<\ You can find an approximate numerical solution using FindRoot, and giving a \ starting value for x.\ \>", "Text"], Cell[BoxData[ \(FindRoot[Cos[x] \[Equal] x, {x, 1}]\)], "Input"], Cell["If you're looking for a solution to simultaneous equations:", "Text"], Cell[BoxData[ \(Solve[{x^2 + y^2 \[Equal] 1, x + 3 y \[Equal] 0}, {x, y}]\)], "Input"], Cell["Here's a look at how you could do a 3D plot:", "Text"], Cell[BoxData[ \(Plot3D[Sin[x\ y], {x, 0, 3}, {y, 0, 3}]\)], "Input"], Cell[BoxData[ \(ParametricPlot3D[{Sin[t], Cos[t], t/3}, {t, 0, 15}]\)], "Input"], Cell[BoxData[ \(ParametricPlot3D[{Cos[t] \((3 + Cos[u])\), Sin[t] \((3 + Cos[u])\), Sin[u]}, {t, 0, 2 Pi}, {u, 0, 2 Pi}]\)], "Input"], Cell["", "Text"] }, Open ]] }, Open ]] }, FrontEndVersion->"4.2 for Macintosh", ScreenRectangle->{{0, 1280}, {0, 828}}, WindowSize->{1059, 740}, WindowMargins->{{0, Automatic}, {Automatic, 0}} ] (******************************************************************* 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[CellGroupData[{ Cell[1776, 53, 426, 8, 107, "Subsubtitle"], Cell[CellGroupData[{ Cell[2227, 65, 52, 0, 56, "Section"], Cell[CellGroupData[{ Cell[2304, 69, 205, 4, 64, "Subsection"], Cell[2512, 75, 46, 1, 27, "Input"] }, Open ]], Cell[2573, 79, 440, 7, 82, "Subsection"], Cell[CellGroupData[{ Cell[3038, 90, 391, 6, 82, "Subsection"], Cell[3432, 98, 98, 2, 27, "Input"] }, Open ]], Cell[3545, 103, 232, 4, 64, "Subsection"], Cell[3780, 109, 205, 4, 46, "Subsection"], Cell[3988, 115, 501, 8, 82, "Subsection"] }, Open ]], Cell[CellGroupData[{ Cell[4526, 128, 31, 0, 56, "Section"], Cell[4560, 130, 394, 6, 82, "Subsection"], Cell[4957, 138, 286, 5, 64, "Subsection"], Cell[CellGroupData[{ Cell[5268, 147, 302, 5, 64, "Subsection"], Cell[5573, 154, 36, 1, 27, "Input"], Cell[5612, 157, 39, 1, 27, "Input"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[5700, 164, 37, 0, 56, "Section"], Cell[CellGroupData[{ Cell[5762, 168, 146, 3, 46, "Subsection"], Cell[5911, 173, 90, 2, 32, "Text"], Cell[6004, 177, 96, 2, 32, "Text"], Cell[6103, 181, 158, 3, 32, "Text"], Cell[6264, 186, 129, 3, 32, "Text"], Cell[6396, 191, 98, 2, 32, "Text"], Cell[6497, 195, 153, 2, 27, "Input"], Cell[6653, 199, 456, 7, 68, "Text"], Cell[7112, 208, 141, 3, 32, "Text"], Cell[7256, 213, 164, 3, 43, "Input"], Cell[7423, 218, 354, 6, 50, "Text"], Cell[7780, 226, 333, 5, 50, "Text"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[8162, 237, 31, 0, 56, "Section"], Cell[CellGroupData[{ Cell[8218, 241, 239, 4, 64, "Subsection"], Cell[CellGroupData[{ Cell[8482, 249, 47, 0, 42, "Subsubsection"], Cell[8532, 251, 110, 2, 27, "Input"], Cell[8645, 255, 138, 3, 32, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[8820, 263, 224, 4, 42, "Subsubsection"], Cell[9047, 269, 229, 4, 75, "Input"], Cell[9279, 275, 145, 3, 50, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[9461, 283, 258, 5, 74, "Subsubsection"], Cell[9722, 290, 60, 1, 27, "Input"], Cell[9785, 293, 62, 0, 32, "Text"], Cell[9850, 295, 79, 1, 27, "Input"], Cell[9932, 298, 159, 3, 32, "Text"], Cell[10094, 303, 68, 1, 27, "Input"], Cell[10165, 306, 158, 3, 32, "Text"], Cell[10326, 311, 71, 1, 27, "Input"], Cell[10400, 314, 65, 0, 32, "Text"], Cell[10468, 316, 85, 1, 27, "Input"], Cell[10556, 319, 69, 0, 32, "Text"], Cell[10628, 321, 69, 1, 27, "Input"], Cell[10700, 324, 94, 2, 32, "Text"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[10855, 333, 34, 0, 56, "Section"], Cell[10892, 335, 38, 1, 27, "Input"], Cell[10933, 338, 40, 1, 27, "Input"], Cell[10976, 341, 176, 3, 32, "Text"], Cell[11155, 346, 43, 1, 27, "Input"], Cell[11201, 349, 45, 1, 27, "Input"], Cell[11249, 352, 94, 2, 32, "Text"], Cell[11346, 356, 51, 1, 27, "Input"], Cell[11400, 359, 88, 2, 32, "Text"], Cell[11491, 363, 43, 1, 27, "Input"], Cell[11537, 366, 145, 3, 32, "Text"], Cell[11685, 371, 44, 1, 27, "Input"], Cell[11732, 374, 89, 2, 32, "Text"], Cell[11824, 378, 40, 1, 27, "Input"], Cell[11867, 381, 86, 2, 33, "Text"], Cell[11956, 385, 43, 1, 30, "Input"], Cell[12002, 388, 98, 2, 33, "Text"], Cell[12103, 392, 40, 1, 30, "Input"], Cell[12146, 395, 86, 2, 33, "Text"], Cell[12235, 399, 55, 1, 30, "Input"], Cell[12293, 402, 65, 0, 33, "Text"], Cell[12361, 404, 51, 1, 30, "Input"], Cell[12415, 407, 57, 0, 33, "Text"], Cell[12475, 409, 34, 1, 30, "Input"], Cell[12512, 412, 123, 3, 33, "Text"], Cell[12638, 417, 36, 1, 30, "Input"], Cell[12677, 420, 56, 0, 33, "Text"], Cell[12736, 422, 184, 4, 52, "Text"], Cell[12923, 428, 72, 1, 30, "Input"], Cell[12998, 431, 221, 4, 52, "Text"], Cell[13222, 437, 73, 1, 30, "Input"], Cell[13298, 440, 134, 3, 33, "Text"], Cell[13435, 445, 48, 1, 30, "Input"], Cell[13486, 448, 56, 0, 33, "Text"], Cell[13545, 450, 42, 1, 30, "Input"], Cell[13590, 453, 178, 4, 33, "Text"], Cell[13771, 459, 57, 1, 30, "Input"], Cell[13831, 462, 93, 2, 33, "Text"], Cell[13927, 466, 50, 1, 30, "Input"], Cell[13980, 469, 50, 1, 30, "Input"], Cell[14033, 472, 58, 1, 30, "Input"], Cell[14094, 475, 91, 2, 33, "Text"], Cell[14188, 479, 52, 1, 30, "Input"], Cell[14243, 482, 60, 0, 33, "Text"], Cell[14306, 484, 65, 1, 30, "Input"], Cell[14374, 487, 65, 1, 30, "Input"], Cell[14442, 490, 77, 1, 30, "Input"], Cell[14522, 493, 123, 3, 33, "Text"], Cell[14648, 498, 68, 1, 30, "Input"], Cell[14719, 501, 75, 0, 33, "Text"], Cell[14797, 503, 91, 1, 30, "Input"], Cell[14891, 506, 60, 0, 33, "Text"], Cell[14954, 508, 72, 1, 30, "Input"], Cell[15029, 511, 84, 1, 30, "Input"], Cell[15116, 514, 148, 2, 30, "Input"], Cell[15267, 518, 16, 0, 33, "Text"] }, Open ]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)