spectral.solve_legendre_tau#

spectral.solve_legendre_tau(epsilon: float, num_modes: int) ndarray[source]#

Solve Exercise A boundary value problem using Legendre tau method.

Solves:

\[-\varepsilon \frac{d^2u}{dx^2} - \frac{du}{dx} = 1, \quad u(0) = u(1) = 0\]
Parameters:
epsilonfloat

Diffusion parameter

num_modesint

Number of Legendre modes

Returns:
np.ndarray

Modal coefficients

Notes

The tau method does not require the residual to vanish pointwise, but instead enforces the differential equation in a weighted sense with boundary conditions imposed through row replacement.

The analytical solution is:

\[u(x) = \frac{e^{-x/\varepsilon}+(x-1)-e^{-1/\varepsilon}x}{e^{-1/\varepsilon}-1}\]

References

Engsig-Karup, “Lecture 5: Boundary Value Problems”, p. 14 Kopriva (2009), “Implementing Spectral Methods for PDEs”, p. 107

Examples using spectral.solve_legendre_tau#

Legendre Tau vs Collocation - Convergence Study

Legendre Tau vs Collocation - Convergence Study

Legendre Tau vs Collocation - Data Generation

Legendre Tau vs Collocation - Data Generation