TExcelTAD
Home › Differential Equations › Laplace's Equation

Laplace's Equation

When the temperature in a plate stops changing, ut=0u_t = 0, and the heat equation in two dimensions becomes Laplace's equation

Δu=uxx+uyy=0.\Delta u = u_{xx} + u_{yy} = 0.

Its solutions, harmonic functions, describe steady-state temperature, electrostatic potential, ideal fluid flow and the shape of a soap film with small slopes. Only boundary values are given; there is no time.

The Dirichlet problem on a rectangle

On 0<x<a0 < x < a, 0<y<b0 < y < b, suppose u=0u = 0 on three sides and u(x,b)=f(x)u(x, b) = f(x) on the top. Separation u=X(x)Y(y)u = X(x)Y(y) gives

X′′X=−Y′′Y=−λ.\frac{X''}{X} = -\frac{Y''}{Y} = -\lambda.

The xx-problem with X(0)=X(a)=0X(0) = X(a) = 0 is the familiar eigenvalue problem, Xn=sin⁡nπxaX_n = \sin\frac{n\pi x}{a}. Now the yy-equation Y′′=λnYY'' = \lambda_nY has exponential (hyperbolic) solutions, and Y(0)=0Y(0) = 0 selects sinh⁡nπya\sinh\frac{n\pi y}{a}:

u(x,y)=∑n=1∞cn sinh⁡(nπy/a)sinh⁡(nπb/a) sin⁡nπxa,u(x, y) = \sum_{n=1}^\infty c_n\,\frac{\sinh(n\pi y/a)}{\sinh(n\pi b/a)}\,\sin\frac{n\pi x}{a},

where cnc_n are the sine coefficients of ff. Each mode decays away from the top edge, high modes fastest: the interior is smooth even if the boundary data are rough. For data on several sides, solve one side at a time and add (superposition).

python · try it yourself
import numpy as np

a = b = 1.0
n = np.arange(1, 200)
c = 2 * (1 - (-1)**n) / (n * np.pi)                     # sine coefficients of f(x) = 1 (hot top edge)
def u(x, y):
    return np.sum(c * np.sinh(n * np.pi * y / a) / np.sinh(n * np.pi * b / a) * np.sin(n * np.pi * x / a))
print("centre:", round(u(0.5, 0.5), 6))
for y in (0.25, 0.5, 0.75, 0.95):
    print(f"u(0.5, {y}) = {u(0.5, y):.4f}")
centre: 0.25
u(0.5, 0.25) = 0.0954
u(0.5, 0.5) = 0.2500
u(0.5, 0.75) = 0.5405
u(0.5, 0.95) = 0.8997

The centre value is exactly 14\frac{1}{4} by symmetry: putting the hot edge on each of the four sides in turn and adding gives u=1u = 1 everywhere, so each contributes a quarter at the centre.

The mean value property

A harmonic function's value at any point equals its average over any circle centred there (inside the domain). Consequences:

  • Maximum principle: a harmonic function attains its maximum and minimum on the boundary, never strictly inside. A steady temperature has no hot spot in the interior.
  • Uniqueness: two solutions with the same boundary values differ by a harmonic function that is 0 on the boundary, hence 0 everywhere.

The mean value property also gives an algorithm: repeatedly replace each grid value by the average of its four neighbours. That is the Jacobi iteration of Jacobi and Gauss-Seidel.

python · try it yourself
import numpy as np

N = 21
U = np.zeros((N, N))
U[-1, :] = 1.0                                   # top edge hot, others 0
for it in range(3000):
    U[1:-1, 1:-1] = 0.25 * (U[:-2, 1:-1] + U[2:, 1:-1] + U[1:-1, :-2] + U[1:-1, 2:])
print("centre after relaxation:", round(U[N // 2, N // 2], 4))
print("interior max:", round(U[1:-1, 1:-1].max(), 4), "(below the boundary max 1)")
centre after relaxation: 0.25
interior max: 0.8993 (below the boundary max 1)

Laplace's equation in a disc

In polar coordinates, Δu=urr+1rur+1r2uθθ\Delta u = u_{rr} + \frac{1}{r}u_r + \frac{1}{r^2}u_{\theta\theta}. Separation gives rncos⁡nθr^n\cos n\theta and rnsin⁡nθr^n\sin n\theta, so the solution in the unit disc with boundary values u(1,θ)=f(θ)u(1, \theta) = f(\theta) is

u(r,θ)=a02+∑n=1∞rn(ancos⁡nθ+bnsin⁡nθ),u(r, \theta) = \frac{a_0}{2} + \sum_{n=1}^\infty r^n\left(a_n\cos n\theta + b_n\sin n\theta\right),

with the full Fourier series coefficients of ff. At the centre u(0)=a02u(0) = \frac{a_0}{2}, the average of ff: the mean value property again.

In software

  • Mesh smoothing and "harmonic" interpolation in graphics (Laplacian smoothing, harmonic coordinates for character deformation) solve discrete Laplace equations.
  • Image inpainting fills a hole by solving Δu=0\Delta u = 0 with the surrounding pixels as boundary values; Poisson image editing (seamless cloning in photo editors) solves Δu=Δg\Delta u = \Delta g.
  • Electrostatics and potential-flow solvers in engineering tools discretize the same equation (Two-Dimensional Poisson Problems).

Exercises

Exercise 1: Is it harmonic?

Which are harmonic: x2−y2x^2 - y^2, x2+y2x^2 + y^2, excos⁡ye^x\cos y?

Answer

x2−y2x^2 - y^2 and excos⁡ye^x\cos y.

Solution

Δ(x2−y2)=2−2=0\Delta(x^2 - y^2) = 2 - 2 = 0; Δ(x2+y2)=4\Delta(x^2 + y^2) = 4; Δ(excos⁡y)=excos⁡y−excos⁡y=0\Delta(e^x\cos y) = e^x\cos y - e^x\cos y = 0.

Exercise 2: Disc

Solve Δu=0\Delta u = 0 in the unit disc with u(1,θ)=3+cos⁡2θu(1, \theta) = 3 + \cos 2\theta.

Answer

u=3+r2cos⁡2θ=3+x2−y2u = 3 + r^2\cos 2\theta = 3 + x^2 - y^2.

Solution

The boundary data is already a Fourier series with a02=3\frac{a_0}{2} = 3 and a2=1a_2 = 1; multiply each term by rnr^n. In Cartesian coordinates r2cos⁡2θ=x2−y2r^2\cos 2\theta = x^2 - y^2.

Exercise 3: Mean value (code)

Check the mean value property for u=excos⁡yu = e^x\cos y on the circle of radius 0.5 around (0.3,0.2)(0.3, 0.2).

Answer

Both equal e0.3cos⁡0.2≈1.322952e^{0.3}\cos 0.2 \approx 1.322952.

Solution
python · try it yourself
import numpy as np
th = np.linspace(0, 2 * np.pi, 100000, endpoint=False)
x, y = 0.3 + 0.5 * np.cos(th), 0.2 + 0.5 * np.sin(th)
print(round(np.mean(np.exp(x) * np.cos(y)), 6), round(np.exp(0.3) * np.cos(0.2), 6))
1.322952 1.322952

Test yourself

Laplace's equation describes…

  1. time-dependent heat flow
  2. steady states: temperature, potentials, ideal flow
  3. waves
  4. population growth

By the maximum principle, a harmonic function on a bounded region…

  1. has its maximum inside
  2. takes its maximum and minimum on the boundary
  3. is constant
  4. has no maximum

In the rectangle solution, the yy-dependence of each mode is…

  1. sin⁡\sin
  2. sinh⁡\sinh (exponential growth away from the zero edge)
  3. e−te^{-t}
  4. constant