# Confused on how Method of Manufactured solutions works?

I am new to computational science and I am trying to wrap my head around how MMS works. I am solving the time independent Helmholtz equation as a simple test of the technique

so my starting equation is following with homogeneous boundary conditions on a line segment

$$\Delta u +k^2u = F$$

So I am supposed to take something that is sufficiently differentiable. So, following other people I pick the following for my 1D case

$$\bar{u} = \sin(\pi x)$$

My new source term created from MMS would be

$$G(x) = -\pi^2\sin(\pi x) + k^{2}\sin(\pi x) - F$$

Now here is where I am stuck. I picked a u and now I have a new F. Somehow I am supposed to be able to verify my rate of convergence of my actual problem with this fictitious one. Are the points the same?

• First of all, the non-homogeneous time-independent Helmholtz equation is: $$\nabla^{2} u + k^{2} u = F$$ Then if I assume your fabricated solution of $u = \sin(\pi x)$, I would have this for $F$ as: $$F = (k^{2} - \pi^{2}) \sin(\pi x)$$ Basically, if you have this equation: $$\frac{d^{2} u}{d x^{2}} + k^{2} u = (k^{2} - \pi^{2}) \sin(\pi x)$$ The analytical solution would be: $u = \sin(\pi x)$. – Alone Programmer Apr 23 at 19:46
• In your code to solve this Helmholtz equation, you put the right-hand side as $F = (k^{2}-\pi^{2})\sin(\pi x)$ then compare your numerical result with the analytical solution of $u = \sin(\pi x)$ to find the rate of convergence of your method with respect to mesh size. – Alone Programmer Apr 23 at 20:22
• The point is that you cannot independently choose whatever solution and right hand side you have in the equation. You can only choose one, and then the other is determined. So if you pick a $\bar u$, then it follows from the equation what $F$ needs to be. – Wolfgang Bangerth Apr 23 at 22:29