Applied Numerical Methods Project
Applied Numerical Methods Project
0 Introduction
1.1 Aim
The aim of this project is to implement the idea that real life scenarios that real-life
scenarios can be studied and observed by creating mathematical models and
computing the data to obtain results using MATLAB.
1.2 Background
Numerical analysis has been around ever since 1650 BC, the time where the Egyptian
Rhind papyrus was created. It describes a root finding method for solving a simple
equation. Ever since then, numerical analysis has been used and applied by many great
scientists, mathematicians & engineers throughout history, such as Archimedes, Isaac
Newton, and many more.
Following the advancements of science & technology in the 20th century, engineers use
numerical analysis as a means to obtain mathematical models for solid and fluid
mechanics. One of the most well known numerical methods that is widely used in the
engineering field is the Finite Element Method (FEM). This involves working with such
models involves approximating a complex, continuous surface, structure, or process by a
finite number of simple elements. Numerical analysis can be broken down into three
categories:
1. Numerical linear and non-linear Algebra
Many problems in applied mathematics involve solving systems of linear equations. They
can be solved directly or iteratively using a sequence of approximating solutions of
increasing accuracy, whereas non-linear problems are solved numerically by reducing them
to a sequence of linear problems.
2. Approximation Theory
This category includes the approximation of functions with simpler or more tractable
functions and methods based on using such approximations.
3. Solving Differential and Integral Equations
There are two types of methods of solving differential and integral equations. The first type
approximates the unknown function in the equation by a simpler function. The second type
works by approximating the derivatives and integrals in the equations.
1.3 Methods Used
• Bisection Method
The bisection method is used to find the roots of a polynomial equation. It
separates the interval and subdivides the interval in which the root of the
equation lies. The principle behind this method is the intermediate theorem for
continuous functions. It works by narrowing the gap between the positive and
negative intervals until it closes in on the correct answer. This method
narrows the gap by taking the average of the positive and negative intervals. It
is a simple method, and it is relatively slow. The bisection method is also
known as interval halving method, root-finding method, binary search method
or dichotomy method. ("Bisection Method - Definition, Procedure, and
Example", 2020)
• Newton Raphson Method
The Newton-Raphson method uses an iterative process to approach one root
of a function. The specific root that the process locates depends on the initial,
arbitrarily chosen x-value. The method was found by English mathematicians,
Isaac Newton and Joseph Raphson. ("Newton-Raphson Method", 2020)
• Gaussian Elimination
The fundamental idea is to add multiples of one equation to the others in order
to eliminate a variable and to continue this process until only one variable is
left. Once this final variable is determined, its value is substituted back into
the other equations in order to evaluate the remaining unknowns. The method
was found by German mathematician, Johann Carl Friedrich Gauss (1777-
1855). ("Gaussian Elimination", 2020)
• Gauss – Seidel Iterative Method
The Gauss-Seidel Method is an improved version of the Jacobi iteration
method, also known as the successive displacement method. This method was
founded by Johann Carl Friedrich Gauss (1777–1855) and Philipp Ludwig
von Seidel (1821–1896). The difference between the Gauss–Seidel and Jacobi
methods is that the Jacobi method uses the values obtained from the previous
step while the Gauss–Seidel method always applies the latest updated values
during the iterative procedures. (Yang, 2018)
1.4 Scope
This project will solely focus on numerical analysis of nonlinear equations and
simultaneous linear algebraic equations. For the nonlinear equations, a beam deflection
problem will be solved using two methods: Bisection method and Newton – Raphson
Method. For the simultaneous linear algebraic equations, a finite element method
problem will be solved using two methods: Gaussian elimination and Gauss - Seidel
Iteration method. For each method, the results will be compared to determine the
accuracy to the true value.
2.0 Methodology
2.1 Algorithm & Flowchart
2.1.1 Bisection Method
1. Find points a and b such that a < b and f(a)•f(b) < 0
𝑎+𝑏
2. Take the interval [a, b] and find the next value xo =
2
3. If f(x0) = 0 then x0 is an exact root, else if 𝑓(𝑎) ∙ 𝑓(𝑥0 ) < 0 then 𝑏 = 𝑥0 , else
if 𝑓(𝑥0 ) ∙ 𝑓(𝑏) < 0 then 𝑎 = 𝑥0 .
4. Repeat steps 2 & 3 until 𝑓(𝑥𝑖 ) = 0 or |𝑓(𝑥𝑖 )| ≤ 𝐴𝑐𝑐𝑢𝑟𝑎𝑐𝑦
Fig 2.1 Bisection Method Flowchart
2.1.2 Newton Raphson Method
1. Find points a and b such that a<b and f(a)⋅f(b)<0.
𝑎+𝑏
2. Take the interval [a, b] and find the next value 𝑥𝑜 =
2
3. Here, the column vector in the variables X is carried along for labeling
the matrix rows.
Now, perform elementary row operations to put the augmented matrix
into the upper triangular form
4. Solve the equation of the th row for , then substitute back into the
equation of the (k-1)st row to
obtain a solution for Xk-1, etc., according to the formula
Theoretical Solution:
𝛴𝑀𝐴 = 0
40 – 10 – B (6) = 0
B = 5 kN
𝛴𝐹𝑦 = 0
A = - 5 kN
𝑑2 𝑦
𝐸𝐼 = 𝑀 = 40 − 5𝑥
𝑑𝑥 2
𝑑𝑦 5𝑥 2
𝐸𝐼 = 40𝑥 − +4
𝑑𝑥 2
40𝑥 2 5𝑥 3
𝐸𝐼𝑦 = − + 𝐶1𝑥 + 𝐶2
2 6
At x=0, y=0
C2=0
At x=6m, y=0
40(6)2 5(6)3
0= − + 𝐶1(6)
2 6
𝐶1 = −90 𝑘𝑁𝑚2
𝑑𝑦 1
= (40𝑥 − 2.5𝑥 2 − 90)
𝑑𝑥 𝐸𝐼
𝑑𝑦
For maximum deflection =0
𝑑𝑥
40𝑥 − 2.5𝑥 2 − 90 = 0
x= 2.708 m
1 5
𝑦𝑚𝑎𝑥 = (20(2.708)2 − (2.708)3 − 90(2.708))
𝐸𝐼 6
𝐸𝐼 = 200𝑥109 𝑥39.9𝑥10−6
𝑦𝑚𝑎𝑥 = −14.2𝑚𝑚
For this beam problem, the point (x) of maximum deflection can be found using the
Bisection and Newton-Raphson method. The iteration process will be done using
codes that correspond with the methods, written in MATLAB. The iterations will also
be presented for comparison to the value found using the theoretical solution.
end
fprintf('The root is: %f\nThe number of bisections: %d\n',x1,i)
x0=1;
maxIter = 50;
tolX = 1e-4;
x = x0;
xold = x0;
fprintf('Iteration x f df f/df\n')
for i = 1:maxIter
f = -2.5*x^2 + 40*x - 90;
df = -5*x + 40;
div = f/df;
x = x - f/df;
err(i) = abs(x-xold);
xold = x;
fprintf('%f %f %f %f %f\n',i,x,f,df,div);
if (err(i)<tolX)
break;
end
end
fprintf('The Root is: %f\nNumber of Iterations: %f\nError:
%f\n',xold,i,err(i));
A tapered bar of a circular cross section is given as below. The length of the bar is 1 m and the
radius varies as r(x) = 0.050 − 0.040x where r and x are in meters. The Young’s modulus for the
material is given as 100 MPa with both ends of the bar fixed and a point load of 10 kN being
applied at the centre of the bar. Set up the stiffness matrix, load and displacement vectors using
four bar elements with equal length. (Note: averaged element cross section area is assumed to be
�𝐴𝑖 𝐴𝑗 = 𝜋𝑟𝑖 𝑟𝑗 )
Solution:
0.25 m
0.25 m
0.25 m 0.25 m
10 kN
1 2 3 4 5
r1=0.05, r2=0.04, r3=0.03, r4=0.02, r5=0.01
𝐴1 = 𝜋(0.05)(0.04) = 2𝑥10−3 𝜋 𝑚2
𝐴2 = 𝜋(0.04)(0.03) = 1.2𝑥10−3 𝜋 𝑚2
𝐴3 = 𝜋(0.03)(0.02) = 6𝑥10−4 𝜋 𝑚2
𝐴4 = 𝜋(0.02)(0.01) = 2𝑥10−4 𝜋 𝑚2
100𝑥106 𝑥2𝑥10−3 𝜋 1 −1
K1= � �
0.25 −1 1
100𝑥106 𝑥1.2𝑥10−3 𝜋 1 −1
K2= � �
0.25 −1 1
100𝑥106 𝑥6𝑥10−4 𝜋 1 −1
K3= � �
0.25 −1 1
100𝑥106 𝑥2𝑥10−4 𝜋 1 −1
K4= � �
0.25 −1 1
2 −2 0 0 0
⎡−2 3.2 −1.2
−4 0 0 ⎤
10𝑥10 𝜋 ⎢ ⎥
[𝐾] = 0 −1.2 1.8 −0.6 0 ⎥
0.25 ⎢
⎢0 0 −0.6 0.8 −0.2⎥
⎣0 0 0 −0.2 0.2 ⎦
𝑅1 0 2 −2 0 0 0 0
⎧ ⎫ ⎧ ⎫ ⎡ ⎤ ⎧ ⎫
⎪ 0 ⎪ ⎪ 0 ⎪ 10𝑥10−4 𝜋 ⎢−2 3.2 −1.2 0 0 ⎪𝑄2⎪
⎥
0 + 10000 = 0.25 ⎢ 0 −1.2 1.8 −0.6 0 ⎥ 𝑄3
⎨0⎬ ⎨ 0 ⎬ ⎢0 0 −0.6 0.8 −0.2⎥ ⎨ ⎬
⎪ ⎪ ⎪ ⎪ ⎪𝑄4⎪
⎩𝑅5⎭ ⎩ 0 ⎭ ⎣0 0 0 −0.2 0.2 ⎦ ⎩ 0 ⎭
0 40.2124 −15.0796 0 𝑄2
�10000� = �−15.0796 22.6195 −7.5398� �𝑄3�
0 0 −7.5398 10.0531 𝑄4
The method for determining the nodal displacements can be done using Gaussian Elimination
and Gauss-Seidel Iteration Method.
%Back-Substitution
Q = zeros(3,1);
Q(3) = KF(3,end)/KF(3,3);
Q(2) = ( KF(2,end)-KF(2,3)*Q(3) ) / KF(2,2);
Q(1) = ( KF(1,end)-KF(1,2)*Q(2)-KF(1,3)*Q(3) ) / KF(1,1);
N = 25;
err = 0.01;
Q = [0 0 0];
QQ(1,:) = Q;
fprintf('Iteration x1 x2 x3\n');
for k = 2 : N
for i = 1:n
s =0;
for j = 1:n
if j ~= i
s = s + K(i,j) * Q(j);
end
end
Q(i) = (1/K(i,i))*(F(i) - s);
end
disp([' ' num2str(k) ' ' num2str(Q) ' ']);
QQ(k,:) = Q; kk = k;
Err = abs(max(QQ(k,:)-QQ(k-1,:))); if Err < err, break; end
end
disp(['The Roots are [ ' num2str(Q) '], with accuracy: ' num2str(Err) ' ,and
' num2str(kk),' iterations'])
5.0 Conclusion
In conclusion, the objective of this project was to implement MATLAB coding skills in solving
Real-Life Based problems with the aid of Numerical Methods. The problems that were
introduced were a beam deflection problem and 1-D Bar finite element problem. The problems
involved a solving non-linear equation and a system of linear algebraic equations, respectively.
For each problem, there were two numerical methods which were used for numerical analysis.
The first problem was analyzed using the bisection method and the Newton-Raphson method
which both yielded the same exact value very accurate to the true value. The only difference is
that the Newton-Raphson method took lesser iterations making it more efficient. The second
problem was analyzed using Gaussian Elimination and the Gauss-Seidel Iteration method in
which the roots were found with 11 iterations. The values yielded between the two methods were
precise and within the accuracy range. Hence, the aim of this project of implementing MATLAB
coding with the aid of Numerical Methods was achieved.
6.0 References
Shah, P. (2020). Bisection method Algorithm & Example-1. Retrieved 16 May 2020, from
https://atozmath.com/example/CONM/Bisection.aspx?he=e&q=bi
Bisection Method Algorithm and Flowchart | Code with C. (2020). Retrieved 16 May 2020, from
https://www.codewithc.com/bisection-method-algorithm-flowchart/
Gauss Seidel Iteration Method Algorithm. (2020). Retrieved 16 May 2020, from
https://www.codesansar.com/numerical-methods/gauss-seidel-iteration-algorithm.htm
Bisection Method - Definition, Procedure, and Example. (2020). Retrieved 25 May 2020, from
https://byjus.com/maths/bisection-method/
Yang, K. (2018). Stepping Through Finite Element Analysis. Basic Finite Element Method As
Applied To Injury Biomechanics, 281-308. doi: 10.1016/b978-0-12-809831-8.00007-6