Numerical
Methods for
Ordinary
Differential
Equations (ODE)
• Initial Value Problem
• Boundary Value Problems
PREPARED BY:
GIA A. GALES
ANDY GARSUTA
JULES PATRICK R. GO
Initial Value Problems
Solving Linear Equations
Lesson Outline
Euler’s Method
Runge-Kutta Methods
Adaptive Step Size Control
Shooting Method
Finite Difference Method
y=-0.5x + 4x - 10x + 8.5x + 1
4 3 2
Can you find the derivative
of the equation?
=-2x + 12x - 20x + 8.5
3 2
dy
dx
dy
dx
=
y=-0.5x + 4x - 10x + 8.5x + 1
4 3 2
Can you find the
derivative of the
equation?
=-2x + 12x - 20x + 8.5
3 2
dy
dx
=-2x + 12x - 20x + 8.5
3 2
dy
dx
y=-0.5x + 4x - 10x + 8.5x + C
4 3 2
NOW,
what is the Anti-derivative of
y=
=-2x + 12x - 20x + 8.5
3 2
dy
dx
y=-0.5x + 4x - 10x + 8.5x + C
4 3 2
NOW,
what is the Anti-derivative
TROUBLE!
Not uniquely defined because
of unknown constant C
But if we are given one point (0,1)
(0,1)
(0,1)
We just need the Derivative
and one Initial Point
Initial Value
Problems for ODE
Euler’s Method
Runge-Kutta Methods
Adaptive Step Size Control
What is an ODE?
When the function involves
one independent variable, the
equation is called an ordinary
differential equation (or ODE).
y=dependent variable
quantity being differentiated
x= independent variable
quantity with respect to which
y is differentiated,
dy
dx
=f(x,y)
dy
dx
From the example, we have as a
function having only x variables, but here
we can deal with derivatives as a function
of both x and y
dy
dx
considered as the simplest way of performing
numerical solution to a 1st order ordinary differential
equation (ODE).
Although this method is not accurate nor efficient
compared to the other methods, it is useful for
understanding the numerical processes for ODE.
Consider a differential equation written in the form:
To solve for of the ODE given a step size, h,
the formula is:
Euler’s Method
Let the initial condition of the differential equation
be .
New value = old value + step size x slope
Use Euler’s method to numerically integrate
from x=0 to x=2 with a step size of 0.5. The initial
condition at x=0 is y=1.
a. Use analytical Method
b. use Euler’s Method
Example:
Euler’s
Method
Substitute the value of x
from 0 to 2
Step
a. Analytical Method
The constant value C from
Remember:
Recall that the exact solution is
given by:
n
y (true/analytical)
0 0 1 0.5
1 0.5 3.21875 1
2 1 3 1.5
3 1.5 2.21875 2
4 2 2
y=-0.5x + 4x - 10x + 8.5x + C
4 3 2
can be solved by substituting the initial
values (0,1)
1=-0.5(0) + 4(0) - 10(0) + 8.5(0) + C
4 3 2
1=C
y=-0.5(0.5) + 4(0.5) - 10(0.5) + 8.5(0.5) +1
=3.21875
4 3 2
y=-0.5(1) + 4(1) - 10(1) + 8.5(1) + 1
=3
4 3 2
y=-0.5(2) + 4(2) - 10(2) + 8.5(2) + 1
=2
4 3 2
y=-0.5(0) + 4(0) - 10(0) + 8.5(0) + 1
=1
4 3 2
y=-0.5(1.5) + 4(1.5) - 10(1.5) + 8.5(1.5) +
1
=2.21875
4 3 2
Identify what are
given the values
Step 1
n
y (true/ analytical) y ( Euler)
0 0 1 1 0.5 5.25
1 0.5 3.21875 5.25 1
5.87
5
2 1 3 5.875 1.5
3 1.5 2.21875 2
4 2 2
b. Euler’s Method
y = y +h f(x , y )
0+1 0 0 0
at n=0
initial condition (x , y )
=(0,1)
h=0.5
0 0
y = 1 + (0.5)[-2(0) +12(0) -20(0) +8.5]
=5.25
1
3 2
y = 5.25+ (0.5)[-2(0.5) +12(0.5) -20(0.5) +8.5]
=5.875
2
3 2
at n=1
y = y +h f(x , y )
1+1 1 1 1
y = y +h f(x , y )
n+1 n n n
=f(x,y)=
dy
dx
-2x +12x -20x +8.5
3 2
Evaluate at n=0 using
the formula:
Step 2
Repeat the process until y is obtained.
Use previously solved values to the next
iteration
Step 3
4
n x
y (true/ analytical) y ( Euler)
0 0 1 1 0.5 5.25
1 0.5 3.21875 5.25 1 5.875
2 1 3 5.875 1.5 5.125
3 1.5 2.21875 5.125 2 4.5
4 2 2 4.5
b. Euler’s Method
y = y +h f(x , y )
2+1 2 2 2
at n=2
y = 5.875+ (0.5)[-2(1) +12(1) -20(1) +8.5]
=5.125
3
3 2
y = 5.125+ (0.5)[-2(1.5) +12(1.5) -20(0.5) +8.5]
=4.5
4
3 2
at n=3
y = y +h f(x , y )
3+1 3 3 3
Repeat the process until y is obtained.
Use previously solved values to the next
iteration
Step 3
4
Note that, although the computation captures
the general trend of the true solution, the error
is considerable.
Euler’s Method
n x y (true/analytical) y ( Euler)
Relative
Error
0 0 1 1
(true-
approximate)
/true
1 0.5 3.21875 5.25 -63.1%
2 1 3 5.875 -95.8%
3 1.5 2.21875 5.125 -131%
4 2 2 4.5 -125%
Runge-Kutta Methods
an effective and widely used method for solving the initial-
value problems of ODEs.
can be used to construct high order accurate numerical
method by functions' self without needing the high order
derivatives of function.
Depending on the number of intermediate iterations, RK
methods can be in 2nd, 3rd, 4th, or higher orders
New value = old value + slope x step size
The constants cannot be solved because
there are only three equations relating
them. Thus, some engineers assume the
value of one constant then solve for the
values of the other three using the
equations. However, the most common
variation of this method are:
(1) Heun's Method
(2) The Midpoint Method, and
(3) Ralston's Method
Note
2nd Order RK
Method or RK2
.
Heun’s
Method RK2
Midpoint
Method RK2
Ralston’s
Method RK2
Ralston’s
Ralston’s
Method
RK2
1.Solve for k
2.Solve for k
3.Solve for new pair (x , y ) which is:
1
2
n+1 n+1
4. Repeat step 1 to 3 until the required value of x is reached.
Example:
Consider the differential equation shown
below:
Solve for the value of y when x = 2 if (0, 1) is
part of the equation. Use the Ralston's
method and h = 0.25
(Note that from the analytical method, the
true value is 2.403770)
Ralston’s
Method
RK2
Identify what are
given the values
Step 1
Ralston’s Method RK2
at n=0
initial condition (x , y )
=(0,1)
h=0.25
0 0
=f(x,y)=
dy
dx
Solve for k1
Step 2
Solve for k2
Step 3
Solve for new pair
(x , y )
Step 4
n+1 n+1
n
0 0 1 1 0.699983 0.25 1.199997
1
2
3
4
Identify what are
given the values
Step 1
Ralston’s Method RK2
at n=1
initial condition (x , y )
=(0,1)
h=0.25
0 0
=f(x,y)=
dy
dx
Solve for k1
Step 2
Solve for k2
Step 3
Solve for new pair
(x , y )
Step 4
n+1 n+1
n
0 0 1 1 0.699983 0.25 1.199997
1 0.25 1.99997 0.653356 0.509512 0.5 1.229362
2
3
4
Ralston’s Method RK2
3rd Order RK
Method or RK3
.
Runge-
Kutta
Method
RK3
1.Solve for
2.Solve for
3.Solve for
4.Solve for new pair (x , y ) which is:
n+1 n+1
5. Repeat step 1 to 4 until the required value of x is reached.
Example:
Consider the differential equation shown
below:
Solve for the value of y when x = 2 if (0, 1) is
part of the equation. Use the classical RK3
method and h = 0.25
(Note that from the analytical method, the
true value is 2.403770)
Runge-
Kutta
Method
RK3
Identify what are
given the values
Step 1
Runge-Kutta Method RK3
at n=0
initial condition (x , y )
=(0,1)
h=0.25
0 0
=f(x,y)=
dy
dx
Solve for k1
Step 2
Step 5
n+1 n+1
Solve for new pair
(x , y )
n
0 0 1 1 0.785021 0.686230 0.25 1.201096
1
2
Solve for k2
Step 3
Solve for k3
Step 4
Identify what are
given the values
Step 1
Runge-Kutta Method RK3
at n=1
initial condition (x , y )
=(0,1)
h=0.25
0 0
=f(x,y)=
dy
dx
Solve for k1
Step 2
Step 5
n+1 n+1
Solve for new pair
(x , y )
n
0 0 1 1 0.785021 0.686230 0.25 1.201096
1 0.25 1.201096 0.652758 0.549619 0.494182 0.5 1.340488
2
Solve for k2
Step 3
Solve for k3
Step 4
=1.340488
Runge-Kutta Method RK3
4th
Order RK
Method or RK4
.
Runge- Kutta
Method
RK4
1.Solve for
2.Solve for
3.Solve for
4.Solve for
5.Solve for new pair (x , y ) which is:
n+1 n+1
6. Repeat step 1 to 5 until the required value of x is reached.
Example:
Consider the differential equation shown
below:
Solve for the value of y when x = 2 if (0, 1) is
part of the equation. Use the classical RK4
method and h = 0.25
(Note that from the analytical method, the
true value is 2.403770)
Runge-
Kutta
Method
RK3
Identify what are
given the values
Step 1
Runge-Kutta Method RK4
at n=0
initial condition (x , y )
=(0,1)
h=0.25
0 0
=f(x,y)=
dy
dx
Solve for k1
Step 2
n
0 0 1 1 0.785021 0.80423 0.652779 0.25 1.201303
1
2
Solve for k2
Step 3
Solve for k3
Step 4
Solve for k4
Step 5
Runge-Kutta Method RK4
Step 6
n+1 n+1
Solve for new pair
(x , y )
n
0 0 1 1 0.785021 0.80423 0.652779 0.25 1.201303
1
2
Identify what are
given the values
Step 1
Runge-Kutta Method RK4
at n=1
initial condition (x , y )
=(0,1)
h=0.25
0 0
=f(x,y)=
dy
dx
Solve for k1
Step 2
Solve for k2
Step 3
Solve for k3
Step 4
Solve for k4
Step 5
n
0 0 1 1 0.785021 0.80423 0.652779 0.25 1.201303
1 0.25 1.201303 0.65264
6
0.549536 0.55511 0.484091 0.50 1.340721
2
Runge-Kutta Method RK4
Step 6
n+1 n+1
Solve for new pair
(x , y )
n
0 0 1 1 0.785021 0.80423 0.652779 0.25 1.201303
1 0.25 1.201303 0.652646 0.549536 0.55511 0.484091 0.50 1.340721
2
Runge-Kutta Method RK4
SUMMARIZE THE TRUE VALUE TO OTHER METHODS
IN A TABLE
References
Chapra, S. C., & Canale, R. P. (2015). Numerical methods for
engineers (7th ed.). McGraw-Hill Education.
SPTechLab. (2020, July 17). Numerical methods lecture 1 [Video].
YouTube.
https://www.youtube.com/watch?v=XtP6UCT779Y&list=PLTfoKpIjBb
wXCxPt-posI6FyoIWpShhyg&index=5
Resource Page
Use these icons and illustrations in your Canva Presentation. Happy designing!
Don’t forget to delete this page before presenting.
Try this background for online class.
*Please delete this section before downloading.
Press these keys
while on Present mode!
for a blur
B for confetti
C
for a drumroll
D for mic drop
M
for bubbles
O for quiet
Q
for unveil
U for a timer
Any number from 0-9

Numerical Methods for ODE Reporting.pptx

  • 1.
    Numerical Methods for Ordinary Differential Equations (ODE) •Initial Value Problem • Boundary Value Problems PREPARED BY: GIA A. GALES ANDY GARSUTA JULES PATRICK R. GO
  • 2.
    Initial Value Problems SolvingLinear Equations Lesson Outline Euler’s Method Runge-Kutta Methods Adaptive Step Size Control Shooting Method Finite Difference Method
  • 3.
    y=-0.5x + 4x- 10x + 8.5x + 1 4 3 2 Can you find the derivative of the equation? =-2x + 12x - 20x + 8.5 3 2 dy dx dy dx =
  • 4.
    y=-0.5x + 4x- 10x + 8.5x + 1 4 3 2 Can you find the derivative of the equation? =-2x + 12x - 20x + 8.5 3 2 dy dx
  • 5.
    =-2x + 12x- 20x + 8.5 3 2 dy dx y=-0.5x + 4x - 10x + 8.5x + C 4 3 2 NOW, what is the Anti-derivative of y=
  • 6.
    =-2x + 12x- 20x + 8.5 3 2 dy dx y=-0.5x + 4x - 10x + 8.5x + C 4 3 2 NOW, what is the Anti-derivative TROUBLE! Not uniquely defined because of unknown constant C
  • 7.
    But if weare given one point (0,1) (0,1) (0,1) We just need the Derivative and one Initial Point
  • 8.
    Initial Value Problems forODE Euler’s Method Runge-Kutta Methods Adaptive Step Size Control
  • 9.
    What is anODE? When the function involves one independent variable, the equation is called an ordinary differential equation (or ODE). y=dependent variable quantity being differentiated x= independent variable quantity with respect to which y is differentiated, dy dx
  • 10.
    =f(x,y) dy dx From the example,we have as a function having only x variables, but here we can deal with derivatives as a function of both x and y dy dx
  • 11.
    considered as thesimplest way of performing numerical solution to a 1st order ordinary differential equation (ODE). Although this method is not accurate nor efficient compared to the other methods, it is useful for understanding the numerical processes for ODE. Consider a differential equation written in the form: To solve for of the ODE given a step size, h, the formula is: Euler’s Method Let the initial condition of the differential equation be . New value = old value + step size x slope
  • 12.
    Use Euler’s methodto numerically integrate from x=0 to x=2 with a step size of 0.5. The initial condition at x=0 is y=1. a. Use analytical Method b. use Euler’s Method Example: Euler’s Method
  • 13.
    Substitute the valueof x from 0 to 2 Step a. Analytical Method The constant value C from Remember: Recall that the exact solution is given by: n y (true/analytical) 0 0 1 0.5 1 0.5 3.21875 1 2 1 3 1.5 3 1.5 2.21875 2 4 2 2 y=-0.5x + 4x - 10x + 8.5x + C 4 3 2 can be solved by substituting the initial values (0,1) 1=-0.5(0) + 4(0) - 10(0) + 8.5(0) + C 4 3 2 1=C y=-0.5(0.5) + 4(0.5) - 10(0.5) + 8.5(0.5) +1 =3.21875 4 3 2 y=-0.5(1) + 4(1) - 10(1) + 8.5(1) + 1 =3 4 3 2 y=-0.5(2) + 4(2) - 10(2) + 8.5(2) + 1 =2 4 3 2 y=-0.5(0) + 4(0) - 10(0) + 8.5(0) + 1 =1 4 3 2 y=-0.5(1.5) + 4(1.5) - 10(1.5) + 8.5(1.5) + 1 =2.21875 4 3 2
  • 14.
    Identify what are giventhe values Step 1 n y (true/ analytical) y ( Euler) 0 0 1 1 0.5 5.25 1 0.5 3.21875 5.25 1 5.87 5 2 1 3 5.875 1.5 3 1.5 2.21875 2 4 2 2 b. Euler’s Method y = y +h f(x , y ) 0+1 0 0 0 at n=0 initial condition (x , y ) =(0,1) h=0.5 0 0 y = 1 + (0.5)[-2(0) +12(0) -20(0) +8.5] =5.25 1 3 2 y = 5.25+ (0.5)[-2(0.5) +12(0.5) -20(0.5) +8.5] =5.875 2 3 2 at n=1 y = y +h f(x , y ) 1+1 1 1 1 y = y +h f(x , y ) n+1 n n n =f(x,y)= dy dx -2x +12x -20x +8.5 3 2 Evaluate at n=0 using the formula: Step 2 Repeat the process until y is obtained. Use previously solved values to the next iteration Step 3 4
  • 15.
    n x y (true/analytical) y ( Euler) 0 0 1 1 0.5 5.25 1 0.5 3.21875 5.25 1 5.875 2 1 3 5.875 1.5 5.125 3 1.5 2.21875 5.125 2 4.5 4 2 2 4.5 b. Euler’s Method y = y +h f(x , y ) 2+1 2 2 2 at n=2 y = 5.875+ (0.5)[-2(1) +12(1) -20(1) +8.5] =5.125 3 3 2 y = 5.125+ (0.5)[-2(1.5) +12(1.5) -20(0.5) +8.5] =4.5 4 3 2 at n=3 y = y +h f(x , y ) 3+1 3 3 3 Repeat the process until y is obtained. Use previously solved values to the next iteration Step 3 4
  • 16.
    Note that, althoughthe computation captures the general trend of the true solution, the error is considerable. Euler’s Method n x y (true/analytical) y ( Euler) Relative Error 0 0 1 1 (true- approximate) /true 1 0.5 3.21875 5.25 -63.1% 2 1 3 5.875 -95.8% 3 1.5 2.21875 5.125 -131% 4 2 2 4.5 -125%
  • 17.
    Runge-Kutta Methods an effectiveand widely used method for solving the initial- value problems of ODEs. can be used to construct high order accurate numerical method by functions' self without needing the high order derivatives of function. Depending on the number of intermediate iterations, RK methods can be in 2nd, 3rd, 4th, or higher orders New value = old value + slope x step size
  • 18.
    The constants cannotbe solved because there are only three equations relating them. Thus, some engineers assume the value of one constant then solve for the values of the other three using the equations. However, the most common variation of this method are: (1) Heun's Method (2) The Midpoint Method, and (3) Ralston's Method Note
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
    Ralston’s Method RK2 1.Solve for k 2.Solvefor k 3.Solve for new pair (x , y ) which is: 1 2 n+1 n+1 4. Repeat step 1 to 3 until the required value of x is reached.
  • 24.
    Example: Consider the differentialequation shown below: Solve for the value of y when x = 2 if (0, 1) is part of the equation. Use the Ralston's method and h = 0.25 (Note that from the analytical method, the true value is 2.403770) Ralston’s Method RK2
  • 25.
    Identify what are giventhe values Step 1 Ralston’s Method RK2 at n=0 initial condition (x , y ) =(0,1) h=0.25 0 0 =f(x,y)= dy dx Solve for k1 Step 2 Solve for k2 Step 3 Solve for new pair (x , y ) Step 4 n+1 n+1 n 0 0 1 1 0.699983 0.25 1.199997 1 2 3 4
  • 26.
    Identify what are giventhe values Step 1 Ralston’s Method RK2 at n=1 initial condition (x , y ) =(0,1) h=0.25 0 0 =f(x,y)= dy dx Solve for k1 Step 2 Solve for k2 Step 3 Solve for new pair (x , y ) Step 4 n+1 n+1 n 0 0 1 1 0.699983 0.25 1.199997 1 0.25 1.99997 0.653356 0.509512 0.5 1.229362 2 3 4
  • 27.
  • 28.
  • 29.
    Runge- Kutta Method RK3 1.Solve for 2.Solve for 3.Solvefor 4.Solve for new pair (x , y ) which is: n+1 n+1 5. Repeat step 1 to 4 until the required value of x is reached.
  • 30.
    Example: Consider the differentialequation shown below: Solve for the value of y when x = 2 if (0, 1) is part of the equation. Use the classical RK3 method and h = 0.25 (Note that from the analytical method, the true value is 2.403770) Runge- Kutta Method RK3
  • 31.
    Identify what are giventhe values Step 1 Runge-Kutta Method RK3 at n=0 initial condition (x , y ) =(0,1) h=0.25 0 0 =f(x,y)= dy dx Solve for k1 Step 2 Step 5 n+1 n+1 Solve for new pair (x , y ) n 0 0 1 1 0.785021 0.686230 0.25 1.201096 1 2 Solve for k2 Step 3 Solve for k3 Step 4
  • 32.
    Identify what are giventhe values Step 1 Runge-Kutta Method RK3 at n=1 initial condition (x , y ) =(0,1) h=0.25 0 0 =f(x,y)= dy dx Solve for k1 Step 2 Step 5 n+1 n+1 Solve for new pair (x , y ) n 0 0 1 1 0.785021 0.686230 0.25 1.201096 1 0.25 1.201096 0.652758 0.549619 0.494182 0.5 1.340488 2 Solve for k2 Step 3 Solve for k3 Step 4 =1.340488
  • 33.
  • 34.
  • 35.
    Runge- Kutta Method RK4 1.Solve for 2.Solvefor 3.Solve for 4.Solve for 5.Solve for new pair (x , y ) which is: n+1 n+1 6. Repeat step 1 to 5 until the required value of x is reached.
  • 36.
    Example: Consider the differentialequation shown below: Solve for the value of y when x = 2 if (0, 1) is part of the equation. Use the classical RK4 method and h = 0.25 (Note that from the analytical method, the true value is 2.403770) Runge- Kutta Method RK3
  • 37.
    Identify what are giventhe values Step 1 Runge-Kutta Method RK4 at n=0 initial condition (x , y ) =(0,1) h=0.25 0 0 =f(x,y)= dy dx Solve for k1 Step 2 n 0 0 1 1 0.785021 0.80423 0.652779 0.25 1.201303 1 2 Solve for k2 Step 3 Solve for k3 Step 4 Solve for k4 Step 5
  • 38.
    Runge-Kutta Method RK4 Step6 n+1 n+1 Solve for new pair (x , y ) n 0 0 1 1 0.785021 0.80423 0.652779 0.25 1.201303 1 2
  • 39.
    Identify what are giventhe values Step 1 Runge-Kutta Method RK4 at n=1 initial condition (x , y ) =(0,1) h=0.25 0 0 =f(x,y)= dy dx Solve for k1 Step 2 Solve for k2 Step 3 Solve for k3 Step 4 Solve for k4 Step 5 n 0 0 1 1 0.785021 0.80423 0.652779 0.25 1.201303 1 0.25 1.201303 0.65264 6 0.549536 0.55511 0.484091 0.50 1.340721 2
  • 40.
    Runge-Kutta Method RK4 Step6 n+1 n+1 Solve for new pair (x , y ) n 0 0 1 1 0.785021 0.80423 0.652779 0.25 1.201303 1 0.25 1.201303 0.652646 0.549536 0.55511 0.484091 0.50 1.340721 2
  • 41.
  • 42.
    SUMMARIZE THE TRUEVALUE TO OTHER METHODS IN A TABLE
  • 43.
    References Chapra, S. C.,& Canale, R. P. (2015). Numerical methods for engineers (7th ed.). McGraw-Hill Education. SPTechLab. (2020, July 17). Numerical methods lecture 1 [Video]. YouTube. https://www.youtube.com/watch?v=XtP6UCT779Y&list=PLTfoKpIjBb wXCxPt-posI6FyoIWpShhyg&index=5
  • 44.
    Resource Page Use theseicons and illustrations in your Canva Presentation. Happy designing! Don’t forget to delete this page before presenting.
  • 45.
    Try this backgroundfor online class. *Please delete this section before downloading.
  • 46.
    Press these keys whileon Present mode! for a blur B for confetti C for a drumroll D for mic drop M for bubbles O for quiet Q for unveil U for a timer Any number from 0-9

Editor's Notes

  • #5 Antiderivative: Refers specifically to the function whose derivative is a given function, plus a constant of integration. Integral: Can refer to either the process of finding an antiderivative (indefinite integral) or calculating the area under a curve (definite integral). The integral has broader applications, particularly in definite integrals.
  • #7 Here comes the initial value problem for ODE in Numerical methods
  • #11 The solution mwthod is based on the principle of calculation of approximate solution by constant increment. I,e. step size=h
  • #19 values for al, a2, p1, and q11 are evaluated by setting y(n+1) of RK2 format equal to a Taylor series expansion to the second-order term. By doing this, we derive three equations to evaluate the four unknown constants.