software for the numerical integration of ode by means of
play

Software for the numerical integration of ODE by means of high-order - PowerPoint PPT Presentation

Introduction A software implementation Software for the numerical integration of ODE by means of high-order Taylor methods (I) ` Angel Jorba angel@maia.ub.es University of Barcelona Advanced Course on Long Term Integrations 1 / 39


  1. Introduction A software implementation Software for the numerical integration of ODE by means of high-order Taylor methods (I) ` Angel Jorba angel@maia.ub.es University of Barcelona Advanced Course on Long Term Integrations 1 / 39

  2. Introduction A software implementation Outline Introduction 1 A software implementation 2 Step size control 2 / 39

  3. Introduction A software implementation Problem: find a function x : [ a , b ] → R m such that � x ′ ( t ) = f ( t , x ( t )) , x ( a ) = x 0 , Taylor method: = x ( a ) , x 0 x m + x ′ ( t m ) h + · · · + x ( p ) ( t m ) h p , x m +1 = p ! for m = 0 , . . . , N − 1. 3 / 39

  4. Introduction A software implementation A first approach is to compute the derivatives by means of the direct application of the chain rule, x ′ ( t m ) = f ( t m , x ( t m )) , x ′′ ( t m ) = f t ( t m , x ( t m )) + f x ( t m , x ( t m )) x ′ ( t m ) , and so on. These expressions have to be obtained explicitly for each equation we want to integrate. 4 / 39

  5. Introduction A software implementation Example: Van der Pol equation. x ′ = y , � . (1 − x 2 ) y − x . y ′ = The n th order Taylor method for the initial value problem is m h + 1 m h 2 + · · · + 1 n ! x ( n ) m h n , x m + x ′ 2! x ′′ = x m +1 m h + 1 m h 2 + · · · + 1 n ! y ( n ) m h n . y m + y ′ 2! y ′′ = y m +1 There are several ways of obtaining the derivatives of the solution w.r.t. time. 5 / 39

  6. Introduction A software implementation A standard way is to take derivatives on the differential equation, (1 − x 2 ) y − x , x ′′ = − 2 xy 2 + [(1 − x 2 ) 2 − 1] y − x (1 − x 2 ) , y ′′ = − 2 xy 2 + [(1 − x 2 ) 2 − 1] y − x (1 − x 2 ) , x ′′′ = 2 y 3 − 8 x (1 − x 2 ) y 2 + [4 x 2 − 2 + (1 − x 2 ) 3 ] y y ′′′ = + x [1 − (1 − x 2 ) 2 ] , . . . Note how the expressions become increasingly complicated. 6 / 39

  7. Introduction A software implementation These closed formulas allow for the evaluation of the derivatives at any point, so they have to be computed only once (for each vector field). 7 / 39

  8. Introduction A software implementation These closed formulas allow for the evaluation of the derivatives at any point, so they have to be computed only once (for each vector field). For a long time integration, the effort needed to produce these formulas is not relevant, the effort to evaluate them is very relevant 7 / 39

  9. Introduction A software implementation There is an alternative procedure to compute derivatives: Automatic differentiation Automatic differentiation is a recursive algorithm to evaluate the derivatives of a closed expression on a given point. Automatic differentiation does not produce closed formulas for the derivatives. A good reference book is: A. Griewank: Evaluating derivatives , SIAM (2000). ISBN: 0-89871-284-X 8 / 39

  10. Introduction A software implementation Assume that a is a real function of a real variable. Definition The normalized j -th derivative of a at the point t is a [ j ] ( t ) = 1 j ! a ( j ) ( t ) . Normalized derivatives are the coefficients of the power expansion of the solution. 9 / 39

  11. Introduction A software implementation Lemma n � If a ( t ) = b ( t ) c ( t ) , then a [ n ] ( t ) = b [ n − i ] ( t ) c [ i ] ( t ) . i =0 Proof. It follows from Leibniz formula: n n ! a ( n ) ( t ) = 1 1 � n � � a [ n ] ( t ) b ( n − i ) ( t ) c ( i ) ( t ) = n ! i i =0 n n 1 n ! � ( n − i )! i ! b ( n − i ) ( t ) c ( i ) ( t ) = � b [ n − i ] ( t ) c [ i ] ( t ) . = n ! i =0 i =0 10 / 39

  12. Introduction A software implementation Lemma n � If a ( t ) = b ( t ) c ( t ) , then a [ n ] ( t ) = b [ n − i ] ( t ) c [ i ] ( t ) . i =0 Proof. It follows from Leibniz formula: n n ! a ( n ) ( t ) = 1 1 � n � � a [ n ] ( t ) b ( n − i ) ( t ) c ( i ) ( t ) = n ! i i =0 n n 1 n ! � ( n − i )! i ! b ( n − i ) ( t ) c ( i ) ( t ) = � b [ n − i ] ( t ) c [ i ] ( t ) . = n ! i =0 i =0 If we know the (normalized) derivatives of b and c at t , up to order n , we can compute the n th derivative of a at t . 10 / 39

  13. Introduction A software implementation Example: Van der Pol equation. = x , u 1   u 2 = y ,      u 3 = u 1 u 1 ,    x ′ �  = y , u 4 = 1 − u 3 ,  (1 − x 2 ) y − x . y ′ = u 5 = u 4 u 2 ,   = u 5 − u 1 , u 6     x ′ = u 2 ,     y ′ = u 6 .  11 / 39

  14. Introduction A software implementation  u [ n ] x [ n ] , = 1   u [ n ]  y [ n ] , =   2   n   u [ n ] u [ n − i ] u [ i ]  � = x ,  = 1 ,  u 1  3 1    u 2 = y ,   i =0       u [ n ] − u [ n ] = u 1 u 1 ,   u 3 = (if n > 0) ,     4 3     u 4 = 1 − u 3 ,   n u [ n ] u [ n − i ] u [ i ] � u 5 = u 4 u 2 , = 2 , 5 4     u 6 = u 5 − u 1 ,   i =0       u [ n ] u [ n ] 5 − u [ n ] x ′ = u 2 ,   = 1 ,    6    y ′ = u 6 .   1  n + 1 u [ n ]  x [ n +1] = 2 ,       1  n + 1 u [ n ]  y [ n +1] = 6 .    12 / 39

  15. Introduction A software implementation The recurrence can be applied up to a suitable order p . It is not necessary to select the value p in advance. 13 / 39

  16. Introduction A software implementation If the functions b and c are of class C n , we have n � b [ i ] ( t ) ± c [ i ] ( t ). 1. If a ( t ) = b ( t ) ± c ( t ), then a [ n ] ( t ) = i =0 n � 2. If a ( t ) = b ( t ) c ( t ), then a [ n ] ( t ) = b [ n − i ] ( t ) c [ i ] ( t ). i =0 3. If a ( t ) = b ( t ) c ( t ), then � n � 1 a [ n ] ( t ) = b [ n ] ( t ) − � c [ i ] ( t ) a [ n − i ] ( t ) . c [0] ( t ) i =1 14 / 39

  17. Introduction A software implementation 4. If α ∈ R \ { 0 } and a ( t ) = b ( t ) α , then n − 1 1 a [ n ] ( t ) = � ( n α − i ( α + 1)) b [ n − i ] ( t ) a [ i ] ( t ) . nb [0] ( t ) i =0 n − 1 5. If a ( t ) = e b ( t ) , then a [ n ] ( t ) = 1 � ( n − i ) a [ i ] ( t ) b [ n − i ] ( t ). n i =0 6. If a ( t ) = ln b ( t ), then n − 1 � � 1 b [ n ] ( t ) − 1 a [ n ] ( t ) = � ( n − i ) b [ i ] ( t ) a [ n − i ] ( t ) . b [0] ( t ) n i =1 15 / 39

  18. Introduction A software implementation 7. If a ( t ) = cos c ( t ) and b ( t ) = sin c ( t ), then n − 1 a [ n ] ( t ) � ib [ n − i ] ( t ) c [ i ] ( t ) = n i =1 n 1 � b [ n ] ( t ) ia [ n − i ] ( t ) c [ i ] ( t ) = n i =1 16 / 39

  19. Introduction A software implementation Many ODE can be “decomposed” as a sequence of binary operations, so it is possible to produce the jet of derivatives of the solution at a given point, in a recursive way. This includes ODEs involving special functions. We will see some examples later on. 17 / 39

  20. Introduction A software implementation Next step is to find an order p and a step size h such that the error is smaller than ε . the total number of operations is minimal. 18 / 39

  21. Introduction A software implementation Lemma (C. Sim´ o, 2001) Assume that the function h �→ x ( t n + h ) is analytic on a disk of radius ρ m . Let A m be a positive constant such that m | ≤ A m | x [ j ] , ∀ j ∈ N . ρ j m Then, if the required accuracy ε tends to 0, the values of h m and p m that give the required accuracy and minimize the global number of operations tend to � ε h m = ρ m p m = − 1 � e 2 , 2 ln − 1 A m 19 / 39

  22. Introduction A software implementation Proof. � p +1 � h The error is of the order of the first neglected term E ≈ A . ρ 1 � ε p +1 . � To obtain an error of order ε we select h ≈ ρ A The operations to obtain the jet of is O ( p 2 ) ≈ c ( p + 1) 2 . So, the number of floating point operations per unit of time is given, in order of magnitude, by φ ( p ) = c ( p +1) 2 p +1 . 1 ρ ( ε A ) � ε Solving φ ′ ( p ) = 0, we obtain p = − 1 � 2 ln − 1. A We use this order with the largest step size that keeps the local error below ε : inserting this value of p in the formula for h we have h = ρ e 2 . 20 / 39

  23. Introduction A software implementation Dangerous step sizes x = − x , ˙ x (0) = 1 , We are interested in computing x (10) = exp( − 10) ≈ 0 . 0000454. The Taylor series at x (0) is very simple to obtain: ( − 1) n h n � x ( h ) = 1 + n ! . n ≥ 1 Due to the entire character of this function, the optimal step size is h = 10, and the degree is selected to have a truncation error smaller than a given precision. From a numerical point of view, this is a disaster! 21 / 39

  24. Introduction A software implementation High accuracy and varying order For instance, assume that the truncation error is exactly h p . If ε = 10 − 16 and p = 8, then the step size has to be h = 0 . 01. Note that, if p is fixed, to achieve an accuracy of 10 − 32 we have to use h = 10 − 4 , that forces to use 100 times more steps (hence, 100 times more operations) than for the ε = 10 − 16 case. Changing the value of p from 8 to 16 allows to keep the same step size h = 0 . 01 while the computational effort required to obtain the derivatives is only increased by a factor 4. If the required precision were higher, these differences would be even more dramatic. 22 / 39

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend