# LU Factorization

In Matlab there are several built-in functions provided for matrix factorization (also called decomposition).
 The name of the built-in function for a Lower-Upper decomposition is 'lu'. To get the LU factorization of a square matrix A, type the command '[L, U] = lu(A)'. Matlab returns a lower triangular matrix L and an upper triangular matrix U such that L*U = A.

Suppose that we need to perform a factorization on

A= [ 1 2 -3
-3 -4 13
2 1 -5]

We can verify that if matrix

L = [ 1 0 0
-3 1 0
2 -1.5 1]

and matrix

U = [1 2 -3
0 2 4
0 0 7]

Then, factors of A are L and U, that is: A = L*U

The decomposition of the matrix A is an illustration of an important and well known theorem. If A is a nonsingular matrix that can be transformed into an upper diagonal form U by the application or row addition operations, then there exists a lower triangular matrix L such that A = LU.

Row addition operations can be represented by a product of elementary matrices. If n such operations are required, the matrix U is related to the matrix A in the following way:

U = En En-1 ... E2 E1 A

The lower triangular matrix L is found from

L = E1-1 E2-1 ... En-1

L will have ones on the diagonal. The off-diagonal elements are zeros above the diagonal, while the elements below the diagonal are the multipliers required to perform Gaussian elimination on the matrix A. The element lij
is equal to the multiplier used to eliminate the (i, j) position.

Example:

In Matlab, let's find the LU decomposition of the matrix

A = [-2 1 -3; 6 -1 8; 8 3 -7]

Write this instruction in the command window or within a script:

[L, U] = lu(A)

L =
-0.2500 -0.5385 1.0000
0.7500 1.0000 0
1.0000 0 0

U =
8.0000 3.0000 -7.0000
0 -3.2500 13.2500
0 0 2.3846

We can test the answer, by typing

L*U

And, finnally, the Matlab answer is:

ans =
-2.0000 1.0000 -3.0000
6.0000 -1.0000 8.0000
8.0000 3.0000 -7.0000

>>

Showing that A = L*U, indeed.

From 'LU Factorization' to 'Matlab home'

From 'LU Factorization' to 'Linear Algebra Menu'

 Top SVD Factorization

## Related pages

rc charging and dischargingimpulse functioncalculate nominal interest rateplotting piecewise functions in matlabconvert binary to gray codegenerate fibonacci seriesnumerical bisection methodmatlab string functionsconvert binary to decimal convertersolving piecewise functionsdepreciation spreadsheetpiecewise defined functiondefine time constant of rc circuitcalculator for factorialsscilab filter designsolve equation with matlabhow to create table in matlabdecimal fraction to binary convertermatlab for loop syntaxoctal to decbinary and hexadecimal number systemstrapezoidal matlabcurve fit tool matlabmatlab dot plotmatlab program for fourier seriessquare root approximation formulacramer rule 3x3inverse a matrix in matlabdifferential equation rc circuithow to create a histogram in matlabdelta di diraccalculate depreciation excelconvert letters to asciidecimal octal conversionmatlab histogram examplegray code to binary conversionpolynomial regression in matlablagrange approximationamortization tables for mortgagematlab polyfitdecimals in binarygeneric programingamoritzation tablenormal distribution plot matlabcombinational logicmatlab plot3dratio of consecutive fibonacci numbersprogram factorialtaylor expansion onlineohms law caculatormatlab txthalf life exponential decayamortization table for mortgagedecay formula calculatorascii table for lettersmatlab visualize 3d matrixcalculating factorialsinfinite geometric series definitionhow do you calculate square feet from inchesde morgans lawgauss jordan matricescapacitor charging curvebijection methodplot points in matlabsimpson's rule calculatorscilab programs examplesmatlab invertdemorgans lawsgraphing a piecewise-defined functionc program pascal trianglefitting curve matlabc program to generate pascal trianglematrix card trickbisection method with exampledefinite integral calculator onlineascii values chartpermutations and combination calculatorascii code for azfibonacci trianglescilab programming tutorialfactorial function calculator