Tut10_Sol

pdf

School

The Chinese University of Hong Kong *

*We aren’t endorsed by this school

Course

3240

Subject

Mathematics

Date

Nov 24, 2024

Type

pdf

Pages

7

Uploaded by MinisterGorilla8297

Report
MATH3240 Numerical Methods for Differential Equations Tutorial 10 (Apr. 13, 2023) 1 Recall: 1. Finite difference methods: Finite difference method(FDM) is one of the most classical and powerful numerical methods for solving both ODEs and PDEs. (a) Finite difference schemes i. first order forward difference: f ( t i +1 ) - f ( t i ) h ; ii. first order backward difference: f ( t i ) - f ( t i - 1 ) h ; iii. first-order central difference: f ( t i +1 ) - f ( t i - 1 ) 2 h ; iv. second-order central difference: f ( t i +1 ) - 2 f ( t i )+ f ( t i - 1 ) h 2 . (b) Consistency: The finite difference scheme is said to be consistent if lim h 0 τ ( h ) = 0 , where τ ( h ) is the local truncation error. (c) Convergence: Let x ( t ) be the true solution of the original BVP, that is, ( u 00 ( t ) + p ( t ) u 0 ( t ) + q ( t ) u ( t ) = w ( t ) , a < t < b u ( a ) = α, u ( b ) = β. Letting e i = x ( t i ) - x i for i = 0 , 1 , . . . , M , we will check whether we have lim h 0 max 1 i M - 1 | e i | = 0 . If so, then we know that the FDM converges. 2. Collocation methods Consider solving the boundary value problem u 00 ( t ) + p ( t ) u 0 ( t ) + q ( t ) u ( t ) = w ( t ) , a < t < b u ( a ) = α, u ( b ) = β (1) Let a function φ ( t ) satisfy the boundary conditions: φ ( a ) = α, φ ( b ) = β and n linearly independent functions φ 1 ( t ) , φ 2 ( t ) , · · · , φ n ( t ) such that φ k ( a ) = φ k ( b ) = 0 , k = 1 , 2 , · · · , n . Then the collocation method is to find an approximate solution of u ( t ) to the BVP (1) in the form: u n ( t ) = φ ( t ) + n X i =1 c i φ i ( t ) . For this, we should find the n coefficients c 1 , c 2 , · · · , c n . (a) Substituting u n ( t ) into (1) gives u 00 n ( t ) + p ( t ) u 0 n ( t ) + q ( t ) u n ( t ) = w ( t ) , a < t < b (2) 1
(b) Choosing n distinct points { t j } n j =1 from the interval ( a, b ) for the equation (2). That is, u 00 n ( t j ) + p ( t j ) u 0 n ( t j ) + q ( t j ) u n ( t j ) = w ( t j ) , j = 1 , 2 , · · · , n. We can write this system as n X i =1 c i { φ 00 i ( t j ) + p ( t j ) φ 0 i ( t j ) + q ( t j ) φ i ( t j ) } = b j , j = 1 , 2 , · · · , n (3) where b j = w ( t j ) - { φ 00 ( t j ) + p ( t j ) φ 0 ( t j ) + q ( t j ) φ ( t j ) } . We can further write (3) as the following linear algebraic system: Ac = b where A = ( a ji ) , c = ( c 1 , c 2 , · · · , c n ) t and b = ( b 1 , b 2 , · · · , b n ) t with a ji = φ 00 i ( t j ) + p ( t j ) φ 0 i ( t j ) + q ( t j ) φ i ( t j ) , i, j = 1 , 2 , · · · , n. (c) Solving the system Ac = b , we can obtain all the coefficients c 1 , c 2 , · · · , c n , and thus the approximate solution u n ( x ) . 3. Finite difference methods for parabolic equations Consider the following heat conduction equation: ∂u ∂t - α 2 u ∂x 2 = f ( x, t ) , 0 < x < 1 , 0 < t < T u ( x, 0) = g ( x ) , 0 x 1 u (0 , t ) = a ( t ) , u (1 , t ) = b ( t ) , 0 t T (4) (a) Forward finite difference methods We divide the time interval [0 , T ] into equally-distributed subintervals: 0 = t 0 < t 1 < · · · < t M = T, with t n = and τ = T M being the time stepsize. For the space interval we also partition it uniformly as follows: 0 = x 0 < x 1 < · · · < x N = 1 , with x i = ih and h = 1 N being the space mesh size. If we use the first order forward finite difference scheme to approximate u t ( x j , t n ) and the second order central finite difference scheme to approximate u xx ( x j , t n ) we can derive the finite difference approximation: u n +1 j - u n j τ - α u n j +1 - 2 u n j + u n j - 1 h 2 = f n j , u 0 j = g ( x j ) , j = 0 , 1 , . . . , N, u n 0 = a ( t n ) , u n N = b ( t n ) , n = 1 , 2 , . . . , M. (5) 2
2 Exercises: Please do star questions during the tutorial and finish the remaining after class. 1. Consider the following BVP ( - u xx + u x + u = f, 0 < x < 1 , u (0) = u (1) = 0 , and the following finite difference method - u j +1 - 2 u j + u j - 1 h 2 + u j +1 - u j - 1 2 h + u j = f j . (a) Compute the local truncation error. (b) Assume that 0 < h < 2 . Show that max j | u j | ≤ max j | f j | . Solution. (a) By definition, the local truncation error is τ i ( h ) = - u ( x j +1 ) - 2 u ( x j ) + u ( x j - 1 ) h 2 + u ( x j +1 ) - u ( x j - 1 ) 2 h + u ( x j ) - f ( x j ) = - u 00 ( x j ) + 1 12 h 2 u (4) ( ξ j ) + u 0 ( x j ) + 1 6 h 2 u (3) ( μ j ) + u ( x j ) - f ( x j ) = - 1 12 h 2 u (4) ( ξ j ) + 1 6 h 2 u (3) ( μ j ) for some ξ j and μ j lying between x j - 1 and x j +1 . (b) Multiplying (1) by 2 h 2 , we obtain - 2( u j +1 - 2 u j + u j - 1 ) + h ( u j +1 - u j - 1 ) + 2 h 2 u j = 2 h 2 f j . After re-arrangement, we have (4 + 2 h 2 ) u j = 2 h 2 f j + (2 - h ) u j +1 + (2 + h ) u j - 1 . Then for 0 < h < 2 , we have (4 + 2 h 2 ) | u j | ≤ 2 h 2 max j | f j | + (2 - h ) max j | u j +1 | + (2 + h ) max j | u j - 1 | . Let k be the index such that | u k | = max j | u j | . Then we have (4 + 2 h 2 ) | u k | ≤ 2 h 2 max j | f j | + (2 - h ) | u k | + (2 + h ) | u k | , which implies | u k | ≤ max j | f j | , i.e. max j | u j | ≤ max j | f j | . 2. Consider the following BVP ( t 2 + 1) y 00 ( t ) = - 2 y 0 ( t ) + y ( t ) + sin( πt ) , y (0) = 1 , y (1) = - 1 . (6) 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
(a) Using the central difference for y 00 ( t ) and the forward difference for y 0 ( t ) , formulate the corresponding finite difference scheme for (6). (b) Write the discrete system obtained in the first question into a matrix-vector form. (c) Find the local truncation error of your constructed FDM. (d) Check if your FDM is convergent under the assumption that | y ( n ) ( t ) | < C (constant) for t [0 , 1] , for all n . Solution. (a) Rewrite the BVP as y 00 ( t ) = - 2 t 2 + 1 y 0 ( t ) + 1 t 2 + 1 y ( t ) + sin( πt ) t 2 + 1 , y (0) = 1 , y (1) = - 1 . Denote w ( t ) = - 2 t 2 + 1 , v ( t ) = 1 t 2 + 1 , u ( t ) = sin( πt ) t 2 + 1 . Then the finite difference scheme is: y 0 = 1 , y n +1 - 2 y n + y n - 1 h 2 = w ( t n ) y n +1 - y n h + v ( t n ) y n + u ( t n ) , y N = - 1 . Rewrite it as y 0 = 1 , u ( t n ) = 1 h 2 y n - 1 + w ( t n ) h - 2 h 2 - v ( t n ) y n + 1 h 2 - w ( t n ) h y n +1 , y N = - 1 . Now we denote a n = 1 h 2 , b n = u ( t n ) , c n = 1 h 2 - w ( t n ) h d n = w ( t n ) h - 2 h 2 - v ( t n ) . Then the system can be written as y 0 = 1 , b n = a n y n - 1 + d n y n + c n y n +1 y N = - 1 . (b) With the notation above, we can rewrite the above system into the following matrix-vector form: d 1 c 1 a 2 d 2 c 2 . . . . . . . . . a N - 2 d N - 2 c N - 2 a N - 1 d N - 1 y 1 y 2 . . . y N - 2 y N - 1 = b 1 - a 1 y 0 b 2 . . . b N - 2 b N - 1 - c N - 1 y N . (c) By Taylor expansion, we have τ i ( h ) = y ( t i +1 ) - 2 y ( t i ) + y ( t i - 1 ) h 2 - w ( t i ) y ( t i +1 ) - y ( t i ) h + v ( t i ) y ( t i ) + u ( t i ) = x 00 ( t i ) + h 2 12 y (4) ( ξ i ) - w ( t i ) y 0 ( t i ) + h 2 y (2) ( μ i ) + v ( t i ) y ( t i ) + u ( t i ) = h 2 12 y (4) ( ξ i ) - h 2 w ( t i ) y (2) ( μ i ) , 4
for some ξ i and μ i lying between t i - 1 and t i +1 . (d) Let e n = y ( t n ) - y n for n = 0 , 1 , · · · , N . Noting that the exact solution y ( t ) satisfies the BVP (6), for n = 1 , · · · , N - 1 we have by Taylor expansion that y ( t n +1 ) - 2 y ( t n ) + y ( t n - 1 ) h 2 - 1 12 h 2 y (4) ( ξ n ) = w ( t n ) y ( t n +1 ) - y ( t n ) h + h 2 y (2) ( μ n ) + v ( t n ) y ( t n ) + u ( t n ) for some ξ n and μ n lying between t n - 1 and t n +1 . Then we have 1 h 2 y ( t n - 1 ) + w ( t n ) h - 2 h 2 - v ( t n ) y ( t n ) + 1 h 2 - w ( t n ) h y ( t n +1 ) = u ( t n ) + h 2 12 y (4) ( ξ n ) + w ( t n ) 2 hy (2) ( μ n ) . Then a n e n - 1 + d n e n + c n e n +1 = g n , where g n = h 2 12 y (4) ( ξ n ) + w ( t n ) 2 hy (2) ( μ n ) . Thus - d n e n = a n e n - 1 + c n e n +1 - g n max 0 n N | g n | + | a n | max 1 n N | e n - 1 | + | c n | max 0 n N - 1 | e n +1 | max 0 n N | g n | + | a n | max 0 n N | e n | + | c n | max 0 n N | e n | . Similarly, we have - d n ( - e n ) = a n ( - e n - 1 ) + c n ( - e n +1 ) + g n max 0 n N | g n | + | a n | max 0 n N | e n | + | c n | max 0 n N | e n | . Thus - d n | e n | ≤ max 0 n N | g n | + | a n | max 0 n N | e n | + | c n | max 0 n N | e n | . Let m be the index such that | e m | = max 0 n N | e n | , then we have ( - d m - | a m | - | c m | ) | e m | ≤ max 0 n N | g n | . Note by definition - d m - | a m | - | c m | = v ( t m ) + 2 h 2 + 2 ( t 2 m + 1) h - 1 h 2 - 1 h 2 - 2 ( t 2 m + 1) h = v ( t m ) . Then we have min 0 t 1 v ( t ) | e m | ≤ max 0 n N | g n | ≤ h 2 12 max 0 t 1 | y (4) ( t ) | + h 2 max 0 t 1 | w ( t ) y (2) ( t ) | , hence | e m | ≤ h 2 12 max 0 t 1 | y (4) ( t ) | + h 2 max 0 t 1 | w ( t ) y (2) ( t ) | min 0 t 1 v ( t ) . Since for t [0 , 1] , v ( t ) v 0 > 0 , | w ( t ) | ≤ C and | y ( n ) ( t ) | ≤ C , when h 0 , we have lim h 0 max 0 n N | e n | = 0 . This proves the convergence of the finite difference method. 5
3. (a) Consider solving the BVP ( u 00 ( t ) + p ( t ) u 0 ( t ) + q ( t ) u ( t ) = w ( t ) , a < t < b, u ( a ) = α, u ( b ) = β. Write down the basic principle of the collocation method to find an approximation solution to the BVP. (b) Consider the BVP ( u 00 ( t ) + u 0 ( t ) + u ( t ) = t 2 , 0 < t < 1 , u (0) = 0 , u (1) = 0 . Develop a collocation method for the numerical solution of this problem using the collocation points: t j = j N + 1 , j = 1 , · · · , N, and the basis functions: φ i ( t ) = sin( iπt ) , i = 1 , · · · , N. Solution. (a) The collocation method is to find an approximate solution of u ( t ) to the BVP in the form: u n ( t ) = φ ( t ) + n X i =1 c i φ i ( t ) , where φ ( t ) is a function satisfying the boundary conditions φ ( a ) = α, φ ( b ) = β , and { φ i } are n linearly independent functions such that φ k ( a ) = φ k ( b ) = 0 , for k = 1 , 2 , · · · , n . To solve the coefficients { c i } , the collocation method suggest to choose n distinct point { t j } from the interval ( a, b ) satisfying the ODE, from which we can obtain a linear system: n X i =1 c i { φ 00 i ( t j ) + p ( t j ) φ 0 i ( t j ) + q ( t j ) φ i ( t j ) } = b j , j = 1 , 2 , · · · , n, where b j = w ( t j ) - { φ 00 ( t j ) + p ( t j ) φ 0 ( t j ) + q ( t j ) φ ( t j ) } . (b) First, simply let the boundary basis function φ ( t ) be φ ( t ) = 0 , which satisfies the boundary conditions. Then the collocation method is the find an approximation solution of u ( t ) to the BVP in the following form: u n ( t ) = N X i =1 c i sin( iπt ) . With the collocation points t j = j N + 1 , j = 1 , 2 , · · · , N , we have the n equations: u 00 n ( t j ) + u 0 n ( t j ) + u n ( t j ) = t 2 j , j = 1 , · · · , N. This system can be written as n X i =1 c i { φ 00 i ( t j ) + φ 0 i ( t j ) + φ i ( t j ) } = b j , j = 1 , 2 , · · · , N, where b j = t 2 j , φ i ( t j ) = sin( iπt j ) , φ 0 i ( t j ) = cos( iπt j ) and φ 00 i = - i 2 π 2 sin( iπt j ) . 4. Consider the following BVP ∂u ∂t + α ∂u ∂x = β 2 u ∂x 2 , 0 < x < 1 , 0 < t < T u ( x, 0) = g ( x ) , 0 x 1 u (0 , t ) = a ( t ) , u (1 , t ) = b ( t ) , 0 t T (7) Derive a FDM using the first order forward finite difference to approximate ∂u ∂t , the first order central finite difference to approximate ∂u ∂x , and the second order central finite difference to approximate 2 u ∂x 2 . 6
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Solution. u n +1 j - u n j τ + α u n j +1 - u n j - 1 2 h = β u n j +1 - 2 u n j + u n j - 1 h 2 . 7