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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 3. APPROXIMATE SOLUTIONS 45<br />

✬<br />

Algorithm 3.1. Forward Euler Method To solve the initial value<br />

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

✩<br />

1. input: f(t, y), t 0 , y 0 , h, t max<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 y = y + hf(t, y)<br />

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

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

(d) output: (t n , y n )<br />

✫<br />

✪<br />

Example 3.1. Solve y ′ = y, y(0) = 1 on the interval [0, 1] using h = 0.25.<br />

Solution. <strong>The</strong> exact solution is y = e x . We compute the values using Euler’s method.<br />

For any given time point t k , the value y k depends purely on the values of t k1 and<br />

y k1 . This is often a source of confusion for students: although the formula y k+1 =<br />

y k + hf(t k , y k ) only depends on t k and not on t k+1 it gives the value of y k+1 .<br />

We are given the following information:<br />

We first compute the solution at t = t 1 .<br />

(t 0 , y 0 ) = (0, 1) (3.16)<br />

f(t, y) = y (3.17)<br />

h = 0.25 (3.18)<br />

y 1 = y 0 + hf(t 0 , y 0 ) = 1 + (0.25)(1) = 1.25 (3.19)<br />

t 1 = t 0 + h = 0 + 0.25 = 0.25 (3.20)<br />

(t 1 , y 1 ) = (0.25, 1.25) (3.21)<br />

<strong>The</strong>n we compute the solutions at t = t 1 , t 2 , . . . until t k+1 = 1.<br />

y 2 = y 1 + hf(t 1 , y 1 ) (3.22)<br />

= 1.25 + (0.25)(1.25) = 1.5625 (3.23)<br />

t 2 = t 1 + h = 0.25 + 0.25 = 0.5 (3.24)<br />

(t 2 , y 2 ) = (0.5, 1.5625) (3.25)<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!