Lecture Module 8 Presentation
Lecture Module 8 Presentation
ENGINEERING MATHEMATICS 4
k c k c
F (t)
x (t) m x (t) m
Equation of motion:
2 2
d x dx d x dx
m 2 + c + k x=0 m 2 + c + k x= F
dt dt dt dt
dv dv
or m + c v+ k x=0 or m + c v+ k x= F
dt dt
BDA34003 Engineering Mathematics IV 4
Waluyo Adi Siswanto ([email protected])
Ordinary Differential Equation
in Engineering
Taylor series can be used to find the variable after initial value:
2 3
h h
y ( x i+ 1 )= y( x i )+ h y ' ( x i )+ y ' ' ( xi )+ y ' ' ' ( x i ) + ...
2! 3!
2
h
y ( x i+ 1 )= y( x i )+ h y ' ( x i )+ y ' ' ( xi) Taylor's method
2
Taylor series can be used to find the variable after initial value:
2 3
h h
v(t i+ 1 )=v (t i )+ h v ' (t i )+ v ' ' (t i )+ v ' ' ' (t i ) + ...
2! 3!
2
h
v(t i+ 1 )=v (t i )+ h v ' (t i )+ v ' ' (t i ) Taylor's method
2
When you are dealing with velocity
this does not exist (not applicable).
The highest order is v' , which is acceleration.
function [x,y]=Euler(func,a,b,y0,h)
% Solving y'=f(x,y) with initial condition y(0)=y0
% func = handle of function.
% for example --> func= @(x,y) (x+y)
% a = lowest of x
% b = highest of x
% h = incremental x
format long;
n = (b-a)/h ;
x =(a+h:h:b);
y(1) = y0 + h*feval(func,a,y0);
for i =2:n
y(i)=y(i-1)+h*feval(func,x(i-1),y(i-1));
end
x = [a x].';
y = [y0 y].';
2x 2x
2y ' + 3y=e e −3y
y '=
2
step x y h y'
initial 0 0 1 −0.2
1 0.2 0.8000 −0.0908
2 0.4 0.7092 0.0098
3 0.6 0.7190 0.1163
4 0.8 0.8353 0.2447
5 1 1.0800
3x
1 2x 6 − 2
Compare the result with the exact solution y ( x)= e + e
7 7
Use the Taylor function in freemat to double check your calculation table
2
step x y h y' (h /2) y ' ' exact
Euler y ( x i+ 1 )= y( x i )+ h y ' ( x i )
k 1 =h f ( x i , y i )
h k1
k 2=h f ( x i + , yi+ )
2 2
3x
1 2x 6 − 2
Compare the result with the exact solution y ( x)= e + e
7 7
k 1 =h f ( x i , y i ) k 1 =h (
e 2x −3y
2 )
h k1
k 2=h f ( x i + , y i + )
2 2
( ( )
)
e 2x −3y
(h )
2
e 2(x+ (h /2))−3( y+ )
k 2=h
2
2
k 2=
2 (
e
[ (
h 2( x+ (h /2))
−3 y+
h 2x
4 )])
( e −3y )
y i+ 1= y i+ k 2
0 0 1 −0.2 −0.1479
1 0.2 0.8521 −0.1064 −0.0575
2 0.4 0.7946 −0.0158 0.0358
3 0.6 0.8304 0.0829 0.144
4 0.8 0.9744 0.203 0.2822
5 1 1.2566 1.2468
Heun's method
f ( x i , y i )= y ' (x i )
1 3
y i+ 1= y i+ k 1+ k 2
4 4
k 1 =h f ( x i , y i )
2h 2k 1
k 2=h f ( x i + , yi + )
3 3
1 1
y i+ 1= y i+ k 1+ k 2
2 2
k 1 =h f ( x i , y i )
k 2=h f ( x i + h , y i + k 1 )
3x
1 2x 6 − 2
Compare the result with the exact solution y ( x)= e + e
7 7
k 1 =h f ( x i , y i ) k 1 =h (
e 2x −3y
2 )
2h 2k 1
k 2=h f ( x i + , yi+ )
3 3
( ( )
)
e 2x −3y
(2h )
2
e 2(x+ (2h /3))−3( y+ )
k 2=h
2
3
k 2=
2 (
h 2( x+ (2h /3))
e
[ ( h
)])
−3 y+ ( e 2x −3y )
3
1 3
y i + 1= y i+ k 1+ k 2
4 4
0 0 1 −0.2 −0.1294
1 0.2 0.8529 −0.1067 −0.0398
2 0.4 0.7964 −0.0164 0.0549
3 0.6 0.8335 0.082 0.167
4 0.8 0.9793 0.2015 0.3126
5 1 1.2641 1.2468
3x
1 2x 6 − 2
Compare the result with the exact solution y ( x)= e + e
7 7
k 1 =h f ( x i , y i ) k 1 =h (
e 2x −3y
2 )
k 2=h f ( x i + h , y i + k 1 )
( ( ) )
2x
2( x+ ¿ h) e −3y
e −3( y+ h )
k 2=h
2
2
k 2=
2(
h 2(x+ h)
e
[ (
h
)])
−3 y+ ( e 2x −3y )
2
1 1
y i+ 1= y i+ k 1+ k 2
2 2
0 0 1 −0.2 −0.0908
1 0.2 0.8546 −0.1072 −0.0017
2 0.4 0.8002 −0.0175 0.0972
3 0.6 0.84 0.08 0.2193
4 0.8 0.9897 0.1984 0.3825
5 1 1.2801 1.2468
k 1 =h f ( x i , y i )
h k1
k 2=h f ( x i + , y i + )
2 2
h k2
k 3 =h f ( x i + , y i+ )
2 2
k 4 =h f ( xi + h , y i + k 3 )
1 2 1
y i+ 1= y i+ k 1+ k 4+ k 5
6 3 6
k 1 =h f ( x i , y i )
1 1
k 2=h f ( x i + h , y i+ k 1 )
3 3
1 1 1
k 3 =h f ( x i + h , y i + k 1+ k 2)
3 6 6
1 1 3
k 4 =h f ( xi + h , yi + k 1+ k 3 )
2 8 8
1 3
k 5 =h f ( x i + h , yi + k 1− k 3+ 2 k 4 )
2 2
3x
1 2x 6 − 2
Compare the result with the exact solution y ( x)= e + e
7 7
k 1 =h f ( x i , y i ) k 1 =h (
e 2x −3y
2 )
h k1
k 2=h f ( x i + , y i + )
2 2
h k2
k 3 =h f ( x i + , y i+ )
2 2
k 4 =h f ( xi + h , y i + k 3 )
1
y i+ 1= y i+ (k 1 + 2 k 2+ 2 k 3+ k4)
6
3x
1 2x 6 − 2
Compare the result with the exact solution y ( x)= e + e
7 7
k 1 =h f ( x i , y i )
1 1
k 2=h f ( x i + h , y i+ k 1 )
3 3
1 1 1
k 3 =h f ( x i + h , yi + k 1+ k 2)
3 6 6
1 1 3
k 4 =h f ( xi + h , yi + k 1+ k 3 )
2 8 8
1 3
k 5 =h f ( x i + h , yi + k 1− k 3+ 2 k 4 )
2 2
1 2 1
y i+ 1= y i+ k 1+ k 4+ k 5
6 3 6
P h
Second order Adams predictor-corrector: y i+ 1= y i+ (3 f i − f i−1 )
2
(two initial values required)
C h P
y i+ 1= y i+ ( f + f i)
2 i+ 1
P h
Third order Adams predictor-corrector: y i+ 1= y i+ (23 f i −16 f i−1 + 5 f i−2 )
12
(three initial values required)
C h P
y i+ 1= y i+ (5 f i+ 1+ 8 f i − f i−1 )
12
P h
Fourth order Adams predictor-corrector: y i+ 1= y i+ (55 f i−59 f i−1 + 37 f i−2−9 f i−3 )
24
(four initial values required)
C h P
y i+ 1= y i+ (9 f i+ 1 + 19 f i −5 f i−1 + f i −2 )
24
3x
1 2x 6 − 2
Compare the result with the exact solution y ( x)= e + e
7 7
k 1 =h f ( x i , y i ) k 1 =h (
e 2x −3y
2 )
h k1 h k2
k 2=h f ( x i + , y i + ) k 3 =h f ( x i + , y i+ )
2 2 2 2
1
k 4 =h f ( xi + h , y i + k 3 ) y i+ 1= y i+ (k + 2 k 2+ 2 k 3+ k4)
6 1
After 3 data, then use
P h
y i+ 1= y i+ (23 f i −16 f i−1 + 5 f i−2 )
12
C h P
y i+ 1= y i+ (5 f i+ 1+ 8 f i − f i−1 )
12
y
C
0.9678 1.0248
P
1 y 1.2417 1.8320
C
1.2500 1.2468
y
x
y'=
y
Solve the ODE above, from 0 to 1 , every 0.2
by using the third order Adams method
(Use RK4 to provide necessary data to start Adams method)
y
C
1.2806 0.6247
P
1 y 1.4138 0.7073
y
C
1.4143
y i+ 1 − 2 y i + yi−1
yi ' ' =
h2
Boundary conditions:
a. Without differentiation
b. With differentiation
y (2)=15
[ ]{ } { }
−1.88 0.88 0 0 y1 −1.152
1.14 −1.88 0.86 0 y 2 = 0.616
0 1.16 −1.88 0.84 y3 0.704
0 0 1.18 −1.88 y4 −11.508
x 1 =1.2 y 1 =2.845
x 2 =1.4 y 2=2.7688
x 3 =1.6 y 3 =7.3698
x 4=1.8 y 4 =10.747
3 4
A system follows a governing equation of y ' ' + xy= x − 3
along the x span from 1 to 2 x
The system is disturbed at the BC: y ' (1)=4 y ' (2)− y (2)=1.5
h=0.2
y 1− y−1 y 6− y 4
=4 − y 5 =1.5
2h 2h
i=1 0.16 3
y i+ 1 − 2 yi + y i−1 + 0.04 x i y i=0.04 x i −
3
xi
3 3
y 2 − 2 y 1 + y 0 + 0.04(1.2) y 1 =0.04(1.2 )−0.16/(1.2 )
y 0−1.952 y 1+ y 2 =−0.0235
i=2 0.16 3
y i+ 1 − 2 yi + y i−1 + 0.04 x i y i=0.04 x i −
3
xi
3 3
y 3 − 2 y 2 + y 1+ 0.04(1.4) y 2=0.04(1.4 )−0.16 /(1.4 )
y 1 −1.944 y 2 + y 3 =0.0515
2 y 4 −1.52 y 5=−0.3