Computational Methods: Test Program For Chasing Method Developed in Matlab
Computational Methods: Test Program For Chasing Method Developed in Matlab
(MATH600807)
Assignment-2
Test Program for Chasing Method Developed in
Matlab
Submitted By
Mujtaba Mujahid, Phd Scholar
Student id: 4119999176
Nuclear Safety and Operation Lab (NUSOL)
Department of Nuclear Science and Technology
Date of Submission
November 29, 2020
Table of Contents
Page 1 of 5
1 Problem Formulation
Here the Test example is considered such that the coefficient matrix A be the 10 × 10 tridiagonal
matrix given by ai,i = 2, ai,i-1 = -1, ai-1,i = -1, for each i = 2; · · · ; 9, and a1,1 = a10,10 = 2; a1,2 = a10,9
= -1. Assume d be the ten-dimensional column vector given by d1 = d10 = 1 and di = 0, for each i
= 2, 3 · · · , 9. This problem will be solved with the help of Chasing Method as described below.
2 Chasing Method
If the coefficient matrix A = (aij) has a special structure, such as aij = 0 for all pairs
(i,j) satisfying |i – j| > 1. Thus, in the ith row, only ai,i-1; ai,i; ai,i+1 can be different
from 0.
Let be the system of tridiagonal matrix represented as
with the condition |b1|>|c1|, |bi| >= |ai| +|ci| for i= 2,……n-1 and |bn|>|an|. The pivoting technique
will not be applied since bi| >= |ai| +|ci|.
The Dolittle factorization applied to solve the tridiagonal system is known as Chasing method. A
tridiagonal matrix is factorized by dolittle method as
Page 2 of 5
𝑳𝑹𝒙 = 𝒅
Firstly from the equation 𝐿𝑦 = 𝑑, the value of y is calculated. In the end the value of x will be
calculated from the equation 𝑅𝑥 = 𝑦.
3 Matlab Code
The Matlab code for the Test Example described in Section1
%The following code is written by Mujtaba Mujahid, Phd Scholar
%Student id: 4119999176
%Nuclear Safety and Operation Lab (NUSOL)
%Assignment #2: Test Program for Chasing Method
% Test Example : Here the Test example is considered such that the coefficient matrix A be the
10 × 10 tridiagonal matrix given by ai,i = 2, ai,i-1 = -1, ai-1,i = -1, for each i = 2; · · · ; 9, and a1,1 =
a10,10 = 2; a1,2 = a10,9 = -1. Assume d be the ten-dimensional column vector given by d1 = d10 = 1
and di = 0, for each i = 2, 3 · · · , 9.
clc
clear all
A= zeros (10,10); %Initializing Matrix A as a zero matrix of 10*10
D= ones (10,1); %Initializing Matrix D as a ones matrix of 10*1
[n,~]= size(A); %n represents the number of rows in matrix A
End
for i=2:1:9
D(i)=0; % Assigning the values to the Matrix D
end
for k=2:1:n
a(k)=-1;
end
for m=1:1:n-1
c(m)=-1;
end
for k=1:1:n
b(k)=2;
r(k)=0;
Page 3 of 5
Y(k)=0;
End
%% Solving the Test Example using In-built functions
4 Results
The results of the above mentioned example is tabulated below
Test Example Result using Result Result using
Matrices General using Mldivide
Algorithm of Linsolve function in
Gaussian function in Matlab
Elimination Matlab
scripted in
Matlab
z=
x= f=
Page 4 of 5
5 Comments
The Test Program of Chasing Method developed in Matlab has the following characteristics
1) First of all using For Loops, The matrix A and D has been assigned values
2) Then the value of values of tridiagonal has been stored in vector a(i), b(i) and c(i)
3) From the equation 𝐿𝑦 = 𝑑, the value of y is calculated and after that the value of x will
be calculated from the equation 𝑅𝑥 = 𝑦.
4) The result of the test program developed in Matlab is compared with the in-built
functions (Linsolve & Mldivide) and it is presented in Section 4.
5) The total Computation Time (Elapsed time) found (using tic toc commands) from the
inbuilt function (f = linsolve (A,D)) is approximately 0.0134 sec.
6) The total Computation Time (Elapsed time) found (using tic toc commands) from the
inbuilt function (f = mldivide (A,D)) is approximately 0.0166 sec.
7) The total Computation Time (Elapsed time) found (using tic toc commands) from the test
program developed in Matlab using the Chasing Method is approximately 0.0357 sec.
8) The total Computation Time (Elapsed time) using the test program is more than the
computation time of in-built functions because in the test program, the data from the
tridiagonal was fetched and stored in the variables a(i), b(i) and c(i), so it took some extra
time.
Page 5 of 5