# On the LU factorization

**URL:** <https://discourse.julialang.org/t/on-the-lu-factorization/75066>\
**Category:** Numerics\
**Tags:** question, linearalgebra\
**Created:** [January 23, 2022, 1:22pm UTC](https://discourse.julialang.org/t/on-the-lu-factorization/75066 "2022-01-23T13:22:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![scheiber\_erno](https://avatars.discourse-cdn.com/v4/letter/s/ecd19e/32.png) [@scheiber\_erno](https://discourse.julialang.org/u/scheiber_erno)\
**Post date:** [January 23, 2022, 1:22pm UTC](https://discourse.julialang.org/t/on-the-lu-factorization/75066/1 "2022-01-23T13:22:06Z")

</div>

What is wrong with my code ? It works well six years ago.  
It is the case of a singular matrix.  
I review the following exercise: Compute the LU factorization of the matrix  
A=[1 2 -1 3 2;2 4 -2 5 1;-1 -2 1 -3 -4;3 6 2 10 7; 1 2 4 0 4].  
The used code is:

using LinearAlgebra  
A=[1 2 -1 3 2;2 4 -2 5 1;-1 -2 1 -3 -4;3 6 2 10 7; 1 2 4 0 4].  
(L,U,p)=lu(A)  
Error message: Error: SingularException

and  
(L,U,p)=lu(A,check=false)  
Error message: Failed factorization of type LU(Float64, Matrix(Float64))

When the matrix is not singular then the lu factorizarion works  
without problem.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [January 23, 2022, 1:29pm UTC](https://discourse.julialang.org/t/on-the-lu-factorization/75066/2 "2022-01-23T13:29:20Z")

</div>

To force it to proceed for a singular `A`, you can use `(L,U,p)=lu(A, check=false)`. Note that the `U` factor has a zero entry on the diagonal in this case, due to the fact that your matrix `A` is singular.
