﻿ polevl, p1evl | Enterprise Architect User Guide

#### Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

 Prev Next

# polevl, p1evl

Evaluate polynomial.

SYNOPSIS:
int N;
double x, y, coef[N+1], polevl[];
y = polevl(x, coef, N);

DESCRIPTION:
Evaluates polynomial of degree N:

2          N
y  =  C  + C x + C x  +...+ C x
0    1     2          N

Coefficients are stored in reverse order:

coef[0] = C  , ..., coef[N] = C  .
N                   0

The function p1evl() assumes that coef[N] = 1.0 and is omitted from the array. Its calling arguments are otherwise the same as polevl().

SPEED:
In the interest of speed, there are no checks for out of bounds arithmetic.  This routine is used by most of the functions in the library.  Depending on available equipment features, the user might want to rewrite the program in microcode or assembly language.

JavaScript:

Example:

function stirlingFormula(x)
{
var STIR = [ 7.87311395793093628397E-4, -2.29549961613378126380E-4,
-2.68132617805781232825E-3, 3.47222221605458667310E-3,
8.33333333333482257126E-2 ];
var SQTPI = 2.50662827463100050242E0;
var MAXSTIR = 143.01608;
var w = 1.0 / x;
var y = cephes.exp(x);
var w = 1.0 + w * cephes.polevl(w, STIR, 4);
if (x > MAXSTIR) {
var v = cephes.pow(x, 0.5 * x - 0.25);
y = v * (v / y);
} else {
y = cephes.pow(x, x - 0.5) / y;
}
y = SQTPI * y * w;
return y;
}