mathsalgebrapolynomial

Poly 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 4793 times and licensed 246 times
www.codecogs.com/d-ox/maths/algebra/polynomial/poly_eval.php
Controller: CodeCogs    Contact Controller

Group Description

Evaluates polynomial of degree N:
(1)
\displaystyle y = C_0 + C_1 x + C_2 x^2 + ... + C_N x^N

Coefficients are stored in reverse order, i.e.
(2)
\displaystyle coef[0] = C_N  , ..., coef[N] = C_0

Interface

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

using namespace Maths::Algebra::Polynomial;

double polyEval (double x, const double coef[], int N)
Evaluates a polynomial of degree N.
Click for details on using CodeCogs in ExcelReal cc_polyEval (Real x, Range coef, Integer N)
This function is available as a Microsoft Excel add-in.
double polyEval1 (double x, const double coef[], int N)
Evaluates a polynomial of degree N, with C_N=1.0.
Click for details on using CodeCogs in ExcelReal cc_polyEval1 (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
 
doublepolyEvaldoublex
const double*coef
intN )
Evaluates polynomial of degree N

Example:
The following code computes solutions to the polynomial
(3)
\displaystyle f(x) = 3 + 2x + 1x^2
#include <stdio.h>
#include <codecogs/maths/algebra/polynomial/poly_eval.h>
 
int main()
{
  using namespace Maths::Algebra::Polynomial;
  static double A[] = { 1,2,3 };
  for(int x=2;x<=5;x++)
    printf("\n polyEval(%d, A, 2)=%.1lf", x, polyEval(x, A, 2));
 
  return 0;
}

Output:
polyEval(2, A, 2)=11.0
polyEval(3, A, 2)=18.0
polyEval(4, A, 2)=27.0
polyEval(5, A, 2)=38.0

References:
Cephes Math Library Release 2.1: December, 1988
Parameters:
xmain variant
coefarray of coefficients coef[0..N] in reverse order[const]
Ndegree of polynomial, also one less that number of coefficients supplied.
Note:
In the interest of speed, there are no checks for out of bounds arithmetic.
Authors:
Stephen L. Moshier Copyright 1984, 1987, 1988
Documentation by Will Bateman (August 2005)
Source Code:
Register

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


Add calculator to your site or email
 
doublepolyEval1doublex
const double*coef
intN )
Evaluates polynomial of degree N, where the coefficient C_N=1.0. i.e. coef[0] = 1.0,
(4)
\displaystyle y = C_0 + C_1 x + C_2 x^2 + ... + x^N

Example:
The following code computes solutions to the polynomial
(5)
\displaystyle f(x) = 4 - 5x + x^2
#include <stdio.h>
#include <codecogs/maths/algebra/polynomial/poly_eval.h>
 
int main()
{
  using namespace Algebra::Polynomial;
  static double A[] = { -5, 4 };
  for(int x=2;x<=5;x++)
    printf("\n polyEval1(%d, A, 2)=%.1lf", x, polyEval(x, A, 2));
 
  return 0;
}

Output:
polyEval1(2, A, 2)=-2.0
polyEval1(3, A, 2)=-2.0
polyEval1(4, A, 2)=0.0
polyEval1(5, A, 2)=4.0

References:
Cephes Math Library Release 2.1: December, 1988
Parameters:
xmain variant
coefarray of coefficients coef[0..N-1] in reverse order[const]
Ndegree of polynomial, also number of coefficients supplied. Must be 2 or more.
Note:
In the interest of speed, there are no checks for out of bounds arithmetic.
Authors:
Stephen L. Moshier Copyright 1984, 1987, 1988
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 20:45:26

Page Comments

  You must login to leave a messge


Valid CSS!   Valid XHTML 1.0 Transitional