(************** 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[ 4885, 139]*) (*NotebookOutlinePosition[ 5820, 171]*) (* CellTagsIndexPosition[ 5776, 167]*) (*WindowFrame->Normal*) Notebook[{ Cell[TextData[{ "EULER'S METHOD NOTEBOOK: \n This is a routine designed to execute \ Euler's Method and compare\n the result to the exact solution to ", Cell[BoxData[ FormBox[ StyleBox[\(dy\/dx\), FontSize->18], TraditionalForm]]], " = f(x,y) when possible. \n The first sequence of commands executes \ Euler's Method to determine a table\n (called ytable) of approximate \ functional values at the designated nodes. Then\n these y-coordinates are \ paired with their respective x-coordinates to form\n points on the graph \ of the approximate solution. (Kendall Richards 3.29.06)" }], "Text", ImageRegion->{{0, 1}, {0, 1}}, FontSize->14, FontColor->RGBColor[0, 0, 1]], Cell["\<\ <", "Input", CellOpen->False, InitializationCell->True, ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "Clear[x,y,f,h,Y,p1,g1,t1,a,b]\n\n", StyleBox["f[x_,y_] :=x-x*y; ", FontColor->RGBColor[1, 0, 0]], StyleBox["(* From dy/dx = f[x,y] *)", FontSize->10, FontColor->RGBColor[1, 0, 0]], StyleBox["\n\nX0=1; ", FontColor->RGBColor[1, 0, 0]], StyleBox["(*X0 is the initial x-value*)\n", FontSize->10, FontColor->RGBColor[1, 0, 0]], StyleBox["Y0=0; ", FontColor->RGBColor[1, 0, 0]], StyleBox["(*Y0 is the initial y-value*)\n\n", FontSize->10, FontColor->RGBColor[1, 0, 0]], StyleBox["h=.1; ", FontColor->RGBColor[1, 0, 0]], StyleBox["(*Here h is the stepsize*)", FontSize->10, FontColor->RGBColor[1, 0, 0]], StyleBox["\nn=4; ", FontColor->RGBColor[1, 0, 0]], StyleBox["(*n is the number of steps *)", FontSize->10, FontColor->RGBColor[1, 0, 0]], StyleBox["\n\n\n", FontColor->RGBColor[0, 0, 1]], StyleBox["(* Mathematica commands to generate Euler iterates*) ", FontColor->RGBColor[0, 0, 1]], StyleBox["\nx[k_] := X0+k*h; ", FontColor->RGBColor[0, 0, 1]], StyleBox["\n", FontSize->10, FontColor->RGBColor[0, 0, 1]], StyleBox["y[0] = Y0;", FontColor->RGBColor[0, 0, 1]], StyleBox["\n", FontSize->10, FontColor->RGBColor[0, 0, 1]], StyleBox["y[k_] := y[k] = y[k-1] + f[x[k-1],y[k-1]]*h//N; ", FontColor->RGBColor[0, 0, 1]], StyleBox["(* y[k] = Euler's Approximates *)\n", FontSize->10, FontColor->RGBColor[0, 0, 1]], " ", StyleBox["\n", FontSize->10, FontColor->RGBColor[0, 0, 1]], " \n(* Mathematica commands to generate graphics and output*) \n\ t1=Table[Point[{x[k],y[k]}],{k,0,n}];\nymin=Min[Table[y[k],{k,0,n}]];\n\ ymax=Max[Table[y[k],{k,0,n}]];\ng1 = \ Graphics[{Hue[2],PointSize[.03],t1},DisplayFunction->Identity] ;\n\ p1=PlotVectorField[{1,f[x,y]},{x,X0-.1,x[n]+.1},{y,ymin-.1,ymax+.1},\ AspectRatio->Automatic,DisplayFunction\[Rule]Identity]\nPrint[\"Starting at \ X0 = \",X0, \" using n = \",n,\" steps of size h = \",h]\nPrint[\"the \ approximate value of the solution at x = \",x[n],\" is \", y[n]]\n\ Print[\"Calculus Rules.\"]\n\ Show[g1,p1,Axes->True,DisplayFunction->$DisplayFunction]\n\n\n" }], "Input", ImageRegion->{{0, 1}, {0, 1}}] }, FrontEndVersion->"5.0 for Macintosh", ScreenRectangle->{{41, 1440}, {0, 878}}, AutoGeneratedPackage->None, WindowToolbars->{}, CellGrouping->Manual, WindowSize->{874, 465}, WindowMargins->{{166, Automatic}, {Automatic, 100}}, PrintingCopies->1, PrintingPageRange->{1, Automatic}, PrivateNotebookOptions->{"ColorPalette"->{RGBColor, -1}}, ShowCellLabel->True, ShowCellTags->False, RenderingOptions->{"ObjectDithering"->True, "RasterDithering"->False} ] (******************************************************************* 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, 733, 15, 159, "Text"], Cell[2490, 68, 127, 6, 19, "Input", CellOpen->False, InitializationCell->True], Cell[2620, 76, 2261, 61, 475, "Input"] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)