MATH 417 Lecture 17

From Notes
Jump to navigation Jump to search

« previous | Tuesday, March 25, 2014 | next »


Review

{y(t)=f(t,y(t))y(a)=α

For t[a,b].

Numerical Methods:

  1. Euler's Method:
    • w0=α
    • wn+1=wn+hf(th,wh)
    • error is |y(tn)wn|ChO(h)
    • one-step error is yn+1exact(yn+hf(tn,yn))O(h2) (but these errors accumulate).
  2. Taylor Series-based Method:
    • hT(n)(t,y)=h(f(t,y)+h2df(t,y(t)dt+h23!d2f(t,y(t))dt2+)
    • Need to know partial derivatives
    • T(n) local error = hn+1, and global error is hn
    • Euler's method is T(1).

Runge-Kutta Method

Replaces derivatives with nested function evaluations.

wn+1=wn+hf(tn+α,wn+βf(tn,wn))=

We want wn+1==yn+1+O(h3)

y(t+h)=y(t)+hy(t)+h22y(t)+O(h3)

The T(2) method uses y(t+h)y(t)+hf(t,y(t))+h22(ft(t,y(t))+fy(t,y(t))f(t,y(t)))+O(h3)


Second order Runge-Kutta method (RK-2) uses y(t+h)y+hf(t+α,y+βf(t,y))+O(h3)


Hence y(t)+hf(t,y(t))+h22(ft(t,y(t))+fy(t,y(t))f(t,y(t)))=y(t+h)+hf(t+α,y(t)+βf(t,y(t))) up to O(h3) difference.

Taylor Series for f(t,y):

f(t+Δt,y+Δy)=f(t,y)+Δtft(t,y)+Δyfy(t,y)+12!(Δt2ftt(t,y)+2ΔtΔyfty(t,y)+Δy2fyy(t,y))++1n!(k=0n(Δt)hk(Δy)k(nk)nktnkkykf(t,y))+O(|Δt|n+1+|Δy|n+1)


RK-2: y(t+h)y+hf(tα,y+βf(t,y)), where α,βO(h)

y(t+h)y+hf(tα,y+βf(t,y))=y(t)+h[f(t,y)+αft(t,y)+βf(t,y)fy(t,y)+O(α2+(βf)2]=y(t)+hf(t,y(t))+αhft+βhffy+hO(h2+h2f2)=T(2)(t,y)α=h2;β=h2

Hence RK-2 is the midpoint method: wn+1=wn+hf(tn+h2,wn+h2f(tn,wn))

If we let k1=hf(tn,wn), we can write wn+1=wn+hf(tn+h2,wn+12k1

Here comes the rule:

  1. w0=α
  2. n=0,1,2,
  3. k1=hf(tn,wn)
  4. wn+1=wn+hf(t+h2,wn+12k1)


Modified Euler

Based on trapezoidal rule to approximate y(tn+h)=y(tn)+tntn+hf(tn,y(tn))dt


y(tn+h)y(tn)+h2(y(tn)+y(tn+1))y(tn)+h2(f(tn,y(tn))+f(tn+h,y(tn+h)))

Use Euler's method to find y(tn+h)y(tn)+hf(tn,y(tn))

y(tn+h)y(tn)+h2(f(tn,y(tn))+f(tn+h,y(tn)+hf(tn,y(tn))))

To find our numeric method, let wn=y(tn) and wn+1=y(tn+h), then

wn+1=wn+h2(f(tn,wn)+f(tn+1,wn+hf(tn,wn)))


Heun's Method

Based on gaussian quadrature method to approximate yn+1=yn+tntn+hf(t,y(t)dtwn+h4f(tn,wn)+3h4f(tn+2h3,y(tn+2h3))

Here's the rule:

  • w0=α
  • n=0,1,2,
  • wn+1=wn+h4f(tn,wn)+3h4f(tn+2h3,wn+2h3f(tn,wn))

The book has an error by saying this is O(h3). It is RK-2, so it must be O(h2).


RK-4

  • w0=α
  • n=0,1,2,
  • k1=hf(tn,wn)
  • k2=hf(tn+h2,wn+12k1)
  • k3=hf(tn+h2,wn+12k2)
  • k4=hf(tn+h,wn+k3)
  • wn+1=wn+16(k1+2k2+2k3+k4)


Multi-Step Method

All methods we've discussed so far are 'one step methods: we only use wn to approximate wn+1.


Assume that you have computed ,(tn1,wn1);(tn,wn).

wn+1=wn+h720(1901f(tn,wn)2774f(tn1,wn1)+2616f(tn2,wn2)1274f(tn3,wn3)+251f(tn4,wn4))

This is an order 5 method, but it has oscillating coefficients (so it is numerically unstable)


Examples

No Solution Example

{y(t)=(y(t))2y(0)=1

  • f(t,y)=y2, which is continuous
  • |fy|=|2y|<C

Exact solution is y(t)=11t, the reason the lipschitz discontinuity is because there is a singularity at t=1

Example 2

{y(t)=y(t)+ty(0)=1

  • f(t,y)=y+t (continuous)
  • |fy|=1, so Lipschitz continuous

For 0t1 and h=0.5, let's find Euler, Midpoint, and Modified Euler approximations:


Euler

t0=0, t1=12, and t2=1.

  • w0=1
  • w1=w0+hf(t0,w0)=1+12f(0,1)=32
  • w2=w1+hf(t1,w1)=32+12f(12,32)=52


Midpoint

wn+1=wn+h2f(tn+h2,wn+h2f(tn,wn))

Something's wrong here...
  • w0=1
  • w1=1+12f(14,1+14f(0,1))=1+38=118
  • w2=118+12f(34+118,1+14f(12,118))=


Modified Euler

wn+1=wn+h2(f(tn,wn)+f(tn+h,wn+hf(tn,wn)))

k1=hf(tn,wn) simplifies the above to wn+12k1+h2f(tn+k1,wn+k1)

  • w0=1
  • w1=1+14(f(0,1)+f(12,1+12f(0,1)))=74
  • 74+14(f(12,74)+f(1,74+12f(12,74)))=