Solutions to 18.03 Problem Set 2 (Part II)

8. (a) Let h = 1/N be the step size. Euler. y_{n} = y_{n−1} + hy_{n−1} = (1 + \frac{1}{N})y_{n−1}. Heun. y_{n} = y_{n−1} + \frac{h}{2}(k_{1} + k_{2}), k_{1} = y_{n−1}, k_{2} = y_{n−1} + hk_{1} = (1 + h)y_{n−1}, so

y_{n} = y_{n−1} + \frac{h}{2}(2 + h)y_{n−1} = (1 + h + \frac{h^{2}}{2} ) y_{n−1} = (1 + \frac{1}{N} + \frac{1}{2N^{2}} ) y_{n−1}.

Runge-Kutta (see EP p. 480). k_{1} = y_{n−1}. k_{2} = y_{n−1} + \frac{1}{2}hy_{n−1} = (1 + \frac{h}{2})y_{n−1}.

k_{3} = y_{n−1} + \frac{1}{2}h(y_{n−1} + \frac{h}{2}y_{n−1}) = (1 + \frac{h}{2} + \frac{h^{2}}{4} ) y_{n−1}.

k_{4} = y_{n−1} + hk_{3} = (1 + h + \frac{h^{2}}{2} + \frac{h^{3}}{4} ) y_{n−1}.

Finally,

y_{n} = y_{n−1} + \frac{h}{6}(k_{1} + 2k_{2} + 2k_{3} + k_{4}) = y_{n−1} (1 + h + \frac{h^{2}}{2} + \frac{h^{3}}{6} + \frac{h^{4}}{24}) .

(Some of you may recognize 1 + h + \frac{h^{2}}{2} + \frac{h^{3}}{6} + \frac{h^{4}}{24} as being the first five terms of a longer series.) Using h = 1/N, we have:

y_{n} = y_{n−1} (1 + \frac{1}{N} + \frac{1}{2N^{2}} + \frac{1}{6N^{3}} + \frac{1}{24N^{4}} ) .

(b) Euler: (1+ \frac{1}{N})^{N}. Heun: (1+ \frac{1}{N} + \frac{1}{2N^{2}} )^{N}. Runge-Kutta: (1 + \frac{1}{N} + \frac{1}{2N^{2}} + \frac{1}{6N^{3}} + \frac{1}{24N^{4}} )^{N}.

(c) The three processes give the following values (for various N):

N = 2  N = 4  N = 8  N = 16
Euler  2.25  2.44140625 2.5657845 2.6379285
Heun  2.640625 2.6948557 2.7118412 2.7165935
Runge-Kutta 2.7173462 2.7182099 2.7182768 2.7182815

(d) The difference between e and each entry in the above table (rounded) is:

N = 2  N = 4  N = 8 N = 16
Euler  .4682818 .2768756 .1524973 .0803533
Heun  .0776568 .0234261 .0064406 .0016883
Runge-Kutta .0009356 .0000719 .0000050 .0000003

Visibly, the entries in the Euler row decrease by roughly a factor of 2; for Heun by a factor of 4; for Runge-Kutta by a factor of 16.

(e) Heun(2)/Euler(4) is about 4. Heun(4)/Euler(8) is about 7. Heun(8)/Euler(16) is about 13. RK(2)/Heun(4) is about 25. RK(4)/Heun(8) is about 90. RK(8)/Heun(16) is about 338. Runge-Kutta is the clear winner.

8.5 —Corrected version. (b) 3.4885

(c) As \frac{dx}{dt} = −1,

\frac{dy}{dt} = \frac{dy}{dx} · \frac{dx}{dt} = −(y^{3} − 3y − x) = −y^{3} + 3y − t.

(e) The value of y′ changes drastically over distances much smaller than the step size.

9. Warning: you can’t substitute any values of of x; they must lie between c and d.

(a) Pick two values x_{0} and x_{1} such that cos(x_{i}) ≠ 0 and tan(x_{0}) ≠ tan(x_{1}). Suppose af +bg = 0. Then substituting x = x_{0}, we get a sin(x_{0})+b cos(x_{0}) = 0, so a tan(x_{0})+b = 0. Similarly a tan(x_{1}) + b = 0. Hence a tan(x_{0}) = a tan(x_{1}). As tan(x_{0}) ≠ tan(x_{1}), a must be 0. Hence b = −a tan(x_{1}) is also 0.

(b) Pick two distinct values x_{0} and x_{1} between c and d. Proceed as before: suppose af + bg = 0. Then ae^{x_{0}} + bx_{0}e^{x_{0}} = 0, so (as e^{x_{0}} ≠ 0) a = −bx_{0}. Similarly, a = −bx_{1}, so bx_{0} = bx_{1}. As x_{0} ≠ x_{1}, b must be 0, so a = −bx_{1} must also be 0.

(c) This is similar to (b). Pick two distinct values x_{0} and x_{1} between c and d. Suppose af + bg = 0. Then ax_{0}^{m} + bx_{0}x_{0}^{n} = 0, so (as x_{0}^{m} ≠ 0) a = −bx_{0}^{n−m}. Similarly, a = −bx_{1}^{n−m}, so bx_{0}^{n−m} = bx_{1}^{n−m}. As x_{0} ≠ x_{1}, b must be 0, so a = −bx_{1}^{n−m} must also be 0.

10. (a)

∫ e^{kt} cos(ωt)dt = ∫ Re (e^{(k+iω)t}) dt + c
= Re (∫ e^{(k+iω)t}dt) + c
= Re (\frac{1}{k + iω} e^{(k+iω)t}) + c
= Re (\frac{k − iω}{1} k^{2} + ω^{2}e^{kt}(cos(ωt) + i sin(ωt))) + c
= e^{kt}Re (\frac{k cos(ωt) + ω sin(ωt)}{k^{2} + ω^{2}} + i\frac{k sin(ωt) − ω cos(ωt)}{k^{2} + ω^{2}}) + c
= e^{kt}Re (\frac{k cos(ωt) + ω sin(ωt)}{k^{2} + ω^{2}} + i\frac{k sin(ωt) − ω cos(ωt)}{k^{2} + ω^{2}}) + c
= e^{kt} \frac{k cos(ωt) + ω sin(ωt)}{k^{2} + ω^{2}} + c

To rephrase the answers in terms of φ and r, we use k^{2} + φ^{2} = r^{2}, k = r cos φ, and ω = r sin φ (polar coordinates). Hence

∫ e^{kt} cos(ωt)dt = e^{kt} \frac{r cos φ cos(ωt) + r sin φ sin(ωt)}{r^{2}} + c = \frac{1}{r}e^{kt} cos(ωt − φ) + c.

(b) The integrating factor is e^{kt}, so we want to solve

\frac{d}{dt} (e^{kt}x) = ke^{kt} cos(ωt).

Integrating both sides with respect to t, we get

e^{kt}x = ake^{kt} \frac{k cos(ωt) + ω sin(ωt)}{k^{2} + ω^{2}} + c

so

x = ak \frac{k cos(ωt) + ω sin(ωt)}{k^{2} + ω^{2}} + ce^{−kt}.

11. (a) As c_{1}e^{ωx} + c_{2}e^{−ωx} = (a + b)e^{ωx}(a − b)e^{−ωx}, a + b = c_{1} and a − b = c_{2}. Thus a = (c_{1} + c_{2})/2, b = (−c_{1} + c_{2})/2.

(b) In (1), y(0) = 1 gives a = 1. Then

y′ = −\frac{p}{2}e^{−px/2} (a cos(ωx) + b sin(ωx)) + e^{−px/2} (−aω sin(ωx) + bω cos(ωx)) .

Then y′(0) = 0 gives −\frac{p}{2}a + bω = 0, so b = \frac{pa}{2ω} = \frac{p}{2ω}. This gives the solution

e^{−px/2} (cos(ωx) + \frac{p}{2ω} sin(ωx)) .

In (2), y(0) = 1 gives a = 1 again. y′ = −\frac{p}{2}e^{−px/2}(a + bx) + be^{−px/2}. Then y′(0) = 0 gives −\frac{p}{2}a + b, so b = pa/2 = p/2. This gives the solution e^{−px/2} (1 + \frac{p}{2}x) . The case of (3) is similar to (1). Notice first that \frac{d}{dz} cosh(z) = sinh(z) and \frac{d}{dz} sinh(z) = cosh(z). As before y(0) = 0 gives a = 1.

y′ = −\frac{p}{2}e^{−px/2} (a cosh(ωx) + b sinh(ωx)) + e^{−px/2} (aω sinh(ωx) + bω cosh(ωx))

Then y′(0) = 0 gives −\frac{p}{2}a + bω = 0, so b = \frac{pa}{2ω} = \frac{p}{2ω} (as in (1)). This gives the solution

e^{−px/2} (cosh(ωx) + \frac{p}{2ω} sinh(ωx)) .

(c) Some preliminaries: q = 4, so ω(p) = \sqrt{|(p/2)^{2} − 4|}. Notice that ω(4) = 0; as p approaches 4 (from either above or below), ω(p) approaches 0 (from above). If p = 4, we are in case (2), and y_{4}(x) = e^{−2x}(1 + 2x) from (b). If p < 4, we wish to show that

lim_{p→4^{−}} e^{−px/2} (cos(ωx) + \frac{p}{2ω} sin(ωx)) = e^{−2x}(1 + 2x).

As lim_{p→4^{−}} e^{−px/2} cos(ω(p)x) = e^{−2x}, we wish to show that

lim_{p→4^{−}} e^{−px/2} (\frac{p}{2ω} sin(ωx)) = e^{−2x}(2x),

i.e.

lim_{p→4^{−}} \frac{sin(ωx)}{ω} = x.

This can be checked to be true using l’Hopital’s rule. For example, a slick approach would be

lim_{p→4^{−}} \frac{sin(ωx)}{ω} = lim_{ω→0} \frac{sin(ωx)}{ω} = lim_{ω→0} \frac{x cos(ωx)}{1} = x.

If p > 4, we wish to show that

lim_{p→4^{+}} e^{−px/2} (cosh(ωx) + \frac{p}{2ω} sinh(ωx)) = e^{−2x}(1 + 2x).

As lim_{p→4^{+}} e^{−px/2} cosh(ω(p)x) = e^{−2x}, we wish to show that

lim_{p→4^{+}} e^{−px/2} (\frac{p}{2ω} sinh(ωx)) = e^{−2x}(2x),

i.e.

lim_{p→4^{+}} \frac{sinh(ωx)}{ω} = x.

This can be checked to be true using l’Hopital’s rule.