Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Flowchart

Start

Clear the command window

Enter the number of equations, n

Enter the elements of matrix A

Enter the elements of matrix B

Create a nxn null matrix, X

Triangularization Loop Starts for i=1 to n-1

Partial Pivoting Loop Starts for c=1 to n

for d=c to n

for e=d+1 to n

No
Is A(d,c) < A(e,c)

Yes

min_a = A([d e]] , :)

A([ d e] , :) = A([ e d]) , :)

A([e d] , :) = min_a

min_b = B([d e]] , :)

B([ d e] , :) = B([ e d]) , :)

B([e d] , :) = min_b

E A B C D F
E A B C D F

Next e

Next d

Partial Pivoting Loop Ends Next c

for j=i+1 to n-1

Prod = A( j ,i ) / A( i ,i )

for k= i to n

A ( j , k ) = A ( j , k ) - Prod * A ( i , k )

Next k

B ( j , 1 ) = B ( j , 1 ) - Prod * B ( i , 1 )

Next j

Triangularization Loop Ends Next i

Display matrix A after triangularization

Display matrix B after triangularization

X(n,1)=B(n,1)/A(n,n)

D
D

Back Substitution Loop for p= n-1 to 1


Starts with decreament of 1

sum = 0

for q = 1 to n-1

No
Is q + p < n

Yes

sum = sum + A ( p , p+q ) * X ( p+q , 1 )

Next q

X ( p , 1) =(B ( p , 1 ) - sum) / A ( p, p )

Back Substitution Loop Ends Next p

Display the solution matrix X

Stop

You might also like