Under The Supervision of Prof.Morteza Haghir Chehreghani
Spring 2021
This repository contains Python code to solve systems of linear equations using LU decomposition and forward/backward substitution. The LU decomposition method allows for efficient solving of multiple systems of equations with the same coefficient matrix A but different vectors b.
- Python 3.x
- NumPy library
The input format for the main script is as follows:
The first line contains two integers, n and m, where n is the size of the square matrix A (n x n) and m is the number of different vectors b to solve for. The next n lines contain the rows of matrix A. The following m lines each contain the elements of a vector b.
The output of the main script consists of m lines, where each line contains the solution vector x for the corresponding vector b, printed up to 4 decimal places.
Input:
3 5
5 6 2
4 5 2
2 4 8
18 7 2
4 5 8
15 7 6
11 9 5
13 12 12
Output:
75.0 -64.0 13.5
-14.0 13.0 -2.0
53.0 -45.0 10.0
0.5 1.5 -0.25
-10.0 11.0 -1.5
Enter the path of the image( make sure its in .bmp format)
This is for image 1, the same can be done for others: