(************** 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[ 9289, 406]*) (*NotebookOutlinePosition[ 9981, 430]*) (* CellTagsIndexPosition[ 9937, 426]*) (*WindowFrame->Normal*) Notebook[{ Cell["\<\ 12.010 Lecture 12 (Fall, 2005)\ \>", "Title"], Cell[CellGroupData[{ Cell[TextData[{ "Slide 03: Examples of basic ", StyleBox["Mathematica", FontSlant->"Italic"], " Features" }], "Section"], Cell[CellGroupData[{ Cell["Code (use shift-return to evaluate)", "Subsection"], Cell["\<\ x = 3; If[x < 4, Print[\"x is less than 4\"], Print[\"x is not less than 4\"]]\ \>", \ "Input"] }, Open ]], Cell[CellGroupData[{ Cell["Numerics to arbitrary precision", "Subsection"], Cell[BoxData[ \(Pi\)], "Input"], Cell["N[Pi] //FullForm", "Input"], Cell["N[Pi, 20]", "Input"], Cell["N[2, 100]", "Input"], Cell["1/7 //N //FullForm", "Input"] }, Open ]], Cell[CellGroupData[{ Cell["Algebra", "Subsection"], Cell["Expand[(a + b)^25]", "Input"] }, Open ]], Cell[CellGroupData[{ Cell["Calculus", "Subsection"], Cell["Integrate[y^2, y]", "Input"], Cell["Integrate[y^n, y]", "Input"], Cell["Integrate[y^-1, y]", "Input"], Cell[BoxData[ \(Log[10]\ // N\)], "Input"], Cell[BoxData[ \(Log[10, \ 20]\)], "Input"], Cell["Integrate[Exp[-y^2/2], y]", "Input"] }, Open ]], Cell[CellGroupData[{ Cell["Graphics", "Subsection"], Cell["Plot[Sin[y], {y, 0, 2Pi}];", "Input"], Cell["Plot[Sin[y], {y, 0, 2Pi}, Frame->True, Axes->False];", "Input"] }, Open ]], Cell[CellGroupData[{ Cell["Notebooks", "Subsection"], Cell[TextData[{ "This file is a notebook. Close it and open it with a text editor to see \ the raw format of a ", StyleBox["Mathematica", FontSlant->"Italic"], " notebook." }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Formats", "Subsection"], Cell["Open the palettes and enter an equation", "Text"], Cell[BoxData[ \(\[Integral]\_\[Pi]\%\(2 \[Pi]\)\(y\^2\) \[DifferentialD]y\)], "Input"], Cell["{{2, 3, 4}, {5, 4, 7}, {8, 6, 1}} ", "Input"], Cell["{{2, 3, 4}, {5, 4, 7}, {8, 6, 1}} //TableForm", "Input"], Cell["{{2, 3, 4}, {5, 4, 7}, {8, 6, 1}} //FullForm", "Input"], Cell[BoxData[ \(2\ + \ sx\ // FullForm\)], "Input"], Cell["Plot[y^2, {y, 2, 4}] //FullForm", "Input"], Cell["BaseForm[1934, 3]", "Input"], Cell["BaseForm[1934, 16]", "Input"], Cell["BaseForm[1934 + 10, 25]", "Input"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Slide 08: Variable types", "Section"], Cell[CellGroupData[{ Cell["Variable types", "Subsection"], Cell["Head[5]", "Input"], Cell["Head[5/2]", "Input"], Cell["Head[4/2]", "Input"], Cell["Head[3.0]", "Input"], Cell["Head[3.0 + 5 I]", "Input"], Cell["Head[rx]", "Input"], Cell["Head[Pi]", "Input"], Cell["Head[N[Pi, 50]]", "Input"], Cell["\<\ n1 = 11111111111111111111111111111111111111111111111111111111111;\ \ \>", "Input"], Cell["Head[n1]", "Input"], Cell["Head[\"this is a string\"]", "Input"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["Slide 09: Examine variable behavior with =", "Section"], Cell[BoxData[{ \(y = 2\ ; \ x\ = 4;\), "\[IndentingNewLine]", \(\(\(x\)\(=\)\(\ \)\(y\)\(\ \ \)\( (*\ This\ will\ assign\ the\ value\ of\ y\ to\ x*) \)\)\)}], "Input"], Cell[BoxData[ \(\(\(x\)\(\ \ \ \)\( (*\ Check\ the\ value\ of\ x\ *) \)\)\)], "Input"], Cell[BoxData[{ \(y\ = \ 4\ \ (*\ Reassign\ the\ value\ of\ y\ *) \), "\[IndentingNewLine]", \(x\ \ (*\ Value\ of\ x\ has\ not\ changed\ *) \)}], "Input"], Cell[BoxData[{ \(x\ := \ y\ \ (*\ This\ delayed\ assignment, \ x\ is\ now\ y\ *) \), "\[IndentingNewLine]", \(x\)}], "Input"], Cell[BoxData[{ \(y\ = \ 6\ (*\ Change\ the\ value\ of\ y\ and\ x\ changes\ also*) \), "\ \[IndentingNewLine]", \(x\)}], "Input"], Cell[CellGroupData[{ Cell["\<\ Precedence (simple cases below, we would need to add parentheses to \ change results or to use IntergerPart)\ \>", "Subsection"], Cell["1 + 2^3 / 4 * 5", "Input"], Cell["1 + 2^3 * 5 / 4", "Input"], Cell[" 2^3 / 4 * 5 + 1", "Input"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["\<\ Slide 10: Example of user Contexts to isolate variables (variables \ available everywhere are Global`)\ \>", "Section"], Cell[CellGroupData[{ Cell["Contexts (As I start here variables are Global` context)", "Subsection"], Cell["\<\ Clear[\"Global`*\",anotherContext`z] (*Add this command to clear \ all variables used so far *) Context[z] z=4\ \>", "Input"], Cell["\<\ BeginPackage[\"anotherContext`\"] (*Begin a package which has its \ own Context. Variables defined in this context will be different to Global` \ eventhough they have the same names*)\ \>", "Input"], Cell[BoxData[ \(\(\(Context[]\)\(\ \ \)\( (*\ Lets\ me\ know\ what\ context\ am\ in\ working\ in*) \)\)\)], "Input"], Cell["z (* z has not been defined and so it is just the symbol *)", "Input"], Cell["\<\ Context[z] z=8\ \>", "Input"], Cell["EndPackage[] (*Ends the Package usage, now back to Global*)", "Input"], Cell[BoxData[ \(\(\(Context[]\)\(\ \ \)\( (*\ Tells\ me\ current\ Context\ *) \)\)\)], "Input"], Cell["Context[z]", "Input"], Cell["Context[anotherContext`z]", "Input"], Cell["$ContextPath (* Tells all the contexts that are available*)", "Input"], Cell[BoxData[ \($Context\)], "Input"], Cell[BoxData[{ \(Global`z\ \ \ (*\ Lets\ me\ see\ the\ values\ in\ the\ differenr\ contexts*) \), "\ \[IndentingNewLine]", \(anotherContext`z\)}], "Input"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Slide 13: Examples of function use", "Section"], Cell[CellGroupData[{ Cell["Types in function definitions", "Subsection"], Cell[BoxData[{ \(Clear[f]\), "\[IndentingNewLine]", \(\(?f\)\)}], "Input"], Cell["\<\ f[x_Integer] := x^2 (* Here we define how f should behave when an \ integer argument is passed*)\ \>", "Input"], Cell["f[9]", "Input"], Cell[BoxData[ \(\(\(f[x_Real]\)\(\ \)\(:=\)\(\ \)\(Sqrt[ x]\)\(\ \ \)\( (*This\ is\ how\ f\ behaves\ with\ a\ real\ argument*) \ \)\)\)], "Input"], Cell[BoxData[ \(\(?f\ \ (*Enquires\ about\ nature\ of\ function\ f*)\)\)], "Input"], Cell["f[9.]", "Input"], Cell["\<\ f[\"hello\"] (* Currently no information on how f should be behave \ when a string is passed*)\ \>", "Input"], Cell["\<\ f[x_String] := StringDrop[x, -1] (*Tells it to drop last \ character*)\ \>", "Input"], Cell["f[\"hello\"]", "Input"], Cell[BoxData[ \(\(\(example\)\(\ \)\(:=\)\(\ \)\(f\)\(\ \ \)\( (*Here\ I\ now\ make\ a\ \ copy\ of\ f\ called\ example*) \)\)\)], "Input"], Cell[BoxData[{ \(example[9]\), "\[IndentingNewLine]", \(example[9. ]\), "\[IndentingNewLine]", \(example["\"]\)}], "Input"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Bugs", "Section"], Cell[CellGroupData[{ Cell["Division", "Subsection"], Cell[BoxData[ \(\(x1 = \ 1.992;\)\)], "Input"], Cell[BoxData[ \(x1/x1\ // FullForm\)], "Input"], Cell[BoxData[ \(\(x2\ = \ 1.9920000000000002;\)\)], "Input"], Cell[BoxData[ \(x2/x2\ // FullForm\)], "Input"], Cell[BoxData[ \(N[x2/x2, \ 17]\)], "Input"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Scratch Area", "Section"], Cell[BoxData[ \(f[x_] := \ {2, \ 3}\)], "Input"], Cell[BoxData[ \({a, \ b}\ = \ f[j]\)], "Input"], Cell[BoxData[ \(c\ = \ f[j]\)], "Input"], Cell[BoxData[{ \(Clear[a]\), "\[IndentingNewLine]", \(f[x_]\ := \ 2*x\ \ \ (*\ Define\ to\ double\ x*) \), "\[IndentingNewLine]", \(g[y_]\ := \ Sin[y]\), "\[IndentingNewLine]", \(h[z_]\ := \ f[z] + g[z]\)}], "Input"], Cell[BoxData[{ \(h[10]\), "\[IndentingNewLine]", \(h[a]\)}], "Input"] }, Closed]] }, FrontEndVersion->"5.0 for Macintosh", ScreenRectangle->{{0, 1280}, {0, 794}}, WindowSize->{730, 684}, WindowMargins->{{136, Automatic}, {22, Automatic}}, Magnification->1, StyleDefinitions -> "Classroom.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[1754, 51, 55, 3, 108, "Title"], Cell[CellGroupData[{ Cell[1834, 58, 130, 5, 59, "Section"], Cell[CellGroupData[{ Cell[1989, 67, 57, 0, 36, "Subsection"], Cell[2049, 69, 105, 4, 52, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[2191, 78, 53, 0, 36, "Subsection"], Cell[2247, 80, 35, 1, 26, "Input"], Cell[2285, 83, 33, 0, 25, "Input"], Cell[2321, 85, 26, 0, 25, "Input"], Cell[2350, 87, 26, 0, 25, "Input"], Cell[2379, 89, 35, 0, 25, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[2451, 94, 29, 0, 36, "Subsection"], Cell[2483, 96, 35, 0, 25, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[2555, 101, 30, 0, 36, "Subsection"], Cell[2588, 103, 34, 0, 25, "Input"], Cell[2625, 105, 34, 0, 25, "Input"], Cell[2662, 107, 35, 0, 25, "Input"], Cell[2700, 109, 47, 1, 26, "Input"], Cell[2750, 112, 46, 1, 26, "Input"], Cell[2799, 115, 42, 0, 25, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[2878, 120, 30, 0, 36, "Subsection"], Cell[2911, 122, 43, 0, 25, "Input"], Cell[2957, 124, 69, 0, 25, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[3063, 129, 31, 0, 36, "Subsection"], Cell[3097, 131, 195, 6, 44, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[3329, 142, 29, 0, 36, "Subsection"], Cell[3361, 144, 55, 0, 29, "Text"], Cell[3419, 146, 91, 1, 43, "Input"], Cell[3513, 149, 51, 0, 25, "Input"], Cell[3567, 151, 62, 0, 25, "Input"], Cell[3632, 153, 61, 0, 25, "Input"], Cell[3696, 155, 57, 1, 26, "Input"], Cell[3756, 158, 48, 0, 25, "Input"], Cell[3807, 160, 34, 0, 25, "Input"], Cell[3844, 162, 35, 0, 25, "Input"], Cell[3882, 164, 40, 0, 25, "Input"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[3971, 170, 43, 0, 39, "Section"], Cell[CellGroupData[{ Cell[4039, 174, 36, 0, 36, "Subsection"], Cell[4078, 176, 24, 0, 25, "Input"], Cell[4105, 178, 26, 0, 25, "Input"], Cell[4134, 180, 26, 0, 25, "Input"], Cell[4163, 182, 26, 0, 25, "Input"], Cell[4192, 184, 32, 0, 25, "Input"], Cell[4227, 186, 25, 0, 25, "Input"], Cell[4255, 188, 25, 0, 25, "Input"], Cell[4283, 190, 32, 0, 25, "Input"], Cell[4318, 192, 92, 3, 25, "Input"], Cell[4413, 197, 25, 0, 25, "Input"], Cell[4441, 199, 43, 0, 25, "Input"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[4533, 205, 61, 0, 39, "Section"], Cell[4597, 207, 186, 3, 41, "Input"], Cell[4786, 212, 90, 1, 26, "Input"], Cell[4879, 215, 172, 3, 41, "Input"], Cell[5054, 220, 143, 3, 41, "Input"], Cell[5200, 225, 146, 4, 41, "Input"], Cell[CellGroupData[{ Cell[5371, 233, 138, 3, 52, "Subsection"], Cell[5512, 238, 32, 0, 25, "Input"], Cell[5547, 240, 33, 0, 25, "Input"], Cell[5583, 242, 33, 0, 25, "Input"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[5665, 248, 129, 3, 63, "Section"], Cell[CellGroupData[{ Cell[5819, 255, 78, 0, 36, "Subsection"], Cell[5900, 257, 135, 5, 66, "Input"], Cell[6038, 264, 209, 4, 52, "Input"], Cell[6250, 270, 127, 2, 26, "Input"], Cell[6380, 274, 77, 0, 25, "Input"], Cell[6460, 276, 39, 3, 39, "Input"], Cell[6502, 281, 77, 0, 25, "Input"], Cell[6582, 283, 106, 2, 26, "Input"], Cell[6691, 287, 27, 0, 25, "Input"], Cell[6721, 289, 42, 0, 25, "Input"], Cell[6766, 291, 77, 0, 25, "Input"], Cell[6846, 293, 41, 1, 26, "Input"], Cell[6890, 296, 172, 4, 41, "Input"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[7111, 306, 53, 0, 39, "Section"], Cell[CellGroupData[{ Cell[7189, 310, 51, 0, 36, "Subsection"], Cell[7243, 312, 83, 2, 41, "Input"], Cell[7329, 316, 122, 3, 39, "Input"], Cell[7454, 321, 21, 0, 25, "Input"], Cell[7478, 323, 158, 3, 41, "Input"], Cell[7639, 328, 87, 1, 26, "Input"], Cell[7729, 331, 22, 0, 25, "Input"], Cell[7754, 333, 120, 3, 39, "Input"], Cell[7877, 338, 96, 3, 39, "Input"], Cell[7976, 343, 29, 0, 25, "Input"], Cell[8008, 345, 142, 2, 26, "Input"], Cell[8153, 349, 144, 3, 56, "Input"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[8346, 358, 23, 0, 39, "Section"], Cell[CellGroupData[{ Cell[8394, 362, 30, 0, 36, "Subsection"], Cell[8427, 364, 50, 1, 26, "Input"], Cell[8480, 367, 52, 1, 26, "Input"], Cell[8535, 370, 65, 1, 26, "Input"], Cell[8603, 373, 52, 1, 26, "Input"], Cell[8658, 376, 47, 1, 26, "Input"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[8754, 383, 31, 0, 39, "Section"], Cell[8788, 385, 52, 1, 26, "Input"], Cell[8843, 388, 52, 1, 26, "Input"], Cell[8898, 391, 45, 1, 26, "Input"], Cell[8946, 394, 246, 5, 72, "Input"], Cell[9195, 401, 78, 2, 41, "Input"] }, Closed]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)