Flow Lab

Syllabus / Module 5: Second-Order Linear ODEs & Oscillations

Lesson 5.8

Series Solutions

Power-series solutions near ordinary points, recurrence relations, regular singular points & Frobenius (intro), Bessel and Legendre equations.

Written byClaude Sonnet

🌊
Why this matters for simulation: Bessel functions describe the vibration of a drumhead and flow in round pipes.

By the end of this lesson you can…

  • Substitute $y = \sum a_nt^n$ into a linear equation, shift indices and read off a recurrence relation for the coefficients.
  • Derive the Airy recurrence $a_{n+3} = a_n/((n+3)(n+2))$, explain why only every third coefficient is nonzero in each family, and compare the series with scipy's Airy function.
  • Predict a radius of convergence from the complex singularities of the coefficient functions and from the coefficient ratio, and demonstrate numerically that partial sums diverge outside it.
  • Solve Euler's equation through its indicial equation $r(r-1) + \alpha r + \beta = 0$, and explain why a repeated root brings a logarithm.
  • Derive the Frobenius series for Bessel's equation of order 0, obtain $J_0$ and its first zeros, and say why the second solution has a $\ln t$ term.
  • Derive Legendre's recurrence and show that integer $n$ gives polynomial solutions $P_n$.
  • Measure how much accuracy a float64 Taylor sum loses to cancellation, and say when to use a solver or a special-function library instead.
On this page
·
  1. Power series, a recap
  2. Solutions near an ordinary point
  3. The Airy equation
  4. A finite radius
  5. Regular singular points and the Frobenius idea
  6. Bessel’s equation of order 0
  7. Legendre’s equation
  8. Numerical honesty: cancellation
  9. Check yourself
  10. Problems
  11. Key Takeaways

Every equation so far had constant coefficients, which is what made erte^{rt} an eigenfunction. Variable coefficients break that: Airy’s y′′=tyy'' = ty describes a wave whose local frequency changes with position, and Bessel’s t2y′′+ty′+t2y=0t^2y'' + ty' + t^2y = 0 describes a round drumhead. Neither has a solution built from exponentials and powers. What survives is the idea behind 2.4 Taylor Series in One and Several Variables: a smooth solution is a power series, and the equation tells us the coefficients one at a time. This lesson turns that idea into a recipe (recurrence relations), finds out how far the result can be trusted (the radius of convergence), extends it to equations with a singular point (the Frobenius method), and ends with a numerical warning that matters for anyone who evaluates series on a computer. It builds on 5.1 Second-Order Linear Equations: Structure and 5.7 Higher-Order Linear Equations, and is the last lesson of the module.

▶ Video Plugging in a power series, the Airy recurrence, partial sums converging and then diverging past the radius, Euler's indicial equation, J0 and its zeros, and cancellation in float64captions only
Transcript
  1. Airy's and Bessel's equations have no exponential solutions, so try a power series and let the equation find the coefficients. The ratio test gives a radius, one over L: infinite for e to the t, but 1 for one over one plus t squared.
  2. Put the series into Airy's equation and shift indices until every sum has t to the n. The constant term forces a 2 to be zero; every other power gives a n plus 3 equals a n over n plus 3 times n plus 2.
  3. The recurrence links indices three apart: three chains, and the one from a 2 stays zero. The others give 1, 1 over 6, 1 over 180, 1 over 12960, and 1, 1 over 12, 1 over 504, 1 over 45360. The Wronskian is 1, and the radius is infinite.
  4. With a 0 and a 1 equal to Ai at zero, about 0.355, and Ai prime at zero, about minus 0.259, the series is the Airy function. An error below 10 to the minus 10 needs degree 16 at t equals 1, 24 at t equals 2, 51 at t equals minus 5.
  5. Tame coefficients can hide a short radius. In one plus t squared times y double prime plus y equals zero, the coefficient blows up at plus or minus i, distance 1 from the origin, and the recurrence factor tends to minus 1: the radius is exactly 1.
  6. Sum to degree 10, 20, 40, 80 and 160 and compare with a solver. At t equals 0.9 the error falls to about 1.5 times 10 to the minus 12; at 1.2 it grows to about 1.9 times 10 to the 8; at t equals 2 it reaches 8.26 times 10 to the 43.
  7. Near a regular singular point, Euler's equation is the model. Try t to the r: the indicial equation r times r minus 1 plus alpha r plus beta equals zero. A double root, r equals 2, brings a log: t squared times one minus 2 ln t, and y of 2 is about minus 1.5452.
  8. Bessel of order zero has indicial equation r squared equals zero. With r equals 0, a n equals minus a n minus 2 over n squared, so only even terms survive, and J zero is 1 minus t squared over 4 plus t to the fourth over 64.
  9. Root-finding gives the zeros 2.404826, 5.520078 and 8.653728. The 8-term partial sum, degree 14, gets the first zero but puts the second at 5.539919, off by 0.02. From memory, a drum's modes have frequency ratios 1, 2.2954, 3.5985, 4.9033: not whole numbers, so no pitch.
  10. A double root gives one Frobenius series. Abel gives W equals C over t, so y 2 equals J zero times the integral of dt over t J zero squared. Near zero that is like the integral of 1 over t: a ln t. From memory, Y zero at 10 to the minus 6 is minus 8.869031, matching the log.
  11. Legendre's numerator, k times k plus 1 minus n times n plus 1, vanishes at k equals n, so for integer n the chain stops. P 2 is 3 t squared minus 1 over 2, P 3 is 5 t cubed minus 3 t over 2, with exact residual 0.
  12. For J zero at t equals 20 the terms grow to 7.6 times 10 to the 6, yet the answer is 0.167, so 7.7 digits are lost. The table compares float64 with exact fractions; digits lost is log ten of the largest term over the answer.
  13. At t equals 40, the largest term is 1.9 times 10 to the 15: 17.4 digits lost, more than float64 holds. The sum returns minus 0.0901; the truth is plus 0.00737. Series are local tools: use libraries or solvers for numbers, series for structure. Next: Laplace transforms.

Power series, a recap

A power series about t0t_0 is ∑n≥0cn(t−t0)n\sum_{n\ge0} c_n(t - t_0)^n. If ∣cn+1/cn∣→L|c_{n+1}/c_n| \to L (or ∣cn∣1/n→L|c_n|^{1/n} \to L), the ratio test says the series converges absolutely for ∣t−t0∣<1/L|t - t_0| \lt 1/L and diverges for ∣t−t0∣>1/L|t - t_0| \gt 1/L. That number ρ=1/L\rho = 1/L is the radius of convergence (ρ=∞\rho = \infty if L=0L = 0); the endpoints must be checked by hand. Inside the radius we may differentiate term by term, (∑cntn)′=∑ncntn−1\bigl(\sum c_nt^n\bigr)' = \sum nc_nt^{n-1} (Calc II, from memory), and a power series that is zero on an interval has all cn=0c_n = 0. The second fact lets us match coefficients of each power separately, the whole basis of the method.

For ete^t, cn+1/cn=1/(n+1)→0c_{n+1}/c_n = 1/(n+1) \to 0, so ρ=∞\rho = \infty. For 1/(1+t2)=∑(−1)kt2k1/(1 + t^2) = \sum(-1)^kt^{2k} the ratio of consecutive nonzero terms is t2t^2 in magnitude, so ρ=1\rho = 1, although the function is smooth on the whole real line (the cause was discussed in 2.4 Taylor Series in One and Several Variables, and returns below).

Solutions near an ordinary point

Write the equation in standard form y′′+p(t)y′+q(t)y=0y'' + p(t)y' + q(t)y = 0. A point t0t_0 is ordinary if pp and qq both have convergent power series about t0t_0. The theorem (Boyce and DiPrima, stated here without proof, from memory) says that near an ordinary point every solution is a power series y=∑an(t−t0)ny = \sum a_n(t - t_0)^n with a0=y(t0)a_0 = y(t_0) and a1=y′(t0)a_1 = y'(t_0) free, converging at least as far as the series of pp and qq do. For rational p,qp, q that distance is the distance from t0t_0 to the nearest singularity of pp or qq in the complex plane.

The recipe, for t0=0t_0 = 0:

  1. Put y=∑n≥0antny = \sum_{n\ge0}a_nt^n, so y′=∑nantn−1y' = \sum na_nt^{n-1} and y′′=∑n(n−1)antn−2y'' = \sum n(n-1)a_nt^{n-2}.
  2. Substitute, and shift indices until every sum is written with tnt^n. For example ∑n≥2n(n−1)antn−2=∑n≥0(n+2)(n+1)an+2tn\sum_{n\ge2}n(n-1)a_nt^{n-2} = \sum_{n\ge0}(n+2)(n+1)a_{n+2}t^n.
  3. Collect the coefficient of each tnt^n and set it to 00. This gives a recurrence relation: an equation for an+2a_{n+2} (or an+3a_{n+3}) in terms of earlier coefficients.
  4. Choose a0,a1a_0, a_1 freely and generate the rest.

The Airy equation

Take y′′=tyy'' = ty. Then y′′=∑(n+2)(n+1)an+2tny'' = \sum(n+2)(n+1)a_{n+2}t^n and ty=∑antn+1=∑n≥1an−1tnty = \sum a_nt^{n+1} = \sum_{n\ge1}a_{n-1}t^n. The powers match as follows.

  • Coefficient of t0t^0: the right side has no constant term, so 2⋅1⋅a2=02\cdot1\cdot a_2 = 0 and a2=0a_2 = 0.
  • Coefficient of tnt^n, n≥1n \ge 1: (n+2)(n+1)an+2=an−1(n+2)(n+1)a_{n+2} = a_{n-1}. Replacing nn by n+1n+1,
an+3=an(n+3)(n+2).a_{n+3} = \frac{a_n}{(n+3)(n+2)} .

The recurrence links indices three apart, so there are three independent chains: a0,a3,a6,…a_0, a_3, a_6, \ldots and a1,a4,a7,…a_1, a_4, a_7, \ldots and a2,a5,a8,…a_2, a_5, a_8, \ldots. The last chain starts at a2=0a_2 = 0 and is zero forever. Two chains survive, each fed by one free constant:

f(t)=1+t36+t6180+t912960+⋯ ,g(t)=t+t412+t7504+t1045360+⋯f(t) = 1 + \frac{t^3}{6} + \frac{t^6}{180} + \frac{t^9}{12960} + \cdots, \qquad g(t) = t + \frac{t^4}{12} + \frac{t^7}{504} + \frac{t^{10}}{45360} + \cdots

(for example a9=a6/(9⋅8)=1/(180⋅72)=1/12960a_9 = a_6/(9\cdot8) = 1/(180\cdot72) = 1/12960). So y=a0f+a1g=y(0)f+y′(0)gy = a_0f + a_1g = y(0)f + y'(0)g. Their Wronskian at 00 is f(0)g′(0)−f′(0)g(0)=1f(0)g'(0) - f'(0)g(0) = 1, so they are independent. Because ∣an+3tn+3∣/∣antn∣=∣t∣3/((n+3)(n+2))→0|a_{n+3}t^{n+3}|/|a_nt^n| = |t|^3/((n+3)(n+2)) \to 0 for every tt, the radius is infinite, as promised by the theorem: p=0p = 0 and q=−tq = -t have no singularities.

All coefficients are positive, so for t>0t \gt 0 both ff and gg grow without bound. For t<0t \lt 0 the equation reads y′′=−∣t∣yy'' = -|t|y, an oscillator whose frequency ∣t∣\sqrt{|t|} increases as we go left, so the solutions oscillate faster and faster. The Airy function Ai(t)\mathrm{Ai}(t) is the combination that decays for t>0t \gt 0; it has Ai(0)=0.3550280538878172\mathrm{Ai}(0) = 0.3550280538878172 and Ai′(0)=−0.2588194037928068\mathrm{Ai}'(0) = -0.2588194037928068 (both from scipy.special.airy). In the sim below you can see its partial sums; in the exercise you build them yourself.

🧪 Coding exerciseExercise: Airy coefficients from the recurrence, compared with scipy.special.airy
⌘/Ctrl + Enter

With the cell completed, it reports degrees 1616, 2424 and 5151 at t=1,2,−5t = 1, 2, -5 for an error below 10−1010^{-10}: the farther from the center, the more terms, because the terms ∣antn∣|a_nt^n| must first grow before they shrink.

A finite radius

An equation with perfectly tame real coefficients can still have a short radius. Take (1+t2)y′′+y=0(1 + t^2)y'' + y = 0, in standard form y′′+11+t2 y=0y'' + \dfrac{1}{1+t^2}\,y = 0. The origin is ordinary. The function 1/(1+t2)1/(1+t^2) is singular where 1+t2=01 + t^2 = 0, at t=±it = \pm i, a distance 11 from the origin, so the theorem guarantees ρ≥1\rho \ge 1. Expand (1+t2)∑n(n−1)antn−2+∑antn=0(1+t^2)\sum n(n-1)a_nt^{n-2} + \sum a_nt^n = 0 and collect tnt^n:

(n+2)(n+1)an+2+n(n−1)an+an=0⟹an+2=−n2−n+1(n+2)(n+1) an.(n+2)(n+1)a_{n+2} + n(n-1)a_n + a_n = 0 \quad\Longrightarrow\quad a_{n+2} = -\frac{n^2 - n + 1}{(n+2)(n+1)}\,a_n .

For large nn this ratio tends to −1-1, so ∣an+2tn+2∣/∣antn∣→t2|a_{n+2}t^{n+2}|/|a_nt^n| \to t^2. The ratio test then gives convergence for ∣t∣<1|t| \lt 1 and divergence for ∣t∣>1|t| \gt 1: the radius is exactly 11 for the solution with y(0)=1y(0) = 1, y′(0)=0y'(0) = 0. No feature on the real axis announces this; the singularities live in the complex plane, which is why a series can fail at a place where the solution looks harmless.

The lab cell below sums the series to degrees 10,20,40,80,16010, 20, 40, 80, 160 and compares with DOP853 at tolerance 10−1310^{-13}. At t=0.9t = 0.9 the errors fall steadily, from 2.34×10−32.34\times10^{-3} (degree 10) to 1.51×10−121.51\times10^{-12} (degree 160). At t=1.2t = 1.2 they grow: 5.76×10−25.76\times10^{-2}, 9.62×10−29.62\times10^{-2}, 9.53×10−19.53\times10^{-1}, then 3.56×1023.56\times10^{2} and 1.94×1081.94\times10^{8} at degree 160. At t=2t = 2 the degree-160 partial sum is off by 8.26×10438.26\times10^{43} (the reference there is −0.1708804675-0.1708804675). At the boundary t=1t = 1 the error shrinks, but slowly: 7.63×10−37.63\times10^{-3} at degree 10 and 3.51×10−53.51\times10^{-5} at degree 160. More terms make things worse outside the radius, because the individual terms no longer tend to zero.

◆ Interactive Raise the degree N and watch the partial sums converge, or fail to, against an RK4 reference

Loading simulation…

On the sim’s finite radius preset with N=40N = 40, the maximum error on [−0.9,0.9][-0.9, 0.9] is 7.167×10−67.167\times10^{-6} (the lab’s t=0.9t = 0.9 row), but on [−1.6,1.6][-1.6, 1.6] it is 1.170×1051.170\times10^{5}. The sim also estimates the radius from the coefficients, ρ≈(∣am−2∣/∣am∣)1/2\rho \approx (|a_{m-2}|/|a_m|)^{1/2} for the last two nonzero coefficients. At N=10N = 10 it reads 1.25661.2566, at N=40N = 40 it reads 1.05301.0530 and at N=160N = 160 it reads 1.01271.0127: it creeps toward 11, because ∣an/an+2∣1/2≈1+2/n|a_n/a_{n+2}|^{1/2} \approx 1 + 2/n for the lower index nn (at n=158n = 158 that is 1.01271.0127). A coefficient ratio can only show a trend, never an exact radius. Switch to the Airy and Bessel presets: there the estimate keeps growing with NN (for Bessel it equals the highest even degree kept, mm, exactly, since ∣am−2/am∣=m2|a_{m-2}/a_m| = m^2), the signature of an infinite radius.

🐍 PythonLab: partial sums versus DOP853, zeros of J0, float64 cancellation, and the second Bessel solution (blocks A to D)
⌘/Ctrl + Enter

Regular singular points and the Frobenius idea

Bessel’s equation t2y′′+ty′+t2y=0t^2y'' + ty' + t^2y = 0, in standard form y′′+1ty′+y=0y'' + \tfrac1t y' + y = 0, has p=1/tp = 1/t, which blows up at 00, so 00 is not ordinary. A power series can fail there (we will see ln⁡t\ln t). The point is nevertheless tame: t p(t)t\,p(t) and t2q(t)t^2q(t) are analytic at 00. Such a point is a regular singular point: near it the equation looks like y′′+(p0/t) y′+(q0/t2) y=0y'' + (p_0/t)\,y' + (q_0/t^2)\,y = 0, with p0=lim⁡tpp_0 = \lim tp and q0=lim⁡t2qq_0 = \lim t^2q.

That model equation is Euler’s equation t2y′′+αty′+βy=0t^2y'' + \alpha ty' + \beta y = 0. Its coefficients scale with tt, which suggests a power of tt. With y=try = t^r (for t>0t \gt 0),

t2⋅r(r−1)tr−2+αt⋅rtr−1+βtr=[r(r−1)+αr+β]tr,t^2\cdot r(r-1)t^{r-2} + \alpha t\cdot rt^{r-1} + \beta t^r = \bigl[r(r-1) + \alpha r + \beta\bigr]t^r ,

so y=try = t^r is a solution exactly when

r(r−1)+αr+β=0,r(r-1) + \alpha r + \beta = 0 ,

the indicial equation. Example: t2y′′+2ty′−6y=0t^2y'' + 2ty' - 6y = 0 gives r2+r−6=(r−2)(r+3)=0r^2 + r - 6 = (r-2)(r+3) = 0, so y=c1t2+c2t−3y = c_1t^2 + c_2t^{-3}. One solution is smooth at the origin and the other blows up, which is typical.

To see what a repeated or complex root does, substitute s=ln⁡ts = \ln t and u(s)=y(t)u(s) = y(t). Then ty′=usty' = u_s and t2y′′=uss−ust^2y'' = u_{ss} - u_s, so the equation becomes the constant-coefficient equation uss+(α−1)us+βu=0u_{ss} + (\alpha - 1)u_s + \beta u = 0, whose characteristic polynomial is r2+(α−1)r+β=r(r−1)+αr+βr^2 + (\alpha - 1)r + \beta = r(r-1) + \alpha r + \beta. This is the indicial equation again. By 5.2 Constant Coefficients & the Characteristic Equation, a double root rr gives u=(c1+c2s)ersu = (c_1 + c_2s)e^{rs}, that is,

y=tr(c1+c2ln⁡t),y = t^r(c_1 + c_2\ln t) ,

and roots a±iba \pm ib give tacos⁡(bln⁡t)t^a\cos(b\ln t) and tasin⁡(bln⁡t)t^a\sin(b\ln t), which oscillate infinitely often as t→0+t \to 0^+. The logarithm is the mechanism behind every “repeated indicial root” below.

Frobenius’ idea (from memory for the general theorem): at a regular singular point, look for y=tr∑n≥0antny = t^r\sum_{n\ge0}a_nt^n with a0≠0a_0 \ne 0. The lowest power of tt in the substituted equation has coefficient a0 [r(r−1)+p0r+q0]a_0\,[r(r-1) + p_0r + q_0], so rr must satisfy the indicial equation; the higher powers give a recurrence for ana_n. The larger root always yields a series solution; the second solution may need a ln⁡t\ln t term when the roots are equal or differ by an integer.

Bessel’s equation of order 0

Here p0=1p_0 = 1 and q0=0q_0 = 0, so the indicial equation is r(r−1)+r=r2=0r(r-1) + r = r^2 = 0: a double root r=0r = 0. Insert y=∑antn+ry = \sum a_nt^{n+r}:

t2y′′+ty′=∑(n+r)2antn+r,t2y=∑an−2tn+r (indices shifted),t^2y'' + ty' = \sum (n+r)^2a_nt^{n+r}, \qquad t^2y = \sum a_{n-2}t^{n+r} \ (\text{indices shifted}),

and the coefficient of tn+rt^{n+r} is (n+r)2an+an−2=0(n+r)^2a_n + a_{n-2} = 0 for n≥2n \ge 2, while n=1n = 1 gives (1+r)2a1=0(1+r)^2a_1 = 0. With r=0r = 0: a1=0a_1 = 0 and an=−an−2/n2a_n = -a_{n-2}/n^2. So only even indices survive, a2k=−a2k−2/(2k)2a_{2k} = -a_{2k-2}/(2k)^2, and with a0=1a_0 = 1:

J0(t)=∑k=0∞(−1)k(k!)2(t2)2k=1−t24+t464−⋯ .J_0(t) = \sum_{k=0}^{\infty}\frac{(-1)^k}{(k!)^2}\Bigl(\frac t2\Bigr)^{2k} = 1 - \frac{t^2}{4} + \frac{t^4}{64} - \cdots .

The ratio of terms is t2/(4k2)→0t^2/(4k^2) \to 0, so the radius is infinite. J0J_0 is even, has J0(0)=1J_0(0) = 1 and oscillates like a damped cosine. Its first three positive zeros, from jn_zeros and (in block B) from root-finding on the 60-term series, are

2.404826,5.520078,8.653728.2.404826, \qquad 5.520078, \qquad 8.653728 .

Partial sums find the zeros one at a time: the degree-14 polynomial (8 terms) has its first zero at 2.4048262.404826 already, but its second at 5.5399195.539919, off by 0.020.02.

Why not a second series? A double root gives only one Frobenius series. To find the other solution, use Abel’s theorem (5.1 Second-Order Linear Equations: Structure): for y′′+y′/t+y=0y'' + y'/t + y = 0, W=Ce−∫dt/t=C/tW = Ce^{-\int dt/t} = C/t. Reduction of order gives y2=J0∫dtt J02y_2 = J_0\int\dfrac{dt}{t\,J_0^2}. Near 00, J02→1J_0^2 \to 1, so the integrand behaves like 1/t1/t and the integral like ln⁡t\ln t. The second solution therefore has a logarithmic singularity, as in the trln⁡tt^r\ln t of Euler’s equation. Block D checks the shape: Y0(10−6)=−8.869031Y_0(10^{-6}) = -8.869031 against 2π(ln⁡(t/2)+γ)=−8.869031\tfrac2\pi(\ln(t/2) + \gamma) = -8.869031, where γ=0.5772156649\gamma = 0.5772156649 is Euler’s constant and Y0≈2π(ln⁡t2+γ)J0+⋯Y_0 \approx \tfrac2\pi(\ln\tfrac t2 + \gamma)J_0 + \cdots is the standard form (from memory). Wherever the solution must stay bounded at t=0t = 0, only J0J_0 is allowed.

Legendre’s equation

(1−t2)y′′−2ty′+n(n+1)y=0(1-t^2)y'' - 2ty' + n(n+1)y = 0 has p=−2t/(1−t2)p = -2t/(1-t^2) and q=n(n+1)/(1−t2)q = n(n+1)/(1-t^2), singular at t=±1t = \pm1. The origin is ordinary, and the theorem guarantees ρ≥1\rho \ge 1. Substituting y=∑aktky = \sum a_kt^k and collecting tkt^k:

(k+2)(k+1)ak+2−k(k−1)ak−2kak+n(n+1)ak=0⟹ak+2=k(k+1)−n(n+1)(k+2)(k+1) ak.(k+2)(k+1)a_{k+2} - k(k-1)a_k - 2ka_k + n(n+1)a_k = 0 \quad\Longrightarrow\quad a_{k+2} = \frac{k(k+1) - n(n+1)}{(k+2)(k+1)}\,a_k .

The numerator vanishes at k=nk = n. For integer nn, that chain therefore stops: an+2=an+4=⋯=0a_{n+2} = a_{n+4} = \cdots = 0, and one of the two families is a polynomial of degree nn. (The other family never terminates and has ratio →1\to 1, so it diverges at t=±1t = \pm1; from memory, logarithmically.) Normalize so that Pn(1)=1P_n(1) = 1.

  • n=2n = 2, start the even chain at a0a_0: a2=0−62a0=−3a0a_2 = \dfrac{0 - 6}{2}a_0 = -3a_0, a4=6−612a2=0a_4 = \dfrac{6 - 6}{12}a_2 = 0. With a0=−12a_0 = -\tfrac12: P2=3t2−12P_2 = \dfrac{3t^2 - 1}{2}.
  • n=3n = 3, start the odd chain at a1a_1: a3=2−126a1=−53a1a_3 = \dfrac{2 - 12}{6}a_1 = -\dfrac53a_1, a5=0a_5 = 0. With a1=−32a_1 = -\tfrac32: P3=5t3−3t2P_3 = \dfrac{5t^3 - 3t}{2}.

The lab cell below builds PnP_n from the recurrence and checks the differential equation. Both residuals come out exactly 00 in exact (rational) arithmetic; evaluated in float64 at 200200 points of [−1,1][-1, 1] the largest residual is 00 for P2P_2 and 7.1×10−157.1\times10^{-15} for P3P_3. From memory, ∫−11PmPn dt=0\int_{-1}^1P_mP_n\,dt = 0 for m≠nm \ne n (orthogonality, the basis of later lessons on generalized Fourier series), and the PnP_n give the angular dependence of solutions of Laplace’s equation in spherical coordinates, the starting point of spherical harmonics.

🐍 PythonLab: Legendre polynomials from the recurrence; residual of the equation in exact and in float arithmetic
⌘/Ctrl + Enter

Numerical honesty: cancellation

A convergent series is not automatically a good algorithm. Look at J0(20)J_0(20). The terms (t/2)2k/(k!)2(t/2)^{2k}/(k!)^2 grow until k=9k = 9, where the term is 7.6×1067.6\times10^6, and only then decay; the answer is J0(20)=0.1670246643J_0(20) = 0.1670246643. Adding numbers of size 10710^7 with alternating signs to get 0.170.17 throws away digits: float64 carries about 1616, so only about 16−7.7≈816 - 7.7 \approx 8 digits survive (the measured error 7.8×10−117.8\times10^{-11} on an answer of 0.1670.167 corresponds to about 99). Block C compares float64 summation with exact rational arithmetic (Python’s Fraction, 200 terms):

ttlargest termdigits lostfloat64 error
59.89.81.71.71.7×10−161.7\times10^{-16}
106.8×1026.8\times10^{2}3.43.42.3×10−142.3\times10^{-14}
207.6×1067.6\times10^{6}7.77.77.8×10−117.8\times10^{-11}
301.1×10111.1\times10^{11}12.112.11.2×10−51.2\times10^{-5}
401.9×10151.9\times10^{15}17.417.49.7×10−29.7\times10^{-2}

Here “digits lost” is log⁡10(largest term/∣J0∣)\log_{10}(\text{largest term}/|J_0|). At t=40t = 40 it exceeds 1616: float64 returns −0.0901-0.0901, but the true value is +0.00737+0.00737. The error is not a truncation error (the series was summed to convergence) and not a convergence failure (the radius is infinite); it is rounding error, of order ε×\varepsilon\times(largest term), amplified because nothing in the sum is small. Library routines such as scipy.special.j0 avoid the problem (their errors in block C are below 10−1610^{-16} at every row); the algorithms are different, and I only know the general idea (from memory).

The sim shows the same tradeoff. On the Bessel preset with window W=20W = 20, N=60N = 60 gives a maximum error of 1.346×10−61.346\times10^{-6}, truncation still dominant; N=150N = 150 gives 1.200×10−91.200\times10^{-9}, and more terms will not help, since the readout says the float64 floor, about 1.1×10−161.1\times10^{-16} times the largest term 7.59×1067.59\times10^{6}, is 8.35×10−108.35\times10^{-10}. The lab’s 7.8×10−117.8\times10^{-11} at t=20t = 20 is smaller than the sim’s number because the two sums round differently (the sim uses Horner’s rule and a separate RK4 reference); both are within an order of magnitude of ε×\varepsilon\times(largest term). That product is a scale, not a guarantee.

Check yourself

✅ Concept check

For $(t^2 + 6t + 13)y'' + ty' + y = 0$, what is the largest radius of convergence about $t_0 = 0$ that the ordinary-point theorem guarantees? (Give a number.)

✅ Concept check

In the Airy series, with $a_0$ and $a_1$ arbitrary, why is $a_5 = 0$?

✅ Concept check

The 200-term series for $J_0(40)$ in float64 returns $-0.0901$, but the true value is $+0.00737$. Why?

Problems

✏️ Pen & paperA series with a closed form●○○

Solve y′′−ty′−y=0y'' - ty' - y = 0 near t0=0t_0 = 0 with y(0)=1y(0) = 1, y′(0)=0y'(0) = 0. (a) Derive the recurrence. (b) Find a2,a4,a6,a8a_2, a_4, a_6, a_8 and recognize the series. (c) Add the terms through t8t^8 at t=1t = 1 and compare with the closed form. What is the radius of convergence?

Show worked solution

(a) y′′=∑(n+2)(n+1)an+2tny'' = \sum(n+2)(n+1)a_{n+2}t^n, ty′=∑nantnty' = \sum na_nt^n and y=∑antny = \sum a_nt^n. The coefficient of tnt^n gives (n+2)(n+1)an+2−nan−an=0(n+2)(n+1)a_{n+2} - na_n - a_n = 0, so (n+2)(n+1)an+2=(n+1)an(n+2)(n+1)a_{n+2} = (n+1)a_n and

an+2=ann+2.a_{n+2} = \frac{a_n}{n+2} .

(b) a1=0a_1 = 0 gives all odd coefficients zero. With a0=1a_0 = 1: a2=12a_2 = \tfrac12, a4=12⋅4=18a_4 = \tfrac{1}{2\cdot4} = \tfrac18, a6=12⋅4⋅6=148a_6 = \tfrac{1}{2\cdot4\cdot6} = \tfrac1{48}, a8=1384a_8 = \tfrac1{384}. In general a2k=1/(2kk!)a_{2k} = 1/(2^kk!), so y=∑k(t2/2)k/k!=et2/2y = \sum_k(t^2/2)^k/k! = e^{t^2/2}. Check: y′=tyy' = ty, hence y′′=y+ty′=y+t2yy'' = y + ty' = y + t^2y, and ty′+y=t2y+yty' + y = t^2y + y. Yes.

(c) At t=1t = 1 the sum through t8t^8 is 1+12+18+148+1384=211128=1.64843751 + \tfrac12 + \tfrac18 + \tfrac1{48} + \tfrac1{384} = \tfrac{211}{128} = 1.6484375, against e1/2=1.6487212707e^{1/2} = 1.6487212707, an error of 2.84×10−42.84\times10^{-4} (the first omitted term is 1/3840=2.6×10−41/3840 = 2.6\times10^{-4}). Since an+2/an=1/(n+2)→0a_{n+2}/a_n = 1/(n+2) \to 0, the radius is infinite, as expected from p=−tp = -t and q=−1q = -1 having no singularities.

✏️ Pen & paperEuler's equation with a repeated root●●○

Solve t2y′′−3ty′+4y=0t^2y'' - 3ty' + 4y = 0 for t>0t \gt 0 with y(1)=1y(1) = 1, y′(1)=0y'(1) = 0. Where does yy first cross zero, and what is y(2)y(2)?

Show worked solution

Here α=−3\alpha = -3 and β=4\beta = 4, so the indicial equation is r(r−1)−3r+4=r2−4r+4=(r−2)2r(r-1) - 3r + 4 = r^2 - 4r + 4 = (r-2)^2: a double root r=2r = 2. By the substitution s=ln⁡ts = \ln t the equation becomes uss−4us+4u=0u_{ss} - 4u_s + 4u = 0, with solution u=(c1+c2s)e2su = (c_1 + c_2s)e^{2s}, that is, y=t2(c1+c2ln⁡t)y = t^2(c_1 + c_2\ln t). Then y(1)=c1=1y(1) = c_1 = 1. Differentiating, y′=2t(c1+c2ln⁡t)+tc2y' = 2t(c_1 + c_2\ln t) + tc_2, so y′(1)=2c1+c2=0y'(1) = 2c_1 + c_2 = 0 and c2=−2c_2 = -2:

y=t2(1−2ln⁡t).y = t^2(1 - 2\ln t) .

It crosses zero where ln⁡t=12\ln t = \tfrac12, at t=e1/2=1.6487212707t = e^{1/2} = 1.6487212707. At t=2t = 2: y(2)=4(1−2ln⁡2)=−1.5451774445y(2) = 4(1 - 2\ln2) = -1.5451774445, which matches solve_ivp (relative tolerance 10−1210^{-12}) to 3.5×10−133.5\times10^{-13}. Without the logarithm, the single solution t2t^2 could not meet both initial conditions.

✏️ Pen & paperA terminating series●●○

Consider y′′−2ty′+6y=0y'' - 2ty' + 6y = 0. (a) Derive the recurrence. (b) Show that the solution with y(0)=0y(0) = 0, y′(0)=−12y'(0) = -12 is a polynomial, and find it. (c) Check it in the equation at t=1t = 1. (d) Is the family started at a0a_0 a polynomial? What is its radius of convergence?

Show worked solution

(a) The coefficient of tkt^k is (k+2)(k+1)ak+2−2kak+6ak=0(k+2)(k+1)a_{k+2} - 2ka_k + 6a_k = 0, so

ak+2=2k−6(k+2)(k+1) ak.a_{k+2} = \frac{2k - 6}{(k+2)(k+1)}\,a_k .

(b) With a0=0a_0 = 0 the even chain is zero. From a1=−12a_1 = -12: a3=2−63⋅2(−12)=8a_3 = \dfrac{2 - 6}{3\cdot2}(-12) = 8 and a5=6−65⋅4a3=0a_5 = \dfrac{6 - 6}{5\cdot4}a_3 = 0, and everything beyond vanishes. So y=8t3−12ty = 8t^3 - 12t.

(c) At t=1t = 1: y=−4y = -4, y′=24t2−12=12y' = 24t^2 - 12 = 12, y′′=48t=48y'' = 48t = 48, and 48−2⋅1⋅12+6⋅(−4)=048 - 2\cdot1\cdot12 + 6\cdot(-4) = 0. Yes.

(d) The numerator 2k−62k - 6 vanishes only at k=3k = 3, which is odd, so the even chain never stops: a2=−3a0a_2 = -3a_0, a4=4−612a2=a02a_4 = \dfrac{4-6}{12}a_2 = \dfrac{a_0}2, and so on. Since ak+2/ak∼2/k→0a_{k+2}/a_k \sim 2/k \to 0, the radius is infinite. This is the same mechanism as Legendre’s equation: the series terminates when the numerator of the recurrence vanishes on the chain’s own parity.

Key Takeaways

  • A power series y=∑antny = \sum a_nt^n inserted into a linear equation, with indices shifted so that every sum has tnt^n, turns the ODE into a recurrence for the coefficients, with a0=y(0)a_0 = y(0) and a1=y′(0)a_1 = y'(0) free.
  • For Airy’s y′′=tyy'' = ty, a2=0a_2 = 0 and an+3=an/((n+3)(n+2))a_{n+3} = a_n/((n+3)(n+2)): three index chains, two of them live, giving f=1+t3/6+⋯f = 1 + t^3/6 + \cdots and g=t+t4/12+⋯g = t + t^4/12 + \cdots with infinite radius.
  • The radius of convergence is at least the distance from the center to the nearest complex singularity of the coefficient functions; (1+t2)y′′+y=0(1+t^2)y'' + y = 0 has radius exactly 11 (ratio of consecutive coefficients tends to −1-1), and partial sums blow up at t=1.2t = 1.2 and beyond.
  • At a regular singular point, try tr∑antnt^r\sum a_nt^n; the lowest power gives the indicial equation r(r−1)+p0r+q0=0r(r-1) + p_0r + q_0 = 0. For Euler’s equation y=try = t^r is exact, and a double root gives trln⁡tt^r\ln t (via s=ln⁡ts = \ln t).
  • Bessel order 00 has a double indicial root r=0r = 0: J0=∑(−1)k(t/2)2k/(k!)2J_0 = \sum(-1)^k(t/2)^{2k}/(k!)^2 with zeros 2.4048262.404826, 5.5200785.520078, 8.6537288.653728; the second solution carries ln⁡t\ln t (from W=C/tW = C/t and reduction of order).
  • Legendre’s recurrence ak+2=[k(k+1)−n(n+1)]ak/((k+2)(k+1))a_{k+2} = [k(k+1) - n(n+1)]a_k/((k+2)(k+1)) terminates for integer nn, giving P2=(3t2−1)/2P_2 = (3t^2-1)/2 and P3=(5t3−3t)/2P_3 = (5t^3-3t)/2.
  • Summing a Taylor series in float64 loses roughly log⁡10\log_{10}(largest term/∣y∣)/|y|) digits: 7.77.7 at J0(20)J_0(20), and all of them by t=40t = 40. Convergence in exact arithmetic is not an algorithm.
  • A series solution is a local tool. For computation, use special-function libraries and ODE solvers, and use the series for structure and understanding.
Finished this lesson?

Mark it complete to track your progress (saved in this browser). Reading every section does this for you.

Where this leads

These later lessons build directly on this one: