Solving the laplacian over a square

79 Views Asked by At

I am preparing for an upcoming exam, and I was solving the following boundary value problem

$$\Delta u(x,y)=0,\ (x,y)\in [0,\pi]^2$$ $$u_y(x,0)=0,\ u_y(x,\pi)=0$$ $$u(0,y)=0$$ $$u(\pi,y)=\cos^2y$$

I tried separation of variables, asusming $u(x,y)=X(x)Y(y)$ and solved it, putting in the boundary conditions and got (assuming the solutions are not trivially zero)

$$X(x)=A(e^{nx}-e^{-nx})$$ $$Y(y)=D\cos(ny)$$ for some constants $A,D$. I then put them together and wrote $$u(x,y)=\sum_{n=1}^\infty A_n(e^{nx}-e^{-nx})\cos(ny)$$ where the $A_n$ are constants to be determined. Am I correct in writing this?

Assuming it is correct, I put in the last boundary condition and using the orthogonality of the fourier basis, I get

$$A_n=\frac{2/\pi}{e^{n\pi}-e^{-n\pi}}\int_0^\pi \cos^2y\cos(ny)\ \mathrm dy$$

which only survives when $n=2$ (for the rest, it is $0$). For $n=2$, it gives $$A_2=\frac{1}{2(e^{2\pi}-e^{-2\pi})}$$

Then plugging in this in the solution, I have

$$u(x,y)=\frac1{2(e^{2\pi}-e^{-2\pi})}(e^{2x}-e^{-2x})\cos(2y)$$


But here is the problem. The final solution doesn't seem to be satisfying the last boundary condition. It gives

$$u(\pi,y)=\frac12\cos(2y)=\cos^2y-\frac12$$ where there is an extra factor of $1/2$. I have been looking at it for hours but I can't find where the error creeps in. Any help is appreciated!