Professional Documents
Culture Documents
COMPUTATION
KKKK3522
jarinah@ukm.edu.my
INITIAL VALUE PROBLEM
OBJECTIVES
1) Knowing how to implement the Runge-Kutta (RK)
methods for a single ODE:
• Euler
• Heun
• Fourth-Order RK
2) Knowing how to implement the Runge-Kutta
methods for systems of ODEs:
• Euler
• Fourth-order RK
1. Interval (1 = 2 to 1 = 3)
2. Step size of h= 2. 4.
3. Initial condition of (1 = 2 , 6 = 7)
Step 4:
Find the error, -. and percentage of error, /.
Step 5:
Repeat the calculation with new step size until obtain the solution
or within the interval
28/11/2019 KKKK3522 Chemical Engineering Computation 6
EULER METHOD (EXCEL)
substitute to substitute to !t
equation formula
x ytrue f(xi,yi) f(xi,yi)*h yeuler Et Et(%)
i 0.0000 1.0000 8.5000 4.2500 1.0000 0.00 0.00
+1 0.5000 3.2188 1.2500 0.6250 5.2500 -2.03 -63.11
1.0000 3.0000 -1.5000 -0.7500 5.8750 -2.88 -95.83
1.5000 2.2188 -1.2500 -0.6250 5.1250 -2.91 -130.99
2.0000 2.0000 0.5000 0.2500 4.5000 -2.50 -125.00
2.5000 2.7188 2.2500 1.1250 4.7500 -2.03 -74.71
3.0000 4.0000 2.5000 1.2500 5.8750 -1.88 -46.88
3.5000 4.7188 -0.2500 -0.1250 7.1250 -2.41 -50.99
4.0000 3.0000 -7.5000 -3.7500 7.0000 -4.00 -133.33
f= @(x) (-0.5*x.^4)+(4*x.^3)-(10*x.^2)+(8.5*x)+1;
df = @(x) (-2*x.^3)+(12*x.^2)-(20*x)+8.5;
x = (xint:h:xend)';
ytrue = f(x);
sh = df(x)*h; % f(xi,yi)h (slope*h)
yeuler = yint;
for i= 2:xend*2
yeuler(i) =sh(i-1)+ yeuler(i-1);
end
!"#
Given the differential equation of !$
= 2 − 6)* . Find the
Submit by 06/12/2019
• Corrector equation
50 50(1 5 2
4 50 , /0 + 4(50(1 , /0(1 )
/0(1 = /0 + ℎ
2
%$ = ,(./ , 1/ )
%' = ,(./ + 3$ ℎ, 1/ + 5$$ %$ ℎ)
%6 = ,(./ + 3' ℎ, 1/ + 5'$ %$ ℎ + 5'' %' ℎ)
⋮
%) = ,(./ + 3)8$ ℎ, 1/ + 5)8$,$ %$ ℎ + 5)8$,' %' ℎ + ⋯ + 5)8$,)8$ %)8$ ℎ)
Where:
)$ = /(1" , !" )
1 1
)+ = /(1" + ℎ, !" + )$ℎ)
2 2
1 1
), = /(1" + ℎ, !" + )+ℎ)
2 2
)- = /(1" + ℎ, !" + ),ℎ) 1" 1"#$/+ 1"#$
Slope
x f(xi,yi) k ymid y(intervalend)
i 0.0000 3.0000 k1 3.0000 0.5000 4.2010 6.20
i+1 1.0000 k2 4.2173 3.5000
k3 3.9130 4.1086
k4 5.9457 5.9130