A1245 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

A12 · Lesson 45 · Lab: special functions in code

Bessel zeros, Legendre expansions, Green's function integrals and induced charge

Lessons 38 to 44 leaned on tables: Bessel zeros like 2.4048, Legendre polynomials, Green's functions. In this lab you'll compute those numbers yourself. You'll sum Bessel's series and find its zeros, which give drum overtones and waveguide cutoffs. You'll build Legendre polynomials by recursion and expand a function in them. Then you'll solve a loaded string by integrating its Green's function, and check that a point charge above a grounded plane induces exactly its own charge, with the opposite sign.

  • The curves are J0(x) and J1(x), computed from their power series. Their zeros are where drums, fibers and waveguides have their modes.
  • The power series converges for every x, but for large x its terms grow huge before they cancel. With 60 terms in double precision the series is good to about 10−9 at x = 20 and only 10−5 at x = 30.
  • The readout gives the drum's first overtone ratio, j11/j01, from the zeros of these two curves.

Predict

A drumhead's fundamental is 100 Hz. Where is its next mode, (1, 1)?

Name it

Series, recursions and their limits

  • Bessel functions from Jn(x)=∑k(−1)kk!(k+n)!(x2)2k+n: fine for moderate x. For large x the terms reach about ex/x before canceling, so rounding errors of 10−16 times that remain. Libraries switch to asymptotic forms there.
  • Legendre polynomials from Bonnet's recursion (k+1)Pk+1=(2k+1)xPk−kPk−1: stable and exact on [−1,1].
  • Zeros by bisection inside brackets where the function changes sign.

Expansions

On [−1,1] the Legendre polynomials are orthogonal with ∫Pn2dx=22n+1, so f=∑anPn with an=2n+12∫−11fPndx. The same pattern, with different weights, holds for Bessel series on a disk.

Green's functions as code

A Green's function turns a boundary-value problem into an integral: u(x)=∫G(x,s)f(s)ds. Numerically that's one quadrature per point, and it works for any load f, measured data included.

Worked example

Find the first three zeros of J0 from its series.

Show the solution
  1. Bracket the zeros. Tabulating J0 shows sign changes in (2, 3), (5, 6) and (8, 9).
  2. Bisect. Bisection in each, with the 60-term series, gives 2.404826, 5.520078 and 8.653728, matching the tables to all six figures.
  3. The gaps. They are 3.115 and 3.134, approaching π: for large x, J0(x)≈2πxcos⁡(x−π4) a slowly fading cosine.
  4. Check the approximation. It gives the third zero as 11π4=8.639, already within 0.2%.

Answer the first three zeros of J0 are 2.404826, 5.520078 and 8.653728.

Worked example

Expand f(x)=|x| on [−1,1] in Legendre polynomials.

Show the solution
  1. Only even terms. f is even, so only even n appear, and an=(2n+1)∫01xPndx
  2. The n = 0 term. With P0=1: a0=12.
  3. The n = 2 term. With P2=3x2−12: ∫01xP2dx=12(34−12)=18 so a2=58.
  4. The n = 4 term. With P4=35x4−30x2+38: a4=9×18(356−304+32)=−316
  5. The expansion. |x|≈12+58P2(x)−316P4(x)
  6. Check at the kink. At x = 0 that gives 12−58⋅12−316⋅38=0.117 The error at the kink shrinks slowly as terms are added, while away from it the series converges quickly.

Answer |x|≈12+58P2(x)−316P4(x).

Check

A circular drumhead of radius 0.1 m has wave speed 50 m/s. What is its fundamental?

Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.

Check

Expand f(x)=1x2+0 on [−1,1] in Legendre polynomials.

(a)

What is a0?

(b)

What is a2?

Check

Write J(n, x) summing 60 terms of the Bessel series and bisect(f, a, b). Set z0 to the first three zeros of J0 (brackets (2, 3), (5, 6), (8, 9)) and ratio to the first zero of J1 (bracket (3, 4.5)) over the first of J0.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Write legendre(n, x) using Bonnet's recursion (x may be a NumPy array). On 200 001 points of [−1,1], set a to the coefficients a0 to a4 of |x|, and norm3 to ∫−11P32dx.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

A string on (0, 1) satisfies −u′′=sin⁡πx with fixed ends. Using G(x,s)=x(1−s) for s≥x and s(1−x) for s<x, set u03 to ∫01G(0.3,s)sin⁡πsds (trapezoid rule, 100 001 points) and exact to sin⁡0.3ππ2.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

A charge q = 1 sits at height h = 1 above a grounded plane, inducing σ(ρ)=−qh2π(ρ2+h2)3/2. Set total to ∫0Rσ2πρdρ with R=104, using the trapezoid rule on np.concatenate([[0], np.logspace(-6, 4, 200001)]), and tail to the charge beyond R, −qhR2+h2.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Explain why

Why does the power series for J0(x) lose accuracy at large x even though it converges for every x?

Practice

Keep practicing

4 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.