0% found this document useful (0 votes)
56 views19 pages

Solutions To Selected Exercises and Additional Examples For My Book Numerical Methods For Evolutionary Differential Equations

This document provides solutions to selected exercises from the author's book on numerical methods for evolutionary differential equations. It contains solutions to problems from Chapters 1-4 of the book, with details on the relevant concepts and steps taken to arrive at each solution. The solutions are intended to serve as additional examples for understanding the concepts in the text. While some details are omitted, the solutions aim to help readers learn while still encouraging them to attempt the problems independently first. This file will be updated over time with more solved examples submitted by others.

Uploaded by

kalantor
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views19 pages

Solutions To Selected Exercises and Additional Examples For My Book Numerical Methods For Evolutionary Differential Equations

This document provides solutions to selected exercises from the author's book on numerical methods for evolutionary differential equations. It contains solutions to problems from Chapters 1-4 of the book, with details on the relevant concepts and steps taken to arrive at each solution. The solutions are intended to serve as additional examples for understanding the concepts in the text. While some details are omitted, the solutions aim to help readers learn while still encouraging them to attempt the problems independently first. This file will be updated over time with more solved examples submitted by others.

Uploaded by

kalantor
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Solutions to selected exercises and additional examples for my book Numerical Methods for Evolutionary Dierential Equations

Uri Ascher July 2, 2009


In this le I have collected solutions to selected exercises appearing in my book. Some of these solutions extend beyond what is strictly required in the question. Others leave details out. These solved exercises serve as additional examples for the text as well. It is seriously recommended that you try to solve the posed problems before taking a peak at the answers. This le represents work in progress, and additions of solved examples (include the source in latex and gures in eps or jpg, please) will be gratefully received and incorporated. However, the rest of the exercises appearing in the book, even those for which I do have solutions that may be shared with friends and teachers using the text, are intended to remain largely without publicly posted solutions, just like research problems in real life. Note: References to exercises, sections, equations, gures and tables of the book appear here like there, generally in the form m.n, where m indicates the chapter number, e.g., Figure 1.8. On the other hand, references and labels to equations, tables and gures of this document have only a single counter, e.g., Figure 2.

Chapter 1
1.4 This relates to Section 1.1. Here P () = 2 a. Hence |eP ()t | = |e ||ea | = |e | 1 . When 0 we obtain the advection equation and |eP ()t | 1. 1.5 This relates to Section 1.2. 1
2 2

(a) As in the text we must consider |1 ()| = |1 + a a[cos() + sin()]. Now, for = /2, |1 ()| |Re()| = |1 + a| > 1. Hence instability is present for any > 0. [Additionally, imagine Figure 1.8 with a > 0.] (b) Exactly the same analysis resulting in 1 is applied here, yielding () = 1 a + ae . This is the same as 1 with (a) replacing a (the negative sign in the exponent merely implies that we trace the same dotted line in Figure 1.8 in the opposite direction). Hence the same stability results hold with a replaced by a.

(d) For ut ux = 0 we have a = 1 < 0. Hence the upwind scheme chooses the forward dierencing. The extra column is therefore the same as the Error in (1.15a) in Table 1.1. 1.7 We have Hence, 0 xx + c u. ut = c 0 xx P () = 0 2 + c . ( + c) 0
2

(c) The upwind scheme simply picks the stable guy, according to the preceding analysis, between the forward and the backward dierences. Hence it is stable for any value of a provided |a| 1.

a b The eigenvalus of a general 2 2 matrix c d are given by 1 a+d 2 (a + d)2 4(ad bc) .

Here we get the purely imaginary eigenvalues ( 2 +c). Since they are dierent the matrix is diagonalizable. So, the situation is precisely as for a hyperbolic PDE system considered in 1.1.2. This IVPDE is well-posed, and it is conservative (i.e., no smoothing, as in Figure 1.3). Incidentally, there is no need to write the PDE as a real-variable system in order to reach the above conclusions. 2

Chapter 2
This chapter can really be learned before (or independently of) Chapter 1. 2.2 (a) Obviously, = 0 gives forward Euler, = 1 gives backward Euler, = 1/2 gives the trapezoidal method.

(b) For the test equation y = y, the -method reads yn+1 = yn + z(yn+1 + (1 )yn ) where z = k, so yn+1 = R(z)yn = 1 + (1 )z yn . 1 z

The method is therefore A-stable when 1/2 1 . (c) For sti decay we must have R() = 0. Clearly R() = 1 ,

so this happens only when = 1. For the backward Euler method indeed the method has sti decay. (d) The question here is for what values of |R(z)| = | 1 + (1 )z | 1 z 1 . 1+

as z ? Substituting for R() we get

(e) As a general Runge-Kutta method, note that there are two evaluations of f , one of which is shared with the next step. So let K1 = f (yn ), K2 = f (yn+1 ) = f (yn + k[K2 + (1 )K1 ]). This gives the tableau 0 0 0 1 1 1 3

(f) Let us check the rst few order conditions: bT C 0 1 bT C1 bT C 2 1 bT A1 = = = = b1 + b2 = 1, b2 = , b2 = , bT C1 = .

Hence the order is 1 for all except = 1/2 for which the order is 2. (g) The advantage is that the method is almost second order and introduces only little damping, which is good for approximating dierential problems that have (almost) no damping. On the other hand, R() = 1+2 , 1+2 which is barely below 1 in magnitude, so the typical oscillatory behavior of the trapezoidal method is essentially reproduced in the sti limit. 2.4 yn+1 = yn1 + 2zyn , z = k. As in the leapfrog treatment in Chapter 1 we guess yn = n and obtain the quadratic equation 2 2z 1 = 0, with the solutions 1,2 = z z 2 + 1. Both these roots must satisfy |1,2 | 1 for stability. If z < 0 is real then obviously z z 2 + 1 < 1 and stability cannot hold.

For the more general case where , hence z, is a complex scalar, note that the two roots of the quadratic equation satisfy 1 2 = 1, so if stability is to hold then |l | = 1, l = 1, 2. For each we can therefore write l = el , so from the quadratic equation z = el el = 2 sin l . Stability therefore implies that z, hence , must be purely imaginary.

2.9 (a) Here fy = 2y, so L = sup |2y| = 2 sup |2/(1 t)| = . 0t1

Theorem 2.3 holds, albeit with a large Lipschitz constant L, for any xed, positive . There is a unique solution, and the perturbation bounds hold as well although they become less meaningful as 0. 4

k= .1 .01 .001 .0001 .00001

FEuler 5.7 7.6e+1 8.3e+2 8.8e+3 9.0e+4

RK2 1.9 2.1e+1 2.1e+2 2.1e+3 2.1e+4

Rk4 7.1e-2 7.1e-1 7.1 7.1e+1 7.1e+2

Table 1: Maximum errors for Exercise 2.9. (b) The required results are listed in Table 1. There is an added row for k = = 105 and an added column for the explicit trapezoidal method. When quickly comparing forward Euler against RK4 one might conclude that there is a fundamental dierence in the performance of the two methods. But in fact, although the error in RK4 is much smaller it is not fundamentally dierent, and the error in forward Euler arises not because of an impending blowup but because the results it produces are below the exact values. The relative error measured over all mesh points, which is more meaningful here, is below 1 for forward Euler, about .21 for the explicit trapezoidal, and about .007 for RK4 for all values of k = listed. (c) Here what corresponds to in the test equation is fy = 2y > 1, so the problem (not the numerical method) is unstable. In general one cannot expect a good pointwise numerical error for an unstable problem. Indeed in chaotic systems, which do contain segments (i.e., subintervals in time) of instability, we may not expect a quality pointwise numerical error after a while unless exponentially small time steps and oating point accuracy are employed. 2.11 (a) We plug the exact x and v into (2.45). By Taylor expansion, assuming as much smoothness on the solution as necessary, we have x(t k) = x(t) kx (t) + Thus, [x(t + k) 2x(t) + x(t k)]/k 2 = x + k 2 x (t) + O(k 4 ), 12 k2 = f (x, v) + x (t) + O(k 4 ). 12 k3 k4 k 2 x (t) x (t) + x (t) + . . . . 2 6 24

Likewise the approximation for v is 2nd order. (b) The choice = .5 centers the formula (2.46b) and makes it 2nd order. Then, in (2.46a), for any 0 1 we have (1)f (x(t))+f (x(t+k)) = f (x(t)) + O(k), so the formula agrees with Taylors expansion up to O(k 3 ) terms, which corresponds to 2nd order accuracy. 5

(c) With = .5 we have a trapezoidal rule in (2.46b). Now with = .5 we have in (2.46a) k k xn+1 = xn + vn + (vn + k(.5fn + .5fn+1 )) 2 2 k = xn + (vn + vn+1 ). 2 So the whole scheme is just the trapezoidal rule for the rst order form (2.44). (d) In (2.46b) its the same trapezoidal rule. In (2.46a) we have xn+1 = xn + kvn + k2 fn . 2

This formula is explicit. The advantage is in case that f = f (x), i.e., when f does not depend on v. Then (2.46b) becomes explicit too, and no nonlinear equations need be solved.

Chapter 3
3.2 (a) The results are tabulated in the rst two rows of Table 2. Clearly the
method (3.38a) (3.38b) 2nd deriv l=1 2.6e-2 8.4e-4 1.7e-2 l=2 2.5e-3 8.3e-6 1.7e-3 l=3 2.5e-4 8.3e-8 1.7e-4 l=4 2.5e-5 8.3e-10 1.7e-5 l=5 2.5e-6 1.5e-11 8.3e-8

Table 2: Errors in approximating rst and second derivatives of ex at x = 0 on nonuniform meshes hj = 10l , hj1 = .5hj . rst method is rst order and the second is second order accurate. The rightmost result for (3.38b) is polluted by oating point cancellation error. (b) The formula (3.38b) is the result of interpolating at the points xj1 , xj , xj+1 by a quadratic polynomial and dierentiating the result at x = xj . Recall the Review section on polynomial interpolation. The derivative of the error according to (2.38) at xj is therefore what we are after. Dierentiating the product and substituting x = xj , the only term that does not vanish is u[xj1 , xj , xj+1 , x](xj xj1 )(xj xj+1 ) = uxxx () hj hj1 . 6

(c) This formula is centered at .5(xj1 + xj+1 ) = xj + h/4. Therefore the calculated value v satises v = ux (xj + h/4) + O(h2 ). But ux (xj + h/4) = 6

ux (xj ) + h/4uxx where the latter is evaluated at a nearby point. Since uxx = 0 in the neighborhood, there is a positive constant such that |ux (xj + h/4) ux (xj )| > ch. Hence |v ux (xj )| |ux (xj + h/4) ux (xj )| |ux (xj + h/4) v| ch + O(h2 ).

Chapter 4
4.2 The amplication factor is g() = cos() a sin(). Thus, assuming |a| 1 we have |g()|2 = cos2 () + 2 a2 sin2 () cos2 () + sin2 () = 1 for any . 4.4 This follows straight from the denitions. For a general scheme
r n+1 i vj+i i=l r

=
i=l

n i vj+i ,

where i and i are s s constant matrices, we have the amplication matrix


r r

G() = (
i=l

i e )

i 1 i=l

i ei .

Consistency requires that the local truncation error


r r

(t, x) = k [
i=l

i u(t + k, x + ih)

i u(t, x + ih)]
i=l

tend to 0 as k, h 0. Take u 1. Then for consistency we must have


r r

i =
i=l i=l

i .

Therefore, G(0) = I, which yields in particular that (G(0)) = 1.

4.8 Stability requires that both roots of the quadratic equation 2 + 2 4 sin2 (/2) sin() + 1 = 0 h2

be bounded by 1 in magnitude, where = k/h. This happens (indeed their magnitude equals 1) if
2

4 2 sin2 (/2) h

sin2 () 1.

The process for getting here is the same as seen before in Chapter 4 and in Exercise 2.3. Deriving a precise yet simplied condition is hard, but the requirement || + 4|| h2 1,

is clearly a simple sucient condition for constant-coecient stability.

Chapter 5
5.4 The obtained errors for the 2nd order schemes are comparable for < 1. The resulting solution curves are generally good, and the oscillations observed for the square wave initial data are much diminished (although they are more present in the non-dissipative box scheme). The Lax-Friedrichs scheme produces much less accurate results. For > 1 only the box scheme produces reasonable results, of course. However, the observed convergence rate is well below what may be expected from 2nd order methods. This is because of the low smoothness of u0 (x) at x = 0, 1, 1. These cusps propagate also for t > 0 at the phase speed c = 1. 5.13 Below is a table of computed errors. The solution is depicted in Figure 1. h 2 28
7

k h 2h 3h h 2h 3h

error .24 .55 * .0090 .092 *

error .075 .18 * .0027 .025 *

The errors for the ner spatial step are signicantly better when k = h, more than just by the expected factor 24 = 16. For k = 3h the method is unstable, as 8

Figure 1: Exercise 5.13: solution using h = k = 28 .

expected for RK4. The solution for the coarser h = k is depicted in Figure 2(a). Compare this to the solution for the ner h = k in Figure 2(b). This suggests that the coarser h is simply not sucient to resolve this sharp solution prole, whereas the ner one is. 5.14 (a) Applying a Fourier transform as usual we get ut = w, (1 + )wt = u.
2

The symbol matrix is therefore P () = The eigenvalues are


1+ 2

0 .

1 + 2

Since they are both imaginary the claims to be proved are obtained. (b) Here we dont know an exact error. The method is l2 -stable even for k = 10h, because the high wave numbers are attenuated, as we see in 9

1.2 u 1
0

1.2 u 1
0

uf

uf

0.8

0.8

0.6

0.6

0.4

0.4

0.2

0.2

0.2

0.2

(a) using h = k = 27

(b) using h = k = 28

Figure 2: Exercise 5.13: solutions at t = 0 and t = 8.


1 u u 0.8
0 f

1 u u 0.8
0 f

0.6

0.6

0.4

0.4

0.2

0.2

0.2

0.2

0.4

0.4

(a) using h = k = 28

(b) using h = 28 and k = 10h

Figure 3: Exercise 5.14: solutions at t = 0 and t = 8. Part (a). But the solution is not physical. The solution for the ner h = k is depicted in Figure 3(a). The solutions for h = 28 , k = 2h, and for h = k = 27 do not look very dierent. But the solution for h = 28 , k = 10h, depicted in Figure 3(b), does look dierent. The error dangerously masquerades as an honest wave. % Exercise 5.14 % Shallow water regime. If b = 0 then becomes the % classical wave equation written as a 1st order system % v_t = u_x, w_t = cv_x, (c = r2/r1 - 1) % w = u - b u_{xx} (b = r2/r1 sqrt(beta) ) % periodic conditions on [0,2pi] % v(0,x) = exp(-a(x-pi)^2), a=50, u(0,x) = 0. % problem coefficients clear all 10

r1 = 1; r2 = 2; c = r2/r1 - 1; b = 0.01; a = 50; tf = 8*pi; J = 2^9; h = 2*pi/J; k = 2*h/sqrt(c); mu = k/h; N = floor(tf / k); xx = [0:h:2*pi]; tt = 0:k:N*k; % final time % spatial step size % time step size

% spatial mesh: identify xx(1) with xx(end)

% construct the almost tridiagonal matrix: note its only J x J r = b/h^2; s = 1+2*r; e = ones(J,1); M = spdiags([-r*e s*e -r*e], -1:1, J, J); M(1,J) = -r; M(J,1) = -r; % initial conditions v(1,:) = exp(-a*(xx-pi).^2); u(1,:) = zeros(1,length(xx)); w(1,:) = zeros(1,length(xx));

% w is the auxuliary variable

% RK4 for n=1:N Yv1 = v(n,:); Yu1 = u(n,:); Yw1 = w(n,:); Kv1(3:J-1) = (8*(Yu1(4:J)-Yu1(2:J-2)) -Yu1(5:J+1)+Yu1(1:J-3) ) / (12*h); Kv1(2) = (8*(Yu1(3)-Yu1(1)) -Yu1(4)+Yu1(J) ) / (12*h); Kv1(1) = (8*(Yu1(2)-Yu1(J)) -Yu1(3)+Yu1(J-1) ) / (12*h); Kv1(J) = (8*(Yu1(J+1)-Yu1(J-1)) -Yu1(2)+Yu1(J-2) ) / (12*h); Kv1(J+1) = Kv1(1); Yv2 = Yv1 + k/2 * Kv1; Kw1(3:J-1) = c * (8*(Yv1(4:J)-Yv1(2:J-2)) -Yv1(5:J+1)+Yv1(1:J-3) ) / (12*h); Kw1(2) = c * (8*(Yv1(3)-Yv1(1)) -Yv1(4)+Yv1(J) ) / (12*h); Kw1(1) = c * (8*(Yv1(2)-Yv1(J)) -Yv1(3)+Yv1(J-1) ) / (12*h); Kw1(J) = c * (8*(Yv1(J+1)-Yv1(J-1)) -Yv1(2)+Yv1(J-2) ) / (12*h); 11

Kw1(J+1) = Kw1(1); Yw2 = Yw1 + k/2 * Kw1; Yu2(1:J) = (M \ Yw2(1:J));

Yu2(J+1) = Yu2(1);

Kv2(3:J-1) = (8*(Yu2(4:J)-Yu2(2:J-2)) -Yu2(5:J+1)+Yu2(1:J-3) ) / (12*h); Kv2(2) = (8*(Yu2(3)-Yu2(1)) -Yu2(4)+Yu2(J) ) / (12*h); Kv2(1) = (8*(Yu2(2)-Yu2(J)) -Yu2(3)+Yu2(J-1) ) / (12*h); Kv2(J) = (8*(Yu2(J+1)-Yu2(J-1)) -Yu2(2)+Yu2(J-2) ) / (12*h); Kv2(J+1) = Kv2(1); Yv3 = Yv1 + k/2 * Kv2; Kw2(3:J-1) = c * (8*(Yv2(4:J)-Yv2(2:J-2)) -Yv2(5:J+1)+Yv2(1:J-3) ) / (12*h); Kw2(2) = c * (8*(Yv2(3)-Yv2(1)) -Yv2(4)+Yv2(J) ) / (12*h); Kw2(1) = c * (8*(Yv2(2)-Yv2(J)) -Yv2(3)+Yv2(J-1) ) / (12*h); Kw2(J) = c * (8*(Yv2(J+1)-Yv2(J-1)) -Yv2(2)+Yv2(J-2) ) / (12*h); Kw2(J+1) = Kw2(1); Yw3 = Yw1 + k/2 * Kw2; Yu3(1:J) = (M \ Yw3(1:J)); Yu3(J+1) = Yu3(1);

Kv3(3:J-1) = (8*(Yu3(4:J)-Yu3(2:J-2)) -Yu3(5:J+1)+Yu3(1:J-3) ) / (12*h); Kv3(2) = (8*(Yu3(3)-Yu3(1)) -Yu3(4)+Yu3(J) ) / (12*h); Kv3(1) = (8*(Yu3(2)-Yu3(J)) -Yu3(3)+Yu3(J-1) ) / (12*h); Kv3(J) = (8*(Yu3(J+1)-Yu3(J-1)) -Yu3(2)+Yu3(J-2) ) / (12*h); Kv3(J+1) = Kv3(1); Yv4 = Yv1 + k * Kv3; Kw3(3:J-1) = c * (8*(Yv3(4:J)-Yv3(2:J-2)) -Yv3(5:J+1)+Yv3(1:J-3) ) / (12*h); Kw3(2) = c * (8*(Yv3(3)-Yv3(1)) -Yv3(4)+Yv3(J) ) / (12*h); Kw3(1) = c * (8*(Yv3(2)-Yv3(J)) -Yv3(3)+Yv3(J-1) ) / (12*h); Kw3(J) = c * (8*(Yv3(J+1)-Yv3(J-1)) -Yv3(2)+Yv3(J-2) ) / (12*h); Kw3(J+1) = Kw3(1); Yw4 = Yw1 + k * Kw3; Yu4(1:J) = (M \ Yw4(1:J)); Yu4(J+1) = Yu4(1);

Kv4(3:J-1) = (8*(Yu4(4:J)-Yu4(2:J-2)) -Yu4(5:J+1)+Yu4(1:J-3) ) / (12*h); Kv4(2) = (8*(Yu4(3)-Yu4(1)) -Yu4(4)+Yu4(J) ) / (12*h); Kv4(1) = (8*(Yu4(2)-Yu4(J)) -Yu4(3)+Yu4(J-1) ) / (12*h); Kv4(J) = (8*(Yu4(J+1)-Yu4(J-1)) -Yu4(2)+Yu4(J-2) ) / (12*h); Kv4(J+1) = Kv4(1); v(n+1,:) = Yv1 + k/6 * (Kv1+2*Kv2+2*Kv3+Kv4); Kw4(3:J-1) = c * (8*(Yv4(4:J)-Yv4(2:J-2)) -Yv4(5:J+1)+Yv4(1:J-3) ) / (12*h); Kw4(2) = c * (8*(Yv4(3)-Yv4(1)) -Yv4(4)+Yv4(J) ) / (12*h); Kw4(1) = c * (8*(Yv4(2)-Yv4(J)) -Yv4(3)+Yv4(J-1) ) / (12*h); Kw4(J) = c * (8*(Yv4(J+1)-Yv4(J-1)) -Yv4(2)+Yv4(J-2) ) / (12*h); 12

Kw4(J+1) = Kw4(1); w(n+1,:) = Yw1 + k/6 * (Kw1+2*Kw2+2*Kw3+Kw4); u(n+1,1:J) = (M \ w(n+1,1:J)); u(n+1,J+1) = u(n+1,1); end figure(1) mesh(xx,tt,v) xlabel(x) ylabel(t) zlabel(\eta) axis([0 7 0 tf -.5 1.5]) figure(2) plot(xx,v(1,:),xx,v(N+1,:)) legend(u_0,u_f)

Chapter 6
6.4 The Hamiltonian system can generally be written as

y = JH(y), where q y= p , 0 I J = I 0 .

The important properties of the matrix J are that it is skew-symmetric, i.e., J T = J, and that it is nonsingular and constant in the independent variable t. Denote the Jacobian matrix by Y (t; c) = y(t; c) , c

with y(0; c) = c for some (arbitrary) initial time. The ow is called symplectic if Y T J 1 Y = J 1 , t.

Dierentiating the ODE for y with respect to c we have Y = J(2 H)Y, 13 Y (0) = I.

Now, the midpoint method reads at time step n yn+1 yn = JH(yn+1/2 ), k where yn+1/2 = (yn + yn+1 )/2 and y0 is given by the initial data. Then also Yn+1 Yn = J2 H(yn+1/2 )Yn+1/2 , k Yn+1 + Yn Yn+1/2 = , n = 0, 1, . . . , 2 and Y0 = I the identity. Consider Z = (Yn+1 Yn )T J 1 (Yn+1 + Yn ) + (Yn+1 + Yn )T J 1 (Yn+1 Yn ). Opening up parentheses, the cross terms cancel and we have
T T Z = 2(Yn+1 J 1 Yn+1 Yn J 1 Yn ).

(1)

On the other hand, by (1) Yn+1 + Yn 1 Yn+1 Yn T J = Yn+1/2 2 H(yn+1/2 )Yn+1/2 , 2 k (Yn+1 Yn )T 1 Yn+1 + Yn T J = Yn+1/2 2 H(yn+1/2 )J T J 1 Yn+1/2 k 2 T = Yn+1/2 2 H(yn+1/2 )Yn+1/2 . Therefore Z = 0. Hence
T T Yn+1 J 1 Yn+1 = Yn J 1 Yn = . . . = Y0T J 1 Y0 = J 1 .

6.5 (a) Half a step of forward Euler gives yn+1/2 = yn + k/2 f (yn ). Following this by half a step of backward Euler gives yn+1 = yn+1/2 + k/2 f (yn+1 ). Adding these two equations up clearly yields the trapezoidal step.

14

(b) Half a step of backward Euler rst gives yn+1/2 = yn + k/2 f (yn+1/2 ). Then forward Euler gives yn+1 = yn+1/2 + k/2 f (yn+1/2 ). Adding these equations up gives yn+1 = yn + k f (yn+1/2 ). Subtracting these equations from one another conrms that indeed yn+1/2 = (yn + yn+1 )/2 so the midpoint step is obtained. (c) Since each trapezoidal step is half a forward-Euler step (denote f ) followed by half a backward-Euler step (denote b), N trapezoidal steps give the sequence (f b)(f b)(f b)(f b)(f b)(f b) . . . (f b). Writing this sequence as f followed by the rest (bf )(bf )(bf )(bf )(b . . . (bf ) and one more b, we obtain the required result. Another way: Writing the trapezoidal scheme and summing these expressions up from n = 0 to n = N 1 yields
N 1

yn+1 = yn + k/2(fn + fn+1 ), n = 0, 1, 2, . . . N 1 yN y0 = k/2 f0 + k fn + k/2 fN .


n=1

On the other hand, doing half a forward-Euler step, y1/2 = y0 + k/2f0 , followed by N 1 midpoint steps from one midstep to the next and then a half backward-Euler step yN = yN 1/2 + k/2fN and summing all these up gives the same expression for yN y0 . (d) An example can be derived by considering as simple an ODE as y = (t)y. Consider the scalar problem and y(0) = 106 . Use a uniform step k = 104 . The exact solution and the midpoint solution both remain below 106 in magnitude, so they are close to each other by less than 105 . For the trapezoidal scheme, on the other hand, we have (t 1)1018 k < 106 k = 102 2, so yN = Hence (tN 1 ) (t0 ) 2 + k(tN 1 ) yN 1 yN 1 . . . (1)N y0 . 2 k(tN ) (tN ) (tN ) |yN | 10126 = 106 . 15 y = 1018 (t 1)y, 0 < t < 1 1012 yn+1/2 = yn1/2 + kfn , n = 1, . . . , N 1,

(a) Order (2,2)

(b) Order (4,4)

Figure 4: Solutions for Exercise 7.4, J = 128.

(a) Order (2,2)

(b) Order (4,4)

Figure 5: Solutions for Exercise 7.4, J = 192.

Chapter 7
7.4 The required plots are displayed in Figures 46. Clearly there is dispersion visible; however, this eect diminishes as the approximation improves, either by raising the order or by decreasing the step sizes k and h. For leapfrog there is still visible dispersion even for J = 256. For the slightly dissipative and more accurate RK4 the eect is less pronounced and indeed invisible to the naked eye for J = 256. 7.5 (a) We have the ODE system d2 vj c2 = 2 (vj1 2vj + vj+1 ) , dt2 h 16 j = 1, . . . , J,

(a) Order (2,2)

(b) Order (4,4)

Figure 6: Solutions for Exercise 7.4, J = 256. with v0 = vJ+1 = 0. This can apparently be written as 2 1 1 2 1 c2 ... ... ... . B= 2 h 1 2 1 1 2
dv dt

= Bv with

(b) The required matrix C is the result of a Cholesky decomposition. For example, in Matlab, C = chol(B). (c) Obviously the sought matrix L= 0 CT C 0

is skew-symmetric. Let dz z = Lz. Multiplying both sides by zT , it follows that in the dt 2-norm 1d z(t) 2 = zi zi = zT Lz = 0. 2 dt i Hence z(t) = z(0) for all t, as in Section 5.3.2. Translating notation we get the required result. (d) I have calculated wn from C T wn = vn+1 vn1 , 2k

but it can equally well be calculated from wn+1/2 = wn1/2 kCvn 17

followed by averaging. This introduces an O(k 2 ) error which is relatively independent of dispersion eects. The error in the invariant arises mainly around when t is a multiple of 10, which is when the pulse reaches the boundary and is reected o it. Thus, the error in the invariant is less aected than the error in the solution by dispersion, but as we take both k and h smaller with xed this error does not decrease as fast as the error in the solution because points closer and closer to the boundary are sampled. If we keep h xed and let k go smaller then the invariant error decreases like O(k 2 ), as expected, and becomes much smaller than the error in the solution.

Chapter 10
10.2 (a) The information is carried along characteristics, and the PDE is linear, but the characteristics are not straight lines. They are dened by dx = sin x. dt For < x(0) < these curves all tend towards 0, see Figure 7(a).
10 9 1 0.8

0.6

7 6 u(t 4) 3 2 1 0 x(t) 1 2 3 4

0.4 0.2

4 3

0.2 0.4

0.6

0.8

0 4

1 0

3 x+

(a) characteristic curves

(b) solution at an early time

Figure 7: Exercise 10.2. They do not cross! Hence there is no discontinuity in the analytical sense. However, the solution develops a very steep prole, depicted in Figure 7(b) before it becomes much steeper. Note that for x > 0, u0 (x) = sin x > 0 and for x < 0, u0 (x) < 0. Thus, all positive value range of sin x gets crammed around x = 0+ and all negative range of sin x gets crammed around x = 0 . 18

(b) A method on a uniform mesh based on centered spatial discretization and RK4, say, would be ne with h = .1 for t = 1 but not for t = 10. At the latter time oscillations develop. An upwind discretization does better, producing no oscillation, although the solution maximum and minimum shrink in absolute value as time progresses. A characteristics method whereby we (approximately) nd the characteristics xj (t) for values of an initially uniform mesh, xj (0) = + jh, j = 1, . . . , J, Jh = 2, and assign u(xj (t)) = sin( + jh), is very accurate at these highly nonuniform mesh points.

19

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy