mathsalgebrapolynomial

Cheb Eval

Available under GPL (Free) and Commercial licence
get a GPL licence
COST (GBP)
this unit 0.90
sub units 0.00
add a commercial licence to your cart
0
viewed 3070 times and licensed 74 times
www.codecogs.com/d-ox/maths/algebra/polynomial/cheb_eval.php
Controller: CodeCogs    Contact Controller

Interface

#include <codecogs/maths/algebra/polynomial/cheb_eval.h>

using namespace Maths::Algebra::Polynomial;

double chebEval (double x, const double coef[], int N)
Evaluates the Chebyshev polynomial series
Click for details on using CodeCogs in ExcelReal cc_chebEval (Real x, Range coef, Integer N)
This function is available as a Microsoft Excel add-in.

Function Documentation

Add calculator to your site or email
 
doublechebEvaldoublex
const double*coef
intN )
Evaluates the Chebyshev polynomial series of the First Kind:
(1)
\displaystyle f(x) = \sum_{i=0}^{N-1} c_i T_i(\frac{x}{2})
where c are the coefficient, and T-i are the Chebyshev polynomials evaluated at x/2,
(2)
\displaystyle T_0(n) = 1
(3)
\displaystyle T_1(n) = x
(4)
\displaystyle T_2(n) = 2n^2 -1
(5)
\displaystyle T_3(n) = 4n^3 - 3n
(6)
\displaystyle T_4(n) = 8n^4 - 8n^2 +1
(7)
\displaystyle T_5(n) = 16n^5 - 20n^3 + 5n
(8)
\displaystyle T_6(n) = 32n^6 = 48n^4 + 18n^2 -1

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
(9)
\displaystyle x \rightarrow \frac{2 (2x - b - a)}{b-a}
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
(10)
\displaystyle x \rightarrow \frac{2 (2ab/x - b - a)}{b-a}

If b is infinity, this becomes
(11)
\displaystyle x \rightarrow \frac{4a}{x} - 1

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
(12)
\displaystyle f(x) = 1 + 2\frac{x}{2} + 3 \left ( 2\frac{x}{2}^2 - 1 \right )
#include <stdio.h>
#include <codecogs/maths/algebra/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:
xvalue to evaluate
coefcoefficients from [0..N-1], stored in reverse order.[const]
Nnumber of coefficients, not the order. Must be 2 or more
Note:
The provided coefficients are stored in reverse order, i.e.
(13)
\displaystyle coef[0] = C_{N-1}, ..., coef[N-1]=C_0
Authors:
Stephen L. Moshier Copyright 1985, 1987
Documentation by Will Bateman (August 2005)
Source Code:
Register

- To get code register with CodeCogs. Already a Member, then Login.


Last Modified: 18 Oct 07 @ 17:07     Page Rendered: 2008-05-08 22:48:14

Page Comments

  You must login to leave a messge


Valid CSS!   Valid XHTML 1.0 Transitional