# [Maxima] LU Decomposition

Dotan Cohen dotancohen at gmail.com
Wed Oct 21 02:45:00 CDT 2009

```2009/10/20 Raymond Toy <raymond.toy at stericsson.com>:
> Dotan Cohen wrote:
>>> Try
>>>
>>> ? lu_factor;
>>>
>>>
>>
>> Naturally, I found lu_factor and get_lu_factor which were mentioned in
>> the man pages. However, I cannot figure out exactly how to use them.
>> lu_factor(M); did not work, and it is not clear to me from the man
>> pages exactly what I need to do. It looks like I need to use lu_factor
>> first and then enter that output into get_lu_factor, but I cannot
>> figure out how to do that.
>>
> Oh.  Here's what I did.  The description of get_lu_factor seems clear to me.
>
> (%o48) matrix([1,2],[3,4])
> (%i49) lu_factor(%);
> (%o49) [matrix([1,2],[3,-2]),[1,2],generalring]
> (%i50) get_lu_factors(%);
> (%o50) [matrix([1,0],[0,1]),matrix([1,0],[3,1]),matrix([1,2],[0,-2])]
>
> And %o50[1] . %o50[2] . %o50[3] gives the original matrix.
>

Thanks, Ray. I think I found the problem, I was using the matrix
identifier (M) instead of the % symbol:

(%i1) M=matrix([1,2],[3,4]);
[ 1  2 ]
(%o1)                            M = [      ]
[ 3  4 ]
(%i2) LU_FACTOR (M);
(%o2)                            LU_FACTOR(M)
(%i3) M=matrix([1,2],[3,4]);
[ 1  2 ]
(%o3)                            M = [      ]
[ 3  4 ]
(%i4) LU_FACTOR (%);
[ 1  2 ]
(%o4)                       LU_FACTOR(M = [      ])
[ 3  4 ]

Why doesn't it work when I use the identifier (variable name M)?

--
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

```