(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 4.0, MathReader 4.0, or any compatible application. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. ***********************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 38382, 1119]*) (*NotebookOutlinePosition[ 39379, 1153]*) (* CellTagsIndexPosition[ 39335, 1149]*) (*WindowFrame->Normal*) Notebook[{ Cell[TextData[{ "Introduction to ", StyleBox["Mathematica", FontSlant->"Italic"], "\nBasic Concepts II" }], "Title", Evaluatable->False, CellHorizontalScrolling->False, TextAlignment->Center, FontFamily->"Times New Roman", FontSize->24, FontWeight->"Bold", FontColor->GrayLevel[0], Background->RGBColor[0, 0.501961, 1]], Cell[TextData[{ "\tBy now you have completed the Introduction to ", StyleBox["Mathematica", FontSlant->"Italic"], ", Basic Concepts I and should understand some of the basic constructs and \ manipulations of ", StyleBox["Mathematica", FontSlant->"Italic"], ". In this ", StyleBox["Mathematica", FontSlant->"Italic"], " notebook, we'll extend your understanding with some more basic concepts. \ Specifically, we'll learn about built-in ", StyleBox["Mathematica", FontSlant->"Italic"], " functions, the extensive ", StyleBox["Mathematica", FontSlant->"Italic"], " Help System, doing some elementary calculus with ", StyleBox["Mathematica", FontSlant->"Italic"], ", and some more of the ", StyleBox["Mathematica", FontSlant->"Italic"], " syntax to include some neat input tricks. You can anticipate that \ completing this notebook with take you about one hour.\n\tLet's jump right \ in. Open each of the cell groups below in turn and work on through them." }], "Text", Evaluatable->False], Cell[CellGroupData[{ Cell["Built-In Functions...", "Section", Evaluatable->False], Cell[TextData[{ "\t", StyleBox["Mathematica", FontSlant->"Italic"], " has a wide variety of built-in functions for simple things like computing \ sines and cosines to very complex tasks like solving differential equations \ and computing Fourier and Laplace transforms. The good news is that they all \ follow the same rules in terms of how we use them." }], "Text", Evaluatable->False], Cell[TextData[{ "The basic rules for using functions in ", StyleBox["Mathematica", FontSlant->"Italic"], " are:\n1) They are case-sensitive and always start with a capital letter \ (and sometimes have capital letters elsewhere usually to denote multiple \ words in the command, like 'LaplaceTransform').\n2) The arguments to the \ function are always enclosed in square brackets ('[-]') like we saw in Basic \ Concepts I.\n3) There are some arguments that must be specified and others \ that are optional parameters which are specified as ", StyleBox["ParameterName->Value", FontSlant->"Italic"], ".\n4) Arguments may be just a single expression or value, or they can be \ a list of expressions or values. Lists are always enclosed by {,}." }], "Text", Evaluatable->False], Cell["\<\ OK, so far so good. Let's look at some examples. Execute each of the input cells below: \ \>", "Text"], Cell[TextData[{ "This one shows a simple evaluation of the sine function at ", Cell[BoxData[ \(TraditionalForm\`\[Pi]\/2\)]], ". ", StyleBox["Remember if you fail to provide the Sine function with an \ argument it's a \"Sin\". Sorry, just some lame math humor.", FontSlant->"Italic"] }], "Text"], Cell[BoxData[ \(Sin[Pi/2]\)], "Input"], Cell["\<\ That was simple. Let's try one with two parameters. Notice that the second parameter is a list that tells us what the independent variable is and gives an interval for that variable on the plot. \ \>", "Text"], Cell[BoxData[ \(Plot[x^2, {x, \(-1\), 1}]\)], "Input"], Cell["\<\ All right! I love pictures. But I like to make them fancy and parameters are the way to do that. Here's another version of our plot command: \ \>", "Text"], Cell[BoxData[ \(Plot[x^2, {x, \(-1\), 1}, Frame -> True, PlotLabel -> "\", GridLines -> Automatic]\)], "Input"], Cell[TextData[{ "Well that was neat, but how do we know what's needed with each \ function/command or what the optional parameters are or even what functions \ and commands are available for that matter?\nWell, I'm glad you asked because \ the next section of this notebook describes the extensive Help System \ provided in ", StyleBox["Mathematica", FontSlant->"Italic"], " and provides us answers to all those questions and more..." }], "Text"], Cell["But, first I have a couple of tasks for you.", "Text", Evaluatable->False], Cell[TextData[StyleBox["Exercise: Plot the cosine function from -\[Pi] to \ \[Pi]. You don't have to get fancy, but you can if you want.", FontWeight->"Bold"]], "Text", Evaluatable->False, Background->RGBColor[0, 1, 1]], Cell[BoxData[""], "Input"], Cell[TextData[StyleBox["Exercise: The commands below aren't working for me. \ Can you help me fix them?", FontWeight->"Bold"]], "Text", Evaluatable->False, Background->RGBColor[0, 1, 1]], Cell[CellGroupData[{ Cell[BoxData[ \(Cos \((Pi)\)\)], "Input"], Cell[BoxData[ \(Cos\ \[Pi]\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Log[e]\)], "Input"], Cell[BoxData[ \(Log[e]\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(tan[0]\)], "Input"], Cell[BoxData[ \(General::"spell1" \(\(:\)\(\ \)\) "Possible spelling error: new symbol name \"\!\(tan\)\" is similar to \ existing symbol \"\!\(Tan\)\"."\)], "Message"], Cell[BoxData[ \(tan[0]\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Plot[x^3]\)], "Input"], Cell[BoxData[ \(Plot::"argmu" \(\(:\)\(\ \)\) "\!\(Plot\) called with 1 argument; \!\(2\) or more arguments are \ expected."\)], "Message"], Cell[BoxData[ \(Plot[x\^3]\)], "Output"] }, Open ]], Cell[TextData[{ "Great, thanks! Let's quickly recap those rules for using functions and \ then get onto that Help System.\nThe basic rules for using functions in ", StyleBox["Mathematica", FontSlant->"Italic"], " are:\n1) They are case-sensitive and always start with a capital letter \ (and sometimes have capital letters elsewhere usually to denote multiple \ words in the command, like LaplaceTransform).\n2) The arguments to the \ function are always enclosed in square brackets (like we saw in Basic \ Concepts I).\n3) There are some arguments that must be specified and others \ that are optional parameters which are specified as ", StyleBox["ParameterName->Value", FontSlant->"Italic"], ".\n4) Arguments may be just a single expression or value, or they can be \ a list of expressions or values. Lists are always enclosed by {,}." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell[TextData[{ StyleBox["Mathematica", FontSlant->"Italic"], "'s Help System (A Road Map to Success!)" }], "Section", Evaluatable->False], Cell[TextData[{ "\t", StyleBox["Mathematica", FontSlant->"Italic"], " has so much to offer that it's impossible for any \"normal\" human to \ know it all. That's why Wolfram Research (", StyleBox["Mathematica", FontSlant->"Italic"], "'s makers) provided a very extensive Help System. There's really two \ parts to it. \nThe first is a simple, immediately available help mechanism \ to give details on a specific command. To use it, simply type a question \ mark followed by the command into an input cell and execute it. For example, \ let's try getting some information on that Plot command." }], "Text", Evaluatable->False], Cell[BoxData[ \(\(?Plot\)\)], "Input"], Cell["\<\ Great, but I really thought it was neat to customize the plot with those nifty parameters. How do I get more information? Thanks for asking. All you need to do is put two question marks before the command and execute it. Try the cell below: \ \>", "Text"], Cell["??Plot", "Input", PageWidth->Infinity], Cell["\<\ Slick, but what if I don't know the name of the command? Good question! You can also just type in a question mark and some starting characters followed by a '*' to get a list of available commands. See the example below: \ \>", "Text"], Cell[BoxData[ \(\(?Plot*\)\)], "Input"], Cell[TextData[{ StyleBox["Exercise: Use the question mark help mechanism to find out some \ information about how to integrate with ", FontWeight->"Bold"], StyleBox["Mathematica", FontWeight->"Bold", FontSlant->"Italic"], StyleBox[".", FontWeight->"Bold"] }], "Text", Evaluatable->False, Background->RGBColor[0, 1, 1]], Cell[BoxData[""], "Input"], Cell[TextData[{ "Hmmm... That was easy... But what if I want more details and examples or \ if I just can't seem to find what I'm looking for?\nThat's where we bring in \ the \"Big Guns\"! Go on up to the Main Toolbar and select Help|Help... The \ form you see is your gateway to the full realm of ", StyleBox["Mathematica", FontSlant->"Italic"], "'s capabilities. \nFirst, you'll notice that there's a box to type in a \ topic/keyword and a Goto button to get help on that topic. Before you try \ that, notice that there are six push buttons to select from right below that. \ These specify where you want to look for help. Wow, it looks like the \ entire ", StyleBox["Mathematica", FontSlant->"Italic"], " reference book is in here (and you're right, it is)!\nPerhaps the easiest \ way to find a topic is to select the Master Index radio button and then \ start searching for your topic. As you do so, you'll notice that ", StyleBox["Mathematica", FontSlant->"Italic"], " automatically moves you through the available topics.\nOnce you click on \ the Goto button, you get some initial information and usually some links \ (underlined blue text) to other related information. This makes it pretty \ easy to find just about everything that's available on the topic." }], "Text"], Cell[TextData[StyleBox["Exercise: Use the Master Index to find out how to \ calculate 'derivatives' with Mathematica.", FontWeight->"Bold"]], "Text", Evaluatable->False, Background->RGBColor[0, 1, 1]], Cell[TextData[StyleBox["Exercise: Play around with the Help System a bit and \ look up some of your \"favorite\" topics.", FontWeight->"Bold"]], "Text", Evaluatable->False, Background->RGBColor[0, 1, 1]], Cell[TextData[{ StyleBox["Exercise: Use the ", FontWeight->"Bold"], StyleBox["Mathematica", FontWeight->"Bold", FontSlant->"Italic"], StyleBox[" Help System to go to section 2.4.8 in the ", FontWeight->"Bold"], StyleBox["Mathematica", FontWeight->"Bold", FontSlant->"Italic"], StyleBox[" Book and learn about the differences between using '=' and ':=' \ for making function definitions. This is a subtle difference but it can \ have significant consequences as you get further along in using ", FontWeight->"Bold"], StyleBox["Mathematica", FontWeight->"Bold", FontSlant->"Italic"], StyleBox[".", FontWeight->"Bold"] }], "Text", Evaluatable->False, Background->RGBColor[0, 1, 1]], Cell["\<\ Well that was helpful. It might take a little while to get used to using this Help System because it is so extensive, but it will be time well spent. There is one other handy help feature to let you know about. If you are typing in a command and having some trouble getting it to work, you can place \ your cursor anywhere within the command and hit the F1 key. This will take you into the Help System to a reference for that command. Let's switch gears now and explore some commands that will help us with elementary calculus. \ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Some Basic Calculus...", "Section"], Cell["\<\ Let's learn how to do some basic calculus with Mathematica before we go on to \ some more syntax rules. \ \>", "Text"], Cell[TextData[{ "First we'll use ", StyleBox["Mathematica", FontSlant->"Italic"], " to compute some limits. Cleverly enough the command we'll use is \"Limit \ \". Execute the command in the input cell below to learn a bit more about \ this command." }], "Text"], Cell[BoxData[ \(?? Limit\)], "Input"], Cell["\<\ Now for some examples. Keeping things simple for starts, we'll evaluate the limit of 7x-5 as x goes to 2 by executing the input cell below. \ \>", "Text"], Cell[BoxData[ \(Limit[7 x - 5, x -> 2]\)], "Input"], Cell[TextData[{ "You may have noticed from the description of the Limit command that you \ can also specify a 'Direction' for computing one-sided limits. To see how \ this works, look up 'Direction' in the Master Index of the ", StyleBox["Mathematica", FontSlant->"Italic"], " Help System." }], "Text"], Cell[TextData[StyleBox["Exercise: Calculate the left and right-hand limits \ of 1/x as x goes to zero.", FontWeight->"Bold"]], "Text", Evaluatable->False, Background->RGBColor[0, 1, 1]], Cell[BoxData[""], "Input"], Cell[TextData[{ "Here's an example of how you might define a function and then use ", StyleBox["Mathematica", FontSlant->"Italic"], " to plot it and find its limits. Execute the input cell below to see how \ things work. Notice how ", StyleBox["Mathematica", FontSlant->"Italic"], " handles the limit as x goes to zero which does not exist for this \ function. On the second limit, notice that I typed in the 'Infinity' limit. \ Alternatively, I could have used the symbol for infinity (\[Infinity]) from \ the BasicInput palette." }], "Text"], Cell[BoxData[{ \(Clear[g, x]\), "\n", \(g[x_] = Sin[1/x]\), "\n", \(Plot[g[x], {x, \(-4\), 4}]\), "\n", \(Limit[g[x], x -> 0]\), "\n", \(Limit[g[x], x -> Infinity]\)}], "Input"], Cell[BoxData[ \(TextForm\`Next\ let' s\ compute\ some\ derivatives . \ \ Actually\ Mathematica\ allows\ \ many\ ways\ to\ do\ this . \ \ We' ll\ use\ the\ function\ f \((x)\) = x\^5\ \ and\ show\ the\ three\ most\ common\ methods\ for\ calculating\ \ derivatives . \ \ The\ first\ is\ the\ D[]\ command\ which\ has\ two\ \ arguments; \ the\ function\ and\ the\ variable\ to\ differentiate\ with\ respect\ to . \ \ \ The\ \ second\ is\ the\ common\ prime\ \((')\)\ notation\ which\ works\ \ very\ easily\ for\ functions\ of\ a\ single\ variable . \ \ Finally, \ there' s\ a\ fancier\ method\ that\ uses\ the\ \ \[PartialD]\_\[Placeholder]\ \[Placeholder]\ \ button\ from\ the\ BasicInput\ \ palette . \ \ Here\ the\ subscript\ box\ will\ hold\ the\ variable\ to\ \ differentiate\ with\ respect\ to\ and\ the\ larger\ box\ will\ hold\ the\ \ function\ being\ differentiated . \ \ Execute\ the\ cell\ below\ to\ see\ how\ \ these\ work . \n\t\t\n\(NOTE : \ \ Instead\ of\ defining\ f[ x]\ and\ using\ that\ notation\), \ we\ could\ have\ replaced\ ' f[x]'\ with\ ' \(x\^5\)'\ in\ either\ the\ first\ or\ third\ \ \(\(methods\)\(.\)\)\)], "Text"], Cell[BoxData[{ \(\(Clear[f, x];\)\), "\n", \(\(f[x_] = x\^5;\)\), "\n", \(D[f[x], x]\), "\n", \(\(f'\)[x]\), "\n", \(\[PartialD]\_x\ f[x]\)}], "Input"], Cell[TextData[{ "It turns out that second derivatives are quite similar. In the D[] \ method, we replace the variable we're differentiating with respect to ('x') \ with '{x,2}' to indicate we're differentiating twice with respect to x. In \ the palette button method, we simply use the ", Cell[BoxData[ \(TraditionalForm\`\[PartialD]\_\(\[Placeholder], \[Placeholder]\)\ \[Placeholder]\)]], " button and put 'x' in for both subscripts. Makes sense, huh? Execute \ the cell below to see how it works." }], "Text"], Cell[BoxData[{ \(D[f[x], {x, 2}]\), "\n", \(\(\(f'\)'\)[x]\), "\n", \(\[PartialD]\_\(x, x\)f[x]\)}], "Input"], Cell[TextData[StyleBox["Exercise: Find the first and second derivatives of \ sin(cos(x^2 exp(x))).", FontWeight->"Bold"]], "Text", Evaluatable->False, Background->RGBColor[0, 1, 1]], Cell[BoxData[""], "Input"], Cell[TextData[{ "Now for some integrals. ", StyleBox["Mathematica", FontSlant->"Italic"], " does both definite and indefinite integrals. Furthermore, it does this \ very well. There's a story about a master's student that compared an earlier \ version of ", StyleBox["Mathematica", FontSlant->"Italic"], " to the table of integrals in the CRC handbook. The two differed on \ three antiderivates. Upon further investigation, it turned out that ", StyleBox["Mathematica", FontSlant->"Italic"], " was right and the CRC handbook was wrong! It's a good one to remember to \ help motivate ", StyleBox["Mathematica", FontSlant->"Italic"], " in class.\nLet's see how to integrate. For indefinite integrals \ (antiderivatives), you can either use the 'Integrate' command or the \ \[Integral]\[DifferentialD]\[Placeholder] button from the BasicInput palette. \ Both have two arguments, the first being the expression to integrate and \ the second being the variable of integration. The integrand can be either a \ previously defined function, f[x], or an expression. Execute the input cell \ below to see how this works." }], "Text"], Cell[BoxData[{ \(\(Clear[h, x];\)\), "\n", \(\(h[x_] = Sin[3 x];\)\), "\n", \(Integrate[h[x], x]\), "\n", \(\[Integral]Sin[3 x] \[DifferentialD]x\)}], "Input"], Cell[BoxData[ \(TextForm\`For\ definite\ integrals, \ you\ can\ use\ ' Integrate', \ the\ \(\[Integral]\_\[Placeholder]\%\[Placeholder] \[Placeholder] \ \[DifferentialD]\[Placeholder]\ button\ on\ the\ BasicInput\ palette\), \ or\ ' NIntegrate'\ \ to\ force\ Mathematica\ to\ do\ a\ numerical\ \ integration . \ \ The\ first\ two\ methods\ try\ to\ first\ find\ an\ \ antiderivative\ and\ if\ that' s\ not\ possible\ they\ resort\ to\ a\ numerical\ method . \ \ The\ ' NIntegrate'\ command\ goes\ straight\ to\ calculating\ the\ definite\ \ integral\ numerically . \ \ \ \n\t\t\n\tWith\ both\ the\ ' Integrate'\ and\ ' NIntegrate'\ commands, \ the\ second\ argument\ \((variable\ of\ integration)\)\ is\ replaced\ by\ \ a\ list\ ' {x, a, b}'\ where\ the\ list\ contains\ the\ variable\ of\ integration\ \ followed\ by\ the\ lower\ and\ upper\ limits\ of\ integration . \ \ The\ \ palette\ button\ simply\ provides\ two\ additional\ boxes\ for\ the\ upper\ \ and\ lower\ limits\ of\ integration . \ \ Execute\ the\ input\ cells\ below\ \ to\ see\ how\ these\ \(\(work\)\(.\)\)\)], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Integrate[Sin[3 x], {x, 0, Pi/2}]\)], "Input"], Cell[BoxData[ \(\[Integral]\_0\%\(\[Pi]/2\)Sin[3 x] \[DifferentialD]x\)], "Input"], Cell[BoxData[ \(NIntegrate[Sin[3 x], {x, 0, \[Pi]\/2}]\)], "Input"] }, Open ]], Cell["\<\ CAUTION: The '\[DifferentialD]x' in the palette form of integrals is \ different from 'dx' and using 'dx' will NOT work for the differential part of \ integrals. Normally this is not a problem since the template you get by \ clicking the palette button gives you the '\[DifferentialD]x', but if you \ accidently delete it, you can get it back by typing 'ddx'.\ \>", "Text", CellFrame->True, Background->GrayLevel[0.849989]], Cell["\<\ NOTE: Sometimes things that should work just don't. For a first example, execute the two input cells below. Notice how the first works but the second \ does not. It turns out that you need to use parentheses when your integrand contains sums. \ \>", "Text"], Cell[BoxData[ \(\[Integral]\((7 x + 3)\) \[DifferentialD]x\)], "Input"], Cell[BoxData[ \(\[Integral]7 x + 3 \[DifferentialD]x\)], "Input"], Cell["\<\ For another, more weird, example, I originally tried to execute all three \ definite integrals from above in one input cell as you see in the input cell \ below. Execute this cell to see what you get. My 'quick fix' was to break \ them up into separate cells. While the error message is a bit cryptic, it's \ basically saying that the '\[DifferentialD]x' in the second line is not \ separated from the 'NIntegrate' on the third line so it got confused. \ Unfortunately, these types of problems are not uncommon, but you can usually \ either resolve or 'work around' the problem with just some playing around or \ by asking someone else to take a look at it.\ \>", "Text"], Cell[BoxData[{ \(Integrate[Sin[3 x], {x, 0, Pi/2}]\), "\n", \(\[Integral]\_0\%\(\[Pi]/2\)Sin[3 x] \[DifferentialD]x\n NIntegrate[Sin[3 x], {x, 0, \[Pi]\/2}]\)}], "Input"], Cell[TextData[{ "Improper integrals can also be tackled by ", StyleBox["Mathematica", FontSlant->"Italic"], " and the current version seems to be pretty good in telling when such \ integrals converge and when they don't. It also seems to be pretty good in \ identifying singularities in the integration interval. Execute the input \ cells below to see how this works." }], "Text"], Cell[BoxData[ \(\[Integral]\_1\%\[Infinity]\( 1\/x\^2\) \[DifferentialD]x\)], "Input"], Cell[BoxData[ \(\[Integral]\_0\%1\( 1\/x\^2\) \[DifferentialD]x\)], "Input"], Cell[BoxData[ \(\[Integral]\_0\%1\( 1\/\@x\) \[DifferentialD]x\)], "Input"], Cell[BoxData[ \(\[Integral]\_1\%\[Infinity]\( 1\/\@x\) \[DifferentialD]x\)], "Input"], Cell[BoxData[ \(\[Integral]\_\(-2\)\%2\( 1\/x\) \[DifferentialD]x\)], "Input"], Cell[TextData[{ StyleBox["Exercise: Find the antiderivatives for cos(\[Pi] x) and ", FontWeight->"Bold"], Cell[BoxData[ \(TraditionalForm\`\(\(\(cos\^2\)(\[Pi]\ x)\)\(.\)\)\)]] }], "Text", Evaluatable->False, Background->RGBColor[0, 1, 1]], Cell[BoxData[""], "Input"], Cell[BoxData[""], "Input"], Cell[TextData[StyleBox["Exercise: Evaluate the definite integral of x \ (sin(x))^2 exp(-x) from x = 0 to x=2\[Pi].", FontWeight->"Bold"]], "Text", Evaluatable->False, Background->RGBColor[0, 1, 1]], Cell[BoxData[""], "Input"], Cell[TextData[{ StyleBox["Exercise: Below are some ", FontWeight->"Bold"], StyleBox["Mathematica", FontWeight->"Bold", FontSlant->"Italic"], StyleBox[" commands that don't seem to be working, can you fix them?", FontWeight->"Bold"] }], "Text", Evaluatable->False, Background->RGBColor[0, 1, 1]], Cell[BoxData[ \(integrate[x^2, {x, 0, 1}]\)], "Input"], Cell[BoxData[ \(\[Integral]Cos \((2 z)\) \[DifferentialD]z\)], "Input"], Cell[BoxData[ \(\[Integral]\_0\%1\( x\^2\) dx\)], "Input"], Cell[BoxData[ \(Limit[1\/x\^2, x -> 0, Direction -> 0]\)], "Input"], Cell[BoxData[ \(\[Integral]x\^2 + 7 x \[DifferentialD]x\)], "Input"], Cell[BoxData[ \(\[Integral]x \[DifferentialD]y\)], "Input"], Cell[TextData[{ "Hopefully you found that ", StyleBox["Mathematica", FontSlant->"Italic"], " can be quite useful in an introductory calculus setting. Turns out it's \ even more useful the further you go in mathematics. With that said, let's \ look at a few more syntax issues that will help us progress to the more \ advanced uses of ", StyleBox["Mathematica", FontSlant->"Italic"], "." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["A Bit More Syntax...", "Section"], Cell[TextData[{ "Ok, now we're cooking with gas... Let's look at some more on the syntax \ of ", StyleBox["Mathematica", FontSlant->"Italic"], ".\nSay you just simplified and expression and now want to plug in a value \ for a variable. The Substitution Operator (/.) in ", StyleBox["Mathematica", FontSlant->"Italic"], " is a great way to do this. The format is a slash and period followed by \ the variable and an arrow and the value (ex: '/.x->5' which says substitute 5 \ in for x). NOTE: The arrow is made by a dash ('-') followed by a greater \ than ('>').\nLet's try an example. We'll first simplify an expression and \ then use the Previous Results Operation (%) to get the results and do a \ substitution operation. Execute the input cell below and we'll see what \ happens." }], "Text"], Cell[BoxData[{ \(Clear[x, y]; \ \ \ \ (*\ Always\ good\ to\ clear\ your\ variables\ first\ *) \n Simplify[\((x^4\ + \ 1)\) y\ + y*x^4]\), "\n", \(% /. x -> 5\)}], "Input"], Cell[TextData[{ "Alright! The Simplify gave us the expression, ", Cell[BoxData[ \(y + 2\ x\^4\ y\)]], ", and the substitution operator replaced the 'x' with a value of 5 to get \ 1251y.\nWhat if we just \"re-discovered\" the quadratic formula and want to \ plug in some values for the coefficients. Since we're substituting in for \ multiple variables, we'll use a list to put them all together. Try the cell \ below to see what happens:" }], "Text"], Cell[BoxData[{ \(\(Clear[a, b, c, x];\)\), "\n", \(Solve[a\ x^2 + b\ x\ + c == 0, x]\), "\n", \(% /. {a -> 1, b -> 2, c -> \(-15\)}\)}], "Input"], Cell[TextData[StyleBox["Exercise: Use Solve to find the general solution to \ a x^3 + b x^2 + c x + d = 0 and then substitute some values in for a, b, c, \ and d.", FontWeight->"Bold"]], "Text", Evaluatable->False, Background->RGBColor[0, 1, 1]], Cell[BoxData[""], "Input"], Cell[TextData[{ "Notice that when we solved for the quadratic equation, ", StyleBox["Mathematica", FontSlant->"Italic"], " gave us the two solutions in a list format (actually it's a list of \ lists). How do we get at pieces of such answers that are embedded in lists?\n\ Another excellent question, Watson! The double square bracket notation lets \ us get into list elements (which may be other lists...). Perhaps this is \ best shown with an example. Let's solve the quadratic equation again but \ this time give the solution a name (something clever like 'sol') so we can \ get back to it easily. We'll then use the 'sol[[-]]' notation to get at \ pieces of this solution. Execute the input cells below and look carefully at \ what each command produces." }], "Text"], Cell[BoxData[{ \(\(Clear[a, b, c, x, sol];\)\), "\n", \(sol = Solve[a\ x^2 + b\ x\ + c == 0, x]\)}], "Input"], Cell[BoxData[ \(sol[\([1]\)]\)], "Input"], Cell[BoxData[ \(sol[\([1, 1]\)]\)], "Input"], Cell[BoxData[ \(sol[\([1, 1, 2]\)]\)], "Input"], Cell["\<\ Do you see what's going on here? The result, 'sol', is a list of lists with two pieces to the inner lists. The 'sol[[1]]' gives us the first sublist. The 'sol[[1,1]]' gives us what's in that first sublist which is a substitution expression for the first solution to the quadratic polynomial. Finally, the 'sol[[1,1,2]]' isolates the second part of that substitution expression. \"Cosmic Coconuts, Batman! That sure looked ugly to begin with, but once you \ break it down, it wasn't that bad!\" \ \>", "Text"], Cell[TextData[StyleBox["Exercise: Use this '[[-]]' notation to get at the \ other expression for the solution to the quadratic (from 'sol' as computed \ above).", FontWeight->"Bold"]], "Text", Evaluatable->False, Background->RGBColor[0, 1, 1]], Cell[BoxData[""], "Input"], Cell[TextData[{ "Let's switch gears a little bit. That BasicInput palette sure seems like \ a neat way to put in some fancy looking math stuff, but all that pointing and \ clicking is driving me crazy! How about a fast keystroke way of doing that.\ \n I hear ya! And so did Wolfram Research. You can hold down the Ctrl key \ while you hit some other specific keys to get many of those nifty constructs \ straight away. Here's some examples:\n", StyleBox["x ^ 3", FontWeight->"Bold"], " gives us ", Cell[BoxData[ \(x\^3\)]], "\n", StyleBox["x / 3", FontWeight->"Bold"], " gives us ", Cell[BoxData[ \(\(\(\ \)\(x\/3\)\)\)]], "\n<", StyleBox["Ctrl>2 x", FontWeight->"Bold"], " gives us ", Cell[BoxData[ \(\@x\)]], "\n", StyleBox["x _ 3", FontWeight->"Bold"], " gives us ", Cell[BoxData[ \(\(\(\ \)\(x\_3\)\)\)]], "\n<", StyleBox["Ctrl>", FontWeight->"Bold"], " moves us out of two-dimensional structures" }], "Text"], Cell[TextData[{ StyleBox["Exercise: Use these new found \"tricks\" to input the \ expression: ", FontWeight->"Bold"], Cell[BoxData[ \(x\^2 + 1\/\(\@x + a\_1\)\)]] }], "Text", Evaluatable->False, Background->RGBColor[0, 1, 1]], Cell[BoxData[""], "Input"], Cell[TextData[{ "Here's some more fun stuff. You can use Input|Create Table/Matrix/Palette \ from the Mail Toolbar to create a matrix. You can then use the following to \ adjust it:\n<", StyleBox["Ctrl>,", FontWeight->"Bold"], " will add a column.\n<", StyleBox["Ctrl>", FontWeight->"Bold"], " will add a row.\n<", StyleBox["Ctrl>", FontWeight->"Bold"], " will move out of the matrix.\nLike those Greek letters and other neat \ stuff on the BasicInput palette? Here's some quick ways to get at them:\n<", StyleBox["Esc> a ", FontWeight->"Bold"], "gives us the \[Alpha].\n<", StyleBox["Esc> b ", FontWeight->"Bold"], " gives us the \[Beta].\n<", StyleBox["Esc> pi ", FontWeight->"Bold"], " gives us the \[Pi].\n<", StyleBox["Esc> int ", FontWeight->"Bold"], " gives us the \[Integral] ." }], "Text"], Cell[TextData[{ StyleBox["Exercise: Create the following matrix: ", FontWeight->"Bold"], Cell[BoxData[ RowBox[{"(", GridBox[{ {"\[Alpha]", "\[Beta]"}, {"\[Pi]", \(\[Alpha]*\[Beta]\)} }], ")"}]]], " ", StyleBox["using the trick you just learned.", FontWeight->"Bold"] }], "Text", Evaluatable->False, Background->RGBColor[0, 1, 1]], Cell[BoxData[""], "Input"], Cell[TextData[{ "Well that was fun, but we need to get back to a more practical issue. Not \ all the capabilities of ", StyleBox["Mathematica", FontSlant->"Italic"], " are directly available in the ", StyleBox["Mathematica", FontSlant->"Italic"], " Kernel. If they were, ", StyleBox["Mathematica", FontSlant->"Italic"], " would be just too big to run on most machines. Therefore, many of the \ more specialized functions in ", StyleBox["Mathematica", FontSlant->"Italic"], " are put in separate ", StyleBox["packages", FontWeight->"Bold"], " which the user must load as needed. \nThere are three issues with these \ packages. First, you have to know which package contains the commands you \ need. The Help System is the life-saver here. It not only tells you which \ package but typically gives you example code that you can cut and paste to \ use as a starting point.\nThe second issue is more subtle and deals with how \ symbols are defined in ", StyleBox["Mathematica", FontSlant->"Italic"], ". If you end up loading a package twice, the symbols, functions, ... in \ the package will be defined in ", StyleBox["Mathematica", FontSlant->"Italic"], " twice and it will get confused. (You'll see a bunch of shadow definition \ messages). That's why ", StyleBox["YOU SHOULD NEVER USE THE '<<' NOTATION TO LOAD PACKAGES!", FontWeight->"Bold"], " The '<<' notation loads the package whether or not it's been already \ loaded. The Needs command is smarter and does a check to see if the package \ is already loaded. If so, it knows better than to try to load it again.\nThe \ final issue is that there's a weird character used in specifying packages. \ It's the ` character which is typed using the top leftmost key on your \ keyboard. Be careful not to confuse this with the apostrophe character.\n \ Here's an example of a command that comes from a package. Go ahead and \ execute this input cell to see what it does." }], "Text"], Cell[BoxData[{ \(Needs["\"]\), "\n", \(PlotVectorField[{Sin[x], \ Cos[y]}, \n\ \ \ \ \ \ \ \ \ \ \ \ \ {x, \ 0, \ Pi}, \ {y, \ 0, \ Pi}]\)}], "Input"], Cell[TextData[{ "Great, that's a pretty neat command which is especially helpful with \ vector calculus.\nLet's quickly summarize what we've learned in this section. \ First, we learned about the substitution operator (/.) that allows us to \ easily put in values for variables in expressions that we create. Then we \ learned about lists which are used quite a bit in ", StyleBox["Mathematica", FontSlant->"Italic"], " and how to use the '[[-]]' notation to access items and sub-lists. This \ was followed by some input short-cuts that utilize the keystrokes. Finally, \ there was a brief introduction to using packages which provide a great deal \ of additional power to ", StyleBox["Mathematica", FontSlant->"Italic"], "." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Conclusion", "Section"], Cell[TextData[{ "Well, I hope this has been a helpful learning exercise for you. You may \ not remember everything you've learned here, but you should be getting more \ comfortable with ", StyleBox["Mathematica", FontSlant->"Italic"], ". I recommend you keep this notebook for future reference. It will also \ be kept on our Internet ", StyleBox["Mathematica", FontSlant->"Italic"], " Notebook Library as well as on our shared drive.\nBefore we close this up \ however, let's quickly review some of the key topics that we just covered \ and then I have a final set of tasks for you that will have you use some of \ what you've just learned as well as teach you something new about ", StyleBox["Mathematica", FontSlant->"Italic"], "." }], "Text"], Cell[TextData[{ "First we learned about using built-in ", StyleBox["Mathematica", FontSlant->"Italic"], " functions. The basic rules for using functions in ", StyleBox["Mathematica", FontSlant->"Italic"], " are:\n1) They are case-sensitive and always start with a capital letter \ (and sometimes have capital letters elsewhere usually to denote multiple \ words in the command, like 'LaplaceTransform').\n2) The arguments to the \ function are always enclosed in square brackets (like we saw in Basic \ Concepts I).\n3) There are some arguments that must be specified and others \ that are optional parameters which are specified as ", StyleBox["ParameterName->Value", FontSlant->"Italic"], ".\n4) Arguments may be just a single expression or value, or they can be \ a list of expressions or values. Lists are always enclosed by {,}." }], "Text"], Cell[TextData[{ "Next we got a brief introduction to ", StyleBox["Mathematica'", FontSlant->"Italic"], "s extensive on-line help system. Here we learned how to get quick help \ with a command by prefacing the command with one or two question marks. We \ also got to play around with the help search mechanism that uses hyperlinks \ and a keyword search to get at help from several different on-line sources. \ This will be most valuable to you as you explore more of what ", StyleBox["Mathematica", FontSlant->"Italic"], " has to offer." }], "Text"], Cell["\<\ This was followed by an introduction to using Mathematica for some elementary \ calculus operations including finding limits, taking derivatives, and computing both indefinite and definite integrals. \ \>", "Text"], Cell["\<\ Finally, we ended with some more Mathematica syntax including the substitution operator, lists and accessing items in them, keyboard input short-cuts, and the use of packages. \ \>", "Text"], Cell["Now for the exercises.", "Text"], Cell[TextData[{ StyleBox["Exercise: Look up 'vectors' in the ", FontWeight->"Bold"], StyleBox["Mathematica", FontWeight->"Bold", FontSlant->"Italic"], StyleBox[" Help System and use what you've learned to accomplish the \ following tasks:\n1) Define vectors a = < 2, 3, 4> and b = < -1, 5 , 7>.\n\ 2) Compute 5 a + b\n3) Compute the Dot Product of a and b.\n4) Compute \ the Cross Product of a and b. HINT: You may need to load a package to do \ this.", FontWeight->"Bold"] }], "Text", Evaluatable->False, Background->RGBColor[0, 1, 1]], Cell[BoxData[""], "Input"], Cell["\<\ In the next Basic Concepts tutorial (Basic Concepts III), we'll learn a whole \ bunch about graphing which can provide some very useful pedagogical tools for \ the instructor. \ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Acknowledgements", "Section"], Cell["\<\ This tutorial notebook is an accumulation of previous work done by many members of the Department of Mathematical Sciences, United States Air Force Academy including Capt Paul Simonich, Major Glenn Sjoden, and Capt Robert Clasen, and many others. It has been enhanced and packaged into its current form by Lt Col Steve Hadfield and Dr Brad Kline. Suggestions on further improvements can be submitted to Lt Col Hadfield via email to: steve.hadfield@usafa.af.mil. \ \>", "Text"] }, Closed]], Cell["", "Subsubtitle"] }, FrontEndVersion->"4.0 for Microsoft Windows", ScreenRectangle->{{0, 800}, {0, 527}}, ScreenStyleEnvironment->"Working", WindowToolbars->{}, CellGrouping->Manual, WindowSize->{641, 476}, WindowMargins->{{2, Automatic}, {Automatic, 5}}, PrintingCopies->1, PrintingPageRange->{Automatic, Automatic}, PrivateNotebookOptions->{"ColorPalette"->{RGBColor, -1}}, ShowCellLabel->True, ShowCellTags->False, RenderingOptions->{"ObjectDithering"->True, "RasterDithering"->False}, StyleDefinitions -> "DemoText.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->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[1717, 49, 345, 13, 70, "Title", Evaluatable->False], Cell[2065, 64, 1054, 28, 155, "Text", Evaluatable->False], Cell[CellGroupData[{ Cell[3144, 96, 62, 1, 54, "Section", Evaluatable->False], Cell[3209, 99, 402, 9, 70, "Text", Evaluatable->False], Cell[3614, 110, 803, 15, 70, "Text", Evaluatable->False], Cell[4420, 127, 116, 5, 70, "Text"], Cell[4539, 134, 316, 8, 70, "Text"], Cell[4858, 144, 42, 1, 70, "Input"], Cell[4903, 147, 224, 6, 70, "Text"], Cell[5130, 155, 58, 1, 70, "Input"], Cell[5191, 158, 170, 5, 70, "Text"], Cell[5364, 165, 149, 3, 70, "Input"], Cell[5516, 170, 460, 9, 70, "Text"], Cell[5979, 181, 82, 1, 70, "Text", Evaluatable->False], Cell[6064, 184, 228, 4, 70, "Text", Evaluatable->False], Cell[6295, 190, 26, 0, 70, "Input"], Cell[6324, 192, 195, 4, 70, "Text", Evaluatable->False], Cell[CellGroupData[{ Cell[6544, 200, 45, 1, 70, "Input"], Cell[6592, 203, 44, 1, 70, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[6673, 209, 39, 1, 70, "Input"], Cell[6715, 212, 40, 1, 70, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[6792, 218, 39, 1, 70, "Input"], Cell[6834, 221, 180, 3, 70, "Message"], Cell[7017, 226, 40, 1, 70, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[7094, 232, 42, 1, 70, "Input"], Cell[7139, 235, 151, 3, 70, "Message"], Cell[7293, 240, 44, 1, 70, "Output"] }, Open ]], Cell[7352, 244, 881, 15, 70, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[8270, 264, 148, 5, 34, "Section", Evaluatable->False], Cell[8421, 271, 655, 14, 70, "Text", Evaluatable->False], Cell[9079, 287, 42, 1, 70, "Input"], Cell[9124, 290, 272, 8, 70, "Text"], Cell[9399, 300, 46, 1, 70, "Input"], Cell[9448, 303, 253, 8, 70, "Text"], Cell[9704, 313, 43, 1, 70, "Input"], Cell[9750, 316, 346, 11, 70, "Text", Evaluatable->False], Cell[10099, 329, 26, 0, 70, "Input"], Cell[10128, 331, 1326, 23, 70, "Text"], Cell[11457, 356, 208, 4, 70, "Text", Evaluatable->False], Cell[11668, 362, 211, 4, 70, "Text", Evaluatable->False], Cell[11882, 368, 740, 22, 70, "Text", Evaluatable->False], Cell[12625, 392, 563, 14, 70, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[13225, 411, 41, 0, 34, "Section"], Cell[13269, 413, 130, 6, 70, "Text"], Cell[13402, 421, 274, 7, 70, "Text"], Cell[13679, 430, 41, 1, 70, "Input"], Cell[13723, 433, 167, 5, 70, "Text"], Cell[13893, 440, 56, 1, 70, "Input"], Cell[13952, 443, 315, 7, 70, "Text"], Cell[14270, 452, 193, 4, 70, "Text", Evaluatable->False], Cell[14466, 458, 26, 0, 70, "Input"], Cell[14495, 460, 569, 12, 70, "Text"], Cell[15067, 474, 201, 5, 70, "Input"], Cell[15271, 481, 1198, 19, 70, "Text"], Cell[16472, 502, 175, 5, 70, "Input"], Cell[16650, 509, 532, 10, 70, "Text"], Cell[17185, 521, 123, 3, 70, "Input"], Cell[17311, 526, 188, 4, 70, "Text", Evaluatable->False], Cell[17502, 532, 26, 0, 70, "Input"], Cell[17531, 534, 1178, 24, 70, "Text"], Cell[18712, 560, 180, 4, 70, "Input"], Cell[18895, 566, 1138, 17, 70, "Text"], Cell[CellGroupData[{ Cell[20058, 587, 67, 1, 70, "Input"], Cell[20128, 590, 87, 1, 70, "Input"], Cell[20218, 593, 72, 1, 70, "Input"] }, Open ]], Cell[20305, 597, 453, 8, 70, "Text"], Cell[20761, 607, 276, 8, 70, "Text"], Cell[21040, 617, 76, 1, 70, "Input"], Cell[21119, 620, 70, 1, 70, "Input"], Cell[21192, 623, 693, 10, 70, "Text"], Cell[21888, 635, 186, 3, 70, "Input"], Cell[22077, 640, 395, 8, 70, "Text"], Cell[22475, 650, 90, 1, 70, "Input"], Cell[22568, 653, 80, 1, 70, "Input"], Cell[22651, 656, 79, 1, 70, "Input"], Cell[22733, 659, 89, 1, 70, "Input"], Cell[22825, 662, 82, 1, 70, "Input"], Cell[22910, 665, 258, 7, 70, "Text", Evaluatable->False], Cell[23171, 674, 26, 0, 70, "Input"], Cell[23200, 676, 26, 0, 70, "Input"], Cell[23229, 678, 205, 4, 70, "Text", Evaluatable->False], Cell[23437, 684, 26, 0, 70, "Input"], Cell[23466, 686, 322, 10, 70, "Text", Evaluatable->False], Cell[23791, 698, 58, 1, 70, "Input"], Cell[23852, 701, 76, 1, 70, "Input"], Cell[23931, 704, 62, 1, 70, "Input"], Cell[23996, 707, 71, 1, 70, "Input"], Cell[24070, 710, 73, 1, 70, "Input"], Cell[24146, 713, 63, 1, 70, "Input"], Cell[24212, 716, 421, 11, 70, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[24670, 732, 39, 0, 34, "Section"], Cell[24712, 734, 828, 16, 70, "Text"], Cell[25543, 752, 194, 4, 70, "Input"], Cell[25740, 758, 470, 9, 70, "Text"], Cell[26213, 769, 160, 3, 70, "Input"], Cell[26376, 774, 253, 5, 70, "Text", Evaluatable->False], Cell[26632, 781, 26, 0, 70, "Input"], Cell[26661, 783, 794, 13, 70, "Text"], Cell[27458, 798, 119, 2, 70, "Input"], Cell[27580, 802, 45, 1, 70, "Input"], Cell[27628, 805, 48, 1, 70, "Input"], Cell[27679, 808, 51, 1, 70, "Input"], Cell[27733, 811, 531, 13, 70, "Text"], Cell[28267, 826, 251, 5, 70, "Text", Evaluatable->False], Cell[28521, 833, 26, 0, 70, "Input"], Cell[28550, 835, 1029, 34, 70, "Text"], Cell[29582, 871, 245, 8, 70, "Text", Evaluatable->False], Cell[29830, 881, 26, 0, 70, "Input"], Cell[29859, 883, 897, 26, 70, "Text"], Cell[30759, 911, 392, 13, 70, "Text", Evaluatable->False], Cell[31154, 926, 26, 0, 70, "Input"], Cell[31183, 928, 2026, 42, 70, "Text"], Cell[33212, 972, 190, 3, 70, "Input"], Cell[33405, 977, 766, 15, 70, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[34208, 997, 29, 0, 34, "Section"], Cell[34240, 999, 780, 17, 70, "Text"], Cell[35023, 1018, 884, 17, 70, "Text"], Cell[35910, 1037, 574, 12, 70, "Text"], Cell[36487, 1051, 227, 7, 70, "Text"], Cell[36717, 1060, 203, 6, 70, "Text"], Cell[36923, 1068, 38, 0, 70, "Text"], Cell[36964, 1070, 572, 14, 70, "Text", Evaluatable->False], Cell[37539, 1086, 26, 0, 70, "Input"], Cell[37568, 1088, 203, 8, 70, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[37808, 1101, 35, 0, 34, "Section"], Cell[37846, 1103, 494, 11, 70, "Text"] }, Closed]], Cell[38355, 1117, 23, 0, 52, "Subsubtitle"] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)