12. Orthogonal Polynomials#
Generically, orthogonal polynomials can be scaled to provide an orthonormal basis for functions on some interval \([a, b]\) with respect to some weighting function \(W(x)\):
As demonstrated in Assignment 6: Orthonormal Bases, one can always construct these from the basis polynomials \(\ket{x^{n}}\) using the Gram-Schmidt process. Let the coefficients be called \(k_n^{(i)}\):
Some examples, with applications to quantum mechanics, are:
While programmatically straightforward, this process is tedious, and does not readily lead to easy-to-work-with expressions. Instead, one often prefers Rodrigues formulas or recurrence formulas. From a practical perspective, most of the properties are well tabulated in resources like [Abramowitz and Stegun, 1965]. In particular, we have the following definitions:
Rodrigues formula is valid if \(p(x)\) is at most quadratic, and \(q(x)\) is linear. The weighting function comes from the self-adjointness condition
Additional, we have the following recurrence formula (see [Hassani, 2013] Eq. (7.12)):
Example: Hermite Polynomials
The (physicist’s) Hermite polynomials \(H_n(x)\) satisfy:
Alternatively, \(\psi_n(x) = e^{-x^2/2}H_n(x)\) satisfies the more familiar harmonic oscillator equation:
Depending on your needs, one or more of these definitions may be useful.
You should recall that one of the key properties of self-adjoint (hermitian) operators is that they admit a complete orthonormal basis. Thus it is natural to expect that orthogonal polynomials might arise as the eigenfunctions for some sort of hermitian ODE such as a Sturm-Liouville problem. This is the basis for Rodrigues formulas.
Recall that a general second-order ODE of the form
is self-adjoint if \(p'(x) = q(x)\).
Do It! Derive this condition.
Recall that, to be self-adjoint, we must have
Starting with
and integrating by parts, we obtain (up to boundary terms, which we neglect for now) the condition \(fpg'' + fqg' = gpf'' + gqf'\)
This is clearly satisfied if \(p' = q\) when we can write
We can thus make a general equation self-adjoint by multiplying by a weight \(W\) chosen such that
Do It! Derive this solution from \((wp)' = wq\).
With this weight, we have
and the eigenfunctions can be chosen to be orthonormal with the inner product
It is not clear that these eigenfunctions are polynomials, and in general, there will be solutions to the differential equation that are not – these are the generalized functions associated with the orthogonal polynomials.
Approximation#
Orthogonal polynomials are extremely useful for approximations. Part of this follows from two theorems discussed in [Hassani, 2013]. These refer to the space of square-integrable functions \(f(x)\):
Theorem 2 (Riesz-Fischer – Theorem 7.2.1 in [Hassani, 2013])
The space \(\mathcal{L}^2_{W}(a, b)\) is complete.
Theorem 3 (Theorem 7.2.2 in [Hassani, 2013])
All complete inner product spaces with countable bases are isomorphic to \(\mathcal{L}^2_{W}(a, b)\).
Theorem 4 (Stone-Weierstrass approximation – Theorem 7.2.3 in [Hassani, 2013])
The set of monomials \(\{x^k\}_{k=0}^{\infty}\) forms a basis for \(\mathcal{L}^2_{W}(a, b)\).
This means that we can approximate any function in \(\mathcal{L}^2_{W}(a, b)\) with polynomials:
To do this with brute force, we might evaluate the function at a set of \(N\) abscissa \([\vect{f}]_{n} = f(x_n)\), then try to interplate:
The matrix \(\mat{V}\) is called a Vandermonde matrix and in can be very poorly conditioned making it hard to solve for \(\vect{a}\) numerically.
In contrast, once you have an orthonormal basis, once can find the coefficients trivially (and stably) by simply computing the overlap integrals.
Quadrature#
Another useful property of orthogonal polynomials is numerical integration or quadrature. In general, given \(N\) abscissa \(\{x_i\}\) one can define \(N\) weights \(w_i\) such that
is exact for polynomials \(f(x)\) of degree \(N-1\) or less.
Do It! Find a formula for the weights \(w_i\).
Solve the following linear system of \(N\) equations for $n \in {0, 1, \dots, N-1}:
This gives a set of weights \(w_i\) that are exact for the monomials \(x^{n}\). Since integration is a linear operation, these are therefore exact for all linear combinations – hence for all polynomials.
Note that solving for \(w_i\) requires inverting the following Vandermonde matrix
For equally spaced abscissa, this matrix becomes ill-conditioned, so this is not a good numerical strategy. Orthogonal polynomials provide a much better approach.
If we can also choose the abscissa, then we can use the additional freedom to make the quadrature rule exact for polynomials up to order \(2N-1\). Such a set of abscissa \(\{x_i\}\) and weights \(\{w_i\}\) is called a Gaussian quadrature rule.
Once you have a set of orthogonal polynomials for a give weight function \(W(x)\) and interval \([a, b]\), the \(N\)-point Gaussian quadrature rule can be obtained by using the \(N\) roots of \(f_n(x_i) = 0\) with weights (see [Press et al., 2007]):
# Example: Hermite Polynomials
import scipy as sp
from scipy.integrate import quad
print(f"{np.__version__=}, {sp.__version__=}")
def W(x):
return np.exp(-x**2)
def braket(f, g):
return quad(lambda x: f(x)*g(x)*W(x), -np.inf, np.inf)[0]
print(" Numpy, Formula above")
for N in range(1,20):
# Monic polynomials
f_N = np.polynomial.hermite.Hermite([0]*(N) + [1/(2)**(N)])
f_N1 = np.polynomial.hermite.Hermite([0]*(N-1) + [1/(2)**(N-1)])
x = f_N.roots()
w = braket(f_N1, f_N1) / f_N1(x) / f_N.deriv()(x)
x_, w_ = np.polynomial.hermite.hermgauss(N)
assert np.allclose(x, x_)
assert np.allclose(w, w_)
M = 2*N
ai = np.array([quad(lambda x: x**n * W(x), -np.inf, np.inf)[0] for n in range(M)])
aq = np.array([sum(sorted(x**n * w)) for n in range(M)])
aq_ = np.array([sum(sorted(x_**n * w_)) for n in range(M)])
print(f"{N=: 3}: {np.allclose(ai, aq_)!s:5}, {np.allclose(ai, aq)!s:5}")
np.__version__='2.3.5', sp.__version__='1.16.3'
Numpy, Formula above
N= 1: True , True
N= 2: True , True
N= 3: True , True
N= 4: True , True
N= 5: True , True
N= 6: True , True
N= 7: True , True
N= 8: True , True
N= 9: True , True
N= 10: True , True
N= 11: True , False
N= 12: True , False
N= 13: False, False
N= 14: True , False
N= 15: False, False
N= 16: False, False
N= 17: False, False
N= 18: False, False
N= 19: False, False
Note, however, that one must be very careful with round-off error. The results above
differ, even on the same hardware but between different versions of NumPy and SciPy. (I
have not traced through where the difference is coming from, but all results are
different, so there is something affecting both scipy.integrate.quad() and
numpy.polynomial.hermite.hermgauss().)
np.__version__='1.26.4', sp.__version__='1.15.2'
Numpy, Formula
N= 1: True , True
N= 2: True , True
N= 3: True , True
N= 4: True , True
N= 5: True , True
N= 6: True , True
N= 7: True , True
N= 8: True , True
N= 9: True , True
N= 10: True , True
N= 11: True , False
N= 12: True , False
N= 13: True , False
N= 14: True , False
N= 15: False, False
N= 16: True , False
N= 17: True , False
N= 18: False, False
N= 19: False, False
Bernoulli Numbers and Polynomials#
The Bernoulli polynomials \(B_n(x)\) defined by the generating function
where \(B_{n} = B_n(0)\) are the Bernoulli numbers
B_1 = -1/2
B_2 = 1/6
B_3 = 0
B_4 = -1/30
B_5 = 0
B_6 = 1/42
B_7 = 0
B_8 = -1/30
B_9 = 0
B_10 = 5/66
B_11 = 0
B_12 = -691/2730
B_13 = 0
B_14 = 7/6
B_15 = 0
B_16 = -3617/510
B_17 = 0
B_18 = 43867/798
B_19 = 0
B_20 = -174611/330
In the last formula, the contour should be taken to be a small circle about \(z=0\) within the radius of convergence for the series. Note that
which leads to the useful property
Expanding a few terms:
Thus
Subtracting off the linear term we find an even function:
Thus, all the remaining terms are even:
Some algebra gives
These are useful in the following series:
The series for \(\tan x\) follows from
Do It! Prove this.
Mittag-Lefler Theorem and \(\zeta(2k)\).#
The Mittag-Lefler theorem states that, if a meromorphic function \(f(z)\) falls off fast enough \(\lim_{\abs{z}\rightarrow \infty} f(z)/\abs{z} \rightarrow 0\), then
where \(r_n\) are the residues of the respective poles.
Do It! Prove this.
Hint: consider
for a contour \(C_{N}\) enclosing the first \(N\) poles (with smallest magnitude) of \(f(z)\).
Noting that \(\cot x\) is periodic with poles at \(x_n = n \pi\) and residues (evaluated with L’Hôpital’s rule)
Expanding each term as a geometric series in \(z^2\), we have
Hence
Equating terms