Topic

Heat, waves and potentials

The three classical partial differential equations, solved by separation of variables with certified Fourier coefficients and a proven bound on the part of the series left out; the wave equation by d'Alembert's formula; and the eigenvalue problems behind separation of variables, by shooting.

const rod = heat({ k: 1, length: 1, initial: "x*(1 - x)", terms: 6 });
rod.at("1/2", "1/10");
// { value: [0.0961618714341, 0.0961618714350], partial: […], tail: 4.9e-22 }

const string = wave({ c: 1, length: 1, position: "sin(pi*x)" });
string.at("1/4", "1/3");             // exact up to rounding: d'Alembert's formula

const plate = laplaceRectangle({ top: "x*(1 - x)", terms: 8 });
plate.at("1/2", "3/4");

Which kind of equation

A second-order linear equation Auxx+Buxy+Cuyy+(lower order)=0A u_{xx} + B u_{xy} + C u_{yy} + (\text{lower order}) = 0 is hyperbolic where B2−4AC>0B^2 - 4AC > 0, parabolic where it is 0 and elliptic where it is negative, like the conic Ax2+Bxy+Cy2Ax^2 + Bxy + Cy^2. The wave, heat and Laplace equations are the three model cases. classifyPDE({ A, B, C }) (also pde.classify) computes the discriminant; when AA, BB, CC depend on xx and yy the type can change from region to region. The Tricomi equation y uxx+uyy=0y\,u_{xx} + u_{yy} = 0 has discriminant −4y-4y: hyperbolic for y<0y < 0, parabolic on y=0y = 0, elliptic for y>0y > 0. at(x, y) decides the type at a point (exactly for polynomial coefficients) and on(rectangle) proves a single type on a rectangle or returns null.

The heat equation

For ut=k uxxu_t = k\,u_{xx} on 0<x<L0 < x < L with both ends held at 0, try u=X(x) T(t)u = X(x)\,T(t). Then T′/(kT)=X′′/XT'/(kT) = X''/X, a function of tt equal to a function of xx, so both are a constant −λ-\lambda. The boundary conditions force X=sin⁡(nπx/L)X = \sin(n\pi x/L) and λ=(nπ/L)2\lambda = (n\pi/L)^2, and superposing,

u(x,t)=∑n=1∞bn e−k(nπ/L)2t sin⁡nπxL,bn=2L∫0Lf(x)sin⁡nπxL dx. u(x, t) = \sum_{n=1}^{\infty} b_n\,e^{-k(n\pi/L)^2 t}\,\sin\frac{n\pi x}{L}, \qquad b_n = \frac{2}{L}\int_0^L f(x)\sin\frac{n\pi x}{L}\,dx .

The bnb_n are the sine coefficients of the initial temperature, which fourier encloses. With insulated ends (ends: "insulated") the series is in cosines and the temperature tends to its mean.

The tail. Since ∣bn∣≤2sup⁡∣f∣|b_n| \le 2\sup|f|, and e−cn2≤ρne^{-cn^2} \le \rho^n for n>Nn > N with ρ=e−c(N+1)\rho = e^{-c(N+1)}, c=kπ2t/L2c = k\pi^2 t/L^2,

∣∑n>Nbne−cn2sin⁡nπxL∣≤2sup⁡∣f∣⋅ρN+11−ρ. \Bigl|\sum_{n > N} b_n e^{-cn^2}\sin\frac{n\pi x}{L}\Bigr| \le 2\sup|f| \cdot \frac{\rho^{N+1}}{1 - \rho}.

So at(x, t) returns the partial sum as an enclosure, this bound as tail, and their sum value, which contains the true temperature. For any t>0t > 0 the tail is tiny after a few terms: the heat equation smooths. At t=0t = 0 the series is the Fourier series of ff, no such bound holds, and value is null.

Laplace's equation

On the rectangle 0<x<a0 < x < a, 0<y<b0 < y < b with u=f(x)u = f(x) on the top edge and 0 on the others,

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

and on the disc of radius RR with boundary values f(θ)f(\theta),

u(r,θ)=a02+∑n=1∞(rR)n(ancos⁡nθ+bnsin⁡nθ). u(r, \theta) = \frac{a_0}{2} + \sum_{n=1}^{\infty} \Bigl(\frac{r}{R}\Bigr)^n (a_n\cos n\theta + b_n\sin n\theta).

Both tails are geometric away from the boundary and are bounded the same way. At the centre of the disc only a0/2a_0/2 survives: the value of a harmonic function at the centre of a circle is the mean of its values on the circle. For the disc, a point is given as (r,s)(r, s) with θ=2πs\theta = 2\pi s, so that a rational ss names an exact direction.

Finitely many modes. When the boundary values are a trigonometric polynomial, such as cos⁡θ\cos\theta, cos⁡2θ\cos^2\theta or sin⁡3θ\sin^3\theta on the circle, or a finite sum of sin⁡(nπx/a)\sin(n\pi x/a) on the top edge, the series has finitely many terms and nothing is left out. Products and powers are expanded with the product-to-sum identities into exact rational coefficients, and the solution carries exact: true, a closedForm, and a tail of 0. With cos⁡θ\cos\theta on the unit circle the solution is rcos⁡θr\cos\theta, which is just xx, and its value at r=1/2r = 1/2, θ=0\theta = 0 is the fraction 1/2. First-order equations are on the characteristics page.

The wave equation

Every solution of utt=c2uxxu_{tt} = c^2 u_{xx} is a wave travelling right plus a wave travelling left. With u(x,0)=fu(x, 0) = f and ut(x,0)=gu_t(x, 0) = g, d'Alembert's formula is

u(x,t)=f(x−ct)+f(x+ct)2+12c∫x−ctx+ctg(s) ds. u(x, t) = \frac{f(x - ct) + f(x + ct)}{2} + \frac{1}{2c}\int_{x - ct}^{x + ct} g(s)\,ds .

On an interval with fixed ends the same formula holds once ff and gg are continued as odd functions of period 2L2L: the reflections at the ends are built in. wave uses this, so its values need no series and carry no truncation error. modes(N) lists the standing waves sin⁡(nπx/L)cos⁡(nπct/L)\sin(n\pi x/L)\cos(n\pi ct/L) with their certified amplitudes.

Sturm-Liouville problems

Separation of variables leads to eigenvalue problems −(p y′)′+q y=λ w y-(p\,y')' + q\,y = \lambda\,w\,y with y(a)=y(b)=0y(a) = y(b) = 0. Solve from aa with y(a)=0y(a) = 0, y′(a)=1y'(a) = 1: the value y(b;λ)y(b; \lambda) is a continuous function of λ\lambda that vanishes exactly at the eigenvalues. sturmLiouville finds the sign changes in floating point, then proves each: two validated solutions, at the ends of a small interval of λ\lambda, have y(b)y(b) of opposite proven signs, so an eigenvalue lies between them.

callreturns
classifyPDE({ A, B, C }), pde.classify{ discriminant, type, regions: { hyperbolic, parabolic, elliptic }, at(x, y), on([[x0, x1], [y0, y1]]) }
heat({ k, length, initial, ends = "fixed", terms = 8 }){ coefficients, modes, at(x, t), formula(terms) }
laplaceRectangle({ width, height, top, terms }){ coefficients, modes, at(x, y), formula }
laplaceDisc({ radius, boundary, terms, angle = "theta" }){ coefficients, mean, at(r, s), formula }; with finitely many modes also { exact: true, closedForm, modes }
s.at(…){ value, partial, tail }
wave({ c, length, position, velocity }){ at(x, t), travelling, modes(N) }; no length means the whole line
sturmLiouville({ p, q, w, interval, count = 3, width = "1e-6", certify = true })[{ index, eigenvalue, estimate, proven }]
Try itEdit the code and run it with @ratmath/analytic and Core's R, Rational, RationalInterval in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.
Ctrl/⌘ + Enter runs