Cheb Eval
Evaluates the Chebyshev polynomial series
Controller: CodeCogs
Contents
Interface
C++
ChebEval
doublechebEval( | double | x | |
const double* | coef | ||
int | N | ) |
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, 1987Note
- The provided coefficients are stored in reverse order, i.e.
Parameters
x value to evaluate coef coefficients from [0..N-1], stored in reverse order. N number of coefficients, not the order. Must be 2 or more
Authors
- Stephen L. Moshier Copyright 1985, 1987
Documentation by Will Bateman (August 2005)
Source Code
Source code is available when you agree to a GP Licence or buy a Commercial Licence.
Not a member, then Register with CodeCogs. Already a Member, then Login.