Clase 3 Calculo Numerico II - PGRA - 2024 - 1
Clase 3 Calculo Numerico II - PGRA - 2024 - 1
Clase 3 Calculo Numerico II - PGRA - 2024 - 1
IF-392
Semana 03
Dr. Pierre Giovanny Ramos Apestegui
They achieve the precision of the Taylor method without the need to calculate
high-order derivatives.
Taylor methods have the property of a higher-order local truncation error, but the
disadvantage of requiring the calculation and evaluation of the derivatives of f(t,y).
This is somewhat slow and complicated in most problems, which is why in
practice they are almost not used.
Euler's method unfortunately requires a very small step for reasonable accuracy.
Cálculo Numérico II-IF392
Higher-Order Runge-Kutta
Higher order Runge-Kutta methods are available.
Know as RK3
k1 = f ( xi , yi )
h 1
k2 = f ( xi + , yi + k1h )
2 2
k3 = f ( xi + h, yi − k1h + 2k2h )
yi +1 = yi + (k1 + 4k2 + k3 )
h
6
Local error is O ( h 4 ) and Global error is O ( h 3 )
Each of the ks represents a slope. The result is a weighted average of those slopes.
Also known as the classical Runge-Kutta method, abbreviated as RK4, with local
truncation error O(h5), and global error O(h4). The price to pay for the
improvement in the error is a greater number of evaluations of the function,
resulting in greater calculation time if the function is complicated. The advantage,
over the Taylor method of order 4 (whose global error is also O(h4), is that it does
not require the calculation of the derivatives of f.
Cálculo Numérico II-IF392
4th Order Runge-Kutta RK4
k1 = f ( xi , yi )
h 1
k2 = f ( xi + , yi + k1h )
2 2
h 1
k3 = f ( xi + , yi + k2h )
2 2
k4 = f ( xi + h, yi + k3h )
dy ( x)
Given = f ( y, x), y (a) = ya
dx
Euler Method :
y (a + h) = y (a) + h f ( y (a), a)
y (a + 2h) = y (a + h) + h f ( y (a + h), a + h)
y (a + 3h) = y (a + 2h) + h f ( y (a + 2h), a + 2h)
Y (a + h) = Y (a ) + h F (Y (a ), a )
Y (a + 2h) = Y (a + h) + h F (Y (a + h), a + h)
Y (a + 3h) = Y (a + 2h) + h F (Y (a + 2h), a + 2h)
Cálculo Numérico II-IF392
Example :
Euler method for solving a system of first order ODEs.
𝑦ሶ1 (𝑥) 𝑦2 𝑦1 (0) −1
= 1 − 𝑦 = 𝐹 𝑌, 𝑥 , 𝑌(0) = =
𝑦ሶ 2 (𝑥) 1 𝑦2 (0) 1
𝑦2 0 + 0.1(1 − 𝑦1 0 ) 0.12
𝐾2 = ℎ𝐹 𝑌 0 + 𝐾1,0 + ℎ = 0.1 =
1 − 𝑦1 0 + 0.1𝑦2 0 0.19
𝑌 0 + ℎ = 𝑌 0 + 0.5 𝐾1 + 𝐾2
𝑦1 (0.1) −1 1 0.1 0.12 −0.89
= + + =
𝑦2 (0.1) 1 2 0.2 0.19 1.195
𝑦ሶ 1 (𝑥) 𝑦2 𝑦 (0) −1
= 1 − 𝑦 = 𝐹(𝑌, 𝑥), 𝑌(0) = 1 =
𝑦ሶ 2 (𝑥) 1 𝑦2 (0) 1
𝑆𝑇𝐸𝑃 2:
𝑦2 (0.1) 0.1195
𝐾1 = ℎ𝐹(𝑌(0.1), 0.1) = 0.1 =
1 − 𝑦1 (0.1) 0.1890
ℎ 0 0.05 0.05
𝐾2 =? ? ? ? 𝑋 0 + = + =
2 0 0.05 0.05
𝐾1ℎ −1 1 −0.95
𝑌 0 + = + 0.05 =
2 1 2 1.1
𝑦2 (0.05) 1.1 𝟏. 𝟏
𝑲𝟐 = 𝐹 𝑌 0 + 𝑘1ℎ/2,0.05 = = =
1 − 𝑦1 (0.05) 1 − (−0.95) 𝟏. 𝟗𝟓
−1 1.0975 −0.89025
𝑌 0 + ℎ𝐾3 = + 0.1 =
1 1.945 1.1945
−𝟎. 𝟖𝟗𝟎𝟏𝟕𝟓
𝒀 𝟎. 𝟏 =
𝟏. 𝟏𝟗𝟒𝟔𝟕𝟏
x + 3 x + 6 x = 1
• How do solve high order ODEs?
z1 z2
z = 1 − 3 z − 6 z ,
x + 3x + 6 x = 1 Convert
2 2 1
Solve
x (0) = 1; x(0) = 4 4
Z ( 0) =
1
Second order ODE Two first order ODEs
z1 z2 4
z = 1 − 3 z − 6 z , Z (0) = 1
2 2 1
Cálculo Numérico II-IF392
Example of Converting a High Order
ODE to First Order ODEs
Convert
x + 2 x + 7 x + 8 x = 0
x(0) = 9, x (0) = 1; x(0) = 4
Using Euler’s method for systems, with step size h = 0.1, find an estimate for y2 = y(0.2).
Solution:
x + 2 x + 8 x = 2
x(0) = 1; x (0) = −2
Select a new set of variables : z1 = x, z 2 = x
The second order equation is expressed as :
1
z z 1
Z = F (Z ) = = 2
, Z ( 0) =
z2 2 − 2 z 2 − 8 z1 − 2
Cálculo Numérico II-IF392
Solution of a Second Order ODE
z2 1
F (Z ) = , Z (0) = , h = 0.1
2 − 2 z 2 − 8 z1 − 2
Z (0 + 0.1) = Z (0) + hF ( Z (0))
1 −2 0.8
= + 0.1 =
− 2 2 − 2(−2) − 8(1) − 2.2
Z (0.2) = Z (0.1) + hF ( Z (0.1))
0.8 − 2.2 0.58
= + 0.1 =
− 2 .2 2 − 2( −2 . 2) − 8( 0.8) − 2 . 2
Cálculo Numérico II-IF392
Summary
• Formulas used in solving a first order ODE are used
to solve systems of first order ODEs.
• Instead of scalar variables and functions, we have vector
variables and vector functions.