Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ordinary Differential Equations

Similar presentations

Presentation on theme: "Ordinary Differential Equations"— Presentation transcript:

1 Ordinary Differential Equations
Jyun-Ming Chen

2 Contents Review Euler’s method 2nd order methods Runge-Kutta Method
Midpoint Heun’s Runge-Kutta Method Systems of ODE Stability Issue Implicit Methods Adaptive Stepsize

3 Review DE (Differential Equation)
An equation specifying the relations among the rate change (derivatives) of variables ODE (Ordinary DE) vs. PDE (Partial DE) The number of independent variables involved

4 Solution of DE vs. Solution of Equation
Review (cont) Solution of DE vs. Solution of Equation Solution of an equation: Geometrically, f(x) x

5 Need additional conditions to specify a solution
Review (cont) Solution of an differential equation: Geometrically: t x

6 Review (cont) Order of an ODE
The highest derivative in the equation nth order ODE requires n conditions to specify the solution IVP (initial value problem): All conditions specified at the same (initial) point BVP (boundary value problem): otherwise

7 IVP VS. BVP Revisit Shooting Problem

8 IVP vs. BVP Physical meaning

9 Maxima on ODE Ode2: solves 1st and 2nd order ODE
Ic1, ic2, bc: setting conditions ‘ do not evaluate Maxima on ODE

10 Linear ODE Linearity: nth order linear ODE
Involves no product nor nonlinear functions of y and its derivatives nth order linear ODE

11 Focus of This Chapter Solve IVP of nth order ODE numerically e.g.,

12 ODE (IVP) First order ODE (canonical form)
Every nth order ODE can be converted to n first order ODEs in the following method:


14 Example

15 End of Review

16 The Canonical Problem This is Euler’s method

17 Example Compare with exact sol:

18 Example (cont) 1 x y y=e–x

19 Error Analysis (Geometric Interpretation)
Think in terms of Taylor’s expansion If the true solution were a straight line, then Euler is exact

20 Error Analysis (From Taylor’s Expansion)
Euler’s Euler’s truncation error O(Dx2) per step 1st order method

21 Cumulative Error y x Remark: Dx Error  But computation time x = 0
x = T Number of steps = T/Dx Cumulative Err. = (T/Dx)  O(Dx2) = O(Dx)

22 Example (Euler’s)

23 Methods Improving Euler
Motivated by Geometric Interpretation

24 Midpoint Method

25 Example (Midpoint)

26 Heun’s Method

27 Note the result is the same as Midpoint!?
Example (Heun’s) Note the result is the same as Midpoint!?

28 Remark Comparison of Euler, Heun, midpoint “order”:
1st order: Euler 2nd order: Heun, midpoint “order”: All are special cases of RK (Runge-Kutta) methods Exact Euler (error) Midpoint (error) y(0.1) 0.905 0.9 (0.005) (0) y(0.2) 0.819 0.81 (0.009) y(0.3) 0.741 0.729 (0.012)

29 RK Methods

30 RK Methods (cont)

31 Taylor’s Expansion

32 RK 1st Order

33 RK 2nd Order

34 RK 2nd Order (cont)

35 RK 4th Order Mostly commonly used one
Higher order … more evaluation, but less gain on accuracy Classical 4th order RK

36 Classical 4th order RK

37 System of ODE Convert higher order ODE to 1st order ODEs
All methods equally apply, in vector form

38 Example (Mass-Spring-Damper System)
Governing Equation After setting the initial conditions x(0) and x’(0), compute the position and velocity of the mass for any t > 0 c k Initial Condition x m

39 Example (cont)

40 Example (cont) set Dt=0.1 Assume m=1,c=1, k=1
(for ease of computation) set Dt=0.1

41 Stability: Symptom

42 Symptom: Unstable Spring System
Become unstable instantly … Start with this … Cause by stiff (k=4000) springs

43 Stability (cont) Example Problem: Conditionally stable

44 Discussion Different algorithm different stability limit
Check Midpoint Method Different problem different stability limit use the previous problem as benchmark

45 Review: Numerical Differentiation
Taylor’s expansion: Forward difference Backward difference

46 Numerical Difference (cont)
Central difference

47 Implicit Method (Backward Euler)
Forward difference Backward difference

48 Example Remark: Always stable (for this problem)
Truncation error the same as Euler (only improve the stability)

49 Stiff Set of ODE Use the change of variable
Get the following solution: Stability limit A stiff equation is a differential equation for which certain numerical methods for solving the equation are numerically unstable, unless the step size is taken to be extremely small


51 Linear System of ODE with Constant Coefficients
Do not really use (..)-1. Solve linear system instead

52 Analysis Explicit and implicit Euler both in the form:
represent x(0) in eigen basis x will converge if |li|  1

53 Analysis (cont) Stiff equations have large eigenvalues
Explicit Euler requires small h to converge Implicit Euler always converges (in this problem)

54 Example Explicit Implicit

55 Semi-Implicit Euler Not guaranteed to be stable, but usually is
Solving implicit methods by linearization is called a “semi-implicit” method Semi-Implicit Euler Not guaranteed to be stable, but usually is Jacobian

56 About Jacobian Taylor’s expansion: Jacobian

57 c k Initial Condition x m Implicit Euler

58 c k Initial Condition x m Semi-Implicit Euler

59 Ex: Semi-Implicit Euler

60 Amazingly, this translates to…
Very similar to Verlet integration formula… no wonder Verlet is pretty stable

61 Adaptive Stepsize Solving ODE numerically … tracing the integral curve y(x) what’s wrong with uniform step size Uniformly small: waste effort Uniformly large: might miss details

62 Step Doubling Idea: Estimate the truncation error by taking each step twice: one full step, two half steps control the step size such that the estimated error is not too big. 1(2h1) 2(h1) Desired h0

63 Ex: RK 2nd Order Overhead: # of f(x,y) evaluations 24–2 = 6

64 Adaptive Step with RK4 (NR)

65 GSL

66 Initialization

67 Iteration

Download ppt "Ordinary Differential Equations"

Similar presentations

Ads by Google