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.

Practice polynomial interpolation and spectral methods.

Part I: Polynomial Interpolation


Q1: Lagrange Interpolation

Find the Lagrange interpolating polynomial for:


Q2: Divided Differences

Compute the divided difference table and Newton interpolant for (1,1),(2,4),(3,9),(4,16)(1, 1), (2, 4), (3, 9), (4, 16).

What polynomial do you get? Is this expected?


Q3: Error Estimation

For f(x)=exf(x) = e^x interpolated at x0=0,x1=1x_0 = 0, x_1 = 1:


Q4: Runge’s Phenomenon

Interpolate f(x)=11+25x2f(x) = \frac{1}{1 + 25x^2} on [1,1][-1, 1] using:

Plot each interpolant along with f(x)f(x). What do you observe?


Q5: Implementation

Implement:

Compare timings for evaluating at 1000 points with n=50n = 50 nodes.


Q6: Adding Points

You have the Newton interpolant for (0,1),(1,0),(2,3)(0, 1), (1, 0), (2, 3).


Q7: Uniqueness Proof

Given a set of points x0<x1<<xnx_0 < x_1 < \cdots < x_n, show that there exists a unique polynomial of degree at most nn that interpolates a function at these points.

Hint: Proceed by contradiction. Assume two different interpolating polynomials exist and consider their difference d(x)d(x). How many roots does d(x)d(x) have?


Q8: Barycentric Formula Derivation

This problem fills in the details of the barycentric interpolation derivation.

(a) Given the node polynomial (x)=k=0n(xxk)\ell(x) = \prod_{k=0}^{n}(x - x_k), show that:

j(x)=(x)(xj)(xxj)\ell_j(x) = \frac{\ell(x)}{\ell'(x_j)(x - x_j)}

(b) Show that j=0nj(x)=1\sum_{j=0}^{n} \ell_j(x) = 1.

Hint: Use the uniqueness of polynomial interpolation—what function do the Lagrange polynomials interpolate when all data values are 1?


Q9: Chebyshev Polynomials

The Chebyshev polynomials are defined as Tk(x)=12(zk+zk)T_k(x) = \frac{1}{2}(z^k + z^{-k}) where z=eiθz = e^{i\theta} and x=cosθx = \cos\theta.

(a) Show that Tk(x)=cos(kθ)T_k(x) = \cos(k\theta) for an appropriate choice of θ\theta.

(b) Compute T0T_0, T1T_1, T2T_2, and T3T_3 explicitly as polynomials in xx.

(c) Write x5x^5 as a sum of Chebyshev polynomials.

(d) Prove the recurrence relation: Tk+1(x)=2xTk(x)Tk1(x)T_{k+1}(x) = 2xT_k(x) - T_{k-1}(x).


Q10: Quadrature Comparison

Consider the integral I=11sin(5x)3dxI = \int_{-1}^{1} |\sin(5x)|^3 \, dx. The exact value is:

I=24+9cos(5)cos(15)30I = \frac{24 + 9\cos(5) - \cos(15)}{30}

(a) Implement the trapezoidal rule with n+1n+1 equispaced points.

(b) Implement Chebyshev quadrature (Clenshaw-Curtis) with n+1n+1 Chebyshev points.

(c) For n=2kn = 2^k with k=1,2,,12k = 1, 2, \ldots, 12, compute the absolute error for both methods. Plot on a log-log scale. What convergence rates do you observe?

(d) Repeat for the Gaussian integral:

I=1πε11e(x/ε)2dx=erf(1/ε)I = \frac{1}{\sqrt{\pi}\varepsilon}\int_{-1}^{1} e^{-(x/\varepsilon)^2} \, dx = \text{erf}(1/\varepsilon)

with ε=0.5\varepsilon = 0.5. How do the methods compare for this smooth function?


Part II: Spectral Differentiation


Q11: Chebyshev Differentiation Matrix


Q12: Spectral vs. Finite Difference

For u(x)=esin(πx)u(x) = e^{\sin(\pi x)} on [1,1][-1, 1]:


Q13: Differentiation Matrix Properties

Consider the function f(x)=sin(πx)f(x) = \sin(\pi x) on [1,1][-1, 1].

(a) Implement the Chebyshev differentiation matrix construction.

(b) Compute the derivative at the Chebyshev points using f=Df\mathbf{f}' = D\mathbf{f}.

(c) Compare with the exact derivative f(x)=πcos(πx)f'(x) = \pi\cos(\pi x) at the same points.

(d) Implement a second-order finite difference approximation on an equispaced grid with the same number of points. Compare the errors.


Part III: Spectral Methods for BVPs


Q14: Simple BVP

Solve u=π2sin(πx)u'' = -\pi^2 \sin(\pi x) on [1,1][-1, 1] with u(±1)=0u(\pm 1) = 0.


Q15: Variable Coefficient BVP

Solve (1+x2)u+2xuu=0(1 + x^2)u'' + 2xu' - u = 0 on [1,1][-1, 1] with u(1)=1u(-1) = 1 and u(1)=2u(1) = 2.


Q16: Neumann Boundary Conditions

Solve u=cos(x)u'' = \cos(x) on [1,1][-1, 1] with u(1)=0u'(-1) = 0 and u(1)=0u(1) = 0.


Q17: Eigenvalue Problem

For the Laplacian eigenvalue problem u=λu-u'' = \lambda u on [1,1][-1, 1] with u(±1)=0u(\pm 1) = 0:


Q18: Helmholtz Equation

Solve u+k2u=f(x)u'' + k^2 u = f(x) on [1,1][-1, 1] with u(±1)=0u(\pm 1) = 0, where k=10k = 10 and f(x)=1f(x) = 1.


Q19: Comparison with scipy.solve_bvp

Use scipy.integrate.solve_bvp to solve:

u=eu,u(1)=u(1)=0u'' = e^u, \quad u(-1) = u(1) = 0

Q20: Fourth-Order Problem

Solve the beam equation u=1u'''' = 1 on [1,1][-1, 1] with clamped boundary conditions: u(±1)=u(±1)=0u(\pm 1) = u'(\pm 1) = 0.


Q21: Periodic Problem with Fourier

Solve u+u=cos(2x)u'' + u = \cos(2x) on [0,2π][0, 2\pi] with periodic boundary conditions.


Self-Assessment Questions

Test your understanding with these conceptual questions:

Polynomial Interpolation

  1. Uniqueness: If you have 4 data points, what is the maximum degree of the interpolating polynomial?

  2. Lagrange: What is L2(x2)L_2(x_2)? What is L2(x0)L_2(x_0)?

  3. Error: Why does the interpolation error formula look similar to Taylor’s theorem error?

  4. Runge: Why do equally spaced nodes cause problems for some functions?

  5. Barycentric: Why is the second barycentric formula “scale invariant”? Why does this matter numerically?

  6. Chebyshev: Why do Chebyshev points cluster near the endpoints of [1,1][-1, 1]?

  7. Coefficient Decay: If a function has a jump discontinuity, what decay rate do you expect for its Chebyshev coefficients?

  8. Gibbs: Does increasing the polynomial degree eliminate the overshoot near a discontinuity? Why or why not?

Spectral Methods

  1. Differentiation Matrix: Why is the Chebyshev differentiation matrix dense while finite difference matrices are sparse?

  2. Accuracy: Why do spectral methods achieve exponential convergence for smooth problems?

  3. Boundary Conditions: How do you modify the spectral system to impose Dirichlet vs. Neumann boundary conditions?

  4. Eigenvalues: Why are the high-frequency eigenvalues of D2D^2 less accurate than low-frequency ones?

  5. Limitations: When would you choose finite differences over spectral methods?

  6. Grid Points: Why do Chebyshev points cluster near the boundaries?

  7. Periodic vs. Non-periodic: When should you use Fourier methods vs. Chebyshev methods?