# Zero pivot in LU factorization

**URL:** https://community.freefem.org/t/zero-pivot-in-lu-factorization/4102
**Category:** General Discussion
**Created:** [October 16, 2025, 5:51am UTC](https://community.freefem.org/t/zero-pivot-in-lu-factorization/4102 "2025-10-16T05:51:51Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![RNlao](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/rnlao/32/2070_2.png) [@RNlao](https://community.freefem.org/u/RNlao)
#### Post date: [October 16, 2025, 5:51am UTC](https://community.freefem.org/t/zero-pivot-in-lu-factorization/4102/1 "2025-10-16T05:51:51Z")

</div>

Dear FreeFEM community,

I‘m new to Freefem and I have been trying to conduct a resolvent analysis with incompressible flow. When I use the KSPSolve to get the inverse matrix, I met a problem

```auto
[0]PETSC ERROR: Zero pivot in LU factorization: 

[0]PETSC ERROR: Zero pivot row 12 value 0. tolerance 2.22045e-14

```

Now I have no idea to resolve this problem. Is there something wrong with my code or matrix construction? I have attached my code and a test case of NACA0012.

[test.zip](https://community.freefem.org/uploads/short-url/nvuiDroqiVnyi8cDuIG7x7qSN9f.zip) (463.7 KB)  
Best,  
Lao

---

<div class="post-metadata">

### Author: ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)
#### Post date: [October 16, 2025, 4:15pm UTC](https://community.freefem.org/t/zero-pivot-in-lu-factorization/4102/2 "2025-10-16T16:15:28Z")

</div>

Try `-pc_factor_mat_solver_type mumps` as an additional option.

---

<div class="post-metadata">

### Author: ![RNlao](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/rnlao/32/2070_2.png) [@RNlao](https://community.freefem.org/u/RNlao)
#### Post date: [October 17, 2025, 8:47am UTC](https://community.freefem.org/t/zero-pivot-in-lu-factorization/4102/3 "2025-10-17T08:47:31Z")

</div>

> [@prj](#):
>
> `-pc_factor_mat_solver_type mumps`

I get the same error after I add the additional option.

```auto
=== Solving for omega = 5.000000000000e-01 ===

  **Warning: set default solver to UMFPACK

  -- discontinuous Galerkin =0 size of Mat =0 Bytes

  -- int (nQP: 7 ) in Optimized = 1, all

  -- CPU init assemble mat 2.099999999994e-05 s

  -- CPU assemble mat 3.052290000000e-01 s

  -- discontinuous Galerkin =0 size of Mat =1583028 Bytes

  -- int (nQP: 7 ) in Optimized = 1, all

  -- CPU init assemble mat 1.600000000002e-05 s

  -- CPU assemble mat 5.736000000000e-02 s

Warning: -- Your set of boundary condition is incompatible with the mesh label.

Warning: -- Your set of boundary condition is incompatible with the mesh label.

    ~HashMatrix: Mean collision in hash: 1.391862640375e+00 0x600003d04000 rank: 0 matmul 0.000000000000e+00s

[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------

[0]PETSC ERROR: Zero pivot in LU factorization: 

[0]PETSC ERROR: Zero pivot row 12 value 0. tolerance 2.22045e-14

```

Does this error occur because I constructed a singular matrix? If the matrix is singular, does it mean that I constructed the wrong matrix or that I can’t compute my problem that way.

---

<div class="post-metadata">

### Author: ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)
#### Post date: [October 17, 2025, 9:25am UTC](https://community.freefem.org/t/zero-pivot-in-lu-factorization/4102/4 "2025-10-17T09:25:12Z")

</div>

That means the option is not being used. Try prefixing the option with `-st_`.
