11.11.2014 Views

Introductory Differential Equations using Sage - William Stein

Introductory Differential Equations using Sage - William Stein

Introductory Differential Equations using Sage - William Stein

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

1.3. EXISTENCE OF SOLUTIONS TO ODES 19<br />

Figure 1.5: Picard iteration for x ′ = 1 − x, x(0) = 2.<br />

sage: picard_iteration(f, a, c, 0)<br />

2<br />

sage: picard_iteration(f, a, c, 1)<br />

2 - t<br />

sage: picard_iteration(f, a, c, 2)<br />

tˆ2/2 - t + 2<br />

sage: picard_iteration(f, a, c, 3)<br />

-tˆ3/6 + tˆ2/2 - t + 2<br />

’’’<br />

if N == 0:<br />

return c*t**0<br />

if N == 1:<br />

x0 = lambda t: c + integral(f(s,c*s**0), s, a, t)<br />

return expand(x0(t))<br />

for i in range(N):<br />

x_old = lambda s: picard_iteration(f, a, c, N-1).subs(t=s)<br />

x0 = lambda t: c + integral(f(s,x_old(s)), s, a, t)<br />

return expand(x0(t))<br />

Exercises:<br />

1. Compute the first three Picard iterates for the IVP<br />

x ′ = 1 + xt, x(0) = 0

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

Saved successfully!

Ooh no, something went wrong!