Chebyshev Polynomials
The Chebyshev polynomials are two sequences of polynomials, $T_n$ and $U_n$. The Chebyshev polynomials of the first kind, $T_n$, can be defined by the recurrence relation:
\[T_0(x)=1,\ T_1(x)=x\]
\[T_{n+1}(x) = 2xT_n(x)-T_{n-1}(x)\]
The Chebyshev polynomioals of the second kind, $U_n(x)$, can be defined by
\[U_0(x)=1,\ U_1(x)=2x\]
\[U_{n+1}(x) = 2xU_n(x) - U_{n-1}(x)\]
Both $T_n$ and $U_n$ have degree $n$, and any polynomial of degree $n$ may be uniquely written as a linear combination of the polynomials $T_0$, $T_1$, ..., $T_n$ (similarly with $U_n$).
First Kind
Polynomials.ChebyshevT — TypeChebyshevT{T, X}(coeffs::AbstractVector)Chebyshev polynomial of the first kind.
Construct a polynomial from its coefficients coeffs, lowest order first, optionally in terms of the given variable var, which can be a character, symbol, or string.
ChebyshevT is not axis-aware, and it treats coeffs simply as a list of coefficients with the first index always corresponding to the coefficient of T_0(x).
Examples
julia> using Polynomials
julia> p = ChebyshevT([1, 0, 3, 4])
ChebyshevT(1⋅T_0(x) + 3⋅T_2(x) + 4⋅T_3(x))
julia> ChebyshevT([1, 2, 3, 0], :s)
ChebyshevT(1⋅T_0(s) + 2⋅T_1(s) + 3⋅T_2(s))
julia> one(ChebyshevT)
ChebyshevT(1.0⋅T_0(x))
julia> p(0.5)
-4.5
julia> Polynomials.evalpoly(5.0, p, false) # bypasses the domain check done in p(5.0)
2088.0The latter shows how to evaluate a ChebyshevT polynomial outside of its domain, which is [-1,1]. (For newer versions of Julia, evalpoly is an exported function from Base with methods extended in this package, so the module qualification is unnecessary.
The ChebyshevT type holds coefficients representing the polynomial $a_0 T_0 + a_1 T_1 + ... + a_n T_n$.
For example, the basis polynomial $T_4$ can be represented with ChebyshevT([0,0,0,0,1]).
Conversion
ChebyshevT can be converted to Polynomial and vice-versa.
julia> c = ChebyshevT([1, 0, 3, 4])
ChebyshevT(1⋅T_0(x) + 3⋅T_2(x) + 4⋅T_3(x))
julia> p = convert(Polynomial, c)
Polynomial(-2.0 - 12.0*x + 6.0*x^2 + 16.0*x^3)
julia> convert(ChebyshevT, p)
ChebyshevT(1.0⋅T_0(x) + 3.0⋅T_2(x) + 4.0⋅T_3(x))