The Computable Differential Equation Lecture ... - Bruce E. Shapiro

The Computable Differential Equation Lecture ... - Bruce E. Shapiro The Computable Differential Equation Lecture ... - Bruce E. Shapiro

bruce.shapiro.com
from bruce.shapiro.com More from this publisher
21.04.2015 Views

90 CHAPTER 5. RUNGE-KUTTA METHODS error of h p . We also observe that O(h) Taylor method is equivalent to Euler’s method. The second order Taylor method has y n = y n−1 + hf + h2 2 (f t + f y f) (5.11) For the test equation y ′ = λy we have f = λy, f t = 0, f y = λ, and hence y n = y n−1 + hλy n + h2 2 λ2 y n (5.12) ) = (1 + hλ + (hλ)2 y n−1 (5.13) 2 Absolute stability occurs when ∣ y n ∣∣∣ (hλ)2 ∣ = y n−1 ∣1 + hλ + 2 ∣ ≤ 1 (5.14) To find the shape of this region, set z = hλ = re iθ , and square both sides of equation 5.14 using the identity |z| 2 = zz∗ to get (1 + re iθ + r2 e 2iθ ) (1 + re −iθ + r2 e −2iθ ) ≤ 1 (5.15) 2 2 1 + re −iθ + r2 e −2iθ + re iθ + r 2 + r 3 e −iθ r2 e 2iθ 2 2 ( e −iθ + e iθ ) 2r + r 2 e−2iθ + e 2iθ + r 3 e−iθ + e iθ 2 2 2 + r 3 e iθ + r4 4 ≤ 1 (5.16) + r 2 + r4 4 ≤ 0 (5.17) 2r cos θ + r 2 cos 2θ + r 3 cos θ + r 2 + r4 4 ≤ 0 (5.18) To plot this equation pick some small interval δθ and do the following: • Set θ = 0 • Repeat 1. Set θ = θ + δθ 2. Solve 5.18 for r, accepting only real solutions 3. Plot the point (r, θ) until θ = 2π In Mathematica we can use Solve to find the solution of 5.18. For example, to find r(π), f[r , theta ] := 2r * Cos[theta] + r^2 * Cos[2*theta] + r^3 Cos[theta] + 0.25* r^4 + r^2; Solve[f[r,Pi]==0] Math 582B, Spring 2007 California State University Northridge c○2007, B.E.Shapiro Last revised: May 23, 2007

CHAPTER 5. RUNGE-KUTTA METHODS 91 which returns a list of rules for r , {{r->0.},{r->1.-1.73205i}, {r->1.+1.73205i}, {r->2.}} To convert this to a list of numbers, replace the Solve with r/.Solve[f[r,Pi]==0] This returns {0.,1.-1.73205i, 1.+1.73205i, 2.} To get only the real roots, Select[r/.Solve[f[r,Pi]==0], And[Im[#] == 0, Re[#] >= 0]&] which now returns the list {0., 2.} Figure 5.1: Region of absolute stability for second-order Taylor series methods. Numerical solutions with hλ that fall inside this region are absolutely stable Putting the whole plotting algorithm together, the following will plot 100 points on the solution. points = {}; Cartesian[{r , theta }] := {r*Cos[theta], r*Sin[theta]}; For[theta = 0, theta = 0]&]; c○2007, B.E.Shapiro Last revised: May 23, 2007 Math 582B, Spring 2007 California State University Northridge

90 CHAPTER 5. RUNGE-KUTTA METHODS<br />

error of h p . We also observe that O(h) Taylor method is equivalent to Euler’s<br />

method.<br />

<strong>The</strong> second order Taylor method has<br />

y n = y n−1 + hf + h2<br />

2 (f t + f y f) (5.11)<br />

For the test equation y ′ = λy we have f = λy, f t = 0, f y = λ, and hence<br />

y n = y n−1 + hλy n + h2<br />

2 λ2 y n (5.12)<br />

)<br />

=<br />

(1 + hλ + (hλ)2 y n−1 (5.13)<br />

2<br />

Absolute stability occurs when<br />

∣ y n ∣∣∣ (hλ)2<br />

∣ =<br />

y n−1<br />

∣1 + hλ + 2 ∣ ≤ 1 (5.14)<br />

To find the shape of this region, set z = hλ = re iθ , and square both sides of equation<br />

5.14 using the identity |z| 2 = zz∗ to get<br />

(1 + re iθ + r2 e 2iθ ) (1 + re −iθ + r2 e −2iθ )<br />

≤ 1 (5.15)<br />

2<br />

2<br />

1 + re −iθ + r2 e −2iθ<br />

+ re iθ + r 2 + r 3 e −iθ r2 e 2iθ<br />

2<br />

2<br />

( e −iθ + e iθ )<br />

2r<br />

+ r 2 e−2iθ + e 2iθ<br />

+ r 3 e−iθ + e iθ<br />

2<br />

2<br />

2<br />

+ r 3 e iθ + r4<br />

4 ≤ 1 (5.16)<br />

+ r 2 + r4<br />

4 ≤ 0 (5.17)<br />

2r cos θ + r 2 cos 2θ + r 3 cos θ + r 2 + r4<br />

4 ≤ 0 (5.18)<br />

To plot this equation pick some small interval δθ and do the following:<br />

• Set θ = 0<br />

• Repeat<br />

1. Set θ = θ + δθ<br />

2. Solve 5.18 for r, accepting only real solutions<br />

3. Plot the point (r, θ)<br />

until θ = 2π<br />

In Mathematica we can use Solve to find the solution of 5.18. For example, to find<br />

r(π),<br />

f[r , theta ] := 2r * Cos[theta] + r^2 * Cos[2*theta] + r^3 Cos[theta]<br />

+ 0.25* r^4 + r^2;<br />

Solve[f[r,Pi]==0]<br />

Math 582B, Spring 2007<br />

California State University Northridge<br />

c○2007, B.E.<strong>Shapiro</strong><br />

Last revised: May 23, 2007

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

Saved successfully!

Ooh no, something went wrong!