(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 3.0, MathReader 3.0, or any compatible application. The data for the notebook starts with the line of 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[ 32406, 1219]*) (*NotebookOutlinePosition[ 33518, 1255]*) (* CellTagsIndexPosition[ 33474, 1251]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell[TextData[{ "\nUsing Numerical Integration to Find the Value of ", StyleBox["e", FontSlant->"Italic"], "\n" }], "Title"], Cell["\<\ Some, but not all, of this notebook is based on material in the Green Lab \ manual. Read through the material for Projects 7.1, 7.2, and 7.3. You \ should also read the projects' descriptions in the text for Math 162 as well.\ \ \>", "Text"], Cell[CellGroupData[{ Cell[TextData[{ "Definition of ", StyleBox["e", FontSlant->"Italic"] }], "Section"], Cell["Look at the plot:", "Text"], Cell["\<\ Clear[f,t,a,b]; f[t_] := 1/t; a = 1; b = 3; Plot[{0,f[t]},{t,a,b}]\ \>", "Input"], Cell[TextData[{ "The function A[x_] :=\t", Cell[BoxData[ FormBox[ RowBox[{ StyleBox[\(\[Integral]\_1\^x\), FontSize->18], StyleBox[" ", FontSize->18], StyleBox[\(1/t\ dt\), FontSize->16]}], TraditionalForm]]], " gives the area under the curve and between ", Cell[BoxData[ \(TraditionalForm\`t = 1\)]], " and ", Cell[BoxData[ \(TraditionalForm\`t = x\)]], ". We know A'[x] = 1/x, and, in fact, A[x] is defined to be the natural \ logarithm of x, i.e. ln[x] or Log[x] in ", StyleBox["Mathematica", FontSlant->"Italic"], "'s notation." }], "Text"], Cell[TextData[{ "We know that there is a unique solution to the equation in ", StyleBox["x", FontSlant->"Italic"], ":" }], "Text"], Cell[TextData[{ "\t\t\t", Cell[BoxData[ FormBox[ RowBox[{ RowBox[{ StyleBox[\(\[Integral]\_1\^x\), FontSize->18], StyleBox[" ", FontSize->18], StyleBox[\(1/t\ dt\), FontSize->16]}], StyleBox[" ", FontSize->16], StyleBox["=", FontSize->16], StyleBox[" ", FontSize->16], StyleBox["1", FontSize->16]}], TraditionalForm]]] }], "Text"], Cell[TextData[{ "In other words, there is a place where the area under y = 1/t and between \ t=1 and t=x is exactly equal to 1. (This equation can also be written as ", Cell[BoxData[ \(TraditionalForm\`ln[x]\ = \ 1\)]], ".)" }], "Text"], Cell[TextData[{ "The number that satisfies the equation is usually called ", StyleBox["e.", FontSlant->"Italic"], " " }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell[" Riemann Sums and Numerical Integration.", "Section"], Cell["\<\ If you are in Sanders's class, you've been introduced to this material in \ lecture. If you're in Carbonara's class, you'll want to go over this in some \ detail.\ \>", "Text"], Cell["", "Text"], Cell[TextData[{ "Recall that ", Cell[BoxData[ \(TraditionalForm\`f[x]\ = \ ln[x]\)]], " is an increasing function. So \n", "\n", "\t\tif ln(b) < 1, we know b < ", StyleBox["e", FontSlant->"Italic"], " ", "\n", "and \n\t\tif ln(b) > 1, then we know b > e." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell[TextData[{ "Using Riemann sums to roughly locate the value of ", StyleBox["e", FontSlant->"Italic"], "." }], "Section"], Cell[TextData[{ "Since ", Cell[BoxData[ FormBox[ RowBox[{ RowBox[{\(ln[x]\), "=", RowBox[{ StyleBox[\(\[Integral]\_1\^x\), FontSize->18], StyleBox[" ", FontSize->18], StyleBox[\(1/t\ dt\), FontSize->16]}]}], StyleBox[" ", FontSize->16]}], TraditionalForm]]], ", we need to look at the area under ", Cell[BoxData[ \(TraditionalForm\`y = 1/t\)]], " from 1 to x." }], "Text"], Cell["\<\ Recall that f[t] is DECREASING. So \t\tLEFT Rectangle estimates are always TOO LARGE and \t\tRIGHT Rectangle estimates are always TOO SMALL\ \>", "Text"], Cell[CellGroupData[{ Cell[TextData[{ "Comparing 2 to ", StyleBox["e", FontSlant->"Italic"], ":" }], "Subsubsection"], Cell["\<\ f[t_] := 1/t; a = 1; b = 2; LeftRects[1]\ \>", "Input"], Cell[TextData[{ "So ln(2) < 1 and that makes ", StyleBox["e", FontSlant->"Italic"], " > 2." }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "Comparing 3 to ", StyleBox["e", FontSlant->"Italic"], ":" }], "Subsubsection"], Cell["\<\ a = 1; b = 3; RightRects[10]\ \>", "Input"], Cell[TextData[{ "So ln(3) > 1 and that makes ", StyleBox["e", FontSlant->"Italic"], " < 3. So we know 2 < ", StyleBox["e", FontSlant->"Italic"], " < 3" }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "Comparing 2.5 to ", StyleBox["e", FontSlant->"Italic"], ":" }], "Subsubsection"], Cell["\<\ a=1; b=2.5; LeftRects[10]\ \>", "Input"], Cell[TextData[{ "So ln(2.5) < 1 and ", StyleBox["e", FontSlant->"Italic"], " > 2.5. So we know 2.5 < ", StyleBox["e", FontSlant->"Italic"], " < 3" }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "Comparing 2.75 and ", StyleBox["e", FontSlant->"Italic"], ":" }], "Subsubsection"], Cell["\<\ a=1; b=2.75; RightRects[100]\ \>", "Input"], Cell[TextData[{ "So ln(2.75) > 1 and ", StyleBox["e", FontSlant->"Italic"], " < 2.75. So we know 2.5 < ", StyleBox["e", FontSlant->"Italic"], " < 2.75" }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "Comparing 2.7 and ", StyleBox["e", FontSlant->"Italic"], ":" }], "Subsubsection"], Cell["\<\ a=1; b=2.70; LeftRects[100]\ \>", "Input"], Cell[TextData[{ "So ln(2.70) < 1 and ", StyleBox["e", FontSlant->"Italic"], " > 2.70. So we know 2.70 < ", StyleBox["e", FontSlant->"Italic"], " < 2.75" }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "Comparing 2.72 and ", StyleBox["e", FontSlant->"Italic"], ":" }], "Subsubsection"], Cell["\<\ a=1; b=2.72; RightRects[1000]\ \>", "Input"], Cell[TextData[{ "So ln(2.72) > 1 (but barely bigger than 1) and ", StyleBox["e", FontSlant->"Italic"], " < 2.72. So we know 2.70 < ", StyleBox["e", FontSlant->"Italic"], " < 2.72 (and probably quite close to 2.72)" }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "Comparing 2.71 and ", StyleBox["e", FontSlant->"Italic"], ":" }], "Subsubsection"], Cell["\<\ a=1; b=2.71; LeftRects[500]\ \>", "Input"], Cell[TextData[{ "So ln(2.71) < 1 (but barely less than 1) and ", StyleBox["e", FontSlant->"Italic"], " > 2.71. So we know 2.71 < ", StyleBox["e", FontSlant->"Italic"], " < 2.72 (and probably closer to 2.72)" }], "Text"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[TextData[{ "Using Simpson's Rule to find ", StyleBox["e", FontSlant->"Italic"], " more precisely.\[AliasDelimiter]" }], "Section"], Cell[TextData[{ "Of course, rectangles converge to slowly to find good estimates of ", StyleBox["e", FontSlant->"Italic"], ". We can build better estimates by using Simpson's Rule. " }], "Text"], Cell[TextData[{ "Simpson's Rule can be programmed into ", StyleBox["Mathematica", FontSlant->"Italic"], " by" }], "Text"], Cell[BoxData[ \(Clear[SimpsonsRule]; \n SimpsonsRule[n_]\ := \ \n\t\ N[\ \ \(\(b - a\)\/\(6\ n\)\) \((f[a]\ + f[b]\ + \ \[Sum]\+\(i = 1\)\%\(n - 1\)\(( 2\ f[a\ + \ 2\ i\ \ \(b - a\)\/\(2 n\)]\ )\) + \ \[Sum]\+\(i = 0\)\%\(n - 1\)\((\ 4 f[a\ + \ \((2\ i\ + 1)\)\ \(b - a\)\/\(2 n\)])\))\)] \)], "Input", InitializationCell->True], Cell["\<\ We'll need to control the error as well. Recall that the error bound on \ Simpson's Rule is given by\ \>", "Text"], Cell[BoxData[ \(Clear[TheorecticalError, \ M]; TheorecticalError[n_]\ := \ N[\((\ \(b - a\)\/180)\)\ M\ \((\ \(b - a\)\/\(2 n\))\)\^4]\)], "Input",\ InitializationCell->True], Cell[TextData[{ "where ", StyleBox["M", FontSlant->"Italic"], " is a bound on the size of the fourth derivative. So lets look at the \ forth derivative of f[t] = 1/t" }], "Text"], Cell["f''''[t]", "Input"], Cell[TextData[{ "Exercise 1) Determine an appropriate bound for ", StyleBox["M", FontSlant->"Italic"], " on any interval of the sort [1,x] where x > 1. (Use the fact that \ f''''[x] is decreasing, and make a plot.)" }], "Text", FontColor->RGBColor[1, 0, 0]], Cell[TextData[{ "Exercise 2) Find a Simpson's Rule estimate (with error sufficiently \ small) that shows that ", StyleBox["e", FontSlant->"Italic"], " > 2.718. Hint: You need to find a Simpson's Rule estimate for \na = 1 \ and b= 2.718 with the estimate ", StyleBox["smaller", FontSlant->"Italic"], " than 1 and the ", StyleBox["error", FontSlant->"Italic"], " smaller than the difference between the estimate and 1. You may want to \ make ", StyleBox["Mathematica", FontSlant->"Italic"], " show more decimal places. You can do that using the N[ ] command. The \ cell below gives 10 significant digits of the 2 parabola estimate, which is \ too large for this problem. " }], "Text", FontColor->RGBColor[1, 0, 0]], Cell["\<\ a=1; b=2.718; N[SimpsonsRule[2],10]\ \>", "Input"], Cell[TextData[{ "Exercise 3) Find a Simpson's Rule estimate (with error sufficiently \ small) that shows that ", StyleBox["e", FontSlant->"Italic"], " < 2.719. See the hints on Problem 2." }], "Text", FontColor->RGBColor[1, 0, 0]], Cell[TextData[{ "Exercise 4) Use Simpson's Rule to determine if ", StyleBox["e", FontSlant->"Italic"], " is larger than or smaller than 2.7185." }], "Text", FontColor->RGBColor[1, 0, 0]], Cell["\<\ Exercise 5) (12 points) Keep using Simpson's Rule to refine your estimate for \ E by coming up with two seven digit approximations that bracket E (one's known \ to be larger and one's known to be smaller) and that both round to 2.71828. \ Your work for this problem shows that E also rounds to 2.71828.\ \>", "Text", FontColor->RGBColor[1, 0, 0]] }, Closed]], Cell[CellGroupData[{ Cell["Initialization Cells---No need to open this group", "Section", Evaluatable->False, InitializationCell->True, AspectRatioFixed->True], Cell[CellGroupData[{ Cell["General", "Subsection", InitializationCell->True], Cell["Read in the Graphics package, Colors.m and turn off spell", "Text", InitializationCell->True], Cell["\<\ Needs[\"Graphics`Colors`\"] Off[General::Spell]\ \>", "Input", InitializationCell->True], Cell["\<\ Make sure that the picture of the function is drawn correctly:\ \>", "Text", InitializationCell->True], Cell[BoxData[{ \(Clear[f, x, \ a, \ b, \ picture]\), \(picture\ := \ Plot[{f[x], 0}, {x, a, b}, \n \t\t\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ DisplayFunction -> Identity]\)}], "Input", InitializationCell->True], Cell["\<\ Define jump[n], the width of each subinterval in the partition:\ \>", "Text", InitializationCell->True], Cell["\<\ Clear[n,jump] jump[n_] := (b-a)/n;\ \>", "Input", InitializationCell->True], Cell["Commands for drawing the partition lines in Purple", "Text", InitializationCell->True], Cell["\<\ Clear[SliceLine] SliceLine[k_,n_] := Graphics[{Purple, Line[{{a + k jump[n], 0}, {a + k jump[n], f[a + k jump[n]]}}] }]\ \>", "Input", InitializationCell->True], Cell["\<\ Slices[n_] := Show[picture, Table[SliceLine[k,n],{k,0,n}], DisplayFunction->$DisplayFunction]\ \>", "Input", InitializationCell->True] }, Closed]], Cell[CellGroupData[{ Cell["Parabolas", "Subsection", InitializationCell->True], Cell["Parabolas in pictures", "Text", InitializationCell->True], Cell["\<\ Clear[ParabolasPicture, ParabolaTop] ParabolaTop[k_,n_] := Module[{x1, x2, x3, a0, a1, a2, coeffs, c0, c1, c2}, {x3 = a + (2 k)jump[2 n]; x2 = a + (2 k - 1)jump[2 n]; x1 = a + (2 k - 2)jump[2 n]; coeffs = Solve[{ \t\t\tf[x1] == a0 + a1 x1 + a2 (x1)^2, \t\t\tf[x2] == a0 + a1 x2 + a2 (x2)^2, \t\t\tf[x3] == a0 + a1 x3 + a2 (x3)^2}, \t\t\t {a0, a1, a2}]; c0 = If[coeffs[[1,1,1]] === a0, c0 = coeffs[[1,1,2]], \t\t If[coeffs[[1,2,1]] === a0, \t\t\t c0 = coeffs[[1,2,2]], \t\t\t c0 = coeffs[[1,3,2]] \t\t\t ]]; c1 = If[coeffs[[1,1,1]] === a1, c1 = coeffs[[1,1,2]], \t\t If[coeffs[[1,2,1]] === a1, \t\t\t c1 = coeffs[[1,2,2]], \t\t\t c1 = coeffs[[1,3,2]] \t\t\t ]]; c2 = If[coeffs[[1,1,1]] === a2, c2 = coeffs[[1,1,2]], \t\t If[coeffs[[1,2,1]] === a2, \t\t\t c2 = coeffs[[1,2,2]], \t\t\t c2 = coeffs[[1,3,2]] \t\t\t ]]; Plot[c0 + c1 x + c2 x^2, {x, x1, x3}, \t\t PlotStyle->{{Green}}, \t\t \t\t DisplayFunction->Identity] \t\t } \t\t ]\ \>", "Input", InitializationCell->True], Cell["\<\ ParabolasPicture[n_] := Show[picture, Table[SliceLine[k,2 n],{k,0,2 n}], Table[ParabolaTop[k,n],{k,1,n}], DisplayFunction->$DisplayFunction]\ \>", "Input", InitializationCell->True], Cell["\<\ ParabolasPicture::usage = \"ParabolasPictures[n] draws a picture of the parabolic estimate. The function f and the values a and b must already \ be defined.\";\ \>", "Input", InitializationCell->True], Cell[BoxData[ \(Clear[SimpsonsRule]; \n SimpsonsRule[n_]\ := \ \n\t\ N[\ \ \(\(b - a\)\/\(6\ n\)\) \((f[a]\ + f[b]\ + \ \[Sum]\+\(i = 1\)\%\(n - 1\)\(( 2\ f[a\ + \ 2\ i\ \ \(b - a\)\/\(2 n\)]\ )\) + \ \[Sum]\+\(i = 0\)\%\(n - 1\)\((\ 4 f[a\ + \ \((2\ i\ + 1)\)\ \(b - a\)\/\(2 n\)])\))\)] \)], "Input", InitializationCell->True], Cell["\<\ SimpsonsRule::usage = \"SimpsonsRule[n] gives the numerical estimate using n parabolas. The function f and the values a and b must already be \ defined.\";\ \>", "Input", InitializationCell->True], Cell["\<\ Clear[Parabolas] Parabolas[n_] := \tModule[{pe}, \t\t\tParabolasPicture[n]; \t\t\tpe = SimpsonsRule[n]; \t\t\tPrint[\"Parabolas estimate is \",pe] \t\t ]\ \>", "Input", InitializationCell->True], Cell["\<\ Parabolas::usage = \"Parabolas[n] draws a picture of the parabolic estimate \ using n parabolas and prints out the estimate. The function f and the values \ a and b must already be defined.\";\ \>", "Input", InitializationCell->True] }, Closed]], Cell[CellGroupData[{ Cell["Right Rectangles", "Subsection", InitializationCell->True], Cell["Commands for showing Right-hand rule rectangles", "Text", Evaluatable->False, InitializationCell->True], Cell["\<\ Clear[RightRectanglesPicture, RightHandTop] RightHandTop[k_,n_] := Graphics[{{Blue, Line[{ {a + (k-1) jump[n], f[a + k jump[n]]}, {a + k jump[n], f[a + k jump[n]]}}] }, If[Abs[f[a + k jump[n]]] > Abs[f[a + (k-1) jump[n]]], {Blue, Line[{ {a + (k-1) jump[n], f[a + k jump[n]]}, {a + (k-1) jump[n], f[a + (k-1)jump[n]]} }] }, {Blue, Point[{a + (k-1) jump[n], f[a + (k-1) jump[n]]}] }]}] \ \>", "Input", InitializationCell->True], Cell["\<\ RightRectanglesPicture[n_] := Show[picture, Table[SliceLine[k,n],{k,0,n}], Table[RightHandTop[k,n],{k,1,n}], DisplayFunction->$DisplayFunction]\ \>", "Input", InitializationCell->True], Cell["\<\ RightRectanglesPicture::usage = \"RightRectanglesPictures[n] draws a picture \ of the right rectangle estimate. The function f and the values a and b must \ already be defined.\";\ \>", "Input", InitializationCell->True], Cell[BoxData[ RowBox[{\(Clear[RightRectsEst]\), ";", "\n", RowBox[{\(RightRectsEst[n_]\), " ", ":=", " ", "\n", " ", RowBox[{"N", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"b", StyleBox[" ", FontSize->11, FontWeight->"Plain"], "-", StyleBox[" ", FontSize->11, FontWeight->"Plain"], "a"}], ")"}], "/", "n"}], StyleBox[" ", FontSize->11, FontWeight->"Plain"], "*", StyleBox[" ", FontSize->11, FontWeight->"Plain"], RowBox[{"Sum", "[", RowBox[{ RowBox[{"f", "[", RowBox[{"a", " ", "+", " ", RowBox[{"i", " ", RowBox[{ RowBox[{"(", RowBox[{"b", StyleBox[" ", FontSize->11, FontWeight->"Plain"], "-", StyleBox[" ", FontSize->11, FontWeight->"Plain"], "a"}], ")"}], "/", "n"}]}]}], "]"}], ",", "\n", "\t \ ", RowBox[{"{", \(i, \ 1, \ n\), StyleBox[" ", FontSize->11, FontWeight->"Plain"], "}"}]}], "]"}]}], "]"}]}]}]], "Input", InitializationCell->True], Cell["\<\ RightRectsEst::usage = \"RightRectsEst[n] gives the numerical estimate using n right rectangles. The function f and the values a and b must already \ be defined.\";\ \>", "Input", InitializationCell->True], Cell["\<\ Clear[RightRects] RightRects[n_] := \tModule[{re}, \t\t\tRightRectanglesPicture[n]; \t\t\tre = RightRectsEst[n]; \t\t\tPrint[\"Right Rectangle estimate is \",re] \t\t ]\ \>", "Input", InitializationCell->True], Cell["\<\ RightRects::usage = \"RightRects[n] draws a picture of the right rectangle \ estimate using n rectangles and prints out the estimate. The function f and \ the values a and b must already be defined.\";\ \>", "Input", InitializationCell->True] }, Closed]], Cell[CellGroupData[{ Cell["Left Rectangles", "Subsection", InitializationCell->True], Cell["\<\ The commands for drawing the picture for Left-hand rule rectangles.\ \>", "Text", Evaluatable->False, InitializationCell->True], Cell["\<\ Clear[LeftRectanglesPicture, LeftHandTop] LeftHandTop[k_,n_] := Graphics[{{Red, Line[{ {a + (k-1) jump[n], f[a + (k-1) jump[n]]}, {a + k jump[n], f[a + (k-1) jump[n]]}}] }, If[Abs[f[a + k jump[n]]] < Abs[f[a + (k-1) jump[n]]], {Red, Line[{ {a + k jump[n], f[a + k jump[n]]}, {a + k jump[n], f[a + (k-1) jump[n]]} }] }, {Red, Point[{a + k jump[n], f[a + k jump[n]]}] }]}]\ \>", "Input", InitializationCell->True], Cell["\<\ LeftRectanglesPicture[n_] := Show[picture, Table[SliceLine[k,n],{k,0,n}], Table[LeftHandTop[k,n],{k,1,n}], DisplayFunction->$DisplayFunction]\ \>", "Input", InitializationCell->True], Cell["\<\ LeftRectanglesPicture::usage = \"LeftRectanglesPictures[n] draws a picture of \ the left rectangle estimate. The function f and the values a and b must \ already be defined.\";\ \>", "Input", InitializationCell->True], Cell[BoxData[ RowBox[{\(Clear[LeftRectsEst]\), ";", "\n", RowBox[{\(LeftRectsEst[n_]\), " ", ":=", " ", "\n", " ", RowBox[{"N", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"b", StyleBox[" ", FontSize->11, FontWeight->"Plain"], "-", StyleBox[" ", FontSize->11, FontWeight->"Plain"], "a"}], ")"}], "/", "n"}], StyleBox[" ", FontSize->11, FontWeight->"Plain"], "*", StyleBox[" ", FontSize->11, FontWeight->"Plain"], RowBox[{"Sum", "[", RowBox[{ RowBox[{"f", "[", RowBox[{"a", " ", "+", " ", RowBox[{"i", " ", RowBox[{ RowBox[{"(", RowBox[{"b", StyleBox[" ", FontSize->11, FontWeight->"Plain"], "-", StyleBox[" ", FontSize->11, FontWeight->"Plain"], "a"}], ")"}], "/", "n"}]}]}], "]"}], ",", "\n", "\t \ ", RowBox[{"{", RowBox[{"i", ",", " ", "0", ",", " ", RowBox[{"n", StyleBox[" ", FontSize->11, FontWeight->"Plain"], "-", StyleBox[" ", FontSize->11, FontWeight->"Plain"], "1"}]}], "}"}]}], "]"}]}], "]"}]}]}]], "Input", InitializationCell->True], Cell["\<\ LeftRectsEst::usage = \"LeftRectsEst[n] gives the numerical estimate using n left rectangles. The function f and the values a and b must already \ be defined.\";\ \>", "Input", InitializationCell->True], Cell["\<\ Clear[LeftRects] LeftRects[n_] := \tModule[{le}, \t\t\tLeftRectanglesPicture[n]; \t\t\tle = LeftRectsEst[n]; \t\t\tPrint[\"Left Rectangle estimate is \",le] \t\t ]\ \>", "Input", InitializationCell->True], Cell["\<\ LeftRects::usage = \"LeftRects[n] draws a picture of the left rectangle \ estimate using n rectangles and prints out the estimate. The function f and \ the values a and b must already be defined.\";\ \>", "Input", InitializationCell->True] }, Closed]], Cell[CellGroupData[{ Cell["Middle Rectangles", "Subsection", InitializationCell->True], Cell["Commands for showing \"Midpoint Rule\" rectangles.", "Text", Evaluatable->False, InitializationCell->True], Cell["\<\ Clear[MiddleRectanglesPicture, MidpointTop] MidpointTop[k_,n_] := Graphics[ {{Brick, Line[{ {a + (k-1) jump[n], f[(a + (k-1) jump[n] + a + k jump[n])/2]}, {a + k jump[n], f[(a + (k-1) jump[n] + a + k jump[n])/2]} }]}, If[Abs[f[a + k jump[n]]] < Abs[f[(a + (k-1) jump[n] + a + k jump[n])/2]], {Brick, Line[{ {a + k jump[n], f[a + k jump[n]]}, {a + k jump[n], f[(a + (k-1) jump[n] + a + k jump[n])/2]} }] }, {Brick, Point[{a + k jump[n], f[(a + (k-1) jump[n] + a + k jump[n])/2]}] }], If[Abs[f[a + (k-1) jump[n]]] < Abs[f[(a + (k-1) jump[n] + a + k jump[n])/2]], {Brick, Line[{ {a + (k-1) jump[n], f[a + (k-1) jump[n]]}, {a + (k-1) jump[n], f[(a + (k-1) jump[n] + a + k jump[n])/2]} }] }, {Brick, Point[{a + (k-1) jump[n], f[(a + (k-1) jump[n] + a + k jump[n])/2]}] }] }]\ \>", "Input", InitializationCell->True], Cell["\<\ MiddleRectanglesPicture[n_] := Show[picture, Table[SliceLine[k,n],{k,0,n}], Table[MidpointTop[k,n],{k,1,n}], DisplayFunction->$DisplayFunction]\ \>", "Input", InitializationCell->True], Cell["\<\ MiddleRectanglesPicture::usage = \"MiddleRectanglesPictures[n] draws a \ picture of the middle rectangle estimate. The function f and the values a \ and b must already be defined.\";\ \>", "Input", InitializationCell->True], Cell[BoxData[ RowBox[{\(Clear[MidRectsEst]\), ";", "\n", RowBox[{\(MidRectsEst[n_]\), " ", ":=", " ", "\n", " ", RowBox[{"N", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"b", StyleBox[" ", FontSize->11, FontWeight->"Plain"], "-", StyleBox[" ", FontSize->11, FontWeight->"Plain"], "a"}], ")"}], "/", "n"}], StyleBox[" ", FontSize->11, FontWeight->"Plain"], "*", StyleBox[" ", FontSize->11, FontWeight->"Plain"], RowBox[{"Sum", "[", RowBox[{ RowBox[{"f", "[", RowBox[{"a", " ", "+", " ", RowBox[{\((i\ + \ 1/2)\), " ", RowBox[{ RowBox[{"(", RowBox[{"b", StyleBox[" ", FontSize->11, FontWeight->"Plain"], "-", StyleBox[" ", FontSize->11, FontWeight->"Plain"], "a"}], ")"}], "/", "n"}]}]}], "]"}], ",", "\n", "\t\t\t\t \ ", RowBox[{"{", RowBox[{"i", ",", " ", "0", ",", " ", RowBox[{"n", StyleBox[" ", FontSize->11, FontWeight->"Plain"], "-", StyleBox[" ", FontSize->11, FontWeight->"Plain"], "1"}]}], "}"}]}], "]"}]}], "]"}]}]}]], "Input", InitializationCell->True], Cell["\<\ MidRectsEst::usage = \"MidRectsEst[n] gives the numerical estimate using n middle rectangles. The function f and the values a and b must \ already be defined.\";\ \>", "Input", InitializationCell->True], Cell["\<\ Clear[MiddleRects] MiddleRects[n_] := \tModule[{me}, \t\t\tMiddleRectanglesPicture[n]; \t\t\tme = MidRectsEst[n]; \t\t\tPrint[\"Middle Rectangle estimate is \",me] \t\t ]\ \>", "Input", InitializationCell->True], Cell["\<\ MiddleRects::usage = \"MiddleRects[n] draws a picture of the middle rectangle \ estimate using n rectangles and prints out the estimate. The function f and \ the values a and b must already be defined.\";\ \>", "Input", InitializationCell->True] }, Closed]], Cell[CellGroupData[{ Cell["Trapezoids", "Subsection", InitializationCell->True], Cell["\<\ Clear[TrapezoidsPicture, TrapTop] TrapTop[k_,n_] := Graphics[{Orange, Line[{ {a + (k-1) jump[n], f[a + (k-1) jump[n]]}, {a + k jump[n], f[a + k jump[n]]}}] }]\ \>", "Input", InitializationCell->True], Cell["\<\ TrapezoidsPicture[n_] := Show[picture, Table[SliceLine[k,n],{k,0,n}], Table[TrapTop[k,n],{k,1,n}], DisplayFunction->$DisplayFunction]\ \>", "Input", InitializationCell->True], Cell["\<\ TrapezoidsPicture::usage = \"TrapezoidsPicture[n] draws a picture of the \ trapezoid estimate. The function f and the values a and b must already be \ defined.\";\ \>", "Input", InitializationCell->True], Cell[BoxData[ \(Clear[TrapsEst]; \n TrapsEst[n_]\ := \ N[\ \((b\ - \ a)\)/n\ *\n\ \((\((f[a]\ + \ f[b])\)/2\ + \ Sum[f[a\ + \ i\ \((b\ - \ a)\)/n], \n \t\t\t\t\t\t\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {i, \ 1, \ n - 1}])\)]\)], "Input", InitializationCell->True], Cell["\<\ TrapsEst::usage = \"TrapsEst[n] gives the numerical estimate using n trapezoids. The function f and the values a and b must already be \ defined.\";\ \>", "Input", InitializationCell->True], Cell["\<\ Clear[Traps] Traps[n_] := \tModule[{te}, \t\t\tTrapezoidsPicture[n]; \t\t\tte = TrapsEst[n]; \t\t\tPrint[\"Trapezoids estimate is \",te] \t\t ]\ \>", "Input", InitializationCell->True], Cell["\<\ Traps::usage = \"Traps[n] draws a picture of the trapezoid estimate using n \ trapezoids and prints out the estimate. The function f and the values a and \ b must already be defined.\";\ \>", "Input", InitializationCell->True] }, Closed]], Cell[CellGroupData[{ Cell["Random Rectangles", "Subsection", InitializationCell->True], Cell["Commands for drawing Random Rectangles", "Text", Evaluatable->False, InitializationCell->True], Cell["\<\ Clear[RandomRects, RandomRtop] RandomRtop[k_,n_] := Module[{xk, RandomRectSum}, xk = a + (k-1 + Random[ ])jump[n]; rk = jump[n]*f[xk]; {Graphics[{{DeepPink, Line[{ {a + (k-1) jump[n], f[xk]}, {a + k jump[n], f[xk]}}] }, If[Abs[f[xk]] > Abs[f[a + k jump[n]]], {DeepPink, Line[{ {a + k jump[n], f[xk]}, {a + k jump[n], f[a + k jump[n]]} }] }, {DeepPink, Point[{a + k jump[n], f[xk]}] }], If[Abs[f[xk]] > Abs[f[a + (k-1) jump[n]]], {DeepPink, Line[{ {a + (k-1) jump[n], f[xk]}, {a + (k-1) jump[n], f[a + (k-1) jump[n]]} }] }, {DeepPink, Point[{a + (k-1) jump[n], f[xk]}] }] }], rk}]\ \>", "Input", InitializationCell->True], Cell["\<\ RandomRects[n_] := \tModule[{tops, areasum, currentslice}, \t\t\tareasum = 0; \t\t\ttops = { }; \t\t\t \t\t\tDo[{currentslice = RandomRtop[k,n]; \t\t\t\tareasum = areasum + currentslice[[2]]; \t\t\t\ttops = Append[tops, currentslice[[1]]]}, \t\t\t\t{k,1,n}]; \t Show[picture, Table[SliceLine[k,n],{k,0,n}], Table[tops[[k]],{k,1,n}], \t\t DisplayFunction->$DisplayFunction]; \t\t Print[\"Random Rectangle estimate is \",areasum] ]\ \>", "Input", InitializationCell->True], Cell["\<\ RandomRects::usage = \"RandomRects[n] draws a picture of a random rectangle \ estimate using n rectangles and prints out the estimate. The function f and \ the values a and b must already be defined.\";\ \>", "Input", InitializationCell->True] }, Closed]] }, Closed]] }, Open ]] }, FrontEndVersion->"Macintosh 3.0", ScreenRectangle->{{0, 800}, {0, 580}}, AutoGeneratedPackage->None, WindowToolbars->{}, WindowSize->{525, 492}, WindowMargins->{{50, Automatic}, {Automatic, 15}}, PrivateNotebookOptions->{"ColorPalette"->{RGBColor, -1}}, ShowCellLabel->True, ShowCellTags->False, RenderingOptions->{"ObjectDithering"->True, "RasterDithering"->False}, Magnification->1, StyleDefinitions -> "ACStyles.nb", MacintoshSystemPageSetup->"\<\ 00<0001804P000000]P2:?oQon82n@960dL5:0?l0080001804P000000]P2:001 0000I00000400`<300000BL?00400@0000000000000006P801T1T00000000000 00000000000000000000000000000000\>" ] (*********************************************************************** 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[1731, 51, 135, 5, 228, "Title"], Cell[1869, 58, 253, 5, 122, "Text"], Cell[CellGroupData[{ Cell[2147, 67, 91, 4, 55, "Section"], Cell[2241, 73, 33, 0, 33, "Text"], Cell[2277, 75, 91, 6, 92, "Input"], Cell[2371, 83, 664, 22, 77, "Text"], Cell[3038, 107, 140, 5, 33, "Text"], Cell[3181, 114, 530, 20, 39, "Text"], Cell[3714, 136, 250, 6, 52, "Text"], Cell[3967, 144, 140, 5, 33, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[4144, 154, 59, 0, 35, "Section"], Cell[4206, 156, 187, 4, 52, "Text"], Cell[4396, 162, 16, 0, 33, "Text"], Cell[4415, 164, 298, 12, 109, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[4750, 181, 134, 5, 35, "Section"], Cell[4887, 188, 540, 19, 39, "Text"], Cell[5430, 209, 167, 6, 109, "Text"], Cell[CellGroupData[{ Cell[5622, 219, 105, 5, 44, "Subsubsection"], Cell[5730, 226, 65, 5, 76, "Input"], Cell[5798, 233, 113, 5, 33, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[5948, 243, 105, 5, 44, "Subsubsection"], Cell[6056, 250, 53, 4, 60, "Input"], Cell[6112, 256, 182, 8, 33, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[6331, 269, 107, 5, 44, "Subsubsection"], Cell[6441, 276, 50, 4, 60, "Input"], Cell[6494, 282, 177, 8, 33, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[6708, 295, 109, 5, 44, "Subsubsection"], Cell[6820, 302, 53, 4, 60, "Input"], Cell[6876, 308, 182, 8, 33, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[7095, 321, 108, 5, 44, "Subsubsection"], Cell[7206, 328, 52, 4, 60, "Input"], Cell[7261, 334, 183, 8, 33, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[7481, 347, 109, 5, 44, "Subsubsection"], Cell[7593, 354, 54, 4, 60, "Input"], Cell[7650, 360, 245, 8, 52, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[7932, 373, 109, 5, 44, "Subsubsection"], Cell[8044, 380, 52, 4, 60, "Input"], Cell[8099, 386, 238, 8, 52, "Text"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[8386, 400, 145, 5, 35, "Section"], Cell[8534, 407, 208, 5, 52, "Text"], Cell[8745, 414, 131, 5, 33, "Text"], Cell[8879, 421, 440, 10, 153, "Input", InitializationCell->True], Cell[9322, 433, 125, 3, 52, "Text"], Cell[9450, 438, 195, 5, 67, "Input", InitializationCell->True], Cell[9648, 445, 189, 6, 52, "Text"], Cell[9840, 453, 25, 0, 28, "Input"], Cell[9868, 455, 271, 7, 52, "Text"], Cell[10142, 464, 756, 20, 147, "Text"], Cell[10901, 486, 60, 4, 60, "Input"], Cell[10964, 492, 245, 7, 52, "Text"], Cell[11212, 501, 199, 6, 52, "Text"], Cell[11414, 509, 360, 7, 90, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[11811, 521, 144, 3, 35, "Section", Evaluatable->False, InitializationCell->True], Cell[CellGroupData[{ Cell[11980, 528, 57, 1, 46, "Subsection", InitializationCell->True], Cell[12040, 531, 101, 1, 27, "Text", InitializationCell->True], Cell[12144, 534, 100, 4, 35, "Input", InitializationCell->True], Cell[12247, 540, 114, 3, 27, "Text", InitializationCell->True], Cell[12364, 545, 269, 6, 51, "Input", InitializationCell->True], Cell[12636, 553, 115, 3, 27, "Text", InitializationCell->True], Cell[12754, 558, 87, 4, 35, "Input", InitializationCell->True], Cell[12844, 564, 94, 1, 27, "Text", InitializationCell->True], Cell[12941, 567, 226, 8, 86, "Input", InitializationCell->True], Cell[13170, 577, 168, 6, 60, "Input", InitializationCell->True] }, Closed]], Cell[CellGroupData[{ Cell[13375, 588, 59, 1, 30, "Subsection", InitializationCell->True], Cell[13437, 591, 65, 1, 33, "Text", InitializationCell->True], Cell[13505, 594, 1134, 40, 684, "Input", InitializationCell->True], Cell[14642, 636, 225, 7, 92, "Input", InitializationCell->True], Cell[14870, 645, 214, 5, 76, "Input", InitializationCell->True], Cell[15087, 652, 440, 10, 153, "Input", InitializationCell->True], Cell[15530, 664, 209, 5, 76, "Input", InitializationCell->True], Cell[15742, 671, 207, 9, 124, "Input", InitializationCell->True], Cell[15952, 682, 246, 5, 92, "Input", InitializationCell->True] }, Closed]], Cell[CellGroupData[{ Cell[16235, 692, 66, 1, 30, "Subsection", InitializationCell->True], Cell[16304, 695, 113, 2, 27, "Text", Evaluatable->False, InitializationCell->True], Cell[16420, 699, 662, 19, 227, "Input", InitializationCell->True], Cell[17085, 720, 228, 7, 73, "Input", InitializationCell->True], Cell[17316, 729, 233, 5, 48, "Input", InitializationCell->True], Cell[17552, 736, 1649, 42, 65, "Input", InitializationCell->True], Cell[19204, 780, 218, 5, 48, "Input", InitializationCell->True], Cell[19425, 787, 222, 9, 99, "Input", InitializationCell->True], Cell[19650, 798, 255, 5, 48, "Input", InitializationCell->True] }, Closed]], Cell[CellGroupData[{ Cell[19942, 808, 65, 1, 30, "Subsection", InitializationCell->True], Cell[20010, 811, 141, 4, 27, "Text", Evaluatable->False, InitializationCell->True], Cell[20154, 817, 647, 19, 227, "Input", InitializationCell->True], Cell[20804, 838, 226, 7, 73, "Input", InitializationCell->True], Cell[21033, 847, 230, 5, 48, "Input", InitializationCell->True], Cell[21266, 854, 1876, 47, 65, "Input", InitializationCell->True], Cell[23145, 903, 215, 5, 48, "Input", InitializationCell->True], Cell[23363, 910, 217, 9, 99, "Input", InitializationCell->True], Cell[23583, 921, 252, 5, 48, "Input", InitializationCell->True] }, Closed]], Cell[CellGroupData[{ Cell[23872, 931, 67, 1, 30, "Subsection", InitializationCell->True], Cell[23942, 934, 116, 2, 27, "Text", Evaluatable->False, InitializationCell->True], Cell[24061, 938, 1155, 39, 483, "Input", InitializationCell->True], Cell[25219, 979, 228, 7, 73, "Input", InitializationCell->True], Cell[25450, 988, 236, 5, 48, "Input", InitializationCell->True], Cell[25689, 995, 1890, 47, 65, "Input", InitializationCell->True], Cell[27582, 1044, 215, 5, 48, "Input", InitializationCell->True], Cell[27800, 1051, 224, 9, 99, "Input", InitializationCell->True], Cell[28027, 1062, 258, 5, 48, "Input", InitializationCell->True] }, Closed]], Cell[CellGroupData[{ Cell[28322, 1072, 60, 1, 30, "Subsection", InitializationCell->True], Cell[28385, 1075, 319, 11, 124, "Input", InitializationCell->True], Cell[28707, 1088, 218, 7, 73, "Input", InitializationCell->True], Cell[28928, 1097, 216, 5, 48, "Input", InitializationCell->True], Cell[29147, 1104, 426, 9, 65, "Input", InitializationCell->True], Cell[29576, 1115, 202, 5, 48, "Input", InitializationCell->True], Cell[29781, 1122, 197, 9, 99, "Input", InitializationCell->True], Cell[29981, 1133, 239, 5, 48, "Input", InitializationCell->True] }, Closed]], Cell[CellGroupData[{ Cell[30257, 1143, 67, 1, 30, "Subsection", InitializationCell->True], Cell[30327, 1146, 104, 2, 27, "Text", Evaluatable->False, InitializationCell->True], Cell[30434, 1150, 1098, 36, 444, "Input", InitializationCell->True], Cell[31535, 1188, 572, 19, 227, "Input", InitializationCell->True], Cell[32110, 1209, 256, 5, 48, "Input", InitializationCell->True] }, Closed]] }, Closed]] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)