Pemodelan dan Metode Numerik
(Modeling and Numerical Methods)
http://www.unhas.ac.id/amil/S2TE/pmn2016/
L #5 ORDINARY DIFFERENTIAL EQUATIONS
Amil Ahmad Ilham
ODE
(ORDINARY DIFFERENTIAL EQUATIONS)
Examples of fundamental laws that are written in ODE
(t = time and x = position)
Runge-Kutta Methods
Solving ODEs of the form
First-Order Runge-Kutta Methods
(Eulers method)
Use Eulers method to numerically integrate
from x = 0 to x = 4 with a step size of 0.5. The initial condition at x = 0 is y = 1.
y(0) = 1
y(0.5) = y(0) + f(0, 1)0.5
f(0, 1) = 2(0)3 + 12(0)2 20(0) + 8.5 = 8.5
y(0.5) = 1.0 + 8.5(0.5) = 5.25
y(1) = y(0.5) + f(0.5, 5.25)0.5
f(0.5, 5.25) = 2(0.5)3 + 12(0.5)2 20(0.5) + 8.5 = 1.25
y(1) = 5.25 + 1.25(0.5) = 5.875
First-Order Runge-Kutta Methods
(Eulers method)
Use Eulers method to numerically integrate
from x = 0 to x = 4 with a step size of 0.5. The initial condition at x = 0 is y = 1.
Second-Order Runge-Kutta Methods (The
Midpoint Method)
Use the midpoint method to numerically integrate
from x = 0 to x = 4 with a step size of 0.5. The initial condition at x = 0 is y = 1.
y(0) = 1
y(0.5) = ?
k1 = f(0,1)
k1 = 2(0)3 + 12(0)2 20(0) + 8.5 = 8.5
k2 = 2(0.25)3 + 12(0.25)2 20(0.25) + 8.5 = 4.21875
y(0.5) = 1 + 4.21875(0.5) = 3.109375
y(1) = ?
k1 = f(0.5,3.1)
Second-Order Runge-Kutta Methods (The
Midpoint Method)
Use the midpoint method to numerically integrate
from x = 0 to x = 4 with a step size of 0.5. The initial condition at x = 0 is y = 1.
Third-Order Runge-Kutta Methods
Fourth-Order Runge-Kutta Methods
The most popular RK methods are fourth order
(classical fourth-order RK method)
Use the classical fourth-order RK to
numerically integrate
from x = 0 to x = 4 with a step size of 0.5.
The initial condition at x = 0 is y = 1.
k1 = 8.5, k2 = 4.21875, k3 = 4.21875, k4 = 1.25
10
Group assignment
Group Assignment
11
Group Assignment #3
1. Solve manually the following problem over the interval from x =
0 to 1 using a step size of 0.25 where y(0) = 1.
(a) Use Eulers method
(b) Fourth-order RK method
2. Develop a user-friendly computer program to solve problem
No. 1.
12
Group Assignment #3
Work in pairs (1 group = 2 members)
Print out the result, screenshot, and source code for no. 2.
For the source code, print only part of the source code where the calculation
is performed.
Prepare for demo!
13