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 the rectangle \[ [0, K] \times [0, L] = \bigl\{(x,y) \in \mathbb{R}^2 : 0 \leq x \leq K \ \ \text{and} \ \ 0 \leq y \leq L \bigr\} \] such that $u$ satisfies the Laplace PDE \begin{equation} \label{eqBVPR} \frac{\partial^2 u}{\partial x^2}(x,y) + \frac{\partial^2 u}{\partial y^2}(x,y) = 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) \quad \text{for all} \quad x \in [0, K], \\ \label{eqBVPR2} u(0,y) & = g_1(y), & \qquad u(K,y) & = g_2(y) \quad \text{for all} \quad y \in [0,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 version 8 with the corresponding pdf printout.

The above solution is implemented in this Mathematica notebook version 12 with the corresponding pdf printout.
An Example with exact solution written as a finite sum

Here we consider the following boundary value problem: Find the real function $u(x,y)$ defined on the rectangle \[ [0, 3] \times [0,2] = \bigl\{(x,y) \in \mathbb{R}^2 : 0 \leq x \leq 3 \ \ \text{and} \ \ 0 \leq y \leq 2 \bigr\} \] such that $u$ satisfies the Laplace PDE \begin{equation} \label{eqBVPRe} \frac{\partial^2 u}{\partial x^2}(x,y) + \frac{\partial^2 u}{\partial y^2}(x,y) = 0 \end{equation} and the boundary conditions \begin{alignat}{3} \label{eqBVPR1e} u(x,0) & = \frac{1}{2} + \frac{4 x}{3}+\sin \left(\frac{\pi x}{3}\right), & \quad u(x,2) & = \frac{7}{2} -\frac{x}{3}+\frac{1}{2} \sin \left(\frac{2 \pi x}{3}\right) & \quad &\text{for all} \quad x \in [0,3], \\ \label{eqBVPR2e} u(0,y) & = \frac{1}{2} + \frac{3 y}{2}-\frac{2}{3} \sin \left(\frac{\pi y}{2}\right), & \quad u(3,y) & = \frac{9}{2} -y-\frac{1}{2} \sin (\pi y) & \quad & \text{for all} \quad y \in [0,2]. \\ \end{alignat} The picture to the left below shows the boundary conditions as the parametric curve in \(xyu\)-space. The picture to the right is the equilibrium temperature, the solution of the Laplace's equation that satisfied the given boundary conditions. In the rest of this section we will explain how the solution is constructed.
This problem is interesting since it can be split into five problems, and for each of those five problems we can find the exact solution. Adding up those five solutions provides the solution of the given problem. Below are the five boundary conditions that added together give the boundary condition pictured above.

For each of these five boundary conditions we find the exact solution of Laplace's Equation and add them together to get the solution of the original problem.

The solution of Laplace's equation that satisfies the first boundary condition is \[ \sin \left(\frac{\pi}{3} x\right) \frac{\sinh \left(\frac{\pi}{3} (2-y)\right)}{\sinh\left(\frac{\pi }{3}\, 2 \right)} \]

The solution of Laplace's equation that satisfies the second boundary condition is \[ \frac{1}{2} \sin \left( \frac{2\pi}{3} x \right) \frac{\sinh \left(\frac{2\pi}{3} (2-y)\right)}{\sinh\left(\frac{2\pi }{3}\, 2 \right)} \]

The first solution, the second solution and the sum of the first and the second solutions are

The solution of Laplace's equation that satisfies the third boundary condition is \[ -\frac{2}{3} \sin \left( \frac{\pi}{2} y \right) \frac{\sinh \left(\frac{\pi}{2} (3-x)\right)}{\sinh\left(\frac{\pi}{2}\, 3 \right)} \]

The third solution, the preceding sum and the sum of the first, the second and the third solutions are

The solution of Laplace's equation that satisfies the fourth boundary condition is \[ -\frac{1}{2} \sin \left( \pi y \right) \frac{\sinh \left(\pi x \right)}{\sinh\left(\pi \, 3 \right)} \]

The fourth solution, the preceding sum and the sum of the first, the second, the third, and the fourth solutions are

The solution of Laplace's equation that satisfies the "straight edges" boundary condition is \[ \frac{1}{6} \bigl( 3 + 8 x + 9 y - 5 x y \bigr) \]

The solution to the "straight edges" boundary condition, the preceding sum, and the sum of the first, the second, the third, the fourth, and the solution to the "straight edges" boundary conditions are

Finally, the solution of the given boundary value problem for Laplace's equation is the sum of the preceding solutions: \begin{align*} \sin \left(\frac{\pi}{3} x\right) & \frac{\sinh \left(\frac{\pi}{3}(2-y)\right)}{\sinh\left(\frac{\pi }{3}\, 2 \right)} +\frac{1}{2} \sin \left( \frac{2\pi}{3} x \right) \frac{\sinh \left(\frac{2\pi}{3}(2-y)\right)}{\sinh\left(\frac{2\pi }{3}\, 2 \right)} \\ &\qquad - \frac{2}{3} \sin \left( \frac{\pi}{2} y \right) \frac{\sinh \left(\frac{\pi}{2}(3-x)\right)}{\sinh\left(\frac{\pi}{2}\, 3 \right)} -\frac{1}{2} \sin \left( \pi y \right) \frac{\sinh \left(\pi x \right)}{\sinh\left(\pi \, 3 \right)} +\frac{1}{6} \bigl( 3 + 8 x + 9 y - 5 x y \bigr) \end{align*} We close this section with a big graph of this solution: