Topic

Series solutions

Many equations of physics have no solution in elementary functions: Airy's, Bessel's, Legendre's. Their solutions are defined by power series. seriesSolution builds those series for y′′+p(x) y′+q(x) y=0y'' + p(x)\,y' + q(x)\,y = 0 about a point, with exact rational coefficients, and says what kind of point it is.

seriesSolution({ q: "-x", order: 7 });            // Airy: y'' = x y
// kind "ordinary", solutions "1 + 1/6*x^3 + 1/180*x^6 + …" and "x + 1/12*x^4 + 1/504*x^7 + …"

seriesSolution({ p: "1/x", q: "(x^2 - 1/4)/x^2" });   // Bessel of order 1/2
// kind "regular singular", indicial "r^2 - 1/4 = 0", exponents [1/2, -1/2], two series

Ordinary points

If pp and qq are analytic at x0x_0, every solution is a power series ∑an(x−x0)n\sum a_n (x - x_0)^n there, and it converges at least as far as the nearest singularity of pp or qq in the complex plane. Substituting the series and matching powers gives a recurrence that determines every ana_n from a0a_0 and a1a_1:

(n+2)(n+1) an+2=−∑k=0n(pk (n−k+1) an−k+1+qk an−k). (n+2)(n+1)\,a_{n+2} = -\sum_{k=0}^{n} \bigl( p_k\,(n-k+1)\,a_{n-k+1} + q_k\,a_{n-k} \bigr).

The two solutions returned are the ones with (y,y′)(x0)=(1,0)(y, y')(x_0) = (1, 0) and (0,1)(0, 1). radius estimates the distance to the nearest singularity.

Regular singular points and Frobenius

If pp has at most a simple pole and qq at most a double pole at x0x_0, the point is a regular singular point. Write xp(x)=∑Pkxkx p(x) = \sum P_k x^k and x2q(x)=∑Qkxkx^2 q(x) = \sum Q_k x^k (taking x0=0x_0 = 0). Frobenius' method looks for y=xr∑anxny = x^r \sum a_n x^n; the lowest power gives the indicial equation

r(r−1)+P0 r+Q0=0, r(r - 1) + P_0\,r + Q_0 = 0,

and for each root rr the recurrence

[(n+r)(n+r−1)+P0(n+r)+Q0] an=−∑k=1n(Pk(n−k+r)+Qk) an−k. \bigl[(n+r)(n+r-1) + P_0 (n+r) + Q_0\bigr]\,a_n = -\sum_{k=1}^{n} \bigl(P_k (n-k+r) + Q_k\bigr)\,a_{n-k}.

The larger root always gives a series. The smaller root gives a second one unless the roots are equal or differ by a whole number, in which case the bracket on the left can vanish for some nn; then the second solution contains log⁡x\log x, and notes says so. (When the right side happens to vanish too, the series exists after all, as for Bessel's equation of order one half.)

A point where the poles are worse is an irregular singular point, and the method does not apply.

A proven remainder

A truncated series is only useful with a bound on what was cut off. Each solution y=(x−x0)rg(x)y = (x - x_0)^r g(x), g=∑an(x−x0)ng = \sum a_n (x - x_0)^n, carries one: remainder(ρ) returns a rational BB with

∣ g(x)−∑n≤Nan(x−x0)n∣≤Bfor all complex x with ∣x−x0∣≤ρ, \Bigl|\, g(x) - \sum_{n \le N} a_n (x - x_0)^n \Bigr| \le B \quad\text{for all complex } x \text{ with } |x - x_0| \le \rho ,

for any ρ\rho below provenRadius. enclose(x) evaluates the partial sum at a rational point and puts that bound on either side.

const cos = seriesSolution({ q: "1", order: 12 }).solutions[0];   // y'' + y = 0, y(0) = 1, y'(0) = 0
cos.remainder(1).bound;        // 447/1000000000000: the terms beyond x^12 are below 4.47e-10 on the unit disc
const e = cos.enclose("1/2");  // { partial, bound, low, high }
e.low.toDecimal(15), e.high.toDecimal(15);   // both 0.877582561890372…: cos(1/2) to 13 places, proven

The proof is the classical convergence argument made quantitative. Take x0=0x_0 = 0. First, a radius: the reciprocals of the roots of the denominators of pp and qq are bounded by root squaring (Graeffe) and Fujiwara's bound, in exact arithmetic, giving RR with no singular point in 0<∣x∣<R0 < |x| < R; that is provenRadius, within about one percent of the true distance. Second, for a radius s<Rs < R, numbers MP,MQM_P, M_Q with ∣Pk∣≤MP/sk|P_k| \le M_P/s^k and ∣Qk∣≤MQ/sk|Q_k| \le M_Q/s^k for all k≥1k \ge 1: the first hundred or so coefficients are used exactly and the rest are bounded by a majorant of the form (1−x/R)−m(1 - x/R)^{-m}. Third, the recurrence. With bn=∣an∣snb_n = |a_n| s^n and cj=MP(∣r∣+j)+MQc_j = M_P(|r| + j) + M_Q it gives

n (n+δ) bn≤Sn:=∑j<ncjbj,Sn+1≤Sn (1+εn),εn=cnn(n+δ), n\,(n + \delta)\, b_n \le S_n := \sum_{j < n} c_j b_j, \qquad S_{n+1} \le S_n\,(1 + \varepsilon_n), \quad \varepsilon_n = \frac{c_n}{n(n + \delta)},

where δ=2r−1+P0\delta = 2r - 1 + P_0, because the bracket in the recurrence equals n(n+δ)n(n + \delta). SN+1S_{N+1} is known exactly from the coefficients already computed, and εn\varepsilon_n decreases to 0. So for ∣x∣≤ρ<s|x| \le \rho < s the tail ∑n>Nbn(ρ/s)n\sum_{n > N} b_n (\rho/s)^n is at most a few explicit terms plus a geometric series, once (1+εn)ρ/s<1(1 + \varepsilon_n)\rho/s < 1. Several values of ss are tried and the smallest bound kept. Every step is rational arithmetic rounded upward.

The bound covers the series gg; the factor (x−x0)r(x - x_0)^r is explicit. Near the edge of the disc a bound still exists but is weak, as it must be: the series itself converges slowly there.

Checking a series

The coefficients are exact, and a partial sum is a polynomial whose value at a rational point is an exact rational. Comparing it with the validated solution of the same initial value problem shows the true truncation error next to the proven bound, as in the box below.

callreturns
seriesSolution({ p, q, about = 0, order = 8, x = "x" }){ about, kind, indicial, exponents, solutions, notes, radius, provenRadius }
solutions[i]{ exponent, coefficients, text, remainder, enclose }, coefficients exact
solutions[i].remainder(ρ){ radius, terms, bound, approx, text }: a proven bound for the terms left out, on the disc of radius ρ
solutions[i].enclose(x){ partial, bound, low, high, exponent }: the series factor at a rational x
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