Solve Laplace's equation:
$$\frac{\partial^2u}{\partial x^2} + \frac{\partial^2u}{\partial y^2} = 0$$
for the region $\{(x, y) : 0 < x < 1, 0 < y < 1\}$, given these boundary conditions:
$$u(0, y) = 0$$ $$u(1,y) = 0$$ $$u(x,0) = 2\sin(\pi x)$$ $$u(x,1) = \sin(3\pi x)$$
I am going to skip over the majority of the working, and just present to you the general solution that I found, which I am 100% sure is correct:
$$u(x,y) = \sum_{n=1}^\infty \{A\sin(n\pi x)\sinh(n\pi y) + B\sin(n\pi x)\cosh(n\pi y)\}$$
Now, I'm struggling to use the last two boundary conditions to find the particular solution. Let me show you what I've done so far:
using $u(x,0) = 2\sin(\pi x)$ we get
$$u(x,0) = 2\sin(\pi x) = \sum_{n=1}^\infty \{ B\sin(n\pi x)\}$$
Using series expansion of the RHS, we see that for $n = 1$, $B = 2$ and for all other $n$, $B = 0$.
Now using $u(x,1) = \sin(3\pi x)$, we get
$$u(x,1) = \sin(3\pi x) = \sum_{n=1}^\infty \{A\sin(n\pi x)\sinh(n\pi y)\}$$
And this point is where I get stuck. How do I use this line to find the value of the constant $A$?
$$u(x,y) = \sum_{n=1}^\infty \{A_n\sin(n\pi x)\sinh(n\pi y) + B_n\sin(n\pi x)\cosh(n\pi y)\}$$ Since the boundary conditions only involve $\sin(\pi x)$ and $\sin(3\pi x)$ as variable terms, the values of $n$ different from $1$ and $3$ can be rejected : $$u(x,y) = A_1\sin(\pi x)\sinh(\pi y) + B_1\sin(\pi x)\cosh(\pi y)+A_3\sin(3\pi x)\sinh(3\pi y) + B_3\sin(3\pi x)\cosh(3\pi y)$$ The conditions $u(0,y)=0$ and $u(1,y)=0$ are satisfied.
The condition $u(x,0)=2\sin(\pi x)= B_1\sin(\pi x) + B_3\sin(3\pi x)$ implies :
$B_1=2$ and $B_3=0$ $$u(x,y) = A_1\sin(\pi x)\sinh(\pi y) + 2\sin(\pi x)\cosh(\pi y)+A_3\sin(3\pi x)\sinh(3\pi y) $$
The condition $u(x,1)=\sin(3\pi x)=A_1\sin(\pi x)\sinh(\pi) + 2\sin(\pi x)\cosh(\pi)+A_3\sin(3\pi x)\sinh(3\pi)$ implies :
$A_1\sinh(\pi)+2\cosh(\pi)=0$ and $A_3\sinh(3\pi)=1$
Hence $A_1=-2\frac{\cosh(\pi)}{\sinh(\pi)}$ and $A_3=\frac{1}{\sinh(3\pi)}$
The solution is : $$u(x,y) = =-2\frac{\cosh(\pi)}{\sinh(\pi)}\sin(\pi x)\sinh(\pi y) + 2\sin(\pi x)\cosh(\pi y)+\frac{1}{\sinh(3\pi)}\sin(3\pi x)\sinh(3\pi y) $$