0% found this document useful (0 votes)
17 views1 page

File: /home/dipankar/dipankar/gelimination.f90 Page 1 of 1: Program Implicit None

This document contains the source code for a program that performs Gaussian elimination on a 3x4 matrix to solve a system of 3 linear equations with 3 unknowns. The program reads in the input matrix, performs pivoting and Gaussian elimination to transform the matrix into row echelon form, and then back-substitutes to solve for the values of the 3 unknowns. It outputs the eliminated matrix and the solution to the linear system. The code uses basic linear algebra operations like addition, subtraction, multiplication and division on the matrix elements within nested loops to perform the elimination and back-substitution steps of Gaussian elimination.

Uploaded by

Pooja Kumari
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)
17 views1 page

File: /home/dipankar/dipankar/gelimination.f90 Page 1 of 1: Program Implicit None

This document contains the source code for a program that performs Gaussian elimination on a 3x4 matrix to solve a system of 3 linear equations with 3 unknowns. The program reads in the input matrix, performs pivoting and Gaussian elimination to transform the matrix into row echelon form, and then back-substitutes to solve for the values of the 3 unknowns. It outputs the eliminated matrix and the solution to the linear system. The code uses basic linear algebra operations like addition, subtraction, multiplication and division on the matrix elements within nested loops to perform the elimination and back-substitution steps of Gaussian elimination.

Uploaded by

Pooja Kumari
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/ 1

File: /home/dipankar/dipankar/gelimination.

f90 Page 1 of 1

program GaussElimination
implicit none
real,dimension(3,4)::a
real ,dimension(3)::x
real ::m,p,amax,xf,temp
integer ::q,i,j,k,n=3
!................Read Input Matrix........................
write(*,*)"............A(3x3) B(3x1) matrix."
open(1,file="input.dat")
read(1,*)((a(i,j),j=1,4),i=1,3)
do i=1,3
write(*,*)(a(i,j),j=1,4)
end do
do k=1,n-1
!...........Pivoting
Part..................................................
amax=abs(a(k,k))
q=k
do i=k+1,n
xf=abs(a(i,k))
if(xf>amax)then
amax=xf
q=i
end if
end do
if(q/=k)then
do j=1,n+1
temp=a(k,j)
a(k,j)=a(q,j)
a(q,j)=temp
end do
end if
!............Now Introduce Gauss Elimination Method.........
do i = k+1,n
m= a(i, k) / a(k, k)
do j =1,n+1
a(i, j) = a(i, j) - m* a(k, j)
end do
end do
end do
write(*,*)"................Eliminated Matrix....."
do i=1,3
write(*,*)(a(i,j),j=1,4)
end do
!..............Solution Part...............................
do i=n,1,-1
p=0
do j=i+1,n
p=p+a(i,j)*x(j)
end do
x(i)=(1/a(i,i))*(a(i,n+1)-p)
end do
!...............Result Is..............................
write(*,*)".Solution Of Linear Differential Equation ."
write(*,*)(x(i),i=1,3)
end program GaussElimination

You might also like