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 is hyperbolic where , parabolic where it is 0 and elliptic where it is negative, like the conic . The wave, heat and Laplace equations are the three model cases. classifyPDE({ A, B, C }) (also pde.classify) computes the discriminant; when , , depend on and the type can change from region to region. The Tricomi equation has discriminant : hyperbolic for , parabolic on , elliptic for . 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 on with both ends held at 0, try . Then , a function of equal to a function of , so both are a constant . The boundary conditions force and , and superposing,
The 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 , and for with , ,
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 the tail is tiny after a few terms: the heat equation smooths. At the series is the Fourier series of , no such bound holds, and value is null.
Laplace's equation
On the rectangle , with on the top edge and 0 on the others,
and on the disc of radius with boundary values ,
Both tails are geometric away from the boundary and are bounded the same way. At the centre of the disc only 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 with , so that a rational names an exact direction.
Finitely many modes. When the boundary values are a trigonometric polynomial, such as , or on the circle, or a finite sum of 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 on the unit circle the solution is , which is just , and its value at , is the fraction 1/2. First-order equations are on the characteristics page.
The wave equation
Every solution of is a wave travelling right plus a wave travelling left. With and , d'Alembert's formula is
On an interval with fixed ends the same formula holds once and are continued as odd functions of period : 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 with their certified amplitudes.
Sturm-Liouville problems
Separation of variables leads to eigenvalue problems with . Solve from with , : the value is a continuous function of 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 , have of opposite proven signs, so an eigenvalue lies between them.
| call | returns |
|---|---|
| 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 }] |
@ratmath/analytic and Core's R, Rational, RationalInterval in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.