0% found this document useful (0 votes)
15 views2 pages

EXPT6

This document summarizes the Gaussian elimination method to solve systems of linear equations. It uses partial pivoting to calculate the upper triangular matrix and back substitution to solve for the roots. The algorithm takes a matrix A of coefficients and a matrix B of constants as input. It performs partial pivoting if needed, calculates the upper triangular form of A, and then uses back substitution on the transformed matrices to solve for the roots x.

Uploaded by

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

EXPT6

This document summarizes the Gaussian elimination method to solve systems of linear equations. It uses partial pivoting to calculate the upper triangular matrix and back substitution to solve for the roots. The algorithm takes a matrix A of coefficients and a matrix B of constants as input. It performs partial pivoting if needed, calculates the upper triangular form of A, and then uses back substitution on the transformed matrices to solve for the roots x.

Uploaded by

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

%Expt no.

6 Guass Elimination Method


%Date-- 11-09-2014
clear all;
clc;
f=0;
while(f==0)
A = input('Enter the coefficinets of variable in matrix form in [
; ]');
B = input('Enter the constants in matrix form in[ ; ; ]');
z=size(A);
n=z(1);
%PARTIAL PIVOTING
w=0;
for q=1:n
for m=q+1:n
if A(q,q)>A(m,q)
else

w=w+1;
F=B(m,1);
B(m,1)=B(q,1);
B(q,1)=F;
for y=1:n
H(q,y)=A(m,y);
A(m,y)=A(q,y);
A(q,y)=H(q,y);
end;

end;

end;
end;

if w==0
disp('Pivoting is not needed')
else
disp('Pivoting is done')
disp('After pivoting the matrices are--')
end;
A
B
%UPPER TRIANGULAR MATRIX
for i=1:n
B(i,1)=B(i,1)/A(i,i);
for j=n:-1:1
A(i,j)=A(i,j)/A(i,i);
end;
for k=i+1:n
B(k,1)=B(k,1)-B(i,1)*A(k,i);
for l=n:-1:1
A(k,l)=A(k,l)-A(i,l)*A(k,i);
end;
end;
end;

%BACK SUBSTITUION
x(n,1)=B(n,1)/A(n,n);
for i=n-1:-1:1
s=0;
for j=i+1:n
s=s+A(i,j)*x(j,1);
end;
x(i,1)=(B(i,1)-s)/A(i,i);
end;
%DISPLAYING ROOTS
disp('The roots are--')
x
f=input('Enter 0 to continue or 1 to exit');
end;

You might also like