You are on page 1of 3

Numerical Methods – Final work-sheet

Numerical derivatives
Forward finite difference
𝑓(𝑥 + ∆𝑥) − 𝑓(𝑥)
𝛿 (𝑥) =
∆𝑥
Backward finite difference
𝑓(𝑥) − 𝑓(𝑥 − ∆𝑥)
𝛿 (𝑥) =
∆𝑥
Centered finite difference
𝑓(𝑥 + ∆𝑥) − 𝑓(𝑥 − ∆𝑥)
𝛿(𝑥) =
2∆𝑥

Numerical Integration
Left endpoint approximation

𝑓(𝑥)𝑑𝑥 ≈ 𝑓(𝑥 )∆𝑥

Right endpoint approximation

𝑓(𝑥)𝑑𝑥 ≈ 𝑓(𝑥 )∆𝑥

Midpoint approximation
𝑥 +𝑥
𝑓(𝑥)𝑑𝑥 ≈ 𝑓 ∆𝑥
2
The Trapezoidal Rule

∆𝑥
𝑓(𝑥)𝑑𝑥 = (𝑓(𝑥 ) + 2 𝑓(𝑥 ) + 𝑓(𝑥 ))
2

Simpson 1/3 Rule


∆𝑥
𝑓(𝑥)𝑑𝑥 = (𝑓(𝑥 ) + 4 𝑓(𝑥 ) + 2 𝑓(𝑥 ) + 𝑓(𝑥 ))
3

Simpson 3/8 Rule


3∆𝑥
𝑓(𝑥)𝑑𝑥 = (𝑓(𝑥 ) + 3 𝑓(𝑥 ) + 2 𝑓(𝑥 ) + 𝑓(𝑥 ))
8
Two-Point Gauss-Legendre Formula
1 1
𝑓(𝑥)𝑑𝑥 = 𝑓 − +𝑓
√3 √3

Change of variable: 𝑥= − 𝑡

Differential Equations
Euler Method
𝑦 = 𝑦 + 𝑓(𝑥 , 𝑦 )ℎ

Heun’ Method
𝑦 = 𝑦 + 𝑓(𝑥 , 𝑦 )ℎ

𝑦 = 𝑦 + (𝑓(𝑥 , 𝑦 ) + 𝑓(𝑥 ,𝑦 ))
2
Midpoint method
𝑦 = 𝑦 + 𝑓(𝑥 , 𝑦 )ℎ

ℎ 𝑥 +𝑥
𝑦 = 𝑦 + 𝑓( ,𝑦 )
2 2

Second order Runge-Kutta Methods


𝑦 = 𝑦 + (𝑎 𝑘 + 𝑎 𝑘 ) ∙ ∆t
𝑘 = 𝑓(𝑡 , 𝑦 )
𝑘 = 𝑓(𝑡 + 𝑝 ℎ, 𝑦 + 𝑞 𝑘 ℎ)
The coefficients satisfy the following relations:

𝑎 =1−𝑎
1
𝑝 =𝑞 =
2𝑎

Fourth-Order Runge-Kutta Method


1
yi 1  yi  k1  2k 2  2k3  k 4 h
6
k1  f ti , yi 
 1 1 
k 2  f  ti  h, yi  k1h 
 2 2 
 1 1 
k3  f  ti  h, yi  k 2 h 
 2 2 
k 4  f ti  h, yi  k3 h 
Systems of ODEs
= 𝑓(𝑡, 𝑥, 𝑦) 𝑥(𝑡 ) = 𝑥
with
= 𝑔(𝑡, 𝑥, 𝑦) 𝑦(𝑡 ) = 𝑦

 Euler method
 Heun’s method
 Midpoint method
 Second order Runge Kutta method

Higher order ODEs


𝑑 𝑦 𝑑𝑦 𝑑 𝑦 𝑑 𝑦
= 𝑓 𝑡, 𝑦, , , ⋯,
𝑑𝑡 𝑑𝑡 𝑑𝑡 𝑑𝑡

𝑑𝑦
⎧ =𝑦
⎪ 𝑑𝑡
⎪ 𝑑𝑦
=𝑦
𝑑𝑡
⎨ ⋮

⎪𝑑𝑦
)
⎩ 𝑑𝑡 = 𝑓(𝑡, 𝑦, 𝑦 , 𝑦 , ⋯ , 𝑦
 Euler method
 Heun’s method
 Midpoint method
 Second order Runge Kutta method

Boundary-Value Problems
General formulation of second order BVPs: = 𝑓 𝑡, 𝑦, , 𝑡 ∈ [𝑎, 𝑏]

𝑦(𝑎) = 𝑦
Boundary conditions:
𝑦(𝑏) = 𝑦
𝑑𝑦 𝑦 −𝑦
=
𝑑𝑡 2∆𝑡
𝑑 𝑦 𝑦 − 2𝑦 + 𝑦
=
𝑑𝑡 ∆𝑡

You might also like