You are on page 1of 30

FACULTY OF ENGINEERING &

TECHNOLOGY

COMPUTATIONAL METHOD FOR


MECHANICAL ENGINEERING
ASSIGNMENT 1 REPORT

EME 3156 TRIMESTER 2 (2016/2017)


Name ID Number Group
CHONG KAH LEONG, JOSHUA 1131122826 311
Chan Kai Wai 1141125128
Ou Chui Yee 1131122942
Lim Xiang Ling 1132700781
Yee Chun Long 1112701071

TABLE OF CONTENTS

Abstract 3
CHAPTER 1: INTRODUCTION 4
Software: MATLAB 4
Numerical methods for Ordinary Differential Equations(ODE) 5

CHAPTER 2: OBJECTIVE AND PROBLEM STATEMENT 6

1
CHAPTER 3: RESULTS AND PRESENTATION 4
Calculation: Formula 7
Calculation: Implicit Euler method 8
Exact Solution 9
Explicit Euler Method 10
Implicit Euler Method 11
3rd order Taylor method 13
Midpoint method (RK2) 15
Runge Kutta method (RK4) 17
Predictor - Corrector method 18
Error Analysis 20
Comparison of each method with the Exact Solution at step size, h = 0.1 20
Comparison of each method step size, h = 0.1, 0.5, 1.0, 1.5, 2.0 final value
with the exact solution 21
Comparison of each method value with the exact solution as the value t
increases 24

CHAPTER 4: DISCUSSIONS 25
Numerical Methods 25
Error Analysis 25

CHAPTER 5: CONCLUSION 28

REFERENCE 28

ABSTRACT

Abstract

In this report, each group are to select an Ordinary Differential Equation (ODE)
question from the list of twelve questions. Students are expected to solve the following
equations using numerical computational software like MATLAB and SciLab. Microsoft
Excel and any ODE functional packageis not advised to be used. The ODE are expected to be
solved through numerical methods for instances :
1. Explicit Euler method,

2
2. Implicit Euler method,
3. 2nd order Taylor method
4. 3rd order Taylor method,
5. Midpoint method, RK2
6. Runge Kutta method, RK4
7. Predictor - Corrector method
8. two-steps Adam-Bashforth method
9. four-steps Adam-Bashforth method
10. two-steps Adam-Moulten method
11. four-steps Adam-Moulten method
12.Extrapolation method

After solving the particular ODE problems, comparison between each numerical
method is done and observed. The error and error percentage for each method is determined
from the difference between the final value of each methods and the exact solution. Different
step sizes, h for each method are also used and its effect on the accuracy of the solution is
determined. The parameters of ODE affecting the accuracy of the results are then discussed
and a conclusion is drawn.

3
CHAPTER 1
INTRODUCTION
Software: MATLAB

In this assignment, we use an analytical computational software called MATLAB to


aid us in obtain concrete results so that we could be compared it with the analytical data from
Excel and determine each method accuracy. MATLAB, also known as matrix laboratory is
a multi-paradigm numerical computing environment and fourth-generation programming
language. Originated from Cleve Moler and developed by MathWorks, MATLAB
allows matrix manipulations, plotting off functions and data in both 2D and 3D,
implementation of algorithms, creation of user interfaces, and interfacing with programs
written in other languages, including C, C++, Java, Fortran and Python.. Millions of
engineers and scientists worldwide use MATLAB to analyze and design the systems and
products that is transforming our world, especially in active safety systems, interplanetary
spacecraft, health monitoring devices, smart power grids, and LTE cellular networks. It is
used for machine learning, signal processing, image processing, computer vision,
communications, computational finance, control design, robotics, and much more.
Typical uses include:

Math and computation

Algorithm development

Modelling, simulation, and prototyping

Data analysis, exploration, and visualization

Scientific and engineering graphics

MATLAB is optimized for solving engineering and scientific problems as it


language is the worlds most natural way to express computational mathematics. Moreover,
built-in graphics make it easy to visualize and gain insights from data. There is also a vast
library of prebuilt toolboxes that enable us to get to the algorithms essential directly. Allow
easy and accurate experimentation, exploration, and discovery.

4
Numerical methods for Ordinary Differential Equations (ODE)

Ordinary differential equation (ODE) is one of the two types of differential equation
which contains one or more functions of one independent variable and its derivatives. The
other differential equation is the partial differential equation which is contrast to ODE and
has more than one independent variable.

Linear ODEs differential equations have exact closed-form solutions which is


applicable to be added and multiplied by coefficients. However ODEs that is lack of additive
solutions are nonlinear. Solving them is more difficult and rather intricate to be present with
elementary functions in closed form. Exact and analytic solutions of ODEs are usually found
in series or integral form. Graphical and numerical methods can be applied to approximate
solutions of ODEs to yield useful information, without the need of exact analytic solutions.

To find numerical approximations to the solutions of ordinary differential equations


(ODEs), numerical methods for ordinary differential equations, known as "numerical
integration", are used. Algorithms studied here like Euler methods, Taylor method and etc.
can be used to compute such an approximation. Another method is to use calculus to obtain a
series expansion of the solution. Ordinary differential equations can occur in many scientific
disciplines, like in physics, chemistry, biology, and economics. For convenience, there are
various methods can allow numerical partial differential equations to be converted into partial
differential equation into an ordinary differential equation, which must then be solved.

Numerical methods for solving first-order initial value problems (IVPs) can be solved
by all kinds of categories: linear multistep methods, or Runge-Kutta methods are famous for
their accuracy to the exact value in spite of the difficulty to carry them out. On the other
hand, a further division can be done by dividing methods into those that are explicit and those
that are implicit (Adams-Moulton methods). Explicit examples from the linear multistep
family include the Adams-Bashforth methods, any Runge-Kutta method and any Taylor
method. In default, any stiff differential equations will require the use of implicit schemes,
whereas non-stiff problems can be solved more efficiently with explicit schemes.

5
6
CHAPTER 2
OBJECTIVE AND PROBLEM STATEMENT
Objective

1 To solve the ordinary differential equations question using any suitable analytical
software. Software: MATLAB

1. To analysis and discuss the comparison in the results that generates by the software
and by Microsoft Excel.

2. To study the error percentage between both of this software and determine the best
method for the ordinary differential equation question.

Problem Statement

From a long time ago, engineers and scientists has emphasized on high efficiency
processing. Deprived from the versatility of computational accuracy, numerical
approximation method calculated through handwritten are laden with human errors at the
time, hence does not yield high efficiency yet consume a big amount of time. However, with
the new wind of technology, new software are developed to overcome these issue and bring
productivity by minimizing the error created, which in return, increase each problem solving
efficiency.

Some of these software are developed to aid us in solving numerical approximation


for ODE, for instance MATLAB, SciLab, and C programming platforms. In this assignment,
MATLAB is selected to provide assistance in solving the given ordinary differential equation
question through several methods. Knowledge of computation numerical methods through
handwritten and MATLAB have to be learned and practiced together in order to be able to
solve the ordinary differential equations manually and write the necessary code for ODE
problem solving.

7
We are assigned to solve the problem below by using 5 methods: Euler method,
Taylor method, Runge Kutta method, Midpoint method and Predictor - Corrector method.
Besides using MATLAB, Microsoft excel is used to solve the following ODE problem too.
The purpose of using Microsoft excel is to compare the result generated by MATLAB. With
the exact equation given, the exact value of each particular point is taken to determine the
error and effect of each methods and each methods variation. We are using step size h=0.1,
0.5, 1.0, 1.5, and 2.0 for all the methods.

Questi Group initial value exact solution methods


on
problem
6 5 dx 4x 1 Explicit Euler method,
7t 2 x(t ) t 3
dt t t4 Implicit Euler method,
, 3rd order Taylor method,
1 t 6 Reference: A Friendly Runge Kutta method, RK4
Introduction to Midpoint method, RK2
Numerical Analysis,
x(1) 2 Brian Bradie,
Predictor - Corrector method
Pearson, 2006, pg
597

CHAPTER 3 RESULTS AND PRESENTATION

Calculation: Formula

a) Explicit Euler Method, d) Midpoint method (RK2)

x i+1=x i +hf ( t i , x i)
h h
k 1=f ( t i , x i ) , x m=x i + k 1 t m=t i+
2 2
b) Implicit Euler Method,

x i+1=x i +hf ( t i +1 , x i+1 ) c) 3rd order k 2=f ( t m , x m ) , x i+1=x i +h k 2

Taylor method,

h2 ' (t , x ) h3 '' (t , x )
x i+1=x i +hf ( t i , x i) + f i i
+ f i i

2! 3!

8
e) Runge Kutta method (RK4) f) Predictor - Corrector method

k 1=f ( t i , x i ) , x i+1 p= xi +h k 2

h k 2=f ( t i+1 , x i +1p ) ,


X n 1 X n ( k1 2 k 2 2 k 3 k 4 )
6
k1 f (t n , X n )
h
k 2 f (t n 21 h, X n 21 hk1 ) xi +1=x i+ ( k 1+ k 2 )
2
k 3 f (t n 21 h, X n 21 hk 2 )
k 4 f (t n h, X n hk3 )

Calculation
Implicit Euler method:

x i+1=x i +hf ( t i +1 , x i+1 )

Ordinary Differential Equation (ODE) :

dx 4x
f ( t i , x i )= dt 7t t
2

4 x i +1
f ( t i+1 , xi +1 )=7 t 2i+1
t i +1

x i+1=x i +hf ( t i +1 , x i+1 ) - From Implicit Euler method

4 xi +1
x i+1=x i +h(7 t 2i+1 )
t i +1

4 h x i+1
x i+1=x i +7 h t 2i +1
t i+1

4h
x i+1 (1+ )=xi +7 h t 2i+1
t i+1

xi +7 h t 2i+1
x i+1=
4h
(1+ )
t i+1

9
xi t i+1 +7 h t 3i +1
x i+1=
t i +1+ 4 h

MATLAB Code

a) Exact Solution

1
x(t ) t 3
t4

t=linspace (1,6); grid


x= (t.^3)+(1./(t.^4)); title('Exact solution and Differential
Equation(red)')
figure % opens new figure window
xlabel('t');
%Plot result
ylabel('x');
hold on
hold off
plot(t, x);

10
Graph 1: Exact Solution MATLAB Graph

b) Euler Explicit Method

clc; k1= Fxt(t(i),x(i));


clear all; x(i+1) = x(i) +(h)*(k1);
%parameters end
h=0.1; %step size, change to h = 0.5, 1.0, 1.5 %Plot result
and 2
hold on
t = 1:h:6;
plot(t, x);
%Define ODE function handle
grid
Fxt = @(t,x) 7*t^2 - (4*x/t);
title('Euler Explicit, h = 0.1, 0.5, 1.0, 1.5
%initial condition &2.0')
x = zeros(1,length(t)); xlabel('t');
x(1) = 2; ylabel('x');
%Euler Explicit Loop hold off
for i=1:(length(t)-1)
MATLAB Graph

11
Graph 2(a): Euler Explicit Method with step size, h = 0.1 MATLAB Graph

Graph 2(b) : step size, h = 0.5 Graph 2(c) : step size,


h = 1.0

Graph 2(d) : step size, h = 1.5 Graph 2(e) : step size,


h = 2.0

c) Euler Implicit Method

clc; h=0.5; %step size, change to h = 0.5, 1.0, 1.5


and 2
clear all;
t = 1:h:6;
%parameters
%initial condition

12
x = zeros(1,length(t)); %Plot result

x(1) = 2; hold on

%Define ODE function handle plot(t, x);

%Euler Implicit Loop grid

for i=1:(length(t)-1) title('Euler Implicit, h = 0.1, 0.5, 1.0, 1.5 and


2')
t(i+1) = t(i)+ h;
xlabel('t');

ylabel('x');

hold off

x(i+1) =
(t(i+1)*x(i)+7*h*t(i+1)^3)/(t(i+1)+4*h);

end

MATLAB Graph

Graph 3(a): Euler Implicit Method with step size, h = 0.1 MATLAB Graph

13
Graph 3(b) : step size, h = 0.5 Graph 3(c) : step size,
h = 1.0

Graph 3(d) : step size, h = 1.5 Graph 3(e) :


step size, h = 2.0

D) 3rd order Taylor Method

% dx/dt=7*(t^2)-(4*x)/t, x(1)=2 f3 =(14-8*x(i)/t(i)^3);


%3rd order taylor method x(i+1) = x(i) + h*f1 + 0.5*h^2*f2 +
(1/6)*h^3*f3;
%parameters
% update x
h=0.1; %step size, change to h = 0.5, 1.0, 1.5
and 2 t(i+1) = t(i)+h;
t = 1:h:6; %solve from t=[1,tfinal] % update t
%initial condition end
x = zeros(1,length(t)); %Plot result
x(1)=2; hold on
%Taylor 3rd order method Loop plot(t,x)
for i=1:(length(x)-1) grid
%Define ODE function handle title('Taylor Series, h = 0.1, 0.5, 1.0, 1.5 and 2')
f1 =(7*t(i)^2-4*x(i)/t(i)); xlabel('t')
f2 =(14*t(i)+4*x(i)/t(i)^2); ylabel('x')

14
set(gca,'Fontsize',16) hold off
MATLAB Graph

Graph 4(a): 3rd order Taylor Method with step size, h = 0.1 MATLAB Graph

Graph 4(b) : step size, h = 0.5 Graph 4(c) : step size,


h = 1.0

15
Graph 4(d) : step size, h = 1.5 Graph 4(e) :
step size, h = 2.0

E) Midpoint Method (RK2)

%dx/dt=7*(t^2)-(4*x)/t, x(1)=2 %Define ODE function handle


% Midpoint Method k1 = Fxt(t(i),x(i));
%parameters lc = x(i) +(h)*(k1);
h=0.1; %step size, change to h = 0.5, 1.0, k2 = Fxt(t(i)+h/2,lc);
1.5 and 2
x(i+1) = x(i) + h*k2;
t = 1:h:6; %solve from t=[1,tfinal]
% update x
Fxt = @(t,x) 7*t^2 - (4*x/t);
t(i+1) = t(i)+h;
%initial condition
% update t
x = zeros(1,length(t));
end
x(1)=2;
%Plot result
%Midpoint (RK2) method Loop
hold on
for i=1:(length(x)-1)
plot(t,x)

16
grid xlabel('x')
title('Midpooint Method, h = 0.1, 0.5, 1.0, set(gca,'Fontsize',16)
1.5 and 2')
hold off
tlabel('t')
MATLAB Graph

Graph 5(a): Midpoint Method (RK2) with step size, h = 0.1 MATLAB
Graph

Graph 5(b) : step size, h = 0.5 Graph 5(c) : step size,


h = 1.0

17
Graph 5(d) : step size, h = 1.5 Graph 5(e) :
step size, h = 2.0

F) Runge-Kutta Method (RK4)

%parameters % update t
h=0.1; %step size, change to h = 0.5, 1.0, % update x
1.5 and 2
k1=f(t(i),x(i));
t = 1:h:6; %solve from t=[1,tfinal]
k2=f(t(i)+0.5*h,x(i)+0.5*k1*h);
%initial condition
k3=f(t(i)+0.5*h,x(i)+0.5*k2*h);
x = zeros(1,length(t));
k4=f(t(i)+h,x(i)+k3*h);
x(1)=2;
x(i+1)=x(i)+h/6*(k1+2*k2+2*k3+k4);
%Define ODE function handle
end
f=@(t,x) (7*(t^2)-(4*x)/t);
%Plot result
%RK4 Loop
hold on
for i=1:(length(x)-1)
plot(t,x)
18
grid xlabel('x')
title('Runge Kutta RK4, h = h = 0.1, 0.5, set(gca,'Fontsize',16)
1.0, 1.5 and 2')
hold off
tlabel('t')
MATLAB Graph

Graph 6(a): Runge-Kutta Method (RK4) with step size, h = 0.1 MATLAB Graph

Graph 6(b) : step size, h = 0.5 Graph 6(c) : step size,


h = 1.0

19
Graph 6(d) : step size, h = 1.5 Graph 6(e) :
step size, h = 2.0

F) Predictor - Corrector method

clc; x(i+1) = x(i) + (h/2)*(k1+k2);


clear all; end
h=0.1; %step size, change to h = 0.5, 1.0, hold on
1.5 and 2
plot(t, x);
t = 1:h:6;
grid
x = zeros(1,length(t));
title('Predictor-corrector methods, h = 0.1,
x(1) = 2; 0.5, 1.0, 1.5 and 2'')
for i=1:(length(x)-1) xlabel('t');
k1 = (7*t(i)^2 - (4*x(i)./t(i))); ylabel('x');
xp= x(i)+ h*k1; hold off
k2 = (7*t(i+1)^2 - (4*xp/t(i+1)));

20
MATLAB Graph

Graph 7(a): Predictor - Corrector method with step size, h = 0.1 MATLAB
Graph

Graph 7(b) : step size, h = 0.5 Graph 7(c) : step size,


h = 1.0
Graph 7(d) : step size, h = 1.5 Graph 7(e) : step
size, h = 2.0

Error Analysis
a) Comparison of each method with the Exact Solution at step size, h = 0.1
Exact Solution Final Value, x(6) = 216.0007716
Calculation:
1. Error = |exact solution, x(6) numerical method, x(6)|

|
2. Error Percentage ( ) =
exact solution , x ( 6 ) |
exact solution, x ( 6 ) numerical method , x ( 6 )
100

Method Final Value, x(6) Error Error Percentage (%)


Explicit Euler 214.194291 1.806480639 0.84
method,
Implicit Euler 217.7954982 1.794726643 0.83
method,
3rd order Taylor 219.6120744 3.61130283 1.67
method,
Midpoint method, 216.0350179 0.034246339 0.02
RK2
Runge Kutta method, 216.0007903 1.87091E-05 0.00
RK4
Predictor - Corrector 216.0811351 0.080363488 0.04
method
Graph
Comparison graph between all the methods
250

200
Exact Solution x(t)
Explicit Euler x(i)
150 Implicit Euler x(i)
Taylor 3rd Order x(i)
x (i)
100 Midpoint x(i)
Runge Kutta 4th Order x(i)
Predictor Corrector x(i)
50

0
1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6

t(i)

Magnified comparision of each method end result


220
219
218 Exact Solution x(t)
217 Explicit Euler x(i)
216 Implicit Euler x(i)
215 Taylor 3rd Order x(i)
x(i)
214 Midpoint x(i)
213 Runge Kutta 4th Order x(i)
212 Predictor Corrector x(i)
211
210
5.9 5.92 5.94 5.96 5.98 6

t(i)

b) Comparison of each method step size, h = 0.1, 0.5, 1.0, 1.5, 2.0 final value with the
exact solution
Error is obtained by comparing each step size final values with respect to exact solution
values :
1. For step size, h= 0.1, 0.5, 1, x(6) of each numerical method is compared with exact
solution values, x(6) values
2.For step size, h=1.5, x(5.5) of each numerical method is compared with exact solution
values, x(5.5) values
3. For step size, h= 2, x(5) of each numerical method is compared with exact solution values,
x(5) values
i) Explicit Euler Method:

Step Size X(6) X(5.5) X(5) Error Error


Percentage (%)
Exact Solution 216.0007716 166.3760928 125.0016 - -
0.1 214.194291 - - 1.80648 0.84
0.5 206.85 - - 9.15078 4.24
1.0 197.4 - - 18.6008 8.61
1.5 - 135.5375 - 30.8386 18.54
2.0 - - 126 0.9984 0.80

ii) Implicit Euler Method:

Step Size X(6) X(5.5) X(5) Error Error


Percentage (%)
Exact Solution 216.0007716 166.3760928 125.0016 - -
0.1 217.7954982 - - 1.7947 0.83
0.5 224.8563874 - - 8.85561 4.10
1.0 233.4142857 - - 17.8556 8.27
1.5 - 187.8517263 - 21.4756 12.91
2.0 - - 148.041958 23.0404 18.43

iii) Taylor Method 3rd order Method:

Step Size X(6) X(5.5) X(5) Error Error


Percentage (%)
Exact Solution 216.0007716 166.3760928 125.0016 - -
0.1 219.6120744 - - 3.61130 1.67
0.5 234.2683529 - - 18.2676 8.46
1.0 252.9259738 - - 36.9252 17.10
1.5 - 212.9975469 - 46.6215 28.02
2.0 - - 180.1893004 55.1877 44.15

iv) Midpoint, RK2:

Step Size X(6) X(5.5) X(5) Error Error


Percentage (%)
Exact Solution 216.0007716 166.3760928 125.0016 - -
0.1 216.0350179 - - 0.03425 0.02
0.5 217.0259354 - - 1.02516 0.47
1.0 222.3347042 - - 6.3393 2.93
1.5 - 193.2208177 - 26.8447 13.89
2.0 - - 188 62.9984 50.40
th
v) Runge Kutta 4 order Method, RK4:

Step Size X(6) X(5.5) X(5) Error Error


Percentage (%)
Exact Solution 216.0007716 166.3760928 125.0016 - -
0.1 216.0007903 - - 1.871E-05 0.00
0.5 216.0140297 - - 0.013253 0.01
1.0 216.2563208 - - 0.255544 0.12
1.5 - 168.338190 - 1.9621 1.18
2.0 - - 135.5111111 10.5095 8.41

vi) Predictor-Corrector Method:

Step Size X(6) X(5.5) X(5) Error Error


Percentage (%)
Exact Solution 216.0007716 166.3760928 125.0016 - -
0.1 216.0811351 - - 0.08036 0.04
0.5 218.2986573 - - 2.29788 1.06
1.0 227.0288889 - - 11.0281 5.11
1.5 - 191.879929 - 25.5038 15.33
2.0 - - 154.2 29.1984 23.35

Step Sizes Error Analysis Graph


60

50
Explicit Euler x(i)
40 Implicit Euler x(i)
Taylor 3rd Order x(i)
Error Percentage (%) 30
Midpoint x(i)
20 Runge Kutta 4th Order x(i)
Predictor Corrector x(i)
10

0
0 0.2 0.40.60.8 1 1.21.41.6 1.8 2

Step Size, h
c) Comparison of each method value with the exact solution as the value t increases
E.g.: Explicit and Implicit Euler method at step size, h = 0.1
Explicit Implicit Explicit Implicit
Exact
Euler Euler Euler Euler
Percenta Percenta
i h t x(i) x(i) x(i) ge Error ge Error
(%) (%)
1 0.1 1.00 2.0000 2.0000 2.0000 0.00 0.00
10 0.1 1.90 6.7199 7.1451 6.9357 3.11 3.02
20 0.1 2.90 23.9721 24.8299 24.4031 1.77 1.75
30 0.1 3.90 58.5564 60.0833 59.3233 1.29 1.28
40 0.1 4.90 116.4443 118.8479 117.6507 1.03 1.02
50 0.1 5.90 203.6329 207.1152 205.3798 0.85 0.84

Error Percentage vs t(i) Error Analysis Graph


6

4
Explicit Euler
Erro Percentage (%) 3
Implicit Euler
2

0
1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6

t(i)
Chapter 4: DISCUSSIONS
A) Numerical Methods

All numerical methods graph yield similar pattern as the exact solution function yet
with different result. The results however do not have much different with each numerical
method respectively which all fall in about the same region of x value ranged from 200 to
250 when t value is 6. One obvious notice in the change of graph is when the step size of the
ODE numerical methods changes. 1. We used the step size value of 0.1. The purpose of using
such small step size is to obtain a more accurate result. However when the step size is small,
more step is required to calculate the problem from the initial condition to the final desired
value. For our case, we are given X(1)=1 and we are required to find the value when X(6).
With a smaller step size, thus it will have more data, with more data, the graph generated will
be smoother and closer to the actual graph. But as the step sizes increase, the smoothness of
curve in each method reduced, giving it a rocky shape. The nodes of the graphs also
decreased as the step sizes increases. This causes the number of conjoining linear function
in the graph to decrease. The length of the MATLAB also varied from methods to methods.
In spite of that, Runge Kutta method, RK4 is observed to have the most code while the Euler
methods have the least code. This shows that the better and more efficient numerical methods
like RK4 are much more tedious to be perform compare to a simpleton Euler Method that
yield less accurate result.

B) Error Analysis

From the table above, the percentage error for Implicit Euler method compared with
exact solution is always smaller than Explicit Euler method. The errors for both method
however decreases when t increases. This resulting pattern is also observed in the rest of the
numerical methods. The step size taken is relatively small, the x(i) values taken at t=6 for
Euler methods are close to exact number. Comparing both Euler methods, implicit method is
proven to give better result than the explicit method. However, their result is only second to
RK methods like Midpoint method and Runge Kutta method.

In the order of increasing accuracy:


3rd order Taylor method, > Explicit Euler method, > Implicit Euler method, > Predictor -
Corrector method > Midpoint method, RK2 > Runge Kutta method, RK4
By comparing different step sizes in each method, we can find that the error
percentage increase as the step size increases. As the error percentage increases, the accuracy
of the numerical method drops, resulting in lower efficiency. At step size, h = 1.5, all methods
efficiency drop tremendously and the order of increasing accuracy changed to

3rd order Taylor method, > Explicit Euler method, > Predictor - Corrector method > Midpoint
method, RK2 > Implicit Euler method > Runge Kutta method, RK4

To retain performance, any numerical methods with error percentage over 10% have to be
rejected, causing step sizes, h = 1.5 and 2 inappropriate to use in this ODE system. In
contrast, we can accept all step sizes for Runge-Kutta method as all its error percentage are
lower than 10%. On the other hand 3rd order Taylor method is proved to be by far the worst
method, with only step sizes, h=0.1 and 0.5 values can be accepted. Thus in the process of
solving the ODE problem, we had discovered the advantages and disadvantages for each of
the method. In term of the software platform used, we can said:

1. As MATLAB is an interpreted language for numerical computation, it allows us to


perform numerical calculations, and visualize the results, eliminating the need for
complicated and time consuming programming. MATLAB also allows its users to
accurately solve problems by reducing the human error possibly stems from
handwriting, thus produce graphs easily and can generate code efficiently. The
advantages are:

Source code is available online for free. It can be modified and upgraded at no cost.
Statements or code in MATLAB can wrote and calculated immediately. They can be
tested as with just a push of a button.
Relatively easy and user friendly to use compare to others software code such as C
programming, Python and Java.
It is able to manage large groups of mathematical workings with just a few lines of
command. Further mathematical workings may not be needed as it can calculate the
mathematical problem itself

The disadvantages are:


Required experienced programming supervision for those are first time in using
MATLAB, it is still much more complicated than Microsoft Excel but not as
tedious as Microsoft Excel.
As it is an interpreted language, it may execute more slowly compare to the
compiled language.
MATLAB is not a freeware and it is way more expensive than other conventional
software. It was too expensive for most individuals to consider purchasing and
some version can only be when it is connected to the internet. It is still a useful
and handy software that offers in most universities

2. As Microsoft Excel is a basic component in the Microsoft Office toolbox, it is


essential software that most people are familiar of. Most Windows operated laptops
and computers already have it inside. Thus unlike MATLAB, this software offers
much convenience to us without the need to buy or download it. The advantages of
using Microsoft Excel s are:

Easy to enter, locate and format data as there are columns and rows provided and
labelled with numbers and alphabets
Can use it easily without any professional training.
Can work quickly in analysing large amounts of data and produce graphs from it
Pivots tables can be used to group or separate the data.

Their disadvantages are:

The mathematical workings written inside Microsoft Excel are longer if the step size
used becomes smaller.
More difficult to troubleshoot and locate human error.
Chapter 5: CONCLUSION

From this assignment, we managed to solve an 2nd order ODE problem with a
numerical computational software. It is discovered that MATLAB is a more accurate software
that can solve ODE easily and instantly. Although it required us to learn its programming
algorithm before proceeding to the actual problem solving, it also require less lines of
command to be written compare to Microsoft Excel. This ultimately save us more time and
energy to solve the ODE problem but with the condition of mastering the programming skill
of MATLAB. On the other hand, Microsoft Excel required more lines of command but it is
relatively easier to learn. Nonetheless, both of the software was equally accurate in
calculating the problem given in this assignment. We found that in increasing order of
efficiency:
3rd order Taylor method, > Explicit Euler method, > Implicit Euler method, >
Predictor - Corrector method > Midpoint method, RK2 > Runge Kutta method, RK4

Runge-Kutta method, RK4 is the best numerical method to solve this ODE problem as it has
0% error for step size, h = 0.1 and below 10% for all step-sizes used. Taylor 3rd order method
is proven by far the worst method to solve this ODE problem as it has 1.67% error for step
size, h = 0.1 and above 10% once it step sizes is equal or more to 1.0. We also study the effect
of step-sizes and numerical parameter t to the accuracy of the numerical method. As the t
value increase, the error obtained from each method decreases while as the step-sizes increase
the error percentage obtained from each method increases, Thus to obtain best solution to this
2nd order ODE problem, we are advised to use Runge-Kutta method with smaller step-size,
and with respect to more t value numerical parameter.

REFERENCES
1. Bradie, Brian (2006). A Friendly Introduction to Numerical Analysis. Upper Saddle River,
New Jersey: Pearson Prentice Hall. ISBN 0-13-013054-0.
2. Halliday, David; Resnick, Robert (1977), Physics (3rd ed.), New York: Wiley, ISBN 0-471-
71716-9 3.
3. MATLAB- The Language of Technical Computing, online(available):
https://www.mathworks.com/products/matlab.html
4. http://www.math.unipd.it/~alvise/CS_2008/ODE/MFILES/ode.pdf
5. http://www.math.ubc.ca/~feldman/math/vble.pdf

You might also like