1. Thurs 1/6 1 1. IVP for ODEs y ! = f (y) , y(0) = y0 : find y(t) ex y! = y , y ! = sin y y(0) = y0 , ⇒ y(0) = y0 y(t) = y0 et ⇒ y(t) = ? def An IVP is well-posed if the following conditions are satisfied. 1. A solution exists. 2. The solution is unique. 3. The solution depends continuously on the data (i.e. y0 , f ). def f satisfies a Lipschitz condition on a domain D if there exists a constant L st |f (y) − f (u)| ≤ L |y − u| for all y , u ∈ D. note : we typically assume that f (y) is smooth, so L = max |fy | thm If f satisfies a Lipschitz condition, then the IVP is well-posed. ex y ! = ay + b , y(0) = y0 ⇒ L = |a| , y(t) = y0 eat + b at (e − 1) a y ! = y 1/2 , y(0) = 0 ⇒ L = ∞ for y ≥ 0 , non-unique solution , y(t) = 0 , y ! = y 2 , y(0) = 1 ⇒ L = ∞ for y ≥ 1 , y(t) = 1 , lim y(t) = ∞ 1 − t t→1 t2 4 2 Euler’s method h = ∆t = step size , tn = nh yn = y(tn ) : exact solution , un : numerical approximation y ! = f (y) : differential equation un+1 − un = f (un ) : finite-difference scheme h un+1 = un + hf (un ) , u0 = y0 ex y ! = y , y0 = 1 u0 = 1 u1 = u0 + hf (u0 ) = 1 + h u2 = u1 + hf (u1 ) = (1 + h) + h(1 + h) = (1 + h)2 ··· un = (1 + h)n tn = 1 ⇒ nh = 1 , yn = y(1) = e = 2.7182818 . . . n 10 20 40 80 h 0.1 0.05 0.025 0.0125 un yn − un (yn − un )/h 2.5937425 0.1245 1.245 2.6532977 0.0650 1.300 2.6850638 0.0332 1.328 2.7014849 0.0168 1.344 3 Euler’s method y ! = y , y(0) = 1 un+1 = un + hun , u0 = 1 h=1 h=1/2 8 8 7 7 6 6 5 5 4 4 3 3 2 2 1 0 0.5 1 1.5 2 1 0 0.5 h=1/4 8 7 7 6 6 5 5 4 4 3 3 2 2 0 0.5 1 1.5 2 1.5 2 h=1/8 8 1 1 1.5 2 1 0 0.5 note 1. The solid line is the exact solution y(t). The circles are the numerical solution un . The dashed line is the piecewise linear interpolant of un . 2. For a fixed time t, the error decreases as h → 0. 3. For a fixed stepsize h, the error increases as t → ∞. 1 4 convergence proof (special case) y ! = y , y0 = 1 ⇒ y(t) = et un+1 = un + hun , u0 = 1 ⇒ un = (1 + h)n 1 n consider t = 1 , h = ! 1 lim un = n→∞ lim 1 + h→0 n ! 1 lim n ln 1 + n→∞ n " "n ! 1 = n→∞ lim exp n ln 1 + n = ∞ · 0 = n→∞ lim ⇒ lim un = e = y(1) h→0 ! ⇒ ln (1 + n1 ) 1 n "" = n→∞ lim ! 1 = exp n→∞ lim n ln 1 + n 1 1+ 1 n Euler’s method converges hw : y ! = ay + b , y(0) = y0 convergence proof (general case) y ! = f (y) , y(0) = y0 un+1 = un + hf (un ) , u0 : given fix t > 0 , set h = t/n ⇒ t = nh = tn , yn = y(tn ) goal : lim un = yn h→0 yn+1 = yn + hf (yn ) + τn , τn : local truncation error step 1 : estimate τn yn+1 = y(tn+1 ) = y(tn + h) = y(tn ) + hy ! (tn ) + h2 !! # y (t) 2 h2 !! # h2 !! # yn+1 = yn + hf (yn ) + y ( t ) ⇒ τn = y (t) 2 2 step 2 : analyze error , en = yn − un : error en+1 = yn+1 − un+1 = yn + hf (yn ) + τn − (un + hf (un )) = yn − un + h(f (yn ) − f (un )) + τn = en + h(f (yn ) − f (un )) + τn ! · −1 n2 · 1 −1 n2 "" = 1 5 |en+1 | ≤ |en | + h|f (yn ) − f (un )| + |τn | ≤ |en | + hL|yn − un | + τ , τ = max |τn | |en+1 | ≤ (1 + hL)|en | + τ |e1 | ≤ (1 + hL)|e0 | + τ |e2 | ≤ (1 + hL)|e1 | + τ ≤ (1 + hL)2 |e0 | + (1 + (1 + hL))τ |e3 | ≤ (1 + hL)|e2 | + τ ≤ (1 + hL)3 |e0 | + (1 + (1 + hL) + (1 + hL)2 )τ ··· |en | ≤ (1 + hL)n |e0 | + n−1 $ (1 + hL)j τ j=0 (1 + hL)n − 1 (1 + hL)n − 1 (1 + hL) = = (1 + hL) − 1 hL j=0 n−1 $ j note : 1 + x ≤ ex ⇒ (1 + x)n ≤ enx ⇒ (1 + hL)n ≤ enhL = eLt eLt − 1 τ |en | ≤ e |e0 | + hL Lt τ = max |τn | = h2 M , M = max |y !! (t)| 2 eLt − 1 M h |en | ≤ e |e0 | + L 2 Lt if lim |e0 | = 0 , then lim |en | = 0 ⇒ lim un = yn , i.e. Euler’s method converges h→0 h→0 h→0 note There are two types of convergence. 1. Fix t, set h = t/n. Does lim un = y(t)? h→0 2. Fix h. Does n→∞ lim un = y(∞)? 2. Tues 1/11 6 roundoff error un+1 = un + hf (un ) : Euler’s method in exact arithmetic vn+1 = vn + hf (vn ) + "n : computed solution in finite precision arithmetic yn+1 = yn + hf (yn ) + τn : exact solution let en = yn − vn en+1 = en + h(f (yn ) − f (vn )) + τn − "n |en+1 | ≤ (1 + hL)|en | + τ + " , τ = max |τn | , " = max |"n | eLt − 1 |en | ≤ e |e0 | + L " → ∞ as h → 0 h Lt ! Mh " + 2 h " note eLt − 1 M h |un − yn | ≤ : error bound L 2 We may rewrite this as un − yn = O(h). % % % % un − yn %%% This means there exists a constant C, independent of h, st % ≤ C for h eLt − 1 M all h sufficiently small. We may take C = . L 2 ex e−1 e y ! = y , y(0) = 1 , L = 1 , t = 1 , M = e , C = ∼ 2.34 1 2 % % % un − y n % % % ∼ 1.34 as h → 0. However, we saw computationally that % % h claim un − yn = hEn + O(h2 ) : asymptotic expansion (Math 557) % % % u − (y + hE ) % n n % % n % ≤C This means there exists a constant C, independent of h, st %% % h2 for all h sufficiently small. The constant En is defined by En = E(tn ), where E ! = fy (y)E − 12 y !! , E(0) = 0. E(t) is the principal error function. 7 ex y ! = y , y(0) = 1 E! = E − 1 2 et ⇒ E(t) = − 1 2 ⇒ un − yn = −1.36h + O(h2 ) tet , E(1) = −1.36 pf define dn = un − (yn + hEn ) we already know that dn = O(h) , we must show that dn = O(h2 ) dn+1 = un+1 − (yn+1 + hEn+1 ) = un + hf (un ) − (yn + hyn! + 12 h2 yn!! + O(h3 ) + h(En + hEn! + O(h2 ))) = un − (yn + hEn ) + h(f (un ) − yn! ) − h2 ( 12 yn!! + En! ) + O(h3 ) f (un ) = f (yn + hEn + dn ) = f (yn ) + fy (yn )(hEn + dn ) + O(h2 ) f (un ) − yn! = fy (yn )(hEn + dn ) + O(h2 ) dn+1 = dn + h(fy (yn )(hEn + dn ) + O(h2 )) − h2 ( 12 yn!! + En! ) + O(h3 ) = dn + hfy (yn )dn + h2 (fy (yn )En − 12 yn!! − En! ) + O(h3 ) & '( dn+1 = dn + hfy (yn )dn + O(h3 ) ) = 0 by definition of E(t) |dn+1 | ≤ (1 + hL)|dn | + κ , κ = O(h3 ) , d0 = 0 ··· eLt − 1 |dn | ≤ κ = O(h2 ) hL note ok un − yn = O(h) un − yn = hEn + O(h2 ) un − yn = hEn + h2 Dn + O(h2 ) , where Dn = D(tn ) hw : find the equation satisfied by D(t) 8 application : Richardson extrapolation un = yn + hEn + h2 Dn + · · · A00 = uh = y + hE + h2 D + O(h3 ) 2 A10 = uh/2 = y + h 2E + ( h2 ) D + O(h3 ) A20 = uh/4 = y + h 4E + ( h4 ) D + O(h3 ) 2 eliminate O(h) term 2A10 − A00 = A11 = y − h2 2 D + O(h3 ) 2A20 − A10 = A21 = y − h2 8 D + O(h3 ) eliminate O(h2 ) term 4A21 − A11 = A22 = y + O(h3 ) 3 note Aj0 = y + O(h) Aj1 = 2Aj0 − Aj−1,0 = y + O(h2 ) 4Aj1 − Aj−1,1 = y + O(h3 ) 3 8Aj2 − Aj−1,2 = = y + O(h4 ) 7 Aj2 = Aj3 ex : y ! = y , y(0) = 1 ⇒ y(1) = e = 2.7182818 j 0 1 2 3 h 0.1 0.05 0.025 0.0125 Aj0 2.5937425 2.6532977 2.6850638 2.7014849 Aj1 2.7128529 2.7168299 2.7179060 O(h) O(h2 ) Aj2 Aj3 2.7181556 2.7182647 2.7182803 O(h3 ) O(h4 ) down a column : decreasing step size , fixed order of accuracy , h-refinement across a row : fixed step size , increasing order of accuracy , p-refinement 3. Thurs 1/13 9 Taylor series methods y ! = f (y) yn+1 = yn + hyn! + h2 2 yn!! + · · · 1st order Taylor series method yn! = f (yn ) un+1 = un + hf (un ) : Euler’s method 2nd order Taylor series method yn!! = fy (yn ) · yn! = fy (yn ) · f (yn ) un+1 = un + hf (un ) + h2 2 fy (un ) · f (un ) ex y ! = y , y(0) = 1 un+1 = un + hun + h2 2 * un = 1 + h + h2 2 + un t = 1 , h = 1/n h 0.1 0.05 0.025 0.0125 un 2.7140808 2.7171911 2.7180039 2.7182117 y n − un (yn − un )/h2 0.0042010 0.4201 0.0010907 0.4363 0.0002779 0.4447 0.0000701 0.4488 10 Runge-Kutta methods y ! = f (y) k1 = f (un ) k2 = f (un + ahk1 ) un+1 = un + h(bk1 + ck2 ) : 2-stage RK method choose a , b , c to minimize the local truncation error yn+1 = yn + h(bf (yn ) + cf (yn + ahf (yn ))) + τn yn+1 = yn + hyn! + h2 2 yn!! + O(h3 ) f (yn ) = yn! f (yn + ahf (yn )) = f (yn ) + fy (yn ) · ahf (yn ) + O(h2 ) = yn! + ahyn!! + O(h2 ) h(byn! + c(yn! + ahyn!! + O(h2 )) + τn = hyn! + h2 2 yn!! + O(h3 ) h(b + c − 1)yn! + h2 (ac − 12 )yn!! + τn = O(h3 ) b + c − 1 = 0 , ac − c= 1 2 = 0 ⇒ τn = O(h3 ) 1 1 , b=1− : 1-parameter family of methods 2a 2a midpoint method : a = 1 2 , b=0 , c=1 k1 = f (un ) k2 = f (un + h 2 k1 ) un+1 = un + hk2 = un + hf (un + h 2 f (un )) modified Euler method : a = 1 , b = 1 2 , c= 1 2 k1 = f (un ) k2 = f (un + hk1 ) un+1 = un + h 2 (k1 + k2 ) = un + h 2 (f (un ) + f (un + hf (un ))) 11 4th order Runge-Kutta k1 = f (un ) k2 = f (un + h 2 k1 ) k3 = f (un + h 2 k2 ) k4 = f (un + hk3 ) un+1 = un + h 6 (k1 + 2k2 + 2k3 + k4 ) : 4 stages ex y ! = y , y(0) = 1 k1 = un k2 = un + h 2 k1 = (1 + h 2 )un k3 = un + h 2 k2 = (1 + h 2 (1 k4 = un + hk3 = (1 + h(1 + un+1 = un + h 6 (1 un+1 = (1 + h + + 2(1 + h2 2 + h3 6 + h 2 ))un + h 2) h 2 + = (1 + h2 4 ))un + 2(1 + h 2 h 2 + = (1 + h + + h2 4 ) un 2.7182511 2.7182797 2.7182817 h2 2 + + (1 + h + h4 24 )un t = 1 , h = 1/n h 0.2 0.1 0.05 h2 4 )un y n − un (yn − un )/h4 0.00003069185 0.01918 0.00000208432 0.02084 0.00000013580 0.02173 h3 4 )un h2 2 + h3 4 ))un 12 note Runge-Kutta methods have the form un+1 = un + hF (un , h). Moreover, (a) F (u, 0) = f (u) # # (b) there exists a constant L, independent of h, st |F (u, h) − F (v, h)| ≤ L|u − v| for all u , v in a given domain and h sufficiently small. ex : modified Euler method un+1 = un + F (u, h) = h 2 (f (un ) 1 2 (f (u) + f (un + hf (un ))) + f (u + hf (u))) (a) F (u, 0) = f (u) ok (b) |F (u, h) − F (v, h)| = = ≤ ≤ 1 2 |f (u) 1 2 |f (u) 1 2 |f (u) 1 2 L|u = 1 2 L|u ≤ 1 2 L|u + f (u + hf (u)) − (f (v) + f (v + hf (v)))| − f (v) + f (u + hf (u)) − f (v + hf (v))| − f (v)| + 12 |f (u + hf (u)) − f (v + hf (v))| − v| + 12 L|u + hf (u) − (v + hf (v)| − v| + 12 L|u − v + h(f (u) − f (v))| − v| + 12 L|u − v| + 12 Lh|f (u) − f (v)| ≤ L|u − v| + 12 Lh · L|u − v| = (L + 12 hL2 )|u − v| # Then |F (u, h) − F (v, h)| ≤ L|u − v| for 0 ≤ h ≤ 1, where L# = L + 12 L2 . hw : midpoint method thm 1. (a) 2. (b) ⇒ ⇒ 3. (a) + (b) τn = O(h2 ) (at least) the scheme is stable wrt initial data ⇒ the scheme converges ( i.e. lim un = y(t) ) h→0 ok 4. Tues 1/18 13 note 1. (a) ⇒ the difference scheme approximates the correct differential equation un+1 = un + hF (un , h) yn+1 = yn + hF (yn , h) + τn yn+1 − yn τn = F (yn , h) + ⇒ yn! = f (yn ) h h In this case we say that the difference scheme is consistent with the differential equation. 2. The scheme is stable wrt initial data if |un − vn | ≤ C|u0 − v0 |, where un , vn are the numerical solutions starting from u0 , v0 and C is independent of h, i.e. a small change in the initial data of the difference scheme leads to a small change in the solution of the difference scheme. 3. The theorem says that consistency + stability ⇒ convergence. pf 1. un+1 = un + hF (un , h) yn+1 = yn + hF (yn , h) + τn yn + hyn! + O(h2 ) = yn + h(F (yn , 0) + O(h)) + τn ok 2. Let un , vn be the numerical solutions starting from u0 , v0 . |un+1 − vn1 | = |un + hF (un , h) − (vn + hF (vn , h))| ≤ |un − vn | + h|F (un , h) − F (vn , h)| ⇒ # ≤ (1 + hL)|u n − vn | # # # n |un − vn | ≤ (1 + hL) |u0 − v0 | ≤ enhL |u0 − v0 | = eLt |u0 − v0 | 3. define en = yn − un ok en+1 = yn+1 − un+1 = yn + hF (yn , h) + τn − (un + hF (un , h)) = · · · # eLt − 1 |en+1 | ≤ (1 + hL)|en | + τn , . . . |en | ≤ e |e0 | + · τ , τ = max τn hL# # # Lt ok 14 note 1. A method of the form un+1 = un + hF (un , h) is an explicit 1-step method. This includes Runge-Kutta and Taylor series methods. 2. If τ = O(hp+1 ), then |un − yn | = O(hp ), i.e. the global error is one order lower than the local truncation error. We say that the method is p-th order accurate. generalization 1. systems y1! = f1 (y1 , . . . , yN ) .. . ! yN = fN (y1 , . . . , yN ) ⇒ y1 . ! . y = f (y) , y = . , f = yN f1 . .. fN 2. non-autonomous equations ! y = f (y, t) , y1 = y y2 = t 6 ⇒ ! y1 y2 "! = y1 y2 "! ! f (y1 , y2 ) 1 " 3. higher order equations !! y1 = y y2 = y ! ! y = f (y, y ) , 6 ⇒ ! = ! y2 f (y1 , y2 ) " def : A vector norm ||y|| has the following properties. 1. ||y|| ≥ 0 , ||y|| = 0 ⇔ y = 0 2. ||αy|| = |α| · ||y|| 3. ||y + u|| ≤ ||y|| + ||u|| ex ||y||1 = N $ i=1 |yi | , ||y||∞ = max |yi | , ||y||2 = note N $ i=1 |yi 1/2 |2 Given a vector norm ||y||, the subordinate matrix norm is ||A|| = max y+=0 ||A|| satisfies properties 1, 2, 3 above and 4, 5 below. 4. ||Ay|| ≤ ||A|| · ||y|| , 5. ||AB|| ≤ ||A|| · ||B|| ||Ay|| . ||y|| 15 ex ||A||1 = max j N $ i=1 ||A||∞ = max i |aij | : max column sum N $ j=1 |aij | : max row sum ||A||2 = max σi (A) : max singular value , maxi |λ(A)| if A is real symmetric i pf : Math 571 note All previous results for a scalar equation also hold for a system of equations, with |y| → ||y|| and L = max |fy | → L = max ||fy || , fy = (∂fi /∂yj ). absolute stability Consider y ! = λy, where y is a scalar and λ is a complex number (test equation). The exact solution is y(t) = y(0)eλt , and if real(λ) ≤ 0, then y(t) is bounded as t → ∞ for all initial data. The analogous property for the numerical method is absolute stability, i.e. a numerical method with step size h is absolutely stable if un is bounded as n → ∞ for all initial data, where un is the result of applying the numerical method to the test equation. ex : Euler’s method y ! = λy ⇒ un+1 = un + hλun = (1 + hλ)un ⇒ un = (1 + hλ)n u0 un is bounded as n → ∞ ⇔ |1 + hλ| ≤ 1 ⇔ |hλ − (−1)| ≤ 1 Euler’s method is absolutely stable ⇔ hλ lies in the region of absolute stability h ! ! plane !2 !1 16 ex y ! = Ay : linear system assume A is diagonalizable : A = XDX −1 D = diag(λ1 , . . . , λN ) , X = [x1 · · · xN ] , Axj = λj xj , j = 1, . . . , N y(t) = α1 eλ1 t x1 + · · · + αN eλN t xN un+1 = un + hAun = (I + hA)un un = (I + hA)n u0 = α1 (1 + hλ1 )n x1 + · · · + αN (1 + hλN )n xN absolute stability ⇔ |1 + hλj | ≤ 1 , j = 1, . . . , N Hence to ensure absolute stability for a diagonalizable linear system y ! = Ay, it is sufficient to ensure absolute stability for the scalar test equation y ! = λy for each eigenvalue of A. ex ! y1 y2 "! ! −11 9 = 9 −11 "! y1 y2 " y(t) = α1 e−20t x1 + α2 e−2t x2 ⇒ : λ1 = −20 , λ2 = −2 : stiff system fast component + slow component un = α1 (1 − 20h)n x1 + α1 (1 − 2h)n x2 absolute stability ⇔ |1 − 20h| ≤ 1 , |1 − 2h| ≤ 1 ⇔ −1 ≤ 1 − 20h ≤ 1 , −1 ≤ 1 − 2h ≤ 1 ⇔ −1 ≤ 1 − 20h , −1 ≤ 1 − 2h ⇔ h ≤ 0.1 , h ≤ 1 Hence we must choose h ≤ 0.1 to ensure that Euler’s method is absolutely stable. note The fast component of the exact solution decays rapidly, and after some time, essentially only the slow component is present, i.e. y(t) ∼ α2 e−2t x2 . The slow component by itself requires only h ≤ 1 for absolute stability, but we must choose h ≤ 0.1 to ensure absolute stability of Euler’s method applied to the system. 17 ex : ! y1 y2 "! ! −11 9 = 9 −11 "! y1 y2 " , ! y1 y2 " 0 = 2 0 3 3 2 2 1 1 0 0 !1 !1 !2 !2 !3 !3 0.5 1 1.5 2 3 3 2 2 1 1 0 0 !1 !1 !2 !2 !3 !3 0.5 1 1.5 2 0 0 forward Euler , h = 0.09 , AS 3 2 2 1 1 0 0 !1 !1 !2 !2 0 0.5 1 1.5 0.5 1 1.5 2 0.5 1 1.5 2 backward Euler , h = 0.09 , AS 3 !3 , solid line = y1 (t) backward Euler , h = 0.1 , AS forward Euler , h = 0.1 , AS 0 " backward Euler , h = 0.1025 , AS forward Euler , h = 0.1025 , not AS 0 ! 2 !3 0 0.5 1 1.5 2 5. Thurs 1/20 18 backward Euler method un+1 − un = f (un+1 ) ⇒ un+1 = un + hf (un+1 ) : implicit h note : forward Euler is explicit claim : τn = O(h2 ) pf : hw test equation : y ! = λy un+1 = un + hλun+1 absolute stability ⇔ ⇒ % % % % %1 (1 − hλ)un+1 = un % 1 %% % ≤ 1 − hλ % ⇔ ⇒ un+1 = 1 un 1 − hλ |1 − hλ| ≥ 1 h ! ! plane 1 note 1. A scheme is called A-stable if the region of absolute stability contains the left half-plane. Backward Euler is A-stable and forward Euler is not A-stable. For an A-stable scheme, the stepsize h is not restricted by absolute stability and it can be chosen entirely on the basis of accuracy requirements. 2. un+1 = un + hf (un+1 ) can be solved by iteration. (0) (m+1) un+1 = un + hf (un ) , un+1 (m) = un + hf (un+1 ) : predictor-corrector Thus implicit schemes require more work per timestep than explicit schemes. 3. un+1 = un + h2 (f (un ) + f (un+1 )) : trapezoid method , implicit claim : τn = O(h3 ) , A-stable pf : hw 19 region of absolute stability for 4th order Runge-Kutta k1 = f (un ) , k2 = f (un + h2 k1 ) , k3 = f (un + h2 k2 ) , k4 = f (un + hk3 ) un+1 = uu + h6 (k1 + 2k2 + 2k3 + k4 ) y ! = λy ⇒ un+1 h2 λ2 h3 λ3 h4 λ4 = 1 + hλ + + + un 2 6 24 4 3 2 1 0 !1 !2 !3 !4 !5 !4 !3 !2 !1 0 1 The region of absolute stability for RK4 : 7 1. is larger than the region for forward Euler, 2. contains an interval on the imaginary axis. 2 3 20 multistep methods Adams-Bashforth un+1 = un + h(β0 f (un ) + β1 f (un−1 ) + · · · + βk f (un−k )) : (k + 1)-step method , explicit idea ! y = f (y) ⇒ yn+1 = yn + 8 t n+1 tn f (y(t)) dt approximate f (y(t)) by an interpolating polynomial p(t) p(tn ) = f (un ) p(tn−1 ) = f (un−1 ) .. . p(tn−k ) = f (un−k ) def ∇fn = fn − fn−1 : backward difference ∇2 fn = ∇(∇fn ) = ∇(fn − fn−1 ) = ∇fn − ∇fn−1 = fn − fn−1 − (fn−1 − fn−2 ) = fn − 2fn−1 + fn−2 .. . Ifn = fn , S− fn = fn−1 ⇒ ∇ = I − S− ∇fn ∇2 fn p(t) = fn + (t − tn ) + (t − tn )(t − tn−1 ) 2 h 2h ∇k fn + · · · + (t − tn ) · · · (t − tn−k+1 ) k! hk & '( ) k terms note p(t) is a polynomial of degree k , it resembles a Taylor polynomial ∇i fn p(t) = (t − tn ) · · · (t − tn−i+1 ) i! hi i=0 k $ 6. Tues 1/25 21 claim 1. p(tn−j ) = fn−j , j = 0, . . . , k : k + 1 interpolation points (t − tn ) · · · (t − tn−k ) dk+1 2. f (y(t)) − p(t) = f (y(α)) for some α = α(t) (k + 1)! dtk+1 note p(t) interpolates f (un−j ) in 1 and f (yn−j ) in 2. pf 1. p(tn ) = fn p(tn−1 ) = fn + (tn−1 − tn ) = fn + (−h) ∇fn h ∇fn = fn − ∇fn = fn − (fn − fn−1 ) = fn−1 h p(tn−2 ) = fn + (tn−2 − tn ) ∇fn ∇2 fn + (tn−2 − tn )(tn−2 − tn−1 ) 2 h 2h ∇fn ∇2 fn = fn + (−2h) + (−2h)(−h) 2 h 2h = fn − 2∇fn + ∇2 fn = fn − 2(fn − fn−1 ) + (fn − 2fn−1 + fn−2 ) = fn−2 ∇i fn p(tn−j ) = (tn−j − tn )(tn−j − tn−1 ) · · · (tn−j − tn−i+1 ) i! hi i=0 j $ (check i = 0) ∇i fn = (−jh)(−(j − 1)h) · · · (−(j − i + 1)h) i! hi i=0 j $ ∇i fn = (−1)i · hi · j(j − 1) · · · (j − i + 1) = i i! h i=0 j $ recall : binomial expansion j $ j aj−i bi (a + b)j = i=0 i ⇒ p(tn−j ) = j $ i=0 , (−1)i i=0 j i ∇ fn i j j! = : binomial coefficient i i!(j − i)! j I j−i (−∇)i f n i j $ = (I − ∇)j fn = S−j fn = fn−j ok 22 recall 8 t n+1 yn+1 = yn + un+1 = un + t − tn h s = tn 8 t f (y(t)) dt n+1 tn p(t) dt ⇒ t − tn = sh t − tn−1 = t − tn + tn − tn−1 = sh + h = (s + 1)h .. . t − tn−k+1 = (s + k − 1)h p(t) = fn + s∇fn + 8 t n+1 tn p(t) dt = 8 1 0 s(s + 1) 2 s(s + 1) · · · (s + k − 1) k ∇ fn + · · · + ∇ fn 2 k! 9 p(t(s))hds = h γ0 fn + γ1 ∇fn + γ2 ∇2 fn + · · · + γk ∇k fn γ0 = 8 1 ds = 1 γ1 = 8 1 s ds = γ2 = 8 1 s(s + 1) ds = 2 8 1 s(s + 1) · · · (s + k − 1) ds , k ≥ 1 k! .. . γk = 0 0 0 0 : 1 2 5 12 k = 0 : 1-step AB un+1 = un + hγ0 fn = un + hfn : Euler’s method k = 1 : 2-step AB 9 : un+1 = un +h (γ0 fn + γ1 ∇fn ) = un +h fn + 12 (fn − fn−1 ) = un + h2 (3fn −fn−1 ) k = 2 : 3-step AB 9 : un+1 = un + h γ0 fn + γ1 ∇fn + γ2 ∇2 fn = un + h 12 (23fn − 16fn−1 + 5fn−2 ) 23 note 1. To get started, we set u0 = y0 , but we also need to compute u1 , u2 , . . . , uk . 2. To compute un+1 from un , only 1 function evaluation fn = f (un ) is needed. 3. Changing the step size h requires interpolation or variable coefficient formulas. pf 2. (t − tn ) · · · (t − tn−k ) dk+1 goal : f (y(t)) = p(t) + f (y(α)) (k + 1)! dtk+1 assume t += tn−j , j = 0, . . . , k g(x) = f (y(x)) − p(x) + (x − tn ) · · · (x − tn−k ) ( p(t) − f (y(t)) ) (t − tn ) · · · (t − tn−k ) g(tn ) = 0 , g(tn−1 ) = 0 , . . . , g(tn−k ) = 0 , g(t) = 0 ⇒ g(x) has k + 2 distinct roots ⇒ g ! (x) has k + 1 distinct roots .. . ⇒ g (k+1) (x) has 1 root , say g (k+1) (α) = 0 then 0 = g (k+1) (α) = ( MVT : Math 451 ) dk+1 (k + 1)!( p(t) − f (y(t)) ) f (y(α)) + dtk+1 (t − tn ) · · · (t − tn−k ) local truncation error : (k + 1)-step AB yn+1 = yn + un+1 = un + yn+1 = yn + ; tn+1 tn ; tn+1 tn ; tn+1 tn τn = yn+1 − yn − = 8 t n+1 = 8 1 tn 0 f (y(t)) dt p(t) dt p(t) dt + τn ; tn+1 tn p(t) dt = ; tn+1 tn ( f (y(t) − p(t) ) dt (t − tn ) · · · (t − tn−k ) dk+1 f (y(α)) dt (k + 1)! dtk+1 s(s + 1) · · · (s + k)hk+1 (k+2) # hk+2 y (α) h ds = γk+1 y (k+2) (α) (k + 1)! ok 7. Thurs 1/27 24 Adams-Moulton ∗ un+1 = un + h(β−1 f (un+1 ) + β0∗ f (un ) + · · · + βk∗ f (un−k )) : (k + 1)-step method , implicit p∗ (t) interpolates fn+1 , fn , . . . , fn−k ∗ p (t) = fn+1 : k + 2 values ∇fn+1 ∇2 fn+1 + (t − tn+1 ) + (t − tn+1 )(t − tn ) h 2h2 + · · · + (t − tn+1 ) · · · (t − tn+1−k ) & '( k + 1 terms ) ∇k+1 fn+1 (k + 1)! hk+1 t − tn = sh ⇒ t − tn+1 = t − tn + tn − tn+1 = sh − h = (s − 1)h p∗ (t) = fn+1 + (s − 1)∇fn+1 + (s − 1)s 2 ∇ fn+1 2 + ··· + un+1 = un + 8 t n+1 ∗ p (t) dt tn = (s − 1) · · · (s + k − 1) k+1 ∇ fn+1 (k + 1)! 8 1 p∗ (t(s))hds 0 9 ∗ un+1 = un + h γ−1 fn+1 + γ0∗ ∇fn+1 + · · · + γk∗ ∇k+1 fn+1 γk∗ = ∗ γ−1 8 1 (s − 1)s · · · (s + k − 1) ds , k ≥ 0 (k + 1)! 0 = 8 1 0 γ0∗ = 8 1 γ1∗ = 8 1 0 0 ds = 1 (s − 1) ds = − 12 (s − 1)s 1 ds = − 12 2 k = −1 ∗ un+1 = un + hγ−1 fn+1 = un + hfn+1 : backward Euler : 25 k = 0 : 1-step AM 9 : ∗ un+1 = un + h (γ−1 fn+1 + γ0∗ ∇fn+1 ) = un + h fn+1 − 12 (fn+1 − fn ) un+1 = un + h2 (fn+1 + fn ) : trapezoid method k = 1 : 2-step AM ∗ un+1 = un + h (γ−1 fn+1 + γ0∗ ∇fn+1 + γ1∗ ∇fn+1 ) un+1 = un + h 12 (5fn+1 + 8fn − fn−1 ) summary AB 9 un+1 = un + h γ0 fn + γ1 ∇fn + · · · + γk ∇k fn γk = 8 1 0 : : k + 1-step s(s + 1) · · · (s + k − 1) ds , k ≥ 1 , γ0 = 1 k! τn = γk+1 y (k+2) (t) hk+2 + O(hk+3 ) AM 9 ∗ un+1 = un + h γ−1 fn+1 + γ0∗ ∇fn+1 + · · · + γk∗ ∇k+1 fn+1 γk∗ = 8 1 0 (s − 1)s · · · (s + k − 1) ∗ ds , k ≥ 0 , γ−1 = 1 (k + 1)! ∗ τn = γk+1 y (k+3) (t) hk+3 + O(hk+4 ) note k-step AB has global order of accuracy k k-step AM · · · · · · · · · · · · ” · · · · · · · · · · · · k + 1 : : k + 1-step 26 region of absolute stability 1 AB hλ-plane 0.8 0.6 0.4 0.2 6 0 5 4 !0.2 !0.4 3 !0.6 !0.8 2 1 !1 !2 !1.5 !1 !0.5 0 0.5 1 5 4 AM hλ-plane 3 2 1 0 3 4 5 6 !1 !2 !3 !4 !5 !8 !6 !4 !2 0 2 4 The method of order k is absolutely stable inside the contour. Note the difference in scale; the regions are much smaller for AB than for AM. (1-step and 2-step AM are not shown because they are A-stable) 27 general multistep methods α0 un + α1 un−1 + · · · + αk un−k + h(β0 f (un ) + β1 f (un−1 ) + · · · + βk f (un−k )) = 0 : k-step method k $ (αi un−i + hβi f (un−i )) = 0 i=0 predictor : β0 = 0 α0 u(0) n =− k $ (αi un−i + hβi f (un−i )) i=1 corrector α0 u(m+1) n = −hβ0 f (u(m) n ) − k $ (αi un−i + hβi f (un−i )) i=1 local truncation error : (general case) k $ (αi yn−i + hβi f (yn−i )) = τn = O(hr+1 ) i=0 yn−i y (j) (t) = y(t − ih) = (−ih)j + O(hr+2 ) j! j=0 τn = r+1 $ k $ i=0 ! (αi yn−i + hβi yn−i ) r+1 $ y (j+1) (t) y (j) (t) j = αi (−ih) + hβi (−ih)j + O(hr+2 ) j! j! i=0 j=0 j=0 k $ r+1 $ r+1 $ y (j) (t) y (j) (t) j = αi (−ih) + hβi (−ih)(j−1) + O(hr+2 ) j! i=0 j=0 j=1 (j − 1)! k $ τn = r+1 $ r+1 $ Cj y (j) (t)hj + O(hr+2 ) j=0 C0 = k $ i=0 αi , (−i)j αi (−i)(j−1) βi Cj = + j! (j − 1)! i=0 k $ If C0 = · · · = Cr = 0 , Cr+1 += 0 , then τn = Cr+1 y (r+1) (t)hr+1 + O(hr+2 ) and we have a k-step method of order r. 8. Tues 2/1 28 ex : leap-frog method y ! = f (y) un+1 − un−1 = f (un ) 2h un+1 − un−1 − 2hf (un ) = 0 : explicit , 2-step , needs u0 , u1 to start α0 = 1 , α1 = 0 , α2 = −1 , β0 = 0 , β1 = −2 , β2 = 0 C0 = k $ αi = α0 + α1 + α2 = 0 k $ (−iαi + βi ) = −α1 − 2α2 + β0 + β1 + β2 = 0 i=0 C1 = i=0 i2 αi α1 C2 = − iβi = + 2α2 − β1 − 2β2 = 0 2 2 i=0 k $ −i3 αi i2 βi −α1 4 1 1 C3 = + = − α2 + β1 + 2β2 = 6 2 6 3 2 3 i=0 k $ 1 (3) y (t)h3 + O(h4 ) ⇒ leap-frog has order 2 3 question : What is the maximum order of a k-step multistep scheme? τn = α0 , . . . , αk , β0 , . . . , βk : 2k + 2 unknown coefficients ⇒ 2k + 1 degrees of freedom ⇒ C0 = · · · = C2k = 0 , C2k+1 += 0 ⇒ τn = O(h2k+1 ) is optimal ⇒ the maximum order of a k-step multistep scheme is 2k ex k = 1 : trapezoid method has order 2 k = 2 : 2-step AB has order 2 , 2-step AM has order 3 In fact, there exists a 2-step method of order 4. (more later) note : RK4 is a 1-step scheme of order 4, but there is no contradiction because RK4 is not a multistep scheme of the form considered here 29 characteristic polynomials of a multistep scheme α0 un + α1 un−1 + · · · + αk un−k + h(β0 f (un ) + β1 f (un−1 ) + · · · + βk f (un−k )) = 0 k def : ρ(ζ) = α0 ζ + α1 ζ k−1 + · · · + αk = σ(ζ) = β0 ζ k + β1 ζ k−1 + · · · + βk = k $ αi ζ k−i k $ βi ζ k−i i=0 i=0 note ρ(1) = k $ αi = C0 k $ βi k $ (k − i)αi = k i=0 σ(1) = i=0 ρ! (1) = i=0 k $ i=0 αi + k $ (−iαi + βi ) − i=0 k $ i=0 βi = kC0 + C1 − σ(1) recall : a method is consistent ⇔ τn = O(hr+1 ) for some r ≥ 1 ⇔ C0 = C1 = 0 ⇔ ρ(1) = 0 , ρ! (1) + σ(1) = 0 ex : leap-frog un − un−2 − 2hf (un−1 ) = 0 ⇒ ρ(ζ) = ζ 2 − 1 , σ(ζ) = −2ζ ρ(1) = 0 , ρ! (1) + σ(1) = 0 ⇒ leap-frog is consistent questions When is a general multistep scheme stable? convergent? absolutely stable? special case : y ! = 0 k $ αi un−i = 0 : linear , constant coefficient , homogeneous difference equation i=0 α0 un + α1 un−1 + · · · + αk un−k = 0 (∗) given u0 , u1 , . . . , uk−1 , use (∗) to solve for uk , uk+1 , . . . 30 note If we set un = ζ n , then k $ αi un−i = i=0 k $ αi ζ n−i = ζ n−k i=0 k $ αi ζ k−i = ζ n−k ρ(ζ). i=0 Hence if ρ(ζ) = 0, then un = ζ n is a solution of (∗). thm If ρ(ζ) has j distinct roots ζ1 , . . . , ζj with multiplicities m1 , . . . , mj , then the general solution of the difference equation (∗) has the form un = (a10 + a11 n + a12 n2 + · · · + a1,m1 −1 nm1 −1 )ζ1n .. . + (aj0 + aj1 n + aj2 n2 + · · · + aj,mj −1 nmj −1 )ζjn , where a10 , . . . , aj,mj −1 are determined by the initial data u0 , . . . , uk−1 . def ζ1 , . . . , ζj are the characteristic roots of the difference equation (∗) ex 1. un + 4un−1 − 5un−2 = 0 ρ(ζ) = ζ 2 + 4ζ − 5 = (ζ − 1)(ζ + 5) ⇒ ζ1 = 1 , ζ2 = −5 , m1 = m2 = 1 un = a1 ζ1n + a2 ζ2n = a1 + a2 (−5)n check . . . 2. un − 2un−1 + un−2 = 0 ρ(ζ) = ζ 2 − 2ζ + 1 = (ζ − 1)2 ⇒ ζ1 = 1 , m1 = 2 un = (a1 + a2 n)ζ1n = a1 + a2 n check . . . note There is an analogy between difference equations and differential equations. α0 y (k) + α1 y (k−1) + · · · + αk y = 0 , y(t) = eλt ⇒ ρ(λ) = 0 1. y !! +4y ! −5y = 0 ⇒ λ1 = 1 , λ2 = −5 , m1 = m2 = 1 ⇒ y(t) = a1 et +a2 e−5t 2. y !! − 2y ! + y = 0 ⇒ λ1 = 1 , m1 = 2 ⇒ y(t) = (a1 + a2 t)et 9. Thurs 2/3 31 pf (sketch) α0 un + α1 un−1 + · · · + αk un−k = 0 α1 αk α1 αk un = − un−1 − · · · − un−k ⇒ uk = − uk−1 − · · · − u0 α0 α0 α0 α0 α1 αk uk uk−1 − · · · · · · − α0 α0 u k−1 . .. = u1 U1 = AU0 , 1 0 ... ... 1 0 ⇒ Un = AUn−1 u k−2 . .. u0 Un = An U0 A = XJX −1 : Jordan form , (−1)k det(A − λI) = ρ(λ) ⇒ α0 e-values of A are characteristic roots of (∗) J= J1 0 ... 0 Jj note , Ji = ζi An = XJ n X −1 1 ... ... ... 0 0 1 ζi : mi × mi ok the difference scheme (∗) is absolutely stable ⇔ every solution un of (∗) is bounded as n → ∞ ⇔ ρ(ζ) satisfies the root condition : 7 1. |ζi | ≤ 1 for i = 1, . . . , j 2. if |ζi | = 1 , then mi = 1 0 if |ζ| < 1 pf : n→∞ lim n |ζ| = 1 if |ζ| = 1 , p = 0 ∞ if |ζ| > 1 or |ζ| = 1 , p ≥ 1 p ex n ρ(ζ) root condition? un ζ + 4ζ − 5 no a1 + a2 (−5)n ζ 2 − 2ζ + 1 no a1 + a2 n 2 ζ −1 yes a1 + a2 (−1)n 2 32 test equation : y ! = λy k $ i=0 (αi un−i + hβi f (un−i )) = 0 ⇒ k $ (αi + hλβi )un−i = 0 i=0 (α0 + hλβ0 )un + (α1 + hλβ1 )un−1 + · · · + (αk + hλβk )un−k = 0 (∗∗) note If we set un = ζ n , then k $ (αi + hλβi )un−i = · · · = ζ n−k (ρ(ζ) + hλσ(ζ)). i=0 Hence if ρ(ζ) + hλσ(ζ) = 0, then un = ζ n is a solution of (∗∗). claim 1. If ρ(1) = 0, ρ! (1) += 0, then ρ(ζ) + hλσ(ζ) has a root ζ1 (h) st lim ζ1 (h) = 1. h→0 r+1 2. If in addition τn = O(h hλ ), then ζ1 (h) = e r+1 + O(h ). note 1. ρ(1) = 0 , ρ! (1) += 0 ⇒ ρ(ζ) has a simple root at ζ = 1 This holds if the scheme is consistent and ρ(ζ) satisfies the root condition. 2. ζ1 (h) is called the principal root of the difference scheme (∗∗); the other roots of ρ(ζ) + hλσ(ζ) are denoted ζ2 (h), . . . and are called the extraneous roots. For fixed t = nh, (∗∗) has a solution of the form un = ζ1 (h)n = (ehλ + O(hr+1 ))n = eλt + O(hr ). This justifies calling ζ1 (h) the principal root. ex : 2-step AB y ! = λy , un − un−1 − 12 hλ(3un−1 − un−2 ) = 0 ρ(ζ) = ζ 2 − ζ ρ(1) = 0 , ρ! (1) += 0 , τn = O(h3 ) ⇒ ρ(ζ) + hλσ(ζ) = ζ 2 − ζ − 12 hλ(3ζ − 1) ζ1 (h) = 1 2 + 34 hλ + 1 2 ζ2 (h) = 1 2 + 34 hλ − 1 2 9 1 + hλ + 94 h2 λ2 9 1 + hλ + 94 h2 λ2 :1/2 :1/2 ζ1 (h)n = (ehλ + O(h3 ))n = eλt + O(h2 ) ζ2 (h)n = O(hn ) un = a1 ζ1 (h)n + a2 ζ2 (h)n = ehλ + O(h3 ) = O(h) ⇒ claim applies 10. Tues 2/8 33 Consider y(0) = 1 , y(t) = eλt . Take u0 = 1 , u1 = ehλ . ! 1 ζ1 1 ζ2 "! a1 a2 " ! 1 = hλ e " ! ⇒ a1 a2 " 1 = ζ1 − ζ2 ! hλ e − ζ2 ζ1 − ehλ ehλ − ζ2 ehλ − ζ1 + ζ1 − ζ2 a1 = = = 1 + O(h3 ) , ζ1 − ζ2 ζ1 − ζ2 ζ1 − ehλ a2 = = O(h3 ) ζ1 − ζ2 9 : 9 " ζ1 − ζ2 = O(1) : un = 1 + O(h3 ) · eλt + O(h2 ) + O(h3 ) · O(hn ) ⇒ lim un = eλt , i.e. the 2-step AB scheme converges for fixed t = nh h→0 ex : leap-frog y ! = λy , un − un−2 − 2hλun−1 = 0 ρ(ζ) = ζ 2 − 1 ρ(1) = 0 , ρ! (1) += 0 , τn = O(h3 ) ⇒ ⇒ ρ(ζ) + hλσ(ζ) = ζ 2 − 1 − 2hλζ claim applies ζ1 (h) = hλ + (1 + h2 λ2 )1/2 = ehλ + O(h3 ) ζ2 (h) = hλ − (1 + h2 λ2 )1/2 = −e−hλ + O(h3 ) ζ1 (h)n = (ehλ + O(h3 ))n = eλt + O(h2 ) ζ2 (h)n = ( − e−hλ + O(h3 ))n = (−1)n e−λt + O(h2 ) 9 : 9 : 9 : un = 1 + O(h3 ) · eλt + O(h2 ) + O(h3 ) · (−1)n e−λt + O(h2 ) ⇒ lim un = eλt , i.e. the leap-frog scheme converges for fixed t = nh h→0 note : if h is fixed and n → ∞, then O(h3 )(−1)n e−λt → 7 0 if real(λ) > 0 ±∞ if real(λ) < 0 This is an example of weak instability, which arises when ρ(ζ) has two distinct roots on the unit circle. In this case, the roots of ρ(ζ) + hλσ(ζ) may lie inside or outside the unit circle. For the leap-frog method with real(λ) > 0, the extraneous root ζ2 (h) lies inside the unit circle and is harmless, but with real(λ) < 0, ζ2 (h) lies outside the unit circle and a2 ζ2 (h)n eventually dominates a1 ζ1 (h)n , even though a2 = O(h3 ). 34 weak instability of the leap-frog method y ! = λy , y(0) = 1 , un+1 = un−1 + 2hλun , u0 = 1 , u1 = ehλ ! = 1 , h = 0.5 ! = !1 , h = 0.5 150 1 100 0.5 50 0 0 0 1 2 3 4 5 !0.5 0 1 ! = 1 , h = 0.25 1 100 0.5 50 0 0 1 2 3 4 5 !0.5 0 1 ! = 1 , h = 0.125 1 100 0.5 50 0 0 1 2 3 4 5 2 3 4 5 4 5 ! = !1 , h = 0.125 150 0 3 ! = !1 , h = 0.25 150 0 2 4 5 !0.5 0 1 2 3 35 absolute stability of leap-frog method y ! = λy , un+1 = un−1 + 2hλun what do we know already? ρ(ζ) = ζ 2 − 1 = 0 ⇒ ζ = ±1 : root condition is satisfied ρ(ζ) + hλσ(ζ) = ζ 2 − 1 − 2hλζ = (ζ − ζ1 )(ζ − ζ2 ) ζ1 = ehλ + O(h3 ) , ζ2 = −e−hλ + O(h3 ) If we ignore the O(h3 ) terms, then (a) |ζ1 | = |ζ2 | = 1 ⇔ λ is purely imaginary, (b) if |ζ1 | < 1, then |ζ2 | > 1, and if |ζ1 | > 1, then |ζ2 | < 1. Now we will make this more precise. ! " 2 9 :1/2 ζ − 1 1 1 ζ = hλ ± 1 + h2 λ2 , hλ = = ζ− : conformal mapping 2ζ 2 ζ ζ-plane hλ-plane i 1 −i 1. the branch points hλ = ±i are fixed by the mapping, and every other point in the hλ-plane corresponds to 2 points in the ζ-plane, e.g. hλ = 0 ⇔ ζ = ±1 9 2. hλ = iy , |y| ≤ 1 ⇒ ζ = iy ± 1 − y 2 :1/2 : unit circle in ζ-plane : 1 9 iθ e − e−iθ = i sin θ : imaginary interval in hλ-plane 2 3. For any value of hλ away from the interval, the corresponding values of ζ are away from the circle. In fact ζ1 ζ2 = −1, so one root lies inside the circle and the other root lies outside. Hence the region of absolute stability of the leap-frog method is the interval in the hλ-plane between −i and i, excluding ±i. ζ = eiθ ⇒ hλ = 11. Thurs 2/10 36 pf (claim) 1. set F (ζ, h) = ρ(ζ) + hλσ(ζ) = 0 , F (1, 0) = ρ(1) = 0 , Fζ (1, 0) = ρ! (1) += 0 implicit function thm ⇒ there exists ζ1 (h) st F (ζ1 (h), h) = 0 , lim ζ1 (h) = 1 h→0 ok λt λnh 2. set y(t) = e = e τn = k $ (αi + hλβi )yn−i = i=0 = eλ(n−k)h k $ (αi + hλβi )eλ(n−i)h i=0 k $ 9 : (αi + hλβi )eλ(k−i)h = eλ(n−k)h ρ(ehλ ) + hλσ(ehλ ) i=0 ρ(ehλ ) + hλσ(ehλ ) = O(hr+1 ) ⇒ set ζ1 (h) = ehλ + " , lim ζ1 (h) = 1 ⇒ lim " = 0 h→0 h→0 0 = ρ(ζ1 (h)) + hλσ(ζ1 (h)) = ρ(ehλ + ") + hλσ(ehλ + ") = ρ(ehλ ) + ρ! (ehλ )" + O("2 ) + hλσ(ehλ ) + O(h") = O(hr+1 ) + O(") + O("2 ) + O(h") ⇒ " = O(hr+1 ) ok convergence theory y ! = f (y) , y(0) = y0 : well-posed IVP k $ (αi un−i + hβi f (un−i )) = 0 , u0 , u1 , . . . , uk−1 : given i=0 def 1. A multistep method is convergent if un → y(t) as n → ∞, under the assumptions that t = nh is fixed and u0 , u1 , . . . , uk−1 → y0 . 2. A multistep method is stable wrt initial data if there exists a constant C st for all n ≥ k, |un − vn | ≤ C · max{|u0 − v0 |, . . . , |uk−1 − vk−1 |}, where un , vn are two solutions of the difference scheme, t = nh is fixed, and h is sufficiently small. The constant C may depend on t, but must be independent of n. thm 1. stability ⇔ root condition for ρ(ζ) 2. if the scheme is consistent, then stability ⇔ convergence 37 ex un + 4un−1 − 5un−2 − h(4f (un−1 + 2f (un−2 )) = 0 : 2-step , explicit hw : τn = O(h4 ) ⇒ the scheme is consistent ρ(ζ) = ζ 2 + 4ζ − 5 = (ζ − 1)(ζ + 5) : root condition fails ⇒ the scheme is unstable ⇒ the scheme is not convergent consider y ! = −y , y(0) = 1 ⇒ y(t) = e−t , u0 = 1 , u1 = e−hλ h=0.2 h=0.05 10 10 5 5 0 0 !5 !5 !10 0 0.2 0.4 0.6 0.8 1 !10 0 0.2 h=0.1 10 5 5 0 0 !5 !5 0 0.2 0.4 0.6 0.6 0.8 1 0.8 1 h=0.025 10 !10 0.4 0.8 1 !10 0 0.2 0.4 0.6 For any step size h, the numerical solution is accurate for some time, but eventually the growing oscillations of the extraneous solution destroy the accuracy; this occurs at an earlier time as: h is reduced. This can be seen in the expression 9 9 : 4 −t 3 4 n 3t/5 un = (1 + O(h )) · e + O(h ) + O(h ) · (−5) e + O(h) (hw). This strong instability is in contrast to weak instability (e.g. leap-frog) where the growing oscillations of the extraneous solution appear at a later time as h is reduced. 38 recall : A k-step scheme has order ≤ 2k. thm (Dahlquist) 7 ≤ k + 1 if k is odd, ≤ k + 2 if k is even. If the scheme has order k + 2, then the roots of ρ(ζ) all lie on the unit circle (and so the method is weakly unstable). A stable k-step scheme has order note k = 1 : the trapezoid method is a stable 1-step scheme of order 2 k = 2 : Milne’s method is a stable 2-step scheme of order 4 : hw recall : A multistep method is A-stable if the region of absolute stability contains the left half-plane (e.g. backward Euler, trapezoid method). thm (Dahlquist) An A-stable multistep method has order ≤ 2. Among all A-stable schemes of 1 order 2, the trapezoid method has the smallest value of C3 (= 12 ). def A multistep method is A(α)-stable for 0 ≤ α ≤ π/2 if the region of absolute stability contains the wedge | arg(hλ) − π| ≤ α. plane hλ α thm (Widlund) For any k ≤ 4 and 0 ≤ α ≤ π/2, there exists a k-step method of order k which is A(α)-stable. 12. Tues 2/15 39 def A multistep method is stiffly stable if the region of absolute stability contains a domain of the type shown below. hλ plane ex : BDF methods (backward differentiation formulas) p(t) = un + (t − tn ) ∇un ∇2 un + (t − tn )(t − tn−1 ) ≈ y(t) h 2h2 ∇un ∇ 2 un p (t) = + (2t − tn − tn−1 ) h 2h2 ! p! (tn ) = ∇un ∇2 un + ≈ y ! (tn ) h 2h ∇un + 12 ∇2 un = hf (un ) : 2-step BDF , implicit 3 2 un − 2un−1 + 12 un−2 − hf (un ) = 0 τn = O(h3 ) : 2nd order accurate ρ(ζ) = 32 ζ 2 − 2ζ + 1 2 = 12 (ζ − 1)(3ζ − 1) ⇒ ζ1 = 1 , ζ2 = thm (Gear) The k-step BDF method is stiffly stable for k ≤ 6. 1 3 : stable 40 region of absolute stability for BDF methods 8 hλ-plane 6 4 2 1 0 2 3 4 !2 !4 !6 6 !8 !6 5 !4 !2 0 2 4 6 8 10 12 For k = 1 : 6, the k-step BDF method is absolutely stable outside the contour. miscellaneous 1. implicit schemes : F (un ) = 0 , fixed-point iteration , Newton’s method 2. other methods for y ! = f (y) : implicit RK , Radau , . . . 3. software : www.netlib.org , Matlab : ode23 , ode45 , . . . 5. adaptive error control : variable timstep/order 6. mechanical systems : M X !! + CX ! + KX = F : Newmark , HHT , . . . 7. Hamiltonian systems : 7 ! p = Hq q ! = −Hp , geometric/symplectic methods 8. text : BVP for ODEs , DAE (differential-algebraic equations) 41 2. IBVP for PDEs heat equation (chap. 2) temperature : v(x, t) , heat flux : κ∇v(x, t) conservation of energy 8 d 8 v dx = κ∇v · n dS ⇒ ∂D dt D model problem 8 D vt dx = 8 D ∇ · κ∇v dx ⇒ vt = ∇ · κ∇v vt = vxx , v(x, 0) = f (x) : find v(x, t) for t > 0 1. −∞ < x < ∞ : free-space 2. 0 ≤ x ≤ 1 , Dirichlet : v(0, t) = v(1, t) = 0 Neumann : vx (0, t) = vx (1, t) = 0 periodic : v(0, t) = v(1, t) , vx (0, t) = vx (1, t) We assume that the problem is well-posed. (Math 454, 556, 656) finite-difference scheme h = ∆x , xj = jh , j = 0, ±1, ±2, . . . k = ∆t , tn = nk , n = 0, 1, 2, . . . v(xj , tn ) ≈ unj , un+1 − unj unj+1 − 2unj + unj−1 j = k h2 stencil n+1 n j−1 j j+1 42 def : λ = k h2 h=k= ⇒ 1 4 un+1 = unj + λ(unj+1 − 2unj + unj−1 ) j ⇒ λ=4 h= 1 4 , k= 1 8 ⇒ λ=2 note D+ unj unj+1 − unj unj − unj−1 n = , D − uj = h h ⇒ un+1 = unj + kD+ D− unj j def ||un ||∞ = max |unj | j The scheme is stable if ||un ||∞ ≤ ||u0 ||∞ for all n ≥ 1 and all u0 . This property is also called the maximum principle. claim : the scheme is stable ⇔ λ ≤ 1 2 pf un+1 = λunj+1 + (1 − 2λ)unj + λunj−1 j ⇐) |un+1 | ≤ λ|unj+1 | + (1 − 2λ)|unj | + λ|unj−1 | j ≤ λ||un ||∞ + (1 − 2λ)||un ||∞ + λ||un ||∞ = ||un ||∞ ⇒ ⇒) ||un+1 ||∞ ≤ ||un ||∞ assume λ > 1 2 ok , we will show that the scheme is unstable consider u0j = (−1)j u1j = λu0j+1 + (1 − 2λ)u0j + λu0j−1 = λ(−1)j+1 + (1 − 2λ)(−1)j + λ(−1)j−1 = (−1)j (−λ + (1 − 2λ) − λ) = (1 − 4λ) · u0j λ> 1 2 ⇒ 1 − 4λ < −1 ⇒ ||u1 ||∞ > ||u0 ||∞ ok 43 ex : un+1 = unj + kD+ D− unj , h = 0.05 , λ = j 1 2 ⇒ kc = λh2 = 0.00125 t=0 t=0 1 1 0.8 0.8 0.6 0.6 0.4 0.4 0.2 0.2 0 0 0.2 0.4 0.6 0.8 1 0 0 h=0.05 , k=0.0013 , 1 timestep 1 0.8 0.8 0.6 0.6 0.4 0.4 0.2 0.2 0 0.2 0.4 0.6 0.8 1 0 0 h=0.05 , k=0.0013 , 25 timesteps 1 0.8 0.8 0.6 0.6 0.4 0.4 0.2 0.2 0 0.2 0.4 0.6 0.8 1 0 0 h=0.05 , k=0.0013 , 50 timesteps 1 0.8 0.8 0.6 0.6 0.4 0.4 0.2 0.2 0 0.2 0.4 0.6 0.8 0.8 1 0.2 0.4 0.6 0.8 1 0.2 0.4 0.6 0.8 1 h=0.05 , k=0.0012 , 50 timesteps 1 0 0.6 h=0.05 , k=0.0012 , 25 timesteps 1 0 0.4 h=0.05 , k=0.0012 , 1 timestep 1 0 0.2 1 0 0 0.2 0.4 0.6 0.8 1 13. Thurs 2/17 44 convergence v(x, t) : exact solution vt = vxx , 0 ≤ x ≤ 1 , v(x, 0) = f (x) , v(0, t) = v(1, t) = 0 unj : numerical solution un+1 − unj unj+1 − 2unj + unj−1 j = k h2 h= 1 N j = 1, . . . , N − 1 , , xj = jh , j = 0, . . . , N tn = nk , k = 0, 1, 2, . . . u0j = f (xj ) , un0 = unN = 0 claim Assume that x = xj = jh, t = tn = nk and λ = k/h2 are fixed. If λ ≤ 1/2, then lim unj = v(x, t). h→0 pf 1. local truncation error n n vjn+1 − vjn vj+1 − 2vjn + vj−1 = + τjn 2 k h (contrast to ODEs) let v = vjn , vt = (vt )nj , . . . + O(k 3 ) vjn+1 = v + kvt + k2 2 vtt n vj+1 = v + hvx + h2 2 vxx + h3 6 vxxx + h4 24 vxxxx + O(h5 ) n vj−1 = v − hvx + h2 2 vxx − h3 6 vxxx * + h4 24 vxxxx + O(h5 ) τjn = vt + k2 vtt + O(k 2 ) − vxx + h2 12 vxxxx + + O(h4 ) vt = vxx , vtt = vxxt = vtxx = vxxxx τjn = * k 2 − h2 12 + vxxxx + O(k 2 ) + O(h4 ) τjn = O(k) + O(h2 ) : 1st order in time , 2nd order in space 45 2. error bound un+1 = λunj+1 + (1 − 2λ)unj + λunj−1 j n n vjn+1 = λvj+1 + (1 − 2λ)vjn + λvj−1 + kτjn define enj = vjn − unj , en+1 = λenj+1 + (1 − 2λ)enj + λenj−1 + kτjn j λ ≤ 1/2 ⇒ ||en+1 ||∞ ≤ ||en ||∞ + k||τ ||∞ ≤ ||en−1 ||∞ + 2k||τ ||∞ · · · ||en ||∞ ≤ ||e0 ||∞ + nk||τ ||∞ = t · O(k) ok note 1. We see (again) that for a consistent scheme, stability ⇒ convergence. 2. unj = v(x, t) + O(k) = v(x, t) + kEjn + O(k 2 ) : hw alternative : method of lines vt = vxx , 0 ≤ x ≤ 1 , v(x, 0) = f (x) , v(0, t) = v(1, t) = 0 define uj (t) ≈ v(xj , t) , xj = jh , h = 1/N , j = 1, . . . , N − 1 t 0 u!j = xj−1 xj xj+1 1 x uj+1 − 2uj + uj−1 : system of ODEs , u0 = uN = 0 h2 u! = Au , u = u1 .. . .. . .. . uN −1 , −2 1 1 −2 1 ... A = 2 h A : tridiagonal , symmetric ⇒ real e-values 1 ... ... ... ... 1 1 −2 Euler’s method : un+1 = un + kAun : finite-difference scheme 46 recall : absolute stability ⇔ − 2 ≤ kµ ≤ 0 for all e-values µ of A thm (Gershgorin) If µ is an e-value of A = (aij ), then there exists i st |µ − aii | ≤ pf : Math 571 (or exercise) % % % %µ % ! "% % % % % −4 ≤ µ ≤ 0 h2 ! " −4 hence, absolute stability holds if −2 ≤ k ≤ 0 ⇔ h2 G ⇒ −2 − h2 ≤ 2 h2 $ j+=i |aij |. ⇒ k 1 ≤ h2 2 ex : compute e-values and e-vectors of A Au = µu , u = (u1 , . . . , uN −1 )T uj+1 − 2uj + uj−1 = µuj , u0 = uN = 0 h2 uj+1 − (2 + µh2 )uj + uj−1 = 0 : difference equation ρ(ζ) = ζ 2 − (2 + µh2 )ζ + 1 = (ζ − ζ1 )(ζ − ζ2 ) = 0 uj = a1 ζ1j + a2 ζ2j u0 = 0 ⇒ a1 + a2 = 0 ⇒ a2 = −a1 uN = 0 ⇒ a1 (ζ1N − ζ1 = e2πim/N = e2πimh ζ2 ζ2N ) =0 ⇒ ζ1N = ζ2N , m = 1, . . . , N − 1 ⇒ ! ζ1 ζ2 "N =1 (m = 0 gives a contradiction) ζ1 ζ2 = 1 ⇒ ζ12 = e2πimh ⇒ ζ1 = eπimh , ζ2 = e−πimh since ζ1 , ζ2 → 1 as h → 0 9 : uj = a1 ζ1j + a2 ζ2j = a1 eπijmh − e−πijmh = a1 · 2i sin πjmh ζ1 + ζ2 − 2 eπimh + e−πimh − 2 2(cos πmh − 1) ζ1 +ζ2 = 2+µh ⇒ µ = = = 2 2 h h h2 −4 πmh e-values of A : µm = 2 sin2 , m = 1, . . . , N − 1 h 2 e-vectors of A : um,j = sin πmxj , j = 1, . . . , N −1 : discrete Fourier modes 2π 2 πm = ξ : wavenumber , wavelength = = ξ m 2 ex : N = 16 , e-values and e-vectors of A = D+ D− + Dirichlet BC ! 0 N !4 / h2 m=1 m=2 m=4 m=15 note : m → 0 : long wavelength modes ⇒ µ → 0 m → N : short · · · · · · · ” · · · · · · · · ⇒ µ → −4/h2 m 47 14. Tues 2/22 48 matrix analysis of convergence vt = vxx un+1 = un + kAun : method of lines + Euler’s method un+1 = (I + kA)un v n+1 = (I + kA)v n + kτ n en = v n − un ⇒ en+1 = (I + kA)en + kτ n ||en+1 || ≤ ||I + kA|| · ||en || + k||τ n || 1 − 2λ λ λ 1 − 2λ ... I + kA = ||I + kA||∞ = ||I + kA||1 = λ ... ... ... ... λ 7 λ 1 − 2λ , λ= k h2 1 if λ ≤ 1/2 4λ − 1 if λ > 1/2 ||I + kA||2 = max of absolute values of e-values of I + kA Gershgorin ⇒ the e-values of A lie in the interval [−4/h2 , 0] 1 2 hence λ ≤ ⇒ · · · · · · · · · · · I + kA · · · · · · · · · · · · · [1 − 4λ , 1] ⇒ ||I + kA||p ≤ 1 for p = 1, 2, ∞ ||en+1 || ≤ ||en || + k||τ n || ||en || ≤ ||e0 || + t||τ || , ||τ || = max ||τ n || n ok Fourier analysis of PDE vt = vxx look for solutions of the form v(x, t) = eωt+iξx : Fourier mode ξ : wavenumber , ω : growth rate , ω = −ξ 2 : dispersion relation −ξ 2 t+iξx v(x, t) = e 7 ξ = 0 : constant mode ξ += 0 : oscillatory in space, decaying in time 49 IVP with free-space BC : PDE −∞<x<∞ vt = vxx , v(x, 0) = f (x) , tools Fourier transform : f?(ξ) = inversion formula : f (x) = 8 ∞ Parseval’s relation : claim 1. v(x, t) = 8 ∞ −∞ −∞ f?(ξ)e−ξ 2 8 ∞ −iξx 1 dx 2π −∞ f (x)e 8 ∞ −∞ f?(ξ)eiξx dξ |f (x)|2 dx = 2π t+iξx 8 ∞ −∞ |f?(ξ)|2 dξ , ||f ||2 = 2π||f?||2 dξ : solution formula 2. ||v(·, t)||2 ≤ ||f ||2 for all t ≥ 0 : L2 -stability pf 1. ? v(ξ, t) v?t (ξ, t) = 8 ∞ −iξx 1 dx 2π −∞ v(x, t)e 8 ∞ −iξx 1 dx 2π −∞ vt (x, t)e = %∞ −iξx %% vx (x, t)e % −∞ = 1 2π = 1 − 2π 8 ∞ −iξx 1 dx 2π −∞ vxx (x, t)e = − 8 ∞ −iξx 1 dx 2π −∞ vx (x, t)(−iξ)e %∞ −iξx %% v(x, t)(−iξ)e % −∞ 8 ∞ 2 −iξx 1 dx 2π −∞ v(x, t)(−iξ) e + ? ? v?t (ξ, t) = −ξ 2 v(ξ, t) , v(ξ, 0) = f?(ξ) ? ⇒ v(ξ, t) = f?(ξ)e−ξ v(x, t) = 8 ∞ −∞ 2 t ? v(ξ, t)eiξx dξ = 2. ||v(·, t)||22 = 8 ∞ −∞ = 2π ≤ 2π 8 ∞ −∞ 2 f?(ξ)e−ξ t eiξx dξ |v(x, t)|2 dx = 2π 8 ∞ −∞ |f?(ξ)|2 e−2ξ t dξ −∞ |f?(ξ)|2 dξ = 8 ∞ 8 ∞ −∞ 2 8 ∞ −∞ ok ? |v(ξ, t)|2 dξ |f (x)|2 dx = ||f ||22 ok 50 Fourier analysis of difference scheme 9 un+1 = unj + λ unj+1 − 2unj + unj−1 j : look for solutions of the form unj = ζ n eiξjh 9 ζ n+1 eiξjh = ζ n eiξjh + λ ζ n eiξ(j+1)h − 2ζ n eiξjh + ζ n eiξ(j−1)h : ζ = 1 + λ(eiξh − 2 + e−iξh ) = 1 + 2λ(cos ξh − 1) = 1 − 4λ sin2 ξh 2 = ρ(ξh) un+1 = ρ(ξh)unj , ρ(ξh) : amplification factor j ρ(ξh) 1 λ=0 0 λ = 1/4 −1 λ = 1/2 λ > 1/2 π/2 π note 1. |ρ(ξh)| ≤ 1 for all ξh ⇔ λ ≤ 1 2 2. unj = ρ(ξh)n u0j 0≤λ≤ 1 4 1 4 1 2 ≤λ≤ λ> 1 2 : all modes decay monotonically in time : : 7 long waves decay monotonically in time short waves oscillate in sign, amplitude decays long waves decay monotonically in time intermediate waves oscillate in sign, amplitude decays short waves oscillate in sign, amplitude grows 3. amplification factor of PDE = e−ξ k = e−λ(ξh) = ρ(ξh) + O((ξh)4 ) For the PDE, all modes decay monotonically in time, in contrast with the difference scheme. 2 2 15. Tues 3/8 51 IVP with free-space BC : difference scheme un+1 = unj + kD+ D− unj , u0j : given , j = 0, ±1, . . . j goal : derive results for unj analogous to results for v(x, t) tools Fourier coefficients : f?m = 8 π 1 2π −π f (x)e−imx dx m=−∞ f?m eimx inversion formula : f (x) = Parseval’s relation : 8 π −π ∞ $ |f (x)|2 dx = 2π ∞ $ m=−∞ |f?m |2 change notation : m → j , f?m → unj , x → ξh , f (x) → u? n (ξh) unj = 8 π −π 8 π −ijξh 1 ?n d(ξh) 2π −π u (ξh)e |u? n (ξh)|2 d(ξh) = 2π ∞ $ j=−∞ , u? n (ξh) = ∞ $ j=−∞ unj eijξh |unj |2 claim 1. unj = 2. λ ≤ 1 2 8 π n −ijξh 1 ?0 d(ξh) 2π −π u (ξh)ρ(ξh) e : solution formula ⇒ ||un ||2 ≤ ||u0 ||2 for all n ≥ 0 : stability pf 1. u? n+1 (ξh) = ∞ $ j=−∞ un+1 eijξh = j ∞ $ (unj + λ(unj+1 − 2unj + unj−1 ))eijξh j=−∞ = (1 + λ(e−iξh − 2 + eiξh ))u? n (ξh) = ρ(ξh)u? n (ξh) ⇒ u? n (ξh) = ρ(ξh)n u? 0 (ξh) 2. ||un ||22 = ≤ ∞ $ j=−∞ |unj |2 = ok 8 π 2 1 ?n 2π −π |u (ξh)| d(ξh) 8 π 2 1 ?0 2π −π |u (ξh)| d(ξh) = ∞ $ j=−∞ = 8 π 1 2π −π |ρ(ξh)n u? 0 (ξh)|2 d(ξh) |u0j |2 = ||u0 ||22 ok 52 implicit schemes PDE : vt = vxx , 0 ≤ x ≤ 1 , v(0, t) = v(1, t) = 0 method of lines : u! = Au , A = 1 h2 trid(1, −2, 1) the e-values of A lie in the interval (− h42 , 0) ⇒ stiff system forward Euler : conditionally stable , i.e. stable ⇔ λ ≤ 1 2 backward Euler : unconditionally stable , i.e. stable for all λ > 0 (hw) Crank-Nicolson : centered differencing in space + trapezoid in time un+1 = un + k2 (Aun + Aun+1 ) : error is O(h2 ) + O(k 2 ) , 2nd order accurate (I − k2 A)un+1 = (I + k2 A)un : linear system (more later) claim : CN is unconditionally stable and convergent pf 1. un+1 = (I − k2 A)−1 (I + k2 A)un ⇒ ||un+1 ||2 ≤ ||(I − k2 A)−1 ||2 · ||I + k2 A||2 · ||un ||2 the e-values of I − k2 A lie in the interval (1, 1 + 2λ) · · · · · · ” · · · · · I + k2 A · · · · · · · ” · · · · · · (1 − 2λ, 1) ||(I − k2 A)−1 ||2 ≤ 1 , ||I + k2 A||2 ≤ max{1, |1 − 2λ|} ≤ 1 ⇔ λ ≤ 1 then λ ≤ 1 ⇒ ||un+1 ||2 ≤ ||un ||2 : not sharp 1 + k2 µ if µ is an e-value of A , then is an e-value of (I − k2 A)−1 (I + k2 A) k 1 − 2µ µ < 0 ⇒ ||(I − k2 A)−1 (I + k2 A)||2 ≤ 1 ⇒ ||un+1 ||2 ≤ ||un ||2 for all λ > 0 2. un+1 = un + k2 (Aun + Aun+1 ) v n+1 = v n + k2 (Av n + Av n+1 ) + kτ n , τ n = O(k 2 ) en = v n − un ⇒ en+1 = en + k2 (Aen + Aen+1 ) + kτ n en+1 = (I − k2 A)−1 (I + k2 A)en + (I − k2 A)−1 kτ n ||en+1 ||2 ≤ ||en ||2 + k||τ n ||2 ⇒ ||en ||2 ≤ ||e0 ||2 + t · O(k 2 ) ok ok 16. Thurs 3/10 53 Fourier analysis (Crank-Nicolson) un+1 = unj + k2 (D+ D− unj + D+ D− un+1 ) j j n+1 λ n n n n un+1 − λ2 (un+1 + un+1 j j+1 − 2uj j−1 ) = uj + 2 (uj+1 − 2uj + uj−1 ) look for solutions of the form unj = ζ n eiξjh 1 + λ2 (eiξh − 2 + e−iξh ) 1 − 2λ sin2 ξh 2 = ρ(ξh) : amplification factor ζ = = λ iξh 2 ξh −iξh 1 − 2 (e − 2 + e ) 1 + 2λ sin 2 unj = ρ(ξh)n u0j ρ(ξh) 1 λ=0 λ = 1/4 0 λ = 1/2 λ=1 λ>1 −1 π/2 note 1. 0 ≤ λ ≤ 1 2 λ> 1 2 π : all modes decay monotonically in time : 7 long waves decay monotonically in time short waves oscillate in sign, amplitude decays 2. |ρ(ξh)| ≤ 1 for all ξh and all λ > 0 ⇒ CN is unconditionally stable (for the IVP with free-space BC) un+1 = unj + k2 (D+ D− unj + D+ D− un+1 ) , j = 0, ±1, . . . j j unj n = 8 π 1 2π −π ρ(ξh)n u? 0 (ξh)e−ijξh d(ξh) 0 ||u ||2 ≤ ||u ||2 for all n ≥ 0 , all λ > 0 : pf as before 54 recall : (I − k2 A)un+1 = (I + k2 A)un write this in the form Ax = f tridiagonal Gaussian elimination : special case a b A = b a ... b ... ... ... ... b b a 1 β 2 = 1 β3 1 ... ... βn 1 α1 b α2 b ... ... ... b αn A = LU , L : unit lower triangular , U : upper triangular steps 1. find L, U 2. solve Ly = f 3. solve U x = y check Ax = LU x = Ly = f ok find L, U a = α1 , b = βk αk−1 ⇒ βk = b αk−1 , a = βk b + αk ⇒ αk = a − βk b , k = 2 : n solve Ly = f y1 = f1 , fk = βk yk−1 + yk ⇒ yk = fk − βk yk−1 , k = 2 : n solve U x = y yn = αn xn ⇒ xn = yn yk − bxk+1 , yk = αk xk + bxk+1 ⇒ xk = , k = n−1 : 1 αn αk note the operation count is O(n) 17. Tues 3/15 55 summary on Fourier analysis : we are using 4 types of transforms 1 continuous /continuous f (x)/f?(ξ) −∞ < x < ∞ / − ∞ < ξ < ∞ 3 discrete/continuous j = 0, ±1, . . . / − π ≤ ξh ≤ π f (x)/{f?m } 2 continuous /discrete ? {uj }/u(ξh) 4 discrete/discrete {uj }/{u? m } 0 ≤ x ≤ 1 / m = 0, ±1, . . . j = 1 : N − 1/m = 1 : N − 1 In each case there is an inversion formula and a Parseval’s relation. The specific form of the transform depends on the boundary conditions. Fourier analysis is used to prove stability in the 2-norm for PDEs and difference schemes. ex : stability analysis of a difference scheme using a discrete/discrete transform vt = vxx , 0 ≤ x ≤ 1 , v(0, t) = v(1, t) = 0 un+1 = (I+kA)un , un = {unj } , un0 = unN = 0 , A = e-values of A : µm = −4 h2 sin2 πmh , m=1:N −1 2 1 h2 trid(1, −2, 1) , Nh = 1 e-vectors of A : qm = {sin πmjh} , j = 1 : N − 1 , orthonormal basis any vector u = {uj } can be expanded in this basis u = N$ −1 m=1 u? m qm ⇒ uj = u? m = u · qm = N$ −1 N$ −1 m=1 u? m sin πmjh : inversion formula uj sin πmjh : discrete Sine transform j=1 u? = {u? m } : the components of u? are the cofficients of u wrt the basis {qm } ||u||22 = N$ −1 j=1 u2j = u · u = N$ −1 m=1 ? 2 : Parseval’s relation u? 2m = ||u|| 2 now consider the difference scheme 0 u = N$ −1 m=1 u? 0m qm , n n 0 u = (I + kA) u = N$ −1 m=1 |1 + kµm | = |1 − 4λ sin2 πmh 2 | ≤ 1 if λ ≤ 1/2 u? 0m (1 + kµm )n qm then ||un ||2 = ||u? n ||2 ≤ ||u? 0 ||2 = ||u0 ||2 : stability hw : Neumann BC , vx (0, t) = vx (1, t) = 0 56 energy method : alternative technique for proving stability in the 2-norm vt = vxx , − ∞ < x < ∞ *8 ∞ define ||v(·, t)||2 = −∞ ( ok too for 0 ≤ x ≤ 1 + Dirichlet BC ) 2 v(x, t) dx +1/2 : energy claim : ||v(·, t)||2 ≤ ||v(·, 0)||2 for all t ≥ 0 : stability pf d d 8∞ 2 2 ||v(·, t)||2 = v dx = dt dt −∞ = %∞ % 2vvx %% − −∞ 2 8 ∞ 8 ∞ −∞ −∞ 8 ∞ 2vvt dx = 2 (vx )2 dx ≤ 0 −∞ vvxx dx ok integration by parts define (f, g) = 8 ∞ −∞ f (x)g(x) dx : inner product , (f, f ) = ||f ||22 claim : (f, g ! ) = −(f ! , g) pf (f g)! = f ! g + f g ! 8 ∞ ! (f g) dx = −∞ 8 ∞ −∞ ! ! ! ! (f g + f g ) dx = (f , g) + (f, g ) = summation by parts define (f, g) = ∞ $ fj gj j=−∞ %∞ % f g %% −∞ = 0 ok , (f, f ) = ||f ||22,h claim : (f, D− g) = −(D+ f, g) pf D+ (f g)j = fj+1 gj+1 − fj gj fj+1 gj+1 − fj+1 gj + fj+1 gj − fj gj = h h = fj+1 D+ gj + (D+ fj )gj ∞ $ D+ (f g)j = j=−∞ ∞ $ (fj+1 D+ gj + (D+ fj )gj ) = j=−∞ = (f, D− g) + (D+ f, g) = ∞ $ fj D− gj + j=−∞ ∞ $ fj+1 gj+1 − fj gj = 0 h j=−∞ ok ∞ $ (D+ fj )gj j=−∞ 57 application to difference schemes n ||u ||2 = ! ∞ $ (unj )2 j=−∞ "1/2 : discrete energy 1. forward Euler/centered difference un+1 = un + kD+ D− un claim : λ ≤ 1/2 ⇒ ||un ||2 ≤ ||u0 ||2 : conditional stability pf ||un+1 ||2 − ||un ||2 = (un+1 , un+1 ) − (un , un ) = (un+1 + un , un+1 − un ) = (2un + kD+ D− un , kD+ D− un ) = 2k(un , D+ D− un ) + k 2 ||D+ D− un ||2 (1) = −2k(D− un , D− un ) = −2k||D− un ||2 (2) = %% n %% 2 %% S+ D− u − k %%%% h %% D− un %%%%2 %% %% ≤ k2 k2 n n 2 (||S D u || + ||D u ||) = · 4||D− un ||2 + − − 2 2 h h k2 ||un+1 ||2 − ||un ||2 ≤ −2k + 4 2 ||D− un ||2 = 2k(2λ − 1)||D− un ||2 ≤ 0 h ok 2. backward Euler/centered difference un+1 = un + kD+ D− un+1 : unconditionally stable (hw) 3. Crank-Nicolson 9 un+1 = un + k2 D+ D− un + un+1 pf : : unconditionally stable ||un+1 ||2 − ||un ||2 = (un+1 + un , un+1 − un ) = (un+1 + un , k2 D+ D− (un + un+1 )) 2D heat equation (chap. 3) vt = vxx + vyy , v(x, y, 0) = f (x, y) , unj,l ≈ v(jh, lh, nk) x n D+ uj,l y n D+ uj,l = − k2 ||D− (un +un+1 )||2 ≤ 0 − ∞ < x, y < ∞ unj+1,l − unj,l unj,l − unj−1,l x n = , D− uj,l = h h unj,l+1 − unj,l unj,l − unj,l−1 y n = , D− uj,l = h h ok 18. Thurs 3/17 58 forward Euler/centered difference y y x x un+1 = unj,l + k (D+ D− + D+ D− ) unj,l j,l 9 un+1 = unj,l + λ unj+1,l − 2unj,l + unj−1,l + unj,l+1 − unj,l + unj,l−1 j,l note 9 1. un+1 = (1 − 4λ)unj,l + λ unj+1,l + unj−1,l + unj,l+1 + unj,l−1 j,l : : claim : ||un ||∞ ≤ ||u0 ||∞ ⇔ λ ≤ 1/4 : maximum principle pf as before 2. unj,l = ρ(ξ, η)n ei(ξj+ηl)h : special solutions ! ξh ηh ρ(ξ, η) = 1 + λ (2 cos ξh − 2 + 2 cos ηh − 2) = 1 − 4λ sin + sin2 2 2 |ρ(ξ, η)| ≤ 1 ⇔ λ ≤ 1/4 unj,l = 1 8π 8π n u? (ξh, ηh)ei(ξh+ηl)h d(ξh)d(ηh) 2 −π −π (2π) u? n (ξh, ηh) = ∞ $ j,l=−∞ |unj,l |2 ∞ $ j,l=−∞ unj,l e−i(ξj+ηl)h 1 8π 8π n = |u? (ξh, ηh)|2 d(ξh)d(ηh) 2 (2π) −π −π claim : λ ≤ 1/4 ⇒ ||un ||2 ≤ ||u0 ||2 pf : u? n+1 (ξh, ηh) = ρ(ξh, ηh)u? n (ξh, ηh) . . . as before backward Euler/centered difference y y x x un+1 = un + k (D+ D− + D+ D− ) un+1 y y x x (I − k (D+ D− + D+ D− )) un+1 = un : linear system 9 : n+1 n+1 n+1 n+1 n (1 + 4λ)un+1 j,l − λ uj+1,l + uj−1,l + uj,l+1 + uj,l−1 = uj,l consider the problem on D = [0, 1]2 v(x, y, 0) = f (x, y) on D v(x, y, t) = 0 on ∂D 2 " 59 y 4 3 3 6 9 2 2 5 8 1 1 4 7 x 0 0 1 2 3 4 1 2 3 4 5 6 7 8 9 u1,1 u1,2 u1,3 u2,1 u2,2 u2,3 u3,1 u3,2 u3,3 1 + 4λ −λ −λ −λ 1 + 4λ −λ −λ −λ 1 + 4λ −λ −λ 1 + 4λ −λ −λ −λ −λ 1 + 4λ −λ −λ −λ −λ 1 + 4λ −λ −λ 1 + 4λ −λ −λ −λ 1 + 4λ −λ −λ −λ 1 + 4λ note 1. the matrix is symmetric, block tridiagonal, positive definite : Math 571 Cholesky, conjugate gradient, FFT, SOR, multigrid, block LU, . . . 2. ρ(ξh, ηh) = ? : 1D case is on hw |ρ(ξh, ηh)| ≤ 1 for all λ : unconditional stability in 2-norm (can also be shown by energy method) 3. global error is O(k) + O(h2 ) 19. Tues 3/22 60 operator splitting y ! = Ay ⇒ y(t) = eAt y0 eAt = I + At + 12 A2 t2 + · · · define SA (t) = eAt : solution operator y(t) = SA (t)y0 9 SA (t) = eAt = eAnk = eAk consider y ! = (A + B)y :n = (SA (k))n claim SA+B (k) = e(A+B)k += eAk eBk = SA (k)SB (k) pf SA+B (k) = e(A+B)k = I + (A + B)k + 12 (A + B)2 k 2 + · · · (A + B)2 = (A + B)(A + B) = A2 + AB + BA + B 2 SA+B (k) = I + (A + B)k + 12 (A2 + AB + BA + B 2 )k 2 + · · · SA (k)SB (k) = eAk eBk = (I + Ak + 12 (Ak)2 + · · ·)(I + Bk + 12 (Bk)2 + · · ·) = I + (A + B)k + ( 12 A2 + AB + 12 B 2 )k 2 + · · · SA+B (k) − SA (k)SB (k) = 12 (BA − AB)k 2 + · · · ok SA+B (k) = SA (k)SB (k) + O(k 2 ) SA+B (nk) = (SA+B (k))n = (SA (k)SB (k) + O(k 2 ))n = (SA (k)SB (k))n + O(k) note : this holds more generally , 1st order accurate in time application : backward Euler/centered difference scheme for 2D heat equation y y x x un+1 = un + k(D+ D− + D+ D− )un+1 y y x x (I − k(D+ D− + D+ D− ))un+1 = un y y −1 x x un+1 = SA+B (k)un , SA+B (k) = (I − k(D+ D− + D+ D− )) y y −1 x x −1 set SA (k) = (I − kD+ D− ) , SB (k) = (I − kD+ D− ) 61 claim : SA+B (k) = SA (k)SB (k) + O(k 2 ) pf y y x x un = (I − k(D+ D− + D+ D− ))un+1 y y y y x x x x n+1 = (I − kD+ D− )(I − kD+ D− )un+1 − k 2 D+ D− D+ D− u y −1 n y x x −1 un+1 = (I − kD+ D− ) (I − kD+ D− ) u + O(k 2 ) ok The backward Euler/centered difference scheme can be replaced by the following. 1 y y (I − kD+ D− )un+ 2 = un x x (I − kD+ D− )un+1 = u note n+ 12 : fractional-step method Only 1D tridiagonal systems need to be solved (if the vector components are ordered correctly). 1st half-step : u1 , u2 , u3 , u4 , u5 , u6 , u7 , u8 , u9 2nd half-step : u1 , u4 , u7 , u2 , u5 , u8 , u3 , u6 , u9 unconditionally stable in 2-norm , global error is O(k) + O(h2 ) pf . . . Crank-Nicolson 9 y y x x un+1 = un + k2 (D+ D− + D+ D− ) un + un+1 : y y y y x x x x (I − k2 (D+ D− + D+ D− ))un+1 = (I + k2 (D+ D− + D+ D− ))un block-tridiagonal, symmetric, positive definite 9 : 1 − 2λ sin2 ξh + sin2 ηh 2 2 : 9 ρ(ξh, ηh) = 2 ξh 2 ηh 1 + 2λ sin 2 + sin 2 ⇒ |ρ(ξh, ηh)| ≤ 1 for all ξ , η , λ unconditionally stable in 2-norm , global error is O(k 2 ) + O(h2 ) fractional-step/Crank-Nicolson y y y y x x (I − k2 D+ D− )un+1/2 = (I + k2 (D+ D− + D+ D− ))un x x (I − k2 D+ D− )un+1 = un+1/2 tridiagonal systems, unconditionally stable, O(k) + O(h2 ) pf . . . 62 alternating direction implicit y y x x (I − k2 D+ D− )un+1/2 = (I + k2 D+ D− )un y y = (I + k2 D+ D− )un+1/2 x x (I − k2 D+ D− )un+1 tridiagonal systems stability of ADI 1 − 2λ sin2 ξh 2 ρ1 (ξh, ηh) = 2 ηh 1 + 2λ sin 2 , 1 − 2λ sin2 ηh 2 ρ2 (ξh, ηh) = 2 ξh 1 + 2λ sin 2 ρ1 (π, 0) = ρ2 (0, π) = 1 − 2λ ⇒ each fractional step is conditionally stable : λ ≤ 1 1 − 2λ sin2 ξh 1 − 2λ sin2 ηh 2 2 ρ1 (ξh, ηh) = ρ1 (ξh, ηh) · ρ2 (ξh, ηh) = · 2 ηh 2 ξh 1 + 2λ sin 2 1 + 2λ sin 2 ⇒ |ρ(ξh, ηh)| ≤ 1 for all ξ , η , λ : each full step is unconditionally stable accuracy of ADI k 2 9 un+1 − un+1/2 = k 2 un+1/2 − un = y y n+1/2 x x n D+ D− u + D+ D− u 9 : y y n+1/2 x x n+1 D+ D− u + D+ D− u 9 : : y y n+1/2 x x un+1 − un = k2 D+ D− un+1 + un + kD+ D− u x x 2un+1/2 − (un+1 + un ) = k2 D+ D− (un − un+1 ) x x un+1/2 = 12 (un+1 + un ) − k4 D+ D− (un+1 − un ) un+1 − un = & k 2 9 : y y x x (D+ D− + D+ D− ) un+1 + un − '( Crank-Nicolson ) ⇒ the global error in ADI is O(h2 ) + O(k 2 ) y k2 y x x 4 D+ D− D+ D− & '( 3 k 4 9 un+1 − un vxxyyt : ) 20. Thurs 3/24 63 hyperbolic equations wave propagation : sound , light , water , gravity scalar wave equation vt + cvx = 0 , − ∞ < x < ∞ , v(x, 0) = f (x) (assume c > 0 wlog) def The line x − ct = α in the xt-plane is called a characteristic. t x − ct = α , slope = α 1 c x claim 1. The solution v(x, t) is constant on characteristics. 2. The solution is v(x, t) = f (x − ct). pf 1. v(x, t) = v(α + ct, t) d v(α + ct, t) = vx (α + ct, t) · c + vt (α + ct, t) = 0 dt 2. v(x, t) = v(α, 0) = f (α) = f (x − ct) ok ok check : if v(x, t) = f (x − ct), then vt + cvx = f ! · −c + c · f ! = 0 note 1. The solution is a traveling wave with wave speed c. 2. The domain of dependence of the differential equation is {α}. ok 64 linear system of 1st order PDEs v1 . . vt + Avx = 0 , v(x, 0) = f (x) , v = . , f = vp f1 . .. fp The system is called hyperbolic if A is diagonalizable and has real e-values, A = T DT −1 , D = diag(λ1 , . . . , λp ) , λi ∈ IR. The e-values of A are the wave speeds of the system. vt + Avx = vt + T DT −1 vx = 0 w = T −1 v ⇒ wt + Dwx ⇒ (wi )t + λi (wi )x , i = 1, . . . , p ex ! v1 v2 " A = + t ! ! 0 1 1 0 0 1 1 0 " "! v1 v2 " = T DT wt + Dwx = 0 ⇒ v1 (x, 0) = f1 (x) v2 (x, 0) = f2 (x) = 0 , x ! 1 0 , D= 0 −1 −1 " (w1 )t + (w1 )x = 0 (w2 )t − (w2 )x = 0 ! 1 1 1 , T =√ 2 1 −1 ⇒ w1 (x, 0) w2 (x, 0) " = T −1 ! f1 (x) f2 (x) " ! 1 f1 (x) + f2 (x) = √ 2 f1 (x) − f2 (x) " v = Tw ! v1 (x, t) v2 (x, t) " = T ! w1 (x, t) w2 (x, t) ! " ! 1 w1 (x, t) + w2 (x, t) = √ 2 w1 (x, t) − w2 (x, t) 1 w1 (x − t, 0) + w2 (x + t, 0) = √ 2 w1 (x − t, 0) − w2 (x + t, 0) " " ! 1 f1 (x − t) + f2 (x − t) + f1 (x + t) − f2 (x + t) = 2 f1 (x − t) + f2 (x − t) − f1 (x + t) + f2 (x + t) The solution is a superposition of traveling waves. , T = T −1 w1 (x, t) = w1 (x − t, 0) w2 (x, t) = w2 (x + t, 0) w = T −1 v ⇒ w(x, 0) = T −1 v(x, 0) = T −1 f (x) ! " " 65 ex : 2nd order scalar wave equation vtt = c2 vxx , v(x, 0) = f (x) , vt (x, 0) = g(x) v1 = vx ⇒ (v1 )t = vxt = vtx = (v2 )x (v2 )t = vtt = c2 vxx = c2 (v1 )x v2 = vt ! v1 v2 " + t A = ! D = ! ! 0 −c2 0 −c2 −1 0 c 0 0 −c " −1 0 " "! v1 v2 " = 0 x = T DT −1 , T = ! 1 1 −c c " , T −1 ! 1 c −1 = 1 2c c " v1 (x, t) = 1 1 (f1 (x + ct) + f1 (x − ct)) + (f2 (x + ct) − f2 (x − ct)) 2 2c vx (x, t) = 1 ! 1 (f (x + ct) + f ! (x − ct)) + (g(x + ct) − g(x − ct)) 2 2c v(x, t) = 1 1 8 x+ct (f (x + ct) + f (x − ct)) + g(s) ds : d’Alembert’s formula 2 2c x−ct t (x, t) x x − ct x + ct The domain of dependence of the differential equation is [x − ct, x + ct]. 66 difference schemes vt + cvx = 0 , v(x, 0) = f (x) v(x, t) = f (x − ct) , c > 0 upwind ⇒ right-moving wave downwind x downwind scheme un+1 − unj j + cD+ unj = 0 k un+1 − unj un − unj k j + c j+1 = 0 ⇒ un+1 = (1 + cλ)unj − cλ unj+1 , λ = j k h h claim The downwind scheme is unconditionally unstable in the ∞-norm. pf set u0j = (−1)j then u1j = (1 + cλ)u0j − cλ u0j+1 = (1 + cλ)(−1)j − cλ(−1)j+1 = (−1)j (1 + 2cλ) ||u1 ||∞ = (1 + 2cλ)||u0 ||∞ ok note t x − ct = α tn α xj x The domain of dependence of the differential equation is {α}. The · · · · · · · · · · · · · ” · · · · · · · · · · · · difference scheme is {xj , xj+1 , . . . , xj+n }. 21. Tues 3/29 67 upwind scheme un+1 − unj j + cD− unj = 0 k un+1 − unj un − unj−1 j +c j = 0 ⇒ un+1 = (1 − cλ)unj + cλ unj−1 j k h claim The upwind scheme is stable in the ∞-norm ⇒ cλ ≤ 1. pf ⇐) un+1 = (1 − cλ)unj + cλ unj−1 j |un+1 | ≤ (1 − cλ)|unj | + cλ |unj−1 | ≤ (1 − cλ)||un ||∞ + cλ||un ||∞ = ||un ||∞ j then ||un+1 ||∞ ≤ ||un ||∞ ok ⇒) set u0j = (−1)j then u1j = (1 − cλ)u0j + cλ u0j−1 = (1 − cλ)(−1)j + cλ(−1)j−1 = (−1)j (1 − 2cλ) hence if cλ > 1, then ||u1 ||∞ = (2cλ − 1)||u0 ||∞ and the scheme is unstable cλ < 1 : small k/large h t cλ > 1 : large k/small h t x − ct = α tn α xj ok x − ct = α tn x α xj The domain of dependence of the differential equation is {α}. The · · · · · · · · · · · · ” · · · · · · · · · · · · · difference scheme is {xj−n , . . . , xj }. x 68 CFL condition : Courant-Friedrichs-Levy The domain of dependence of the differential equation is contained in the domain of dependence of the difference scheme. 1. downwind scheme violates CFL for all λ 2. upwind scheme satisfies CFL ⇔ cλ ≤ 1 local truncation error : upwind scheme vt + cvx = 0 n vjn − vj−1 vjn+1 − vjn +c = τjn k h 9 : v − v − hvx + 12 h2 vxx + O(h3 ) v + kvt + 12 k 2 vtt + O(k 3 ) − v τ = +c k h = vt + 12 kvtt + O(k 2 ) + c(vx − 12 hvxx + O(h2 )) = vt + cvx + 12 h(λvtt − cvxx ) + O(h2 ) vt = −cvx , vtt = −cvxt = −cvtx = −c(−cvx )x = c2 vxx τ = 12 hc(cλ − 1)vxx + O(h2 ) = O(k) convergence : upwind scheme , cλ ≤ 1 un+1 = (1 − cλ)unj + cλunj−1 j n vjn+1 = (1 − cλ)vjn + cλvj−1 + kτjn enj = vjn − unj en+1 = (1 − cλ)enj + cλenj−1 + kτjn j ··· ||en+1 ||∞ ≤ ||en ||∞ + k||τ n ||∞ ··· ||en ||∞ ≤ ||e0 ||∞ + nk||τ ||∞ = t · O(k) ⇒ en → 0 if u0 = f (xj ) j h, k → 0 with λ= k h fixed st cλ ≤ 1 69 note The upwind scheme is exact for cλ = 1. pf un+1 = (1 − cλ)unj + cλunj−1 = unj−1 j unj = u0j−n = f (xj−n ) xj−n = xj − nh = xj − tn tn h = xj − = xj − ctn k λ unj = f (xj−n ) = f (xj − ctn ) = v(xj , tn ) ok note Lh unj un+1 − unj unj − unj−1 j = +c = 0 , Lh : difference operator k h Lh vjn n vjn+1 − vjn vjn − vj−1 = +c = vt + cvx + 12 hc(cλ − 1)vxx + O(h2 ) k h vt + cvx = 0 ⇒ Lh vjn = O(h) , unj = vjn + O(h) for cλ ≤ 1 claim φt + cφx = 12 hc(1 − cλ)φxx ⇒ Lh φnj = O(h2 ) , unj = φnj + O(h2 ) for cλ ≤ 1 & '( ) model equation for the upwind scheme , 1 2 hc(1−cλ)φxx : artificial viscosity pf Lh φnj = O(h2 ) check . . . enj = φnj − unj , Lh enj = Lh φnj − Lh unj = O(h2 ) ··· ||en ||∞ ≤ ||e0 ||∞ + t · O(h2 ) ok note Stability of the difference scheme is equivalent to requiring ||L−1 h || ≤ 1 for all h sufficiently small. (more later) 22. Thurs 3/31 70 Fourier analysis : PDE vt + cvx = 0 look for solutions of the form v(x, t) = eωt+iξx ω + icξ = 0 ⇒ ω = −icξ v(x, t) = e−icξt+iξx = eiξ(x−ct) IVP with free-space BC vt + cvx = 0 , v(x, 0) = f (x) , −∞<x<∞ goal : solution formula , stability ? v(ξ, t) = v?t (ξ, t) 1 8∞ v(x, t)e−iξx dx −∞ 2π 1 8∞ = vt (x, t)e−iξx dx 2π −∞ 1 8∞ = −cvx (x, t)e−iξx dx 2π −∞ %∞ 1 1 8∞ −iξx %% = −c · v(x, t)e + c· v(x, t)(−iξ)e−iξx dx % −∞ 2π 2π −∞ ? ? v?t (ξ, t) = −icξ v(ξ, t) , v(ξ, 0) = f?(ξ) ? v(ξ, t) = f?(ξ)e−icξt v(x, t) = 8 ∞ −∞ ? v(ξ, t)eiξx dξ = = ||v(·, t)||2 = ||f ||2 ok 8 ∞ −∞ f?(ξ)e−icξt eiξx dξ −∞ f?(ξ)eiξ(x−ct) dξ = f (x − ct) 8 ∞ ok 71 Fourier analysis : difference schemes look for solutions of the form unj = ρ(ξh)n eijξh downwind scheme un+1 = (1 + cλ)unj − cλunj+1 j ⇒ ρ(ξh) = 1 + cλ − cλeiξh ρ-plane max |ρ(ξh)| = 1 + 2cλ ⇒ 7 unconditionally unstable in 2-norm short waves are amplified the most upwind scheme un+1 = (1 − cλ)unj + cλunj−1 j 0 < cλ < 1 2 ⇒ 1 2 0 < cλ < 1 ⇒ |ρ(ξh)| ≤ 1 ⇒ cλ > 1 ⇒ ρ(ξh) = 1 − cλ + cλe−iξh < cλ < 1 7 cλ > 1 scheme is stable in 2-norm short waves are damped the most max |ρ(ξh)| = 2cλ − 1 ⇒ 7 scheme is unstable in 2-norm short waves are amplified the most 72 question In a system with positive and negative wave speeds (e.g. vtt = c2 vxx ), there is no unique upwind direction. Is there is a scheme which is stable in this case? centered-difference scheme vt + cvx = 0 un+1 − unj unj+1 − unj−1 j n n + cD0 uj = 0 , D0 uj = k 2h un+1 = unj − 12 cλ(unj+1 − unj−1 ) j claim 1. The CFL condition is satisfied if |c|λ ≤ 1. 2. The scheme is unconditionally unstable in the 2-norm. pf 1. ok , 2. ρ(ξh) = 1 − 12 cλ(eiξh − e−iξh ) = 1 − icλ sin ξh ok Lax-Friedrichs : add artificial viscosity to stabilize the centered-difference scheme vt + cvx = 0 un+1 − 12 (unj+1 + unj−1 ) j + cD0 unj = 0 ⇒ k claim un+1 − unj k j + cD0 unj = D+ D− unj 2 k 2λ 1. The CFL condition is satisfied if |c|λ ≤ 1. 2. LF is stable in the 2-norm if |c|λ ≤ 1. 3. LF is 1st order accurate (i.e. error = O(k) ). 4. The model equation for LF is φt + cφx = h 2λ (1 − c2 λ2 )φxx . pf : hw 23. Tues 4/5 73 Lax-Wendroff vt + cvx = 0 ⇒ vt = −cvx , vtt = c2 vxx vjn+1 − vjn v + kvt + 12 k 2 vtt + O(k 3 ) − v = = vt + 12 kvtt + O(k 2 ) k k = −cvx + 12 kc2 vxx + O(k 2 ) un+1 − unj j + cD0 unj = 12 kc2 D+ D− unj k interpretation : the centered-difference scheme is stabilized by adding artificial viscosity and the viscosity coefficient is chosen to obtain 2nd order accuracy claim 1. The CFL condition is satisfied if |c|λ ≤ 1. 2. LW is stable in the 2-norm if |c|λ ≤ 1. 3. LW is 2nd order accurate (i.e. error = O(k 2 ) ). 4. The model equation for LW is (fill in for hw). pf un+1 = (1 − c2 λ2 )unj − 12 cλ(1 − cλ)unj+1 + 12 cλ(1 + cλ)unj−1 j ρ(ξh) = 1 − icλ sin ξh − 2c2 λ2 sin2 ξh 2 = 1 − c2 λ2 + c2 λ2 cos ξh − icλ sin ξh : ellipse 0 < |c|λ < 1 2 1 2 < |c|λ < 1 |c|λ > 1 74 note If |c|λ ≤ 1, upwind and LF are stable in the ∞-norm, but LW is not. phase error compare : v(x, t) = eiξ(x−ct) , unj = ρ(ξh)n eijξh ρ(ξh) = |ρ(ξh)|eiθ(ξh) θ(ξh) = arg ρ(ξh) , − π < θ(ξh) < π unj = |ρ(ξh)|n einθ(ξh) eijξh = |ρ(ξh)|n ei(jξh + nθ(ξh)) tn θ(ξh) i(jξh + nθ(ξh)) = iξ xj + = iξ(xj − c# tn ) kξ # c# = c(ξh) = θ(ξh) θ(ξh) = : numerical wave speed −kξ −λ ξh unj = |ρ(ξh)|n eiξ(xj − #c tn ) : discrete traveling wave (damped or amplified) def : A system is called dispersive if it has traveling wave solutions in which the wave speed depends on the wavelength. 1. vt + cvx = 0 is non-dispersive v(x, t) = eiξ(x − ct) : all waves travel at the same speed 2. φt + φxxx = 0 is dispersive φ(x, t) = eωt+iξx ⇒ ω + (iξ)3 = 0 ⇒ φ(x, t) = eiξ(x − ξ 2 t) ⇒ c = c(ξ) = −ξ 2 , short waves travel faster than long waves # 3. c# = c(ξh) ⇒ numerical scheme is dispersive ex : Lax-Wendroff ρ(ξh) = 1 − icλ sin ξh − 2c2 λ2 sin2 ξh 2 1. consider long waves , ξh → 0 9 : ρ(ξh) = 1 − icλ ξh − 16 (ξh)3 + · · · − 2c2 λ2 · 14 (ξh)2 + · · · 75 −cλξh + 16 cλ(ξh)3 + · · · tan θ = 1 − 12 c2 λ2 (ξh)2 + · · · 9 :9 : = −cλξh + 16 cλ(ξh)3 + · · · 1 + 12 c2 λ2 (ξh)2 + · · · = −cλξh + 9 1 6 cλ : − 12 c3 λ3 (ξh)3 + · · · = α1 " + α2 "2 + α3 "3 + · · · , " = ξh θ = β1 " + β2 "2 + β3 "3 + · · · tan θ = θ + 13 θ3 + · · · 9 : = β1 " + β2 "2 + β3 "3 + · · · + 9 : 1 3 (β1 " + · · ·)3 + · · · = β1 " + β2 "2 + β3 + 13 β13 "3 + · · · β1 = α1 = −cλ β2 = α2 = 0 β3 + 13 β13 = α3 ⇒ β3 = 9 1 6 cλ θ = −cλξh + 16 cλ(1 − c2 λ2 )(ξh)3 + · · · c# = : − 12 c3 λ3 − 13 (−cλ)3 = 16 cλ(1 − c2 λ2 ) 9 : θ(ξh) = c 1 − 16 (1 − c2 λ2 )(ξh)2 + · · · −λξh Thus, discrete traveling waves have the correct wave speed in the long wave limit (ξh → 0), but under the assumption that |c|λ < 1, their wave speed is less than the exact wave speed, i.e. they exhibit a phase lag. 2. consider short waves , ξh → π , assume c > 0 wlog ρ(ξh) = 1 − icλ sin ξh − 2c2 λ2 sin2 ξh 2 0 < cλ < 1 2 ⇒ ρ(π) = 1 − 2c2 λ2 ⇒ 0 < ρ(π) < 1 ⇒ arg ρ(π) = 0 ⇒ c# = 0 ⇒ short waves are trapped 1 2 < cλ < 1 ⇒ − 1 < ρ(π) < 0 ⇒ arg ρ(π) = −π ⇒ c# = ⇒ short waves travel faster than the exact wave note : this explains why LW is not stable in the ∞-norm 1 >c λ 24. Thurs 4/7 76 hyperbolic systems v1 . vt + Avx = 0 , v = .. vp A = T DT −1 , D = diag(c1 , . . . , cp ) , ci : real w = T −1 v ⇒ wt = Dwx ⇒ (wi )t = ci (wi )x ⇒ wi (x, t) = wi (x − ci t, 0) characteristics : x − ci t = αi ex : c1 < c2 < 0 < c3 < c4 t (x, t) α4 α3 α2 α1 x domain of dependence of v(x, t) : {α1 , α2 , α3 , α4 } Lax-Wendroff : CFL condition : un+1 = unj − kAD0 unj + 12 k 2 A2 D+ D− unj j max |ci |λ ≤ 1 i 2-norm stability theory for systems un+1 = Qunj : Q = Q1 S+ + Q0 I + Q−1 S− : 3-point difference operator j ex 9 : QLW = − 12 λA (I − λA) S+ + I − λ2 A2 I + 12 λA (I + λA) S− Fourier analysis unj = 8 π −ijξh 1 ?n d(ξh) 2π −π u (ξh)e , u? n (mh) = ∞ $ j=−∞ unj eijmh u? n+1 = G(ξh)u? n , G(ξh) = Q1 eiξh + Q0 + Q−1 e−iξh : amplification matrix 77 u? n (ξh) = Gn (ξh)u? 0 (ξh) ||un ||22 = ∞ $ ||unj ||22 j=−∞ = 8 π 1 2π −π 1 ≤ max ||Gn (ξh)||22 · 2π ξh ?n ||u 8 π −π (ξh)||22 d(ξh) = 8 π 1 2π −π ||u? 0 (ξh)||22 d(ξh) ||Gn (ξh)u? 0 (ξh)||22 d(ξh) ||un ||2 ≤ max ||Gn (ξh)||2 · ||u0 ||2 ξh def G(ξh) is uniformly power bounded if max ||Gn (ξh)||2 ≤ K for all n ≥ 0, where ξh K is independent of h, k, n (but may depend on λ = k/h and t = nk). note The scheme un+1 = Qunj is stable in the 2-norm ⇔ G(ξh) is unif power bdd. j ex : Lax-Wendroff for hyperbolic systems 9 : G(ξh) = − 12 λA (I − λA) eiξh + I − λ2 A2 + 12 λA (I + λA) e−iξh = I − iλA sin ξh − 2λ2 A2 sin2 ξh 2 9 : −1 = T I − iλD sin ξh − 2λ2 D2 sin2 ξh 2 T 9 Gn (ξh) = T I − iλD sin ξh − 2λ2 D2 sin2 ξh 2 :n T −1 ||Gn (ξh)||2 ≤ ||T ||2 · ||T −1 ||2 if max |ci |λ ≤ 1 i ⇒ G(ξh) is uniformly power bounded and hence LW for a hyperbolic system is stable in the 2-norm if the CFL condition is satisfied. ex : leap-frog/centered-difference scheme for scalar wave equation vt + cvx = 0 un+1 − un−1 j j + cD0 unj = 0 2k CFL is satisfied if |c|λ ≤ 1. Does this ensure stability in the 2-norm? ! un+1 j unj " ! −2ckD0 = 1 1 0 "! unj un−1 j " un+1 = Qunj , Q = Q1 S+ + Q0 I + Q−1 S− j 78 ? n+1 ?n u iξh = G(ξh)u , G(ξh) = Q1 e −iξh + Q0 + Q−1 e = ! −2icλ sin ξh 1 1 0 " det (G(ξh) − µI) = µ2 + 2icλ sin ξh · µ − 1 = 0 µ = −icλ sin ξh ± @ 1 − c2 λ2 sin2 ξh ⇒ |µ| = 1 if |c|λ ≤ 1 µ-plane i|c|λ µ2 µ1 -i|c|λ case 1 : |c|λ < 1 µ1 += µ2 , |µ1 | = |µ2 | = 1 , µ1 + µ2 = −2icλ sin ξh , µ1 µ2 = −1 G(ξh) = ! µ 1 + µ2 1 ! 1 T = −µ2 1 −µ1 " 1 0 " = T DT −1 ! µ1 , D= 0 0 µ2 " , T −1 1 = µ2 − µ1 ! −µ1 µ2 −1 1 " Gn (ξh) = T Dn T −1 ⇒ ||Gn (ξh)||2 ≤ ||T ||2 · ||T −1 ||2 claim If A is a p × p matrix, then ||A||2 ≤ √ p ||A||∞ and ||A||∞ ≤ √ p ||A||2 . pf (claim) 1. ||Ax||22 = ⇒ p $ i=1 |(Ax)i |2 ≤ p ||Ax||2∞ ≤ p ( ||A||∞ · ||x||∞ )2 ≤ p ||A||2∞ · ||x||22 ||Ax||2 √ ≤ p ||A||∞ ||x||2 2. omit ok 25. Tues 4/12 ||T ||∞ ≤ 2 ||T −1 ||∞ ≤ √ ||T ||2 ≤ 79 2 1 1 √ = √ ≤ |µ2 − µ1 | 1 − c 2 λ2 1 − c2 λ2 sin2 mh 2·2 √ ||T −1 ||2 ≤ 2 · √ ⇒ 1 1 − c 2 λ2 max ||Gn (ξh)||2 ≤ √ ξh case 2 : |c|λ = 1 4 : unif power bdd if |c|λ < 1 1 − c 2 λ2 previous bound fails assume wlog cλ = −1 and consider ξh = G( π2 ) ! = ! 2i 1 1 0 " " = ! i 1 1 −i = i 0 i 0 1 Gn ( π2 ) = ! i 1 1 0 "! ! i 1 1 0 " i 1 0 i "! i 1 0 i "! ! i 1 0 i "n ⇒ "n ! 0 1 1 −i = i n ! " 1 −i 0 1 " "n = i ! n ! 1 −ni 0 1 0 1 n + 1 −ni = . . . = in 1 −i −ni 1 − n max ||Gn (ξh)||2 ≥ ||Gn ( π2 )||2 ≥ ξh π 2 √1 2 ||Gn ( π2 )||∞ = 2n+1 √ 2 " " : not unif power bdd Hence the leap-frog/centered-difference scheme for the scalar wave equation is stable in the 2-norm ⇔ |c|λ < 1. This can be generalized to hyperbolic systems. note 1. Fourier method ⇒ ||un+1 ||22 + ||un ||22 ≤ 2. energy method pf ⇒ ||un+1 ||22 + ||un ||22 ≤ : 16 9 1 2 0 2 ||u || + ||u || 2 2 1 − c 2 λ2 : 1 + |c|λ 9 1 2 ||u ||2 + ||u0 ||22 1 − |c|λ set Ln = ||un ||22 + ||un−1 ||22 + 2kc(un , D0 un−1 ) , show Ln+1 = Ln for n ≥ 1 . . . 80 lower order terms scalar equation vt + cvx = bv , v(x, 0) = f (x) The characteristics are still the lines x − ct = α in the xt-plane. d v(α + ct, t) = vx (α + ct, t) · c + vt (α + ct, t) = bv(α + ct, t) dt ⇒ v(α + ct, t) = ebt v(α, 0) ⇒ v(x, t) = ebt f (x − ct) check . . . ||v(·, t)||2 = ebt ||f ||2 : energy of exact solution changes in time un+1 = unj − kcD0 unj + 12 k 2 c2 D+ D− unj + kbunj j (for example) ρ(ξh) = ρ0 (ξh) + kb , ρ0 (ξh) : LW recall : |c|λ ≤ 1 ⇒ |ρ0 (ξh)| ≤ 1 ⇒ |ρ(ξh)| ≤ 1 + k|b| 9 ρn (ξh) ≤ (1 + k|b|)n ≤ ek|b| :n = e|b|t , t = nk u? n (ξh) = ρ(ξh)n u? 0 (ξh) ⇒ ||un ||2 ≤ e|b|t ||u0 ||2 : stability system vt + Avx = Bv , A = T DT −1 un+1 = unj − kAD0 unj + 12 k 2 A2 D+ D− unj + kBunj j G(ξh) = G0 (ξh) + kB , G0 (ξh) : LW goal : show that G(ξh) is uniformly power bounded recall : max |ci |λ ≤ 1 ⇒ ||Gn0 (ξh)||2 ≤ ||T ||2 · ||T −1 ||2 = g , set ||B||2 = b i ||Gn ||2 = ||(G0 + kB)n ||2 ≤ ||G0 + kB||n2 ≤ (||G0 ||2 + k||B||2 )n = (g + kb)n = (g(1 + kb/g))n ≤ g n e(b/g)t : ok if g ≤ 1 , not ok if g > 1 case 1 : G0 B = BG0 Gn = (G0 + kB)n = n 9 : $ n i=0 n ||G ||2 ≤ n 9 : $ n i=0 n−i i ||G0 ||2 i i Gn−i 0 (kB) i · ||(kB) ||2 ≤ g n 9 : $ n i=0 i (kb)i ≤ g(1 + kb)n ≤ gebt ok 26. Thurs 4/14 81 case 2 : G0 B += BG0 (G0 + kB)2 = G20 + k(G0 B + BG0 ) + k 2 B 2 (G0 +kB)3 = G30 + k(G20 B +G0 BG0 +BG20 ) + k 2 (G0 B 2 +BG0 B +B 2 G0 ) + k 3 B 3 9 : n 1 terms with one B and (n − 1) G0 9 : + k 2 · n2 terms with two B and (n − 2) G0 9 : 9 : ||(G0 + kB)n ||2 ≤ g + k n1 g 2 b + k 2 n2 g 3 b2 + · · · n $ n g (kgb)i = g(1 + kgb)n ≤ gegbt ok (G0 + kB)n = Gn0 + k · ||Gn ||2 ≤ = i=0 + ··· i summary : if G0 (ξh) is unif power bdd, then so is G(ξh) = G0 (ξh) + kB further theoretical results von Neumann condition : max ρ(G(ξh)) ≤ 1 + kb ξh ↑ spectral radius (largest magnitude of an e-value) claim 1. The vN condition is necessary for stability in the 2-norm. 2. If p = 1, the vN condition is necessary and sufficient for stability in the 2-norm. 3. If p ≥ 2, the vN condition in not sufficient for stability in the 2-norm. note The Kreiss matrix theorem gives several conditions on G(ξh) which are necessary and sufficient for stability in the 2-norm. Lax equivalence theorem Consider a linear constant coefficient PDE of the form vt = A0 v + A1 vx + A2 vxx (for example) and a finite-difference scheme of the form un+1 = Qun . If the initial value problem for the PDE is well-posed and the difference scheme is consistent, then stability is necessary and sufficient for convergence. 82 convection-diffusion equation vt + cvx = νvxx , assume c > 0 un+1 − unj j + cD− unj = νD+ D− unj k un+1 = unj − kcD− unj + νkD+ D− unj j = unj − cλ1 (unj − unj−1 ) + νλ2 (unj+1 − 2unj + unj−1 ) k k , λ2 = 2 h h consider stability in the ∞-norm λ1 = un+1 = (1 − cλ1 − 2νλ2 )unj + (cλ1 + νλ2 )unj−1 + νλ2 unj+1 j then ||un+1 ||∞ ≤ ||un ||∞ ⇔ 1 − cλ1 − 2νλ2 ≥ 0 pf . . . νλ2 1/2 cλ1 1 ⇒ cλ1 ≤ 1 − 2νλ2 : more restrictive than for vt + cvx = 0 νλ2 ≤ 1 2 − 12 cλ1 : · · · · · · · · · · · ” · · · · · · · · · · vt = νvxx problem : if ν << 1, then artificial viscosity can overwhelm physical viscosity analysis of numerical wave speed for leap-frog scheme vt + cvx = 0 un+1 − un−1 j j + cD0 unj = 0 , needs u0j , u1j to start 2k 83 ! un+1 j unj " ! ! u? n+1 (ξh) −2icλ sin ξh 1 = u? n (ξh) 1 0 −2ckD0 = 1 " 1 0 ! "! unj un−1 j " "! u? n (ξh) u? n−1 (ξh) e-values of G(ξh) : µ = −icλ sin ξh ± " @ 1 − c2 λ2 sin2 ξh We showed that G(ξh) is unif power bdd ⇔ |c|λ < 1. However even when the scheme is stable, there is still a problem due to the extraneous root. recall : numerical wave speed = c# = µ1 = −icλ sin ξh + @ 1 − c2 λ2 sin2 ξh θ(ξh) , θ(ξh) = arg ρ(ξh) −λξh = −icλ(ξh − 16 (ξh)3 + · · ·) + 1 − 12 c2 λ2 (ξh)2 + · · · −cλξh + 16 cλ(ξh)3 + · · · tan θ1 = 1 − 12 c2 λ2 (ξh)2 + · · · : same as LW c#1 = c(1 − 16 (1 − c2 λ2 )(ξh)2 + · · ·) µ2 = −icλ sin ξh − @ 1 − c2 λ2 sin2 ξh = −icλ(ξh − 16 (ξh)3 + · · ·) − (1 − 12 c2 λ2 (ξh)2 + · · ·) −cλξh + 16 cλ(ξh)3 + · · · tan θ2 = −1 + 12 c2 λ2 (ξh)2 + · · · = (−cλξh + 16 cλ(ξh)3 + · · ·)(−1 − 12 c2 λ2 (ξh)2 + · · ·) c#2 = c(−1 + 16 (1 − c2 λ2 )(ξh)2 + · · ·) : wrong direction recall : the numerical solution has components of the form unj = µn eijξh µ1 = 1 − icλξh − 12 c2 λ2 (ξh)2 + · · · = e−icλξh + · · · unj = µn1 eijξh ≈ eiξ(xj −#c1 tn ) : genuine solution of PDE µ2 = (−1)(1 + icλξh − 12 c2 λ2 (ξh)2 + · · ·) = −eicλξh + · · · unj = µn2 eijξh ≈ (−1)n eiξ(xj −#c2 tn ) : spurious solution The spurious solution oscillates in time and travels in the wrong direction.