Bessel and Legendre Functions
Separating variables in the heat, wave or Laplace equation on a disc, a cylinder or a sphere (Fourier Series and PDEs) leads to two variable-coefficient equations so often that their solutions have names. Bessel functions describe vibrating drums and heat in cylinders; Legendre polynomials describe fields on a sphere. Both are computed in SciPy.
Bessel's equation
is a regular singular point with indicial roots (Frobenius Method). The Frobenius series for gives the Bessel function of the first kind
For integer , the second solution (second kind) contains and blows up at 0. Physically meaningful solutions that stay finite at the centre use only .
import math
from scipy.special import jv, yv
def J_series(nu, x, terms=30):
return sum((-1)**k / (math.factorial(k) * math.gamma(k + nu + 1)) * (x / 2)**(2*k + nu) for k in range(terms))
for x in (0.5, 2.0, 5.0):
print(f"x = {x}: series J0 = {J_series(0, x):.10f}, scipy jv = {jv(0, x):.10f}, Y0 = {yv(0, x): .6f}")x = 0.5: series J0 = 0.9384698072, scipy jv = 0.9384698072, Y0 = -0.444519
x = 2.0: series J0 = 0.2238907791, scipy jv = 0.2238907791, Y0 = 0.510376
x = 5.0: series J0 = -0.1775967713, scipy jv = -0.1775967713, Y0 = -0.308518
Zeros of Bessel functions and drums
oscillates like a decaying cosine, with zeros , . A circular drum of radius clamped at the edge vibrates in radially symmetric modes , with frequencies proportional to . Since these are not integer multiples of each other, a drum does not sound a clean musical note the way a string does.
from scipy.special import jn_zeros
z = jn_zeros(0, 4)
print("zeros of J0:", z.round(4))
print("frequency ratios to the lowest mode:", (z / z[0]).round(3))zeros of J0: [ 2.4048 5.5201 8.6537 11.7915]
frequency ratios to the lowest mode: [1. 2.295 3.598 4.903]
Legendre's equation
is an ordinary point, and the recurrence terminates when is a non-negative integer: the Legendre polynomials , , , , … (scaled so ). The singular points correspond to the poles of a sphere when , and only the polynomial solutions stay finite there.
They are orthogonal on : for , and for .
import numpy as np
import sympy as sp
from scipy.integrate import quad
from scipy.special import eval_legendre
x = sp.symbols("x")
print([sp.expand(sp.legendre(n, x)) for n in range(4)])
for m, n in ((2, 3), (3, 3), (4, 4)):
val, _ = quad(lambda t: eval_legendre(m, t) * eval_legendre(n, t), -1, 1)
print(f"integral P{m} P{n} = {val:.6f} (2/(2n+1) = {2 / (2 * n + 1):.6f})")[1, x, 3*x**2/2 - 1/2, 5*x**3/2 - 3*x/2]
integral P2 P3 = -0.000000 (2/(2n+1) = 0.285714)
integral P3 P3 = 0.285714 (2/(2n+1) = 0.285714)
integral P4 P4 = 0.222222 (2/(2n+1) = 0.222222)
In software
scipy.specialprovidesjv,yv,jn_zeros,eval_legendre,lpmv(associated Legendre functions) and spherical harmonicssph_harm.- Spherical harmonics, built from Legendre functions, are used in computer graphics for real-time lighting ("spherical harmonic lighting" of irradiance in game engines) and in geodesy for Earth's gravity models.
- Gauss-Legendre quadrature uses the zeros of as integration nodes (Gaussian Quadrature).
Exercises
Exercise 1: Check a Legendre polynomial
Verify that solves Legendre's equation with .
Answer
It does: all terms cancel.
Solution
, . Then .
Exercise 2: Small- behaviour
Use the series to approximate for small .
Answer
.
Solution
: . : .
Exercise 3: Drum frequencies (code)
A drum's lowest radially symmetric mode is at 100 Hz. Where are the next two such modes?
Answer
About 229.5 Hz and 359.8 Hz.
Solution
Frequencies scale with the zeros of :
from scipy.special import jn_zeros
z = jn_zeros(0, 3)
print((100 * z / z[0]).round(1))[100. 229.5 359.8]
Test yourself
Which Bessel function stays finite at ?
- both
- neither
Legendre's equation has polynomial solutions when…
- is a non-negative integer
- is negative
- always
- never
Why does a drum not sound like a single musical note with harmonics?
- Its mode frequencies follow the zeros of , which are not integer multiples
- It has only one mode
- Bessel functions are periodic
- Drums have no modes