Page 228 - Applied Numerical Methods Using MATLAB
P. 228

DIFFERENCE APPROXIMATION FOR SECOND AND HIGHER DERIVATIVE  217
              Now, we turn our attention to the high-order derivatives. But, instead of deriv-
            ing the specific formulas, let’s make an algorithm to generate whatever difference
            approximation formula we want. For instance, if we want to get the approxima-
            tion formula of the second derivative based on the function values f 2 ,f 1 ,f 0 ,f −1 ,
            and f −2 , we write

                      (2)       c 2 f 2 + c 1 f 1 + c 0 f 0 + c −1 f −1 + c −2 f −2
                    D (x, h) =                                           (5.3.3)
                      c4                        2
                                               h
            and take the Taylor series expansion of f 2 ,f 1 ,f −1 ,and f −2 excluding f 0 on the
            right-hand side of this equation to rewrite it as

             (2)
           D (x, h)
             c4
                                   (2h)       (2h)       (2h)
                                      2          3          4            
                                         (2)       (3)        (4)        
                    c 2 f 0 + 2hf +    f   +      f   +      f   +· · ·
                                0        0          0          0          
                                                                         
                                    2          3!        4!              
                                                                         
                                                                         
                                                                         

                                    2       3        4                   
                                   h       h       h                     
                                       (2)     (3)     (4)               
                    +c 1 f 0 + hf +  f 0  +  f 0  +   f 0  +· · · + c 0 f 0  
                   
                                0
                                                                          
                 1                 2       3!       4!                   
              =
                  2                   2       3        4
                h                   h   (2)  h  (3)  h  (4)              
                    +c −1 f 0 − hf +  f 0  −   f 0  +  f 0  −· · ·       
                                                                         
                                  0
                   
                                                                          
                                     2      3!       4!                  
                                                                         
                                                                         
                                                                         

                                         2          3         4           
                                     (2h)       (2h)       (2h)          
                                           (2)        (3)        (4)     
                   
                    +c −2 f 0 − 2hf +     f   −      f  +      f         
                                   0        0          0          0  − ··· 
                                        2         3!         4!

                                                                      
                    (c 2 + c 1 + c 0 + c −1 + c −2 )f 0 + h(2c 2 + c 1 − c −1 − 2c −2 )f 
                                                                     0 
                                                                      

                                  2                  2                
                                 2      1    1      2                 
                              2                             (2)       
                            +h     c 2 + c 1 + c −1 +  c −2 f         
                                                            0         
                                   2     2    2       2                
                                                                      
                   
                 1                                                    
                                   3                   3
              =                   2     1      1      2                  (5.3.4)
                  2            3                              (3)
                h          +h      c 2 +  c 1 −  c −1 −  c −2 f       
                                                             0        
                                 3!    3!    3!      3!               
                                                                      
                                                                      
                                                                      
                                4                    4
                                                                      
                              2      1     1       2       (4)        
                           4                                          
                         +h     c 2 +  c 1 +  c −1 +  c −2 f  +· · ·  
                               4!     4!    4!      4!
                                                          0           
            We should solve the following set of equations to determine the coefficients
            c 2 ,c 1 ,c 0 ,c −1 ,and c −2 so as to make the expression conform to the second
                      (2)
            derivative f  at x + 0h = x.
                      0
                       1     1   1     1       1      c 2     
                                                 
                                                               0
                       2     1   0    −1     −2
                                                 
                                                     c 1    0 
                     2                      2    
                    2 /2!  1/2!  0   1/2!                           (5.3.5)
                                            2 /2! 
                                                     c 0  =  1 
                   
                                                  
                                              3
                    3     1/3!  0 −1/3!    −2 /3!      c −1     
                                                               0
                     2 /3!
                      4
                                             4
                     2 /4!  1/4!  0   1/4!  2 /4!     c −2     0
   223   224   225   226   227   228   229   230   231   232   233