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 17<br />

for 0 ≤ t ≤ 100, the command is<br />

ns = NDSolve[{y’[t]==-x[t]-.1y[t], x’[t]==3y[t],<br />

y[0]==Sqrt[3], x[0]==1 },<br />

{x[t], y[t]}, {t, 0, 1000}]<br />

<strong>The</strong> solution is returned is<br />

{{x[t] → InterpolatingFunction[{{0.,1000.}}, ][t]<br />

y[t] → InterpolatingFunction[{{0.,1000.}}, ][t]}}<br />

<strong>The</strong> interpolating functions can be treated like any other function. For example, to<br />

plot the solution for x(t) from t = 0 to t = 25,<br />

Plot[Evaluate[x[t] /. ns], t, 0, 25]<br />

To plot both x(t) and y(t) from t = 0 to t = 100, with x plotted in red, and y<br />

plotted in blue, ⇐=<br />

Plot[Evaluate[{x[t], y[t]} /.<br />

ns],<br />

{t, 0, 100}, PlotStyle -> {Red, Blue}, PlotRange -> All]<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!