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

MN TP05

Uploaded by

belllaa976
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)
10 views1 page

MN TP05

Uploaded by

belllaa976
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

2info Univ_Bouira

TP05_ NM: GAUSS ELIMINATION METHOD (Continued)


Exo_01: GAUSS ELIMINATION Method
Write a python script of the GAUSS elimination method, for this:
- Read the order of the system, the square matrix A and the array Y.
- Use a function to triangularize the matrix A.
- Use a function to calculate the solution X.
import numpy as np
# Function to perform Gaussian elimination and convert the matrix to upper triangular form
def Triang(m, Y):
…………………………………………..
return m, Y
# Function to perform back substitution and find the solution
def backSub(m, Y):
…………………………………………..
return X
# Input the order of the system
n = int(input("Enter the system order: "))

# Initialize and input matrix A


…………………………………………..
# Initialize and input vector Y
…………………………………………..

# Apply Gaussian elimination to transform A into an upper triangular matrix


A, Y = Triang(A, Y)

# Perform back substitution to solve for X


X = backSub(A, Y)

# Output the solution vector X


print("Solution X:")
print(X)
2 4 −2 0 𝑥0 −6 1 2 −1 0 𝑥0 −3
1 3 0 1 𝑥1 0 0 1 1 1 𝑥1 3
Exp to test: (
3 −1 1 2
) (𝑥 ) = ( ) ==>
2 8
(
0 0 1 0.82
) (𝑥 ) = (
2 3.45
)
0 −1 2 1 𝑥3 6 0 0 0 1 𝑥3 3

Exo_02: GAUSS Method with pivot maximization


Write a python script that solves a linear equations system using the Gauss Elimination Method
with pivot maximization.

1/1

You might also like