spectral.solve_legendre_collocation#

spectral.solve_legendre_collocation(epsilon: float, num_nodes: int) tuple[ndarray, ndarray][source]#

Solve Exercise A boundary value problem using Legendre-Gauss-Lobatto collocation.

Solves:

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

The collocation method enforces the differential equation exactly at the collocation nodes (Legendre-Gauss-Lobatto points). This nodal approach naturally incorporates boundary conditions at the endpoints.

Parameters:
epsilonfloat

Diffusion parameter

num_nodesint

Number of collocation nodes

Returns:
xinp.ndarray

Collocation nodes

coeffsnp.ndarray

Modal coefficients

Notes

Legendre-Gauss-Lobatto points include the domain endpoints, making them natural for imposing Dirichlet boundary conditions. The spectral differentiation matrix is constructed directly at these nodes.

The same coordinate transformation as the tau method applies: \(x = \frac{1}{2}(t + 1)\).

References

Engsig-Karup, “Lecture 5: Boundary Value Problems”, p. 39

Examples using spectral.solve_legendre_collocation#

Legendre Tau vs Collocation - Convergence Study

Legendre Tau vs Collocation - Convergence Study

Legendre Tau vs Collocation - Data Generation

Legendre Tau vs Collocation - Data Generation