# Solution to Laplace equation with zero average

**URL:** <https://community.freefem.org/t/solution-to-laplace-equation-with-zero-average/1804>\
**Category:** General Discussion\
**Created:** [June 8, 2022, 6:23pm UTC](https://community.freefem.org/t/solution-to-laplace-equation-with-zero-average/1804 "2022-06-08T18:23:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neutrino](https://avatars.discourse-cdn.com/v4/letter/n/bb73d2/32.png) [@Neutrino](https://community.freefem.org/u/Neutrino)\
**Post date:** [June 8, 2022, 6:23pm UTC](https://community.freefem.org/t/solution-to-laplace-equation-with-zero-average/1804/1 "2022-06-08T18:23:57Z")

</div>

Suppose that I am looking to solve the following:

\begin{cases} -\Delta u = f \quad &\text{on } \Omega,\\ \nabla u \cdot \textbf{n} = 0 \quad &\text{on } \partial \Omega, \end{cases}

with the additional assumption that \int\_\Omega u=0. The [following question](https://math.stackexchange.com/questions/2112280/zero-average-in-solution-to-laplace-problem-with-lagrange-multipliers) on Math Stack Exchange suggests the following: Define f \in \mathbb{R}^N be the load vector of the original problem with the components f\_j = \int\_\Omega f \varphi\_i \,\mathrm{d}x, let g \in \mathbb{R}^N with the components g\_j = \int\_\Omega \varphi\_j\,\mathrm{d}x, and let A be the mass matrix . Then the mean value zero is imposed by solving the modified matrix system

\begin{pmatrix} A & g \\ g^T & 0 \end{pmatrix} \begin{pmatrix} u \\ \lambda \end{pmatrix} = \begin{pmatrix} f \\ 0 \end{pmatrix},

where \lambda\in\mathbb{R} and u\in\mathbb{R}^N are the unknowns.

Is there a way to do this in FreeFemm++? If not this way, maybe some other method?

---

<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:** [June 8, 2022, 8:21pm UTC](https://community.freefem.org/t/solution-to-laplace-equation-with-zero-average/1804/2 "2022-06-08T20:21:51Z")

</div>

> <https://github.com/FreeFem/FreeFem-sources/blob/master/examples/tutorial/Laplace-lagrange-mult.edp>

---

<div class="post-metadata">

**Author:** ![Neutrino](https://avatars.discourse-cdn.com/v4/letter/n/bb73d2/32.png) [@Neutrino](https://community.freefem.org/u/Neutrino)\
**Post date:** [June 10, 2022, 7:48am UTC](https://community.freefem.org/t/solution-to-laplace-equation-with-zero-average/1804/3 "2022-06-10T07:48:37Z")

</div>

Thank you very much!
