TExcelTAD
Home › Differential Equations › Boundary Value Problems and Eigenfunctions

Boundary Value Problems and Eigenfunctions

So far conditions were given at one point: y(0)y(0) and y′(0)y'(0). In a boundary value problem (BVP) they are given at two ends, such as the temperature at both ends of a rod or a string fixed at both ends. BVPs behave very differently from initial value problems: they may have no solution, one, or infinitely many. That last case, the eigenvalue problem, is the key to solving PDEs with Fourier series.

Existence is not guaranteed

Consider y′′+y=0y'' + y = 0 with different boundary conditions. The general solution is y=Acos⁡x+Bsin⁡xy = A\cos x + B\sin x.

Conditions Result
y(0)=0y(0) = 0, y(π/2)=1y(\pi/2) = 1 A=0A = 0, B=1B = 1: unique solution sin⁡x\sin x
y(0)=0y(0) = 0, y(π)=0y(\pi) = 0 A=0A = 0, BB arbitrary: infinitely many
y(0)=0y(0) = 0, y(π)=1y(\pi) = 1 A=0A = 0 and 0=10 = 1: no solution

The eigenvalue problem

Find all λ\lambda for which

y′′+λy=0,y(0)=0,y(L)=0y'' + \lambda y = 0, \qquad y(0) = 0, \quad y(L) = 0

has a nonzero solution. Such λ\lambda are eigenvalues and the solutions eigenfunctions, by analogy with Av=λvA\mathbf{v} = \lambda\mathbf{v}: here the "matrix" is the operator −d2dx2-\frac{d^2}{dx^2} with the boundary conditions.

  • λ<0\lambda < 0: y=Ae−λx+Be−−λxy = Ae^{\sqrt{-\lambda}x} + Be^{-\sqrt{-\lambda}x}; the conditions force A=B=0A = B = 0.
  • λ=0\lambda = 0: y=A+Bxy = A + Bx; again only y=0y = 0.
  • λ>0\lambda > 0: y=Acos⁡λx+Bsin⁡λxy = A\cos\sqrt{\lambda}x + B\sin\sqrt{\lambda}x. y(0)=0y(0) = 0 gives A=0A = 0, and y(L)=Bsin⁡λL=0y(L) = B\sin\sqrt{\lambda}L = 0 with B≠0B \ne 0 needs λL=nπ\sqrt{\lambda}L = n\pi.
λn=(nπL)2,yn(x)=sin⁡nπxL,n=1,2,3,…\lambda_n = \left(\frac{n\pi}{L}\right)^2, \qquad y_n(x) = \sin\frac{n\pi x}{L}, \qquad n = 1, 2, 3, \dots

These are the shapes of a vibrating string's harmonics.

Eigenvalues numerically: a matrix approximation

Replace y′′y'' by the finite difference yi−1−2yi+yi+1h2\frac{y_{i-1} - 2y_i + y_{i+1}}{h^2} on NN interior grid points. The problem becomes a matrix eigenvalue problem −Dy=λy-D\mathbf{y} = \lambda\mathbf{y}, and the smallest eigenvalues approximate λn\lambda_n (more in Finite Differences for Boundary Value Problems):

python · try it yourself
import numpy as np

L, N = np.pi, 200
h = L / (N + 1)
D = (np.diag(-2 * np.ones(N)) + np.diag(np.ones(N - 1), 1) + np.diag(np.ones(N - 1), -1)) / h**2
lam = np.sort(np.linalg.eigvalsh(-D))
print("numerical:", lam[:5].round(4))
print("exact n^2:", [n**2 for n in range(1, 6)])
numerical: [ 1.      3.9997  8.9984 15.9948 24.9873]
exact n^2: [1, 4, 9, 16, 25]

Other boundary conditions

Changing the conditions changes the eigenfunctions:

Conditions Eigenvalues Eigenfunctions
y(0)=y(L)=0y(0) = y(L) = 0 (Dirichlet) (nπL)2\left(\frac{n\pi}{L}\right)^2, n≥1n \ge 1 sin⁡nπxL\sin\frac{n\pi x}{L}
y′(0)=y′(L)=0y'(0) = y'(L) = 0 (Neumann) (nπL)2\left(\frac{n\pi}{L}\right)^2, n≥0n \ge 0 cos⁡nπxL\cos\frac{n\pi x}{L} (including the constant)
periodic on [−L,L][-L, L] (nπL)2\left(\frac{n\pi}{L}\right)^2, n≥0n \ge 0 cos⁡nπxL\cos\frac{n\pi x}{L} and sin⁡nπxL\sin\frac{n\pi x}{L}

The Dirichlet sines lead to sine series, the Neumann cosines to cosine series, and the periodic case to full Fourier series (Fourier Series).

Orthogonality

Eigenfunctions with different eigenvalues are orthogonal: ∫0Lsin⁡mπxLsin⁡nπxL dx=0\int_0^L \sin\frac{m\pi x}{L}\sin\frac{n\pi x}{L}\,dx = 0 for m≠nm \ne n. This mirrors the fact that a symmetric matrix has orthogonal eigenvectors, and it is what makes Fourier coefficients easy to compute.

python · try it yourself
import sympy as sp

x = sp.symbols("x")
L = sp.pi
for m, n in ((1, 2), (2, 5), (3, 3)):
    print(f"m={m}, n={n}:", sp.integrate(sp.sin(m * x) * sp.sin(n * x), (x, 0, L)))
m=1, n=2: 0
m=2, n=5: 0
m=3, n=3: pi/2

In software

  • scipy.integrate.solve_bvp solves nonlinear two-point boundary value problems by collocation.
  • Structural engineers compute the vibration modes of beams and buildings as eigenvalue problems of this kind, with sparse eigensolvers on discretized operators.
  • Quantum mechanics: the energy levels of a "particle in a box" are exactly the Dirichlet eigenvalues above (times ℏ22m\frac{\hbar^2}{2m}).

Exercises

Exercise 1: Solve a BVP

Solve y′′=6xy'' = 6x, y(0)=0y(0) = 0, y(1)=2y(1) = 2.

Answer

y=x3+xy = x^3 + x.

Solution

y=x3+Ax+By = x^3 + Ax + B. y(0)=B=0y(0) = B = 0 and y(1)=1+A=2y(1) = 1 + A = 2.

Exercise 2: Eigenvalues on a different interval

Find the eigenvalues and eigenfunctions of y′′+λy=0y'' + \lambda y = 0, y(0)=y(2)=0y(0) = y(2) = 0.

Answer

λn=n2π24\lambda_n = \frac{n^2\pi^2}{4}, yn=sin⁡nπx2y_n = \sin\frac{n\pi x}{2}.

Solution

Use the general formula with L=2L = 2.

Exercise 3: Mixed conditions (code)

For y′′+λy=0y'' + \lambda y = 0, y(0)=0y(0) = 0, y′(π)=0y'(\pi) = 0, show that λn=(n−12)2\lambda_n = \left(n - \frac{1}{2}\right)^2, and check the first three numerically.

Answer

λ=0.25,2.25,6.25,…\lambda = 0.25, 2.25, 6.25, \dots with yn=sin⁡(n−12)xy_n = \sin\left(n - \frac{1}{2}\right)x.

Solution

y=Bsin⁡λxy = B\sin\sqrt{\lambda}x and y′(π)=Bλcos⁡λπ=0y'(\pi) = B\sqrt{\lambda}\cos\sqrt{\lambda}\pi = 0 needs λπ=(n−12)π\sqrt{\lambda}\pi = \left(n - \frac{1}{2}\right)\pi. Numerically, the Neumann end can be handled with a ghost point (yN+1=yN−1y_{N+1} = y_{N-1}), which doubles one off-diagonal entry; the matrix is no longer symmetric, so use eigvals:

python · try it yourself
import numpy as np
N = 400; h = np.pi / N
D = (np.diag(-2 * np.ones(N)) + np.diag(np.ones(N - 1), 1) + np.diag(np.ones(N - 1), -1)) / h**2
D[-1, -2] = 2 / h**2                       # ghost point at x = pi
print(np.sort(np.linalg.eigvals(-D).real)[:3].round(4))
[0.25   2.25   6.2498]

Test yourself

The eigenvalues of y′′+λy=0y'' + \lambda y = 0, y(0)=y(L)=0y(0) = y(L) = 0 are…

  1. nπ/Ln\pi/L
  2. (nπ/L)2(n\pi/L)^2 for n=1,2,…n = 1, 2, \dots
  3. all real numbers
  4. only 0

Unlike an initial value problem, a boundary value problem…

  1. always has a unique solution
  2. may have no solution or infinitely many
  3. never has a solution
  4. is always nonlinear

Neumann conditions y′(0)=y′(L)=0y'(0) = y'(L) = 0 give eigenfunctions…

  1. sin⁡(nπx/L)\sin(n\pi x/L)
  2. cos⁡(nπx/L)\cos(n\pi x/L) including the constant
  3. enxe^{nx}
  4. polynomials