FUNCTION
Cheb_Eval
Evaluates the Chebyshev polynomial series
You're viewing an older version of this page (#71). View the current version.
Interface
#include <codecogs/maths/approximation/polynomial/cheb_eval.h>
using namespace Maths::Approximation::Polynomial;
Evaluates the Chebyshev polynomial series of the First Kind:
where c are the coefficient, and are the Chebyshev polynomials evaluated at x/2,
The Chebyshev polynomials of the first kind are a set of orthogonal polynomials defined as the solutions to the Chebyshev differential equation. They are also used as an approximation to a least squares fit and are intimately connected with trigonometric multiple-angle formulas.
If coefficients are for the interval a to b, x must be transformed to
before entering the routine. This maps x from (a, b) to (-1, 1), over which the Chebyshev polynomials are defined.
If the coefficients are for the inverted interval, in which (a, b) is mapped to (1/b, 1/a), the transformation required is
If b is infinity, this becomes
Speed:
Taking advantage of the recurrence properties of the Chebyshev polynomials, the routine requires one more addition per loop than evaluating a nested polynomial of the same degree.
Example:
The following code computes solutions to the polynomial
#include <stdio.h>
#include <codecogs/maths/approximation/polynomial/cheb_eval.h>
int main()
{
using namespace Maths::Algebra::Polynomial;
static double C[] = { 3,2,1 };
for(int x=2;x<=5;x++)
printf("\n chebEval(%d, A, 2)=%.1lf", x, chebEval(x, C, 2));
return 0;
}
Output:
chebEval(2, A, 2)=4.0
chebEval(3, A, 2)=5.5
chebEval(4, A, 2)=7.0
chebEval(5, A, 2)=8.5
References
Cephes Math Library Release 2.0: April, 1987
Parameters
The provided coefficients are stored in reverse order, i.e.