21.04.2015 Views

The Computable Differential Equation Lecture ... - Bruce E. Shapiro

The Computable Differential Equation Lecture ... - Bruce E. Shapiro

The Computable Differential Equation Lecture ... - Bruce E. Shapiro

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 1. CLASSIFYING THE PROBLEM 21<br />

f[t , y ]:= Cos[t] - 2t Sin[t];<br />

solution=EulersMethod[f, 0, 1, 4Pi, .5]<br />

When we run the program it will return a list of values:<br />

{{0,1},{0.5,1.5},{1.,1.69908},{1.5, 1.12776},{2.,-0.333115},<br />

{2.5,-2.35978},{3.,-4.25654},{3.5,-5.17489},{4.,-4.41538},<br />

{4.5,-1.71499},{5.,2.5785},{5.5,7.51495},{6.,11.7498},{6.5, 13.9063},<br />

{7.,12.9963},{7.5,8.77439},{8., 1.91271},{8.5,-6.07491},{9.,-13.1631},<br />

{9.5,-17.3277},{10.,-17.1123},{10.5, -12.0917},{11.,-3.09262},<br />

{11.5,7.90948},{12.,18.2188},{12.5,25.0796}}<br />

Since we set the value of the variable solution equal to the return value of<br />

EulersMethod, Mathematica will remember the values in this list and we can use<br />

them again later. For example, suppose we want to make a plot of the solution. We<br />

can do this with the function ListPlot:<br />

ListPlot[solution]<br />

This plots the list of points using dots to represent each point:<br />

To plot the figure with the dots connected,<br />

ListPlot[solution, PlotJoined->True]<br />

To get a plot with a blue line and with small red dots,<br />

plot1 = ListPlot[solution, PlotStyle -> Red, PointSize[.02]];<br />

plot2 = ListPlot[solution, PlotJoined -> True, PlotStyle -> Blue];<br />

Show[plot1, plot2];<br />

c○2007, B.E.<strong>Shapiro</strong><br />

Last revised: May 23, 2007<br />

Math 582B, Spring 2007<br />

California State University Northridge

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!