Laplace's equation in a rectangle

Branko Ćurgus

Boundary value problem

Here we consider the following boundary value problem: Let $K$ and $L$ be positive real numbers. Let $f_1$ and $f_2$ be real functions defined on $[0,K]$ and let $g_1$ and $g_2$ be real functions defined on $[0,L]$. Find the real function $u$ defined on a rectangle $\bigl\{(x,y) : 0 \leq x \leq K, 0 \leq y \leq L \bigr\}$ which satisfies the Laplace PDE \begin{equation} \label{eqBVPR} \frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2} = 0 \end{equation} and the boundary conditions \begin{alignat}{2} \label{eqBVPR1} u(x,0) & = f_1(x), & \qquad u(x,L) & = f_2(x), \qquad 0 \leq x \leq K, \\ \label{eqBVPR2} u(0,y) & = g_1(y), & \qquad u(K,y) & = g_2(y), \qquad 0 \leq y \leq L. \\ \end{alignat}
Split the given problem in two problems

Solving Problem 1

Solving Problem 2

The solution of the boundary value problem

The solution of the given boundary value problem \eqref{eqBVPR}, \eqref{eqBVPR1}, \eqref{eqBVPR2} is the sum $u_1(x,y)+u_2(x,y)$, that is \begin{multline*} u(x,y) = \sum_{n=1}^{\infty} a_n \sin\left( \dfrac{n \pi}{L} y \right)\dfrac{\sinh\left( \dfrac{n \pi}{L} (K- x) \right)}{\sinh\left( \dfrac{n \pi}{L} K \right)} + \sum_{n=1}^{\infty} b_n \sin\left( \frac{n \pi}{L} y \right)\, \dfrac{\sinh\left( \dfrac{n \pi}{L} x \right)}{\sinh\left( \dfrac{n \pi}{L} K \right)} \\ + \sum_{n=1}^{\infty} c_n \sin\left( \dfrac{n \pi}{K} x \right)\dfrac{\sinh\left( \dfrac{n \pi}{K} (L - y) \right)}{\sinh\left( \dfrac{n \pi}{K} L \right)} + \sum_{n=1}^{\infty} d_n \sin\left( \frac{n \pi}{K} x \right)\, \dfrac{\sinh\left( \dfrac{n \pi}{K} y \right)}{\sinh\left( \dfrac{n \pi}{K} L \right)} \end{multline*} with the coefficients $a_n, b_n, c_n, d_n$ calculated by \begin{align*} a_n & = \frac{2}{L} \int_0^L g_1(y) \sin\left( \dfrac{n \pi}{L} y \right) dy, \qquad n \in {\mathbb N}, \\ b_n & = \frac{2}{L} \int_0^L g_2(y) \sin\left( \dfrac{n \pi}{L} y \right) dy, \qquad n \in {\mathbb N}, \\ c_n & = \frac{2}{K} \int_0^K f_1(x) \sin\left( \dfrac{n \pi}{K} x \right) dx, \qquad n \in {\mathbb N}, \\ d_n & = \frac{2}{K} \int_0^K f_2(x) \sin\left( \dfrac{n \pi}{K} x \right) dx, \qquad n \in {\mathbb N}. \end{align*}
Mathematica implementation of the solution

The above solution is implemented in this Mathematica notebook.