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 4. IMPROVING ON EULER’S METHOD 85<br />

delta = yvaln-yvalp;<br />

If[Abs[delta] < tol, Break[]];<br />

];<br />

yval = yvaln;<br />

AppendTo[r, {time + h, yval}];<br />

];<br />

Return[r];<br />

]<br />

✬<br />

✩<br />

Algorithm 4.2. Backward Euler Method Using Newton’s<br />

Method To solve the initial value problem<br />

y ′ = f(t, y), y(t 0 ) = y 0<br />

on an interval [t 0 , t max ] with a fixed step size h.<br />

1. input: f(t, y), t 0 , y 0 , h, t max , tol<br />

2. output: (t 0 , y 0 )<br />

3. let t = t 0 , y = y 0<br />

4. while t < t max<br />

(a) let i = 0, y (0)<br />

n<br />

(b) Repeat:<br />

until |y (i+1)<br />

n<br />

y (i+1)<br />

n<br />

(c) let y = y (i+1)<br />

n<br />

(d) let t = t + h<br />

= y<br />

i = i + 1<br />

(e) let t n = t, y n = y<br />

= y (i)<br />

n<br />

− y (i)<br />

n | < tol<br />

− y(i) n<br />

(f) output: (t 0 , y 0 ), . . . , (t n , y n )<br />

− y n−1 − hf(t, y (i)<br />

n )<br />

1 − hf y (t, y (i)<br />

n )<br />

✫<br />

✪<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!