Fast and stable algorithms for transformation between Legendre and Chebyshev expansions.