Laplace’s equation (using separation of variables)-- Is the solution correct? I am trying to solve Laplace’s equation (using the separation of variables). I found a result below. But for some reason does not seems right to me. Any suggestions? Thank you in advance
$$
\begin{align}
 u_{xx}+u_{yy}&=0 \quad ,\ (x,y) \in\,(0,a)\times(0,b) \tag1 \\ 
u(0,y)=u_x(a,y)&=0 \quad  ,\,y \in [0,b] \tag2\\ 
u_y(x,0)+u(x,0)&=0  \quad \ \,x\in[0,a] \tag3 \\
u(x,b)&=g(x) \tag 4
\end{align}
$$
Assuming separable functions
$$u(x,y)=X(x)Y(y)$$
Then \begin{align}
u_{xx}&=X''(x)Y(y) \\
u_{yy}&=X(x)Y''(y)
\end{align}
Substituting that into the equation $(1)$ we have
\begin{align}
X''(x)Y(y)+X(x)Y''(y)&=0 \\
X''(x)Y(y))&=-X(x)Y''(y)\\
\frac{X''(x)}{X(x)}&=-\frac{Y''(y)}{Y(y)}=- \lambda
\end{align}
where $\lambda$ is a constant.
Thus, \begin{align}
X''(x)+ \lambda X(x)&=0 \quad 0<x<a \tag5 \\
Y''(y)-\lambda Y(y) &=0 \quad 0<y<b \tag 6
\end{align}
The boundary conditions will be the following
\begin{align}
X(0)=X'(a)=0 \tag7 \\
Y'(0)+Y(0)=0 \tag8
\end{align}
So we have $X$ as the unknown in the Sturm-Liouville problem.
We have to find the eigenvalues and eigenfunctions of
\begin{align}
X''(x)+ \lambda X(x)&=0\\
X(0)=X'(0)&=0
\end{align}
Now we solve this problem for different values of $\lambda$

*

*If $\lambda=0$
Then the equation becomes the form
$$X''(x)=0$$
The general solution is $$X(x)=c_1x+c_2 \tag9$$
Now we differentiate the expression $(9)$ we have
$$X'(x)=c_1$$
Then we plug in the boundary conditions and we have
$$c_1=0, c_2=0$$
hence zero is not an eigenvalue.


*If $\lambda<0$
The general solution is
$$X(x)=c_1 e^{\sqrt{\lambda}x}+c_2 e^{-\sqrt{\lambda}x}\tag{10}$$
Then we plug in the boundary conditions and we have
\begin{align}
X(0)=0 \Leftrightarrow c_1+c_2=0 \Leftrightarrow c_2=-c_1 \\
X'(a)=0 \Leftrightarrow c_1 \sqrt{\lambda} e^{\sqrt{\lambda}a}-c_2 \sqrt{\lambda} e^{-\sqrt{\lambda}a}=0
\end{align}
No positive eigenvalues since $c_2=0$


*If $\lambda>0$
The general solution is
$$X(x)=c_1 \cos(\sqrt{\lambda}x)+c_2 \sin(\sqrt{\lambda}x) \tag{11}$$
and the for the boundaries conditions we have
\begin{align}
X(0)=0 \Leftrightarrow c_1=0\\
X'(a)=0 \Leftrightarrow c_2 \sqrt{\lambda} \cos(\sqrt{\lambda}a)=0
\end{align}
Then the eigenvalues are $$\lambda_n=\Big(\frac{(2n-1)\pi}{2a}\Big)^2, \quad n=1,2,...$$
with eigenfunction
$$X_n(x)=\cos\Big(\frac{(2n-1)\pi x}{2a}\Big)$$
With $$\lambda_n=\Big(\frac{(2n-1)\pi}{2a}\Big)^2:=v_n^2, \quad n=1,2,...$$
the ODE $$Y''(y)-\lambda Y(y)=0$$ has the general solution
$$Y_n(y)=A_n \cosh(v_n y)+B_n sinh(v_n y) \tag{12}$$
We want $(12)$ satisfies the boundary conditions
$$u_y(x,0)+u(x,0)=0 \quad (13)$$
To solve for $u(x, 0)$, we can integrate both sides with respect to y, using the method of integrating factors:
$$∫(u_y(x, 0) + u(x, 0))dy = ∫0$$
$$u_y(x, y) = -u(x, y) + C(x)$$
where C(x) is an arbitrary function of $x$ that can be determined from the initial or boundary conditions.
Given the boundary condition $u_y(x, 0) + u(x, 0) = 0$, we can substitute $u_y(x, 0) = -u(x, 0)$ into the equation, and solve for $u(x, 0)$:
\begin{align}
-u(x, 0) + u(x, 0) &= 0\\
2u(x, 0) &= 0\\
u(x, 0)& = 0 \tag{14}
\end{align}
So $$Y(0)=0 \Leftrightarrow A_n=0 \quad(15)$$
Thus the solutions are
\begin{align*}
     u(x,y)&=( B_n \sinh(v_n y)) \cos(v_n x) 
 \end{align*}
Superposing these functions we get
$$ u(x,y)=\sum_{n=1}^{\infty} B_n \sinh(v_n y) \cos(v_n x) \quad (16) $$
From $(16)$ we have
$$u(x,b)=\sum_{n=1}^{\infty} B_n \sinh(v_n b) \cos(v_n x)=g(x)$$
This looks like a Fourier cosine series and if we let $c_n = B_n \sinh v_nb$, this becomes
$$\sum_{n=1}^{\infty} c_n \cos(v_n x)=g(x)$$
which is precisely a Fourier cosine series.
The coefﬁcients $c_n$ are given
$$c_n=\frac{2}{a}\int_{0}^{a} g(x) \cos(v_n x) \,dx$$
and since $c_n = B_n \sinh v_nb$ , this gives
$$B_n=\frac{2}{a \sinh(v_n b)}\int_{0}^{a} g(x) \cos(v_n x) \,dx$$
 A: I did not understand what you did after your equation $(13)$. Your original robin boundary condition $(3)$ was transformed to a Dirichlet BC at the equation $(14)$.
You solution is different from mine after that point.
While you got
$$Y(y) = B_n \sinh v_{n} y$$
This function doesn't satisfy your robin boundary condition.
I got
$$Y(y) = B_{n} \left(\cosh v_{n} y - \sinh v_{n} y\right)$$
Complete solution:
$$\nabla^2 u = 0$$
On a retangular domain $(x, \ y) \in \left[0, \ a\right] \times \left[0, \ b\right]$.
Boundary conditions are
$$\begin{align}u(0, \ y) & = 0 \label{1}\tag{1} \\ \dfrac{\partial u}{\partial x}(a, \ y) & = 0 \label{2}\tag{2} \\ \dfrac{\partial u}{\partial y}(x, \ 0) + u(x, \ 0) & = 0 \label{3}\tag{3} \\u(x, \ b) & = g(x) \label{4}\tag{4}\end{align}$$
\eqref{1} and \eqref{4} are Dirichlet boundary conditions, while \eqref{2} is Neumann's and \eqref{3} is Robin's
Separation of variables:
$$u(x, \ y)=X(x) \cdot Y(y)$$
$$\nabla^2 u = X'' \cdot Y + X \cdot Y'' = 0$$
$$\dfrac{X''}{X} = -\dfrac{Y''}{Y} = -\lambda$$

*

*For $\lambda = 0$
$$X'' = 0 \Rightarrow X(x) = c \cdot x + d$$
Applying boundary conditions of \eqref{1} and \eqref{2}, we get $c= d = 0$.
No solution here


*For $\lambda < 0$, then $\lambda = -\mu^2$ for some $\mu \in \mathbb{R}$
$$\begin{matrix}X'' - \mu^2 X = 0 \\ Y'' + \mu^2 Y = 0 \end{matrix} \Rightarrow \begin{matrix}X = & c_0 \cdot \cosh \mu x + d_0 \cdot \sinh \mu x\\ Y = & e_0 \cdot \cos \mu y + f_0 \cdot \sin \mu y\end{matrix}$$
Applying boundary conditions of \eqref{1} and \eqref{2} we get
$$X(0) = 0 \Rightarrow c_0 = 0$$
$$X'(a) = 0 \Rightarrow c_0\mu \cdot \sinh\left(\mu a\right) + d_0\mu \cdot \cosh\left(\mu a\right) = 0$$
Then $c_0 = d_0 = 0$
No solution here


*For $\lambda > 0$, then $\lambda = \mu^2$ for some $\mu \in \mathbb{R}$
$$\begin{matrix}X'' + \mu^2 X = 0 \\ Y'' - \mu^2 Y = 0 \end{matrix} \Rightarrow \begin{matrix}X = & c_0 \cdot \cos \mu x + d_0 \cdot \sin \mu x\\ Y = & e_0 \cdot \cosh \mu y + f_0 \cdot \sinh \mu y\end{matrix}$$
Applying boundary conditions of \eqref{1} and \eqref{2} we get
$$X(0) = 0 \Rightarrow c_0 = 0$$
$$X'(a) = 0 \Rightarrow -c_0 \mu \cdot \sin\left(\mu a\right) + d_0\mu \cdot \cos\left(\mu a\right) = 0$$
As $c_0=0$, to satisfy the second boundary condition, either $d_0 = 0$ or $\cos \mu a =0$. For the first case, there's no solution. Then
$$\cos \mu a = 0 \Rightarrow \mu_{k} \cdot a = \dfrac{\pi}{2} + k\pi \Rightarrow \boxed{\mu_{k} = \dfrac{\pi}{a} \left(k+\dfrac{1}{2}\right)} \ \ \ \ \ \forall k  \in  \mathbb{Z}$$
$$X_k(x) = d_{k} \cdot \sin \left[\dfrac{\pi x}{a}\left(k + \dfrac{1}{2}\right)\right] \tag{5}\label{5}$$
For $Y(y)$,

*

*Using boundary condition \eqref{3}
$$X(x) Y'(0) + X(x)Y(0) = 0 \ \ \forall x $$
$$Y'(0) + Y(0) = 0$$
$$\left(e_0+f_0\right)\left[\cosh (\mu y) + \sinh (\mu y)\right]_{y=0} = 0$$
$$e_0 + f_0 = 0 \tag{6}\label{6}$$

*Using boundary condition \eqref{4}
$$X(x)Y(b) = g(x) \ \ \forall x $$
$$Y(b) = 1$$
$$ e_0 \cosh (\mu b) + f_0 \sinh (\mu b)  = 1\tag{7}\label{7}$$
Mixing \eqref{6} and \eqref{7} we get \eqref{8}
$$Y_k(y) = \dfrac{\cosh \mu_k y - \sinh \mu_k y}{\cosh \mu_k b - \sinh \mu_k b}\label{8}\tag{8}$$
Therefore, there are solutions only if $\lambda > 0$. We mix \eqref{5} and \eqref{8} to get \eqref{9}
$$u(x, \ y) = \sum_{k=0}^{\infty} d_{k} \cdot \sin \left(\mu_{k} x \right)\dfrac{\cosh \left(\mu_k y\right) - \sinh \left(\mu_k y\right)}{\cosh \left(\mu_k b\right) - \sinh \left(\mu_k b\right)}\label{9}\tag{9}$$
The last thing to do is use \eqref{4} to find all the coefficients $d_{k}$ such.
$$u(x, b) = \sum_{k=0}^{\infty} d_{k} \cdot \sin \left(\mu_{k} x \right) = g(x)$$
$$\mu_{k} = \dfrac{\pi x}{a}\left(k + \dfrac{1}{2}\right) \ \ \ \ \ \ \ \forall k  \in  \mathbb{N}^{+}  \cup  \left \{0 \right \}$$
