Академический Документы
Профессиональный Документы
Культура Документы
Transforming lives by CSU is committed to transform the lives Productivity Compassion Competent
of people and communities through high Accessibility Accountability
quality instruction and innovative Relevance
Self-disciplined
Excellence
research, development, production and
COLLEGE OF ENGINEERING
(ChE 56)
1
Name of Students: ABAYA, MARIA HAZEL M.
ANDRADA, FILMAR T.
2
NUMERICAL APPROXIMATION METHODS FOR THE SOLUTIONS OF
ORDINARY DIFFERENTIAL EQUATION USING MATLAB®
Table of Contents
I. Introduction……………………...……………………………………………..………….1
II. Theoretical Background………………………………………………………..………….2
Discussion of methods
3
I. Introduction
4
II. Theoretical Background
𝑑𝑦
= 𝑓( 𝑡, 𝑦) (1)
𝑑𝑡
where the slope φ is called an increment function and according to this equation, the slope
estimate of φ is used to extrapolate from an old value yi to a new value yi+1 over a distance h.
One-step methods are expressed in this general form, with only the manner in which the
slope is estimated being the difference. These one-step methods are discussed,
A. EULER’S METHOD
The simplest approach to solving ordinary differential equations is to use the differential
equation to estimate the slope in the form of the first derivative at ti. The slope at the
beginning of the interval is taken as an approximation of the average slope over the whole
interval. This approach of obtaining an approximation to a solution curve is attributed to the
mathematician Euler. This approach is called the Euler’s method.
y
Predict
True
}
h
𝑡𝑖 𝑡𝑖+1
5
Figure 1: Euler’s Method
In Euler’s method, the first derivative provides a direct estimate of the slope at ti ,
𝜑 = 𝑓(𝑡𝑖 , 𝑦𝑖 ) (3)
where f (ti, yi) is the differential equation evaluated at ti and yi. This estimate can be
substituted into Equation 1.2:
𝑦𝑖+1 = 𝑦𝑖 + 𝑓(𝑡𝑖 , 𝑦𝑖 )ℎ (4)
This formula is referred to as the Euler’s method (or the Euler-Cauchy or point-slope
method). A new value of y is predicted using the slope (equal to the first derivative at the
original value of t) to extrapolate linearly over the step size h (Figure 1.1).
B. HEUN’S METHOD
A fundamental source of error in Euler’s method is that the derivative at the beginning of
the interval is assumed to apply across the entire interval. Two simple modifications are
available to help circumvent this shortcoming. One modification, being the Heun’s method, is
first discussed.
One method to improve the estimate of the slope involves the determination of two
derivatives for the interval—one at the beginning and another at the end. The two derivatives
are then averaged to obtain an improved estimate of the slope for the entire interval. This
approach is called the Heun’s method and is depicted graphically in Fig. 1.2.
𝑡𝑖 𝑡𝑖+1 t
Figure 2: Graphical depiction of Heun’s method. (a) Predictor and (b) corrector
6
Recall that in Euler’s method, the slope at the beginning of an interval
0
𝑦𝑖+1 = 𝑦𝑖 + 𝑓(𝑡𝑖 , 𝑦𝑖 )ℎ (6)
For the standard Euler method we would stop at this point. However, in Heun’s method
0
the 𝑦𝑖+1 calculated in Equation1.6 is not the final answer, but an intermediate prediction.
Equation 1.6 is called a predictor equation. It provides an estimate that allows the calculation
of a slope at the end of the interval:
′ 0
𝑦𝑖+1 = 𝑓(𝑡𝑖+1 , 𝑦𝑖+1 ) (7)
Thus, the two slopes Equations 1.5 and 1.7 can be combined to obtain an average slope
for the interval:
This average slope is then used to extrapolate linearly from yi to yi+1 using Euler’s method:
C. MIDPOINT METHOD
7
(a) Predictor and (b) corrector
Another simple modification of Euler’s method is called the midpoint method. This
technique uses Euler’s method to predict a value of y at the midpoint of the interval (Figure
3):
h
yi 1/ 2 yi f (ti , yi )
2 (10)
Then, this predicted value is used to calculate a slope at the midpoint:
yi' 1/ 2 f (ti 1/ 2 , yi 1/ 2 )
(11)
which is assumed to represent a valid approximation of the average slope for the entire
interval. This slope is then used to extrapolate linearly from t i to t i 1 (Figure 3b):
RUNGE-KUTTA METHODS
Runge-Kutta methods achieve the accuracy of a Taylor series approach without requiring
the calculation of higher derivatives. Many variations exist but all can be cast in the
generalized form of Equation 2:
𝑦𝑖+1 = 𝑦𝑖 + φh
a1 k1 a 2 k 2 ... a n k n
(13)
k1 f (ti , yi )
(14)
k 2 f (t i p1h, yi q11k1h)
(15)
8
k3 f (ti p2 h, yi q21k1h q22k2 h)
(16)
...
k n f (ti pn1 , yi qn1 ,1 k1h qn1, 2 k 2 h ... qn1 , n1 k n1h) (17)
The p’s and q’s are constants. The k’s are recurrence relationships. That is, k1 appears in
the equation for k2, which appears in the equation for k3, and so forth. Because each k is a
functional evaluation, this recurrence makes RK methods efficient for computer calculations.
Various types of Runge-Kutta methods can be devised by employing different numbers of
terms in the increment function as specified by n. The number of terms n usually represents
the order of the approach.
9
1
p1 q11
2 a2 (25)
Because we can choose an infinite number of values for a2, there are an infinite number of
second-order RK methods. Every version would yield exactly the same results if the solution
to the ODE were quadratic, linear, or a constant. However, they yield different results when
(as is typically the case) the solution is more complicated. Three of the most commonly used
1 1
yi 1 yi k1 k 2 h (26)
2 2
Where
k1 f (ti , yi ) (27)
Note that k1 is the slope at the beginning of the interval and k2 is the slope at the end of
10
iii. Ralston’s Method (a2 = 2/3)
Ralston (1962) and Ralston and Rabinowitz (1978) determined that choosing a2=2/3
provides a minimum bound on the truncation error for the second-order RK algorithms. For
this version, a1 =1/3 and p1 =q11 =3/4, and Eq. (18) becomes
1 2
yi 1 yi k1 k2 h (32)
3 3
Where
k1 f (ti , yi ) (33)
3 3
k 2 f ti h, yi k1h (34)
4 4
The fourth-order RK method is similar to the Heun approach in that multiple estimates of
the slope are developed to come up with an improved average slope for the interval. As
11
depicted in Figure 1.4, each of the k’s represents a slope. Equation (35) then represents a
weighted average of these to arrive at the improved slope.
12
III. Numerical analysis:
General algorithm for Euler’s method
1. Start
2. Define the function.
3. Declare the variables (dydt, t,y).
4. State initial conditions (t0, y0) , n, and step size(h).
5. Start loop. Check if i<n
If yes, continue to 6
If no proceed to 9
6. Calculate the value of y
7. Add a step
8. Return to 5
9. Display the results.
10. Plot (t,y).
11. End.
13
GENERAL FLOWCHART FOR EULER’S METHOD
Start
F(t, y)
t(1)=t0, y(1)=y0
steps size, h
i+1
Plot(t,y) print(t,y) i< n
No
Yes
END
yi+1 = yi + f (ti,yi)h
ti1 ti h
The program to solve the problem using MATLAB starts with the definition of function,
declaration of variables, and reading the required initial conditions. The next part is the loop
where the program checks if the function is executed as the number of times specified. If not,
he program will proceed in solving the equation given and find for the required outputs. This
14
process will continue until it satisfies the desired number of executions needed. In the last
part, the program will display the results with the graph.
% eulers method
ta(1)=t0 ;
ya(1)=y0 ;
for i=1:n
disp(sprintf('\nStep %g',i))
disp(sprintf('------------------------------------------------'))
15
% Adding Step Size
ta(i+1)=ta(i)+h ;
% Using eulers formula
ya(i+1)=ya(i)+ f(ta(i),ya(i))*h
disp(sprintf('\n\n***********************Results********************'))
16
General Algorithm for Heun’s method:
1. Start
2. Define the function.
3. Declare the variables (dydt, t,y).
4. State initial conditions (t0, y0) , n, and step size(h).
5. Start loop. Check if i<n
If yes, continue to 6
If no proceed to 9
6. Calculate y
7. Add a step
8. Return to 5
9. Display the results.
10. Plot (t,y).
11. End.
17
General Flowchart for Heun’s method
Start
F(t, y)
t(1)=t0, y(1)=y0
steps size, h
i+1
Plot(t,y) print(t,y) i< n
No
Yes
END
h
y i 1 y i ( k1 2 k 2 2 k 3 k 4 )
6
ti1 ti h
The program to solve the problem using MATLAB starts with the definition of function,
declaration of variables, and reading the required initial conditions. The next part is the loop
where the program checks if the function is executed as the number of times specified. If not,
he program will proceed in solving the equation given and find for the required outputs. This
process will continue until it satisfies the desired number of executions needed. In the last
part, the program will display the results with the graph.
18
Problem Code for the solution of ODE using Heun’s method:
% heuns method
ta(1)=t0 ;
ya(1)=y0 ;
for i=1:n
disp(sprintf('\nStep %g',i))
disp(sprintf('-------------------------------------------------'))
19
% Adding Step Size
ta(i+1)=ta(i)+h ;
disp(sprintf('\n\n*********************Results*************************'))
20
General Algorithm for midpoint method:
1. Start
2. Define the function.
3. Declare the variables (dydt, t,y).
4. State initial conditions (t0, y0) , n, and step size(h).
5. Start loop. Check if i<n
If yes, continue to 6
If no proceed to 10
6. Calculate the values of k1, and k2 using the initial values given.
7. Calculate the value of y using the values of k1, and k2 calculated.
8. Add a step
9. Return to 5
10. Display the results.
11. Plot (t,y).
12. End.
21
General Flowchart for Midpoint method
Start
F(t, y)
t(1)=t0, y(1)=y0
steps size, h
i+1
Plot(t,y) print(t,y) i< n
No
Yes
END
k1 f (ti , yi )
k2 f (ti h / 2, yi k1h / 2)
yi 1 yi k 2 h
ti 1 ti h
The program to solve the problem using MATLAB starts with the definition of function,
declaration of variables, and reading the required initial conditions. The next part is the loop
22
where the program checks if the function is executed as the number of times specified. If not,
he program will proceed in solving for the values of k depending on the order of the method
used then compute the required outputs. This process will continue until it satisfies the
desired number of executions needed. In the last part, the program will display the results
with the graph.
% midpoint
23
ta(1)=t0 ;
ya(1)=y0 ;
for i=1:n
disp(sprintf('\nStep %g',i))
disp(sprintf('------------------------------------------------'))
24
disp(sprintf('\n\n**********************Results*************************'))
General Algorithm for Ralston’s method:
1. Start
2. Define the function.
3. Declare the variables (dydt, t,y).
4. State initial conditions (t0, y0) , n, and step size(h).
5. Start loop. Check if i<n
If yes, continue to 6
If no proceed to 10
6. Calculate the values of k1,and k2 using the initial values given.
7. Calculate the value of y using the values of k1, k2 calculated.
8. Add a step
9. Return to 5
10. Display the results.
11. Plot (t,y).
12. End.
25
General Flowchart for Ralston’s method
Start
F(t, y)
t(1)=t0, y(1)=y0
steps size, h
i+1
Plot(t,y) print(t,y) i< n
No
Yes
END
k1 f (ti , yi )
3 3
k 2 f ti h, yi k1h
4 4
1 2
yi 1 yi k1 k2 h
3 3
ti 1 ti h
26
The program to solve the problem using MATLAB starts with the definition of function,
declaration of variables, and reading the required initial conditions. The next part is the loop
where the program checks if the function is executed as the number of times specified. If not,
he program will proceed in solving for the values of k depending on the order of the method
used then compute the required outputs. Since this is a second order method, the program will
first determine two values of k. This process will continue until it satisfies the desired number
of executions needed. In the last part, the program will display the results with the graph.
function dydt=f(t,y)
dydt='f(t,y)' ;
f=inline(dydt,'t','y') ;
27
disp(sprintf(' = %g',h))
ta(1)=t0 ;
ya(1)=y0 ;
for i=1:n
disp(sprintf('\nStep %g',i))
disp(sprintf('-------------------------------------------------------
'))
28
title
disp(sprintf('\n\n*********************Results**************************'))
General Algorithm for 4th order Runge-Kutta method:
1. Start
2. Define the function.
3. Declare the variables (dydt, t,y).
4. State initial conditions (t0, y0) , n, and step size(h).
5. Start loop. Check if i<n
If yes, continue to 6
If no proceed to 10
6. Calculate the values of k1, k2, k3, k4 using the initial values given.
7. Calculate the value of y using the values of k1, k2, k3, k4 calculated.
8. Add a step
9. Return to 5
10. Display the results.
11. Plot (t,y).
12. End.
29
General Flowchart for 4th order Runge-Kutta method
Start
F(t, y)
t(1)=t0, y(1)=y0
steps size, h
i+1
Plot(t,y) print(t,y) i< n
No
Yes
END
k1 f (ti , yi )
1 1
k2 f (ti h, yi hk1 )
2 2
1 1
k3 f (ti h, yi hk2 )
2 2
k4 f (ti h, yi hk3 )
h
y i 1 y i ( k1 2 k 2 2 k 3 k 4 )
6
ti 1 ti h
30
The program to solve the problem using MATLAB starts with the definition of function,
declaration of variables, and reading the required initial conditions. The next part is the loop
where the program checks if the function is executed as the number of times specified. If not,
he program will proceed in solving for the values of k depending on the order of the method
used then compute the required outputs. Since this is a fourth order method, the program will
first determine four values of k. This process will continue until it satisfies the desired
number of executions needed. In the last part, the program will display the results with the
graph.
Problem Code for the solution of ODE using 4th- Order Runge-Kutta Method:
% RK4 method
31
disp(sprintf('\n\nThe 4th Order Runge-Kutta Method of Solving Ordinary
Differential Equations'))
h=(tf-t0)/n ;
disp(sprintf(' h = ( tf - t0 ) / n '))
disp(sprintf(' = ( %g - %g ) / %g ',tf,t0,n))
disp(sprintf(' = %g',h))
ta(1)=t0 ;
ya(1)=y0 ;
for i=1:n
disp(sprintf('\nStep %g',i))
disp(sprintf('------------------------------------------------------
'))
32
disp(sprintf(' = f( %g + 0.5 * %g , %g + 0.5 * %g *
%g)',ta(i),h,ya(i),k2,h))
disp(sprintf(' = f( %g , %g )',ta(i)+0.5*h,ya(i)+0.5*k2*h))
disp(sprintf(' = %g\n',k3))
disp(sprintf(' k4 = f( t%g + h, y%g + k3*h)',i-1,i-1))
disp(sprintf(' = f( %g , %g )',ta(i)+h,ya(i)+k3*h))
disp(sprintf(' = %g\n',k1))
disp(sprintf('2) Apply the Runge-Kutta 4th Order method to estimate
y%g',i))
disp(sprintf(' y%g = y%g + 1/6*( k1 + 2*k2 + 2*k3 +k4) * h',i,i-
1))
disp(sprintf(' = %g + %g * %g *
%g',ya(i),1/6,(k1+2*k2+2*k3+k4),h))
disp(sprintf(' = %g\n',ya(i+1)))
disp(sprintf(' at t%g = %g',i,ta(i+1)))
end
plot(ta,ya);
xlabel
ylabel
title
disp(sprintf('\n\n********************Results************************'))
33
IV. Application:
Problem statement:
Solve the following problem over the interval from t = 0 to 1 using a step size of 0.25
where y(0) = 1.
𝑑𝑦
= ( 1 + 4𝑡)√𝑦
𝑑𝑡
Analytical method:
𝑑𝑦
= ( 1 + 4𝑡) √𝑦
𝑑𝑡
𝑑𝑦
= (1 + 4𝑡)𝑑𝑡
√𝑦
1
𝑦 −2 𝑑𝑦 = (1 + 4𝑡)𝑑𝑡
2√𝑦 = 𝑡 + 2𝑡 2 + c
At x=0, y(0)=1 , c = 2
Therefore the final expression is:
(𝑡 + 2𝑡 2 + 2)2
𝑦(𝑡) =
4
Substituting values of t into the equation on the interval [0,1] with the step size 0.25, the
values of y obtained are 1.410156, 2.25, 3.7539,6.25.
34
Euler’s Method
Algorithm:
1. Start
2. Function definition: dydt = (1+4x) y
3. Variable declaration (dydt, t,y).
4. State initial conditions
t0= 0
y0= 1
tf = 1
h= 0.25
5. Start loop. Check if i<n
n= 4
If yes, continue to 6
If no proceed to 8
6. Calculate the value of y
y i 1 yi f (ti, yi )h
Add a step: i+1
7. Return to 5
8. Display the results.
9. Plot (t,y).
10. End.
35
Flowchart
Start
F(t, y)
dydt = (1+4x) y
t0=0, y0=1
i+1
i< n
Plot(t,y) print(t,y)
No n=4
Yes
END
yi+1 = yi + f (ti,yi)h
ti1 ti h
36
Problem Code for the solution of ODE using Euler’s method:
% eulers method
ta(1)=t0 ;
ya(1)=y0 ;
for i=1:n
37
disp(sprintf('\nStep %g',i))
disp(sprintf('------------------------------------------------'))
disp(sprintf('\n\n*********************Results*******************'))
38
Output:
39
40
41
Heun’s Method
Algorithm:
1. Start
2. Function definition: dydt = (1+4x) y
3. Variable declaration (dydt, t,y).
4. State initial conditions
t0= 0
y0= 1
tf = 1
h= 0.25
5. Start loop. Check if i<n
n= 4
If yes, continue to 6
If no proceed to 9
6. Calculate the value of y
h
y i 1 y i ( k1 2 k 2 2 k 3 k 4 )
6
7. Add a step: i+1
8. Return to 5
9. Display the results.
10. Plot (t,y).
11. End.
42
Flowchart
Start
F(t, y)
dydt = (1+4x) y
t0=0,y0=1
i< n i+1
Plot(t,y) print(t,y)
No n=4
Yes
END
h
y i 1 y i ( k1 2 k 2 2 k 3 k 4 )
6
ti1 ti h
43
% heuns method
ta(1)=t0 ;
ya(1)=y0 ;
for i=1:n
disp(sprintf('\nStep %g',i))
disp(sprintf('-------------------------------------------------'))
44
disp(sprintf('1) Apply the heuns method to estimate y%g',i))
disp(sprintf(' y%g = y%g +
0.5*h*(f(ta(i),ya(i))+f(ta(i)+h*ya(i)+h*f(ta(i),ya(i))))',i,i-1))
disp(sprintf(' = %g + %g * %g *
%g',ya(i),0.5,h,(f(ta(i),ya(i))+f(ta(i)+h,ya(i)+h*f(ta(i),ya(i)))),h))
disp(sprintf(' = %g\n',ya(i+1)))
disp(sprintf(' at t%g = %g',i,ta(i+1)))
end
plot(ta,ya);
xlabel('time')
ylabel('y')
title('heuns method result')
disp(sprintf('\n\n*********************Results*************************'))
Output:
45
46
Midpoint Method
Algorithm:
1. Start
2. Function definition: dydt = (1+4x) y
3. Variable declaration (dydt, t,y).
4. State initial conditions
t0= 0
y0= 1
tf = 1
h= 0.25
5. Start loop. Check if i<n
n= 4
If yes, continue to 6
If no proceed to 9
6. Calculate the values of k1, and k2 using the initial values given.
k1 f (ti , yi )
k2 f (ti h / 2, yi k1h / 2)
47
Flowchart
Start
F(t, y)
dydt = (1+4x) y
t0=0,y0=1
i+1
i< n
Plot(t,y) print(t,y)
No n=4
Yes
END
k1 f (ti , yi )
k2 f (ti h / 2, yi k1h / 2)
yi 1 yi k 2 h
ti 1 ti h
48
Problem Code for the solution of ODE using midpoint method:
% midpoint
ta(1)=t0 ;
ya(1)=y0 ;
for i=1:n
disp(sprintf('\nStep %g',i))
disp(sprintf('------------------------------------------------'))
49
% Calculating k1, and k2
k1 = f(ta(i),ya(i)) ;
k2 = f(ta(i)+0.5*h,ya(i)+0.5*k1*h) ;
disp(sprintf('\n\n**********************Results**********************'))
50
Output:
51
52
Ralston’s Method
Algorithm:
1. Start
2. Function definition: dydt = (1+4x) y
3. Variable declaration (dydt, t,y).
4. State initial conditions
t0= 0
y0= 1
tf = 1
h= 0.25
5. Start loop. Check if i<n
n= 4
If yes, continue to 6
If no proceed to 9
6. Calculate the values of k1, and k2 using the initial values given.
k1 f (ti , yi )
3 3
k 2 f ti h, yi k1h
4 4
7. Calculate the value of y using the values of k1, and k2 calculated.
1 2
yi 1 yi k1 k2 h
3 3
8. Add a step: i+1
9. Return to 5
10. Display the results.
11. Plot (t,y).
12. End.
53
Flowchart
Start
F(t, y)
dydt = (1+4x) y
t0=0,y0=1
i+1
i< n
Plot(t,y) print(t,y)
No n=4
Yes
END k1 f (ti , yi )
3 3
k 2 f ti h, yi k1h
4 4
1 2
yi 1 yi k1 k2 h
3 3
ti 1 ti h
54
Problem Code for the solution of ODE using Ralston method:
% ralston method
function dydt=f(t,y)
dydt='(1+4*t)*sqrt(y)' ;
f=inline(dydt,'t','y') ;
t0=0 ;
y0=1;
tf=1;
% n, number of steps to take
n=4;
% Displays title information
disp(sprintf('\n\nthe Ralston method of solving differential
equations'))
h=(tf-t0)/n ;
disp(sprintf(' h = ( tf - t0 ) / n '))
disp(sprintf(' = ( %g - %g ) / %g ',tf,t0,n))
disp(sprintf(' = %g',h))
ta(1)=t0 ;
ya(1)=y0 ;
for i=1:n
disp(sprintf('\nStep %g',i))
55
disp(sprintf('-------------------------------------------------------
'))
disp(sprintf('\n\n*********************Results***********************'))
56
Output:
57
58
4th Order Runge-Kutta Method
Algorithm:
1. Start
2. Function definition: dydt = (1+4x) y
3. Variable declaration (dydt, t,y).
4. State initial conditions
t0= 0
y0= 1
tf = 1
h= 0.25
5. Start loop. Check if i<n
n= 4
If yes, continue to 6
If no proceed to 9
6. Calculate the values of k1, k2,k3 and k4 using the initial values given.
k1 f (ti , yi )
1 1
k2 f (ti h, yi hk1 )
2 2
1 1
k3 f (ti h, yi hk2 )
2 2
k4 f (ti h, yi hk3 )
7. Calculate the value of y using the values of k1, k2, k3, and k4 calculated.
h
y i 1 y i ( k1 2 k 2 2 k 3 k 4 )
6
8. Add a step: i+1
9. Return to 5
10. Display the results.
11. Plot (t,y).
12. End.
59
Flowchart
Start
F(t, y)
dydt = (1+4x) y
t0=0, y0= 1
i< n i+1
Plot(t,y) print(t,y)
No n=4
Yes
END
k1 f (ti , yi )
1 1
k2 f (ti h, yi hk1 )
2 2
1 1
k3 f (ti h, yi hk2 )
2 2
k4 f (ti h, yi hk3 )
h
y i 1 y i ( k1 2 k 2 2 k 3 k 4 )
6
ti 1 ti h
60
Problem Code for the solution of ODE using 4th- Order Runge-Kutta Method:
% RK4 method
t0=0 ;
% y0, value of y at t0
y0=1;
% tf, upper boundary of time t
tf=1;
% n, number of steps to take
n=4;
% Displays title information
disp(sprintf('\n\nThe 4th Order Runge-Kutta Method of Solving Ordinary
Differential Equations'))
h=(tf-t0)/n ;
disp(sprintf(' h = ( tf - t0 ) / n '))
disp(sprintf(' = ( %g - %g ) / %g ',tf,t0,n))
disp(sprintf(' = %g',h))
ta(1)=t0 ;
ya(1)=y0 ;
for i=1:n
disp(sprintf('\nStep %g',i))
disp(sprintf('------------------------------------------------------
'))
61
% Adding Step Size
ta(i+1)=ta(i)+h ;
% Calculating k1, k2, k3, and k4
k1 = f(ta(i),ya(i)) ;
k2 = f(ta(i)+0.5*h,ya(i)+0.5*k1*h) ;
k3 = f(ta(i)+0.5*h,ya(i)+0.5*k2*h) ;
k4 = f(ta(i)+h,ya(i)+k3*h) ;
62
end
plot(ta,ya);
sxlabel('time')
ylabel('y')
title('rk4 method result')
disp(sprintf('\n\n***********************Results*********************'))
Output:
63
64
65
V. Generalization
Table of values of y obtained using different methods:
0
0 0.2 0.4 0.6 0.8 1 1.2
66
If the exact solution to the differential equation is a polynomial or order n it will be
solved exactly by an n-th Runge-Kutta method. For example, forward Euler will be exact if
the solution is a line and RK4 will be exact if the solution is a polynomial of degree 2-4.
67
VI. References
Steve Chapra(2005), Applied Numerical Methods with MATLAB for Engineers and
Scientists, 3rd ed., McGraw-Hill, New York.
Ahmad, R.R. and Yaacob, N. (2005) Third-order composite Runge–Kutta method for
stiff problems, International Journal of Computer Mathematics, 82(10)
Butcher, J.C. (1994) Initial value problems: numerical methods and mathematics,
Computers and Mathematics with Applications, 28(10-12)
Jaan Kiusalaas(2005), Numerical Methods in Engineering with MATLAB,
Cambridge University Press
Steven J. Chapman(2001), MATLAB Programming for Engineers, 2nd ed.
Kopal, Z. (1955) Numerical Analysis, John Wiley & Sons, New-York.
68