LU Decomposition to factor a square matrix A

Dr. K. G. TeBeest

Load the linalg library package:

> with( linalg ) :

Define square matrix A:

> A := matrix( [ [ 2, 4, 6, 8 ] , [ 4, 12, 36, 32 ] , [ -8, 4, 93, 63 ] , [ 12, 12, -42, 32 ] ] ) ;

A := matrix([[2, 4, 6, 8], [4, 12, 36, 32], [-8, 4, 93, 63], [12, 12, -42, 32]])


Use Maple's
LUdecomp command to factor A. This example also stores L and U:

> LUdecomp( A, L = 'L', U = 'U' ) ;

matrix([[2, 4, 6, 8], [0, 4, 24, 16], [0, 0, -3, 15], [0, 0, 0, 2]])

Display matrix L:

> evalm( L ) ;

matrix([[1, 0, 0, 0], [2, 1, 0, 0], [-4, 5, 1, 0], [6, -3, 2, 1]])

Display matrix U:

> evalm( U ) ;

matrix([[2, 4, 6, 8], [0, 4, 24, 16], [0, 0, -3, 15], [0, 0, 0, 2]])

Let's multiply L times U to verify that the product equals A:

> multiply( L, U ) ;

matrix([[2, 4, 6, 8], [4, 12, 36, 32], [-8, 4, 93, 63], [12, 12, -42, 32]])


Created by
Dr. Kevin G. TeBeest
Associate Professor of Applied Mathematics