Skip to content

subashini-debug/LU-Decomposition

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

LU Decomposition

AIM:

To write a program to find the LU Decomposition of a matrix.

Equipments Required:

  1. Hardware – PCs
  2. Anaconda – Python 3.7 Installation / Moodle-Code Runner

Algorithm

  1. Import numpy

  2. Import lu from scipy.linalg

  3. Get the inputs using numpy.array

  4. Use the function lu() to find the L and U matrices

Program:

(i) To find the L and U matrix

/* Program to find the L and U matrix. Developed by: Subashini K RegisterNumber: 212225240160 */


import numpy as np

from scipy.linalg import lu

A=np.array(eval(input()))

P,L,U=lu(A)

print(L)

print(U)

(ii) To find the LU Decomposition of a matrix

/* Program to find the LU Decomposition of a matrix. Developed by: Subashini K RegisterNumber: 212225240160 */

import numpy as np

from scipy.linalg import lu_factor,lu_solve

A=np.array(eval(input()))

B=np.array(eval(input()))

lu,piv=lu_factor(A)

X=lu_solve((lu,piv),B)

print(X)

Output:

(i) To find the L and U matrix

Screenshot (233) Screenshot (234)

(ii) To find the LU Decomposition of a matrix

Screenshot (235)

Result:

Thus the program to find the LU Decomposition of a matrix is written and verified using python programming.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%