Sei sulla pagina 1di 4

MATLAB Command Window Page 1

LU factorization
Input the number of rows: 4
Input the number of columns: 4
Input the entries: 2

A =

Input the entries: 0

A =

2 0

Input the entries: 1

A =

2 0 1

Input the entries: 2

A =

2 0 1 2

Input the entries: 1

A =

2 0 1 2
1 0 0 0

Input the entries: 1

A =

2 0 1 2
1 1 0 0

Input the entries: 0

A =

2 0 1 2
1 1 0 0

Input the entries: 2

A =
MATLAB Command Window Page 2

2 0 1 2
1 1 0 2

Input the entries: 2

A =

2 0 1 2
1 1 0 2
2 0 0 0

Input the entries: -1

A =

2 0 1 2
1 1 0 2
2 -1 0 0

Input the entries: 3

A =

2 0 1 2
1 1 0 2
2 -1 3 0

Input the entries: 1

A =

2 0 1 2
1 1 0 2
2 -1 3 1

Input the entries: 3

A =

2 0 1 2
1 1 0 2
2 -1 3 1
3 0 0 0

Input the entries: -1

A =

2 0 1 2
1 1 0 2
MATLAB Command Window Page 3

2 -1 3 1
3 -1 0 0

Input the entries: 4

A =

2 0 1 2
1 1 0 2
2 -1 3 1
3 -1 4 0

Input the entries: 3

A =

2 0 1 2
1 1 0 2
2 -1 3 1
3 -1 4 3

A =

2 0 1 2
1 1 0 2
2 -1 3 1
3 -1 4 3

L =

2.0000 0 0 0
1.0000 1.0000 0 0
2.0000 -1.0000 1.5000 0
3.0000 -1.0000 2.0000 1.0000

U =

1.0000 0 0.5000 1.0000


0 1.0000 -0.5000 1.0000
0 0 1.0000 0
0 0 0 1.0000

LU =

2 0 1 2
1 1 0 2
2 -1 3 1
MATLAB Command Window Page 4

3 -1 4 3

The inverse of L is

X =

1.0000 -0.0000 -0.5000 -1.0000


-0.0000 1.0000 0.5000 -1.0000
-0.0000 0.0000 1.0000 -0.0000
0.0000 0 -0.0000 1.0000

The inverse of U is

Y =

0.5000 -0.0000 0.0000 0


-0.5000 1.0000 -0.0000 0.0000
-1.0000 0.6667 0.6667 0.0000
-0.0000 -0.3333 -1.3333 1.0000

So the inverse of A is

C =

1.0000 -0.0000 1.0000 -1.0000


-1.0000 1.6667 1.6667 -1.0000
-1.0000 0.6667 0.6667 -0.0000
-0.0000 -0.3333 -1.3333 1.0000

The determinant of the matrix is

A_det =

>>

Potrebbero piacerti anche