0% found this document useful (0 votes)
5 views3 pages

Assignment 1 PDF

The document is an assignment submission for the course ME-864 in Computational Fluid Dynamics at the National Institute of Technology, Karnataka. It includes MATLAB code for solving a third-order polynomial using Gaussian elimination, with results showing the coefficients A, B, C, and D. The assignment also discusses a potential issue with the method when the first element of the augmented matrix is zero and describes a workaround implemented in the code.

Uploaded by

ratnesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Assignment 1 PDF

The document is an assignment submission for the course ME-864 in Computational Fluid Dynamics at the National Institute of Technology, Karnataka. It includes MATLAB code for solving a third-order polynomial using Gaussian elimination, with results showing the coefficients A, B, C, and D. The assignment also discusses a potential issue with the method when the first element of the augmented matrix is zero and describes a workaround implemented in the code.

Uploaded by

ratnesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment 1 (Date – 13/01/2025)

Submitted in partial fullfilment of the course

ME-864

COMPUTATIONAL FLUID DYNAMICS

in

THERMAL ENGINEERING

DEPARTMENT OF MECHANICAL ENGINEERING (M.TECH)


NATIONAL INSTITUTE OF TECHNOLOGY, KARNATAKA
SURATHKAL, MANGALORE-575025

Submitted By – Submitted To –

Ratnesh Kumar Sharma Dr.Ranjith M.

Roll No.-242TH013

Resistration No. - 2420373


Matlab code

% solve third order polynomial with the help of Gaussian elimination


% methoid.
clc;
clear;
tic
A = [27 9 3 1;1 1 1 1;8 4 2 1;0 0 0 1;];
B = [58;14;29;7;];
N = length(B);
a = zeros(N,1);
AUG_M = [A B];
% forward elimination
for i = 1:N-1

for k = i+1:N
Ratio = AUG_M(k,i)/AUG_M(i,i);

AUG_M(k,:) = AUG_M(k,:) - Ratio * AUG_M(i,:);


end
end
AUG_M
% backward substitution
a(N) = AUG_M(N,N+1)/AUG_M(N,N);
for j = N-1:-1:1
a(j) = (AUG_M(j,N+1) - AUG_M(j,j+1:N) * a(j+1:N))/AUG_M(j,j);
end
a
% Result

fprintf('Solution: A = %.2f, B = %.2f, C = %.2f, D = %.2f\n', a(1), a(2), a(3),


a(4));
toc
Results

a=

1.0000

1.0000

5.0000

7.0000

Solution: A = 1.00, B = 1.00, C = 5.00, D = 7.00

Cpu_ time is 0.002544 seconds.

Comment

In Gauss elimination method, the argumented matrix should be in upper


tringular matrix or echelon form.If the first element of the argumented matrix in
the given problem is zero then the ratio will become infinite and this method
will fail.Now to solve this problem,In this problem, row R1 has changed by
rowR4 and row R4 has changed by R1.

You might also like