Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Total Variation

For discontinuous ff', interpret this as the sum of f|f'| integrals plus the jump magnitudes.

The Fundamental Theorem

Interpretation:

Analytic Functions: The Bernstein Ellipse

For analytic functions, we can give a precise geometric characterization of the convergence rate.

The largest ρ\rho for which ff is analytic inside Eρ\mathcal{E}_\rho determines the convergence rate. Singularities in the complex plane—even far from [1,1][-1, 1]—limit ρ\rho and slow convergence.

Approximation Error

The error in truncating the Chebyshev series at nn terms:

fpnk=n+1ck\|f - p_n\|_\infty \leq \sum_{k=n+1}^{\infty} |c_k|

Using the coefficient decay:

SmoothnessCoefficient DecayApproximation Error
DiscontinuousO(k1)O(k^{-1})O(n1/2)O(n^{-1/2})
ContinuousO(k1)O(k^{-1})O(n1)O(n^{-1})
C1C^1O(k2)O(k^{-2})O(n1)O(n^{-1})
CpC^pO(kp1)O(k^{-p-1})O(np)O(n^{-p})
AnalyticO(ρk)O(\rho^{-k})O(ρn)O(\rho^{-n})

Example: The Sign Function

f(x)=sign(x)f(x) = \text{sign}(x) is discontinuous at x=0x = 0.

n = 2000
x = chebpts(n)
f = np.sign(x)
c = vals2coeffs(f)

# Coefficients decay as O(k^{-1})
plt.semilogy(np.abs(c))
# Only odd coefficients are nonzero (antisymmetric function)

Approximation error: fpn=O(n1)\|f - p_n\|_\infty = O(n^{-1}) (not O(n1/2)O(n^{-1/2}) because Chebyshev avoids Gibbs phenomenon in max norm).

Example: x|x|

f(x)=xf(x) = |x| is continuous but not differentiable at x=0x = 0.

n = 1000
x = chebpts(n)
f = np.abs(x)
c = vals2coeffs(f)

# Coefficients decay as O(k^{-2})
# Approximation error: O(n^{-1})

The error bound:

fpn8π(n1)\|f - p_n\|_\infty \leq \frac{8}{\pi(n-1)}

Example: sin(5x)3|\sin(5x)|^3

This function has three continuous derivatives (jumps in f(3)f^{(3)} at roots of sin(5x)\sin(5x)).

f = lambda x: np.abs(np.sin(5*x))**3

n = 10000
x = chebpts(n)
c = vals2coeffs(f(x))

# Coefficients decay as O(k^{-4})
# Approximation error: O(n^{-3})

Example: Analytic Function

f(x)=sin(6x)+sin(60ex)f(x) = \sin(6x) + \sin(60 e^x) is entire (analytic everywhere).

f = lambda x: np.sin(6*x) + np.sin(60*np.exp(x))

n = 250
x = chebpts(n)
c = vals2coeffs(f(x))

# Coefficients decay EXPONENTIALLY
# Around n=150, coefficients hit machine precision

The coefficients plateau at 1015\sim 10^{-15} (machine precision), indicating the series has converged.

Visualizing Coefficient Decay

fig, axes = plt.subplots(3, 2, figsize=(10, 8))

functions = [
    (np.sign, r"$\mathrm{sign}(x)$", "Discontinuous"),
    (np.abs, r"$|x|$", "Continuous, not $C^1$"),
    (lambda x: np.abs(np.sin(5*x))**3, r"$|\sin(5x)|^3$", "$C^3$"),
]

for i, (f, label, desc) in enumerate(functions):
    x = chebpts(1000)
    vals = f(x)
    coeffs = vals2coeffs(vals)

    axes[i, 0].plot(x, vals, 'k')
    axes[i, 0].set_title(f"{label} — {desc}")

    axes[i, 1].semilogy(np.abs(coeffs), 'k.')
    axes[i, 1].set_ylabel("$|c_k|$")
    axes[i, 1].set_ylim([1e-16, 1e1])

The Gibbs Phenomenon

For discontinuous functions, polynomial approximations exhibit overshoot near discontinuities:

xs = np.linspace(-1, 1, 10000)

for n in [10, 50, 100]:
    x = chebpts(n)
    f = np.sign(x)
    p = bary(xs, f, x)

    print(f"n={n}: max overshoot = {np.max(p):.4f}")
    # Always around 1.09 regardless of n

Adaptive Resolution

The coefficient decay principle enables adaptive algorithms:

def adaptive_approx(f, tol=1e-12):
    """Find n such that coefficients decay below tol."""
    for n in [16, 32, 64, 128, 256, 512, 1024]:
        x = chebpts(n)
        c = vals2coeffs(f(x))

        # Check if last few coefficients are small
        if np.max(np.abs(c[-5:])) < tol * np.max(np.abs(c)):
            # Trim to significant coefficients
            k = np.where(np.abs(c) > tol * np.max(np.abs(c)))[0][-1]
            return c[:k+1], n

    raise ValueError("Function requires more than 1024 points")

This is the core idea behind Chebfun’s automatic degree selection.

Locating Non-Smoothness

The coefficient decay pattern reveals where smoothness breaks down:

For functions with boundary layers or internal layers, the coefficients reveal the layer location and sharpness.

Lebesgue Constants

The Lebesgue constant quantifies how close interpolation is to best approximation.

The Lebesgue constant tells us how much worse interpolation can be compared to best approximation.

Growth Rates by Node Type

NodesΛn\Lambda_n growth
Chebyshev2πlog(n+1)+O(1)\frac{2}{\pi}\log(n+1) + O(1) (logarithmic)
Equispaced2n+1enlogn\frac{2^{n+1}}{en\log n} (exponential!)
Lower bound (any nodes)2πlog(n+1)+γ\frac{2}{\pi}\log(n+1) + \gamma

Chebyshev nodes are nearly optimal—their Lebesgue constant grows only logarithmically.

The Weierstrass Approximation Theorem

A foundational result guaranteeing that polynomials can approximate any continuous function:

This theorem applies even to pathological continuous functions (like those that are continuous but nowhere differentiable).

The Faber-Bernstein Result

However, Weierstrass does not guarantee uniform convergence of interpolants:

This means: for any node choice, there exists some continuous function whose interpolants diverge. However, for the vast majority of functions encountered in practice (those with some smoothness), Chebyshev interpolation works phenomenally well.

Practical Guidelines

  1. Check coefficient decay to verify your approximation is resolved

  2. Exponential decay to machine precision indicates an analytic function

  3. Algebraic decay suggests limited smoothness—count the rate to find pp

  4. Plateauing coefficients at some level indicates numerical noise or rounding

Summary

What You SeeWhat It Means
ckρk|c_k| \sim \rho^{-k}Analytic function
ckkp1|c_k| \sim k^{-p-1}Function has pp derivatives
ckk1|c_k| \sim k^{-1}Discontinuous function
Plateau at 10-15Machine precision reached
No decayFunction not resolved, need more points

The key insight: Chebyshev coefficients encode smoothness. Spectral methods achieve their remarkable accuracy because smooth functions have rapidly decaying coefficients.