# Methods to solve system of linear equations with equiality constraint

**URL:** https://discourse.julialang.org/t/methods-to-solve-system-of-linear-equations-with-equiality-constraint/110403
**Category:** Numerics
**Created:** [February 19, 2024, 1:43pm UTC](https://discourse.julialang.org/t/methods-to-solve-system-of-linear-equations-with-equiality-constraint/110403 "2024-02-19T13:43:01Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Gregstrq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gregstrq/32/20620_2.png) [@Gregstrq](https://discourse.julialang.org/u/Gregstrq)
#### Post date: [February 19, 2024, 1:43pm UTC](https://discourse.julialang.org/t/methods-to-solve-system-of-linear-equations-with-equiality-constraint/110403/1 "2024-02-19T13:43:01Z")

</div>

Hello, everyone. I want to solve a system of linear equations

```julia
Ax = b

```

with some linear equality constraints. `A` is square but non-symmetric.  
The equation corresponds to a linearized stationary Boltzman equation, and the equality constraints correspond to the boundary conditions and restrict the angular harmonics of the distribution.

My question is, what is the go to method to solve the system of linear equations with linear equality constraints? Of course, one could define the system of coordinates where the constraints are taken into account, however, in my case it is inconvenient.

---

<div class="post-metadata">

### Author: ![jlchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlchan/32/10958_2.png) [@jlchan](https://discourse.julialang.org/u/jlchan)
#### Post date: [February 19, 2024, 1:55pm UTC](https://discourse.julialang.org/t/methods-to-solve-system-of-linear-equations-with-equiality-constraint/110403/2 "2024-02-19T13:55:17Z")

</div>

I usually use Lagrange multipliers; this just involves solving an augmented system which includes some new unknowns (Lagrange multipliers) which help enforce the constraint.

---

<div class="post-metadata">

### Author: ![jlchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlchan/32/10958_2.png) [@jlchan](https://discourse.julialang.org/u/jlchan)
#### Post date: [February 19, 2024, 1:57pm UTC](https://discourse.julialang.org/t/methods-to-solve-system-of-linear-equations-with-equiality-constraint/110403/3 "2024-02-19T13:57:53Z")

</div>

Specifically, if your constraints are Cx=f, the system would be

[A C’][x] = [b]  
[C O][lambda] [f]

---

<div class="post-metadata">

### Author: ![Gregstrq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gregstrq/32/20620_2.png) [@Gregstrq](https://discourse.julialang.org/u/Gregstrq)
#### Post date: [February 19, 2024, 2:46pm UTC](https://discourse.julialang.org/t/methods-to-solve-system-of-linear-equations-with-equiality-constraint/110403/4 "2024-02-19T14:46:07Z")

</div>

Does this approach works well when A is neither symmetric nor Hermitian?

---

<div class="post-metadata">

### Author: ![jlchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlchan/32/10958_2.png) [@jlchan](https://discourse.julialang.org/u/jlchan)
#### Post date: [February 19, 2024, 3:00pm UTC](https://discourse.julialang.org/t/methods-to-solve-system-of-linear-equations-with-equiality-constraint/110403/5 "2024-02-19T15:00:02Z")

</div>

I’ve used it before in that setting, but I’m not sure if it always works “well”. IIRC the system is derived for SPD matrices `A` in the context of optimization; if `A` is not SPD then this interpretation doesn’t hold, but I think it still “works”.

If the constraint is consistent with the system I think it generally works OK. Either way, if you have access to the matrix, it’s not hard to set up the system and try it out.
