Header File
math.h
Category
Math Routines
Prototype
double poly(double x, int degree, double coeffs[]);
long double polyl(long double x, int degree, long double coeffs[]);
Description
Generates a polynomial from arguments.
poly generates a polynomial in x, of degree degree, with coefficients coeffs[0], coeffs[1], ..., coeffs[degree]. For example, if n = 4, the generated polynomial is:
polyl is the long double version; it takes long double arguments and returns a long double result.
Return Value
poly and polyl return the value of the polynomial as evaluated for the given x.
Example
#include <stdio.h> #include <math.h> /* polynomial: x**3 - 2x**2 + 5x - 1 */ int main(void) { double array[] = { -1.0, 5.0, -2.0, 1.0 }; double result; result = poly(2.0, 3, array); printf("The polynomial: x**3 - 2.0x**2 + 5x - 1 at 2.0 is %lf\n", result); return 0; }
Portability
|
POSIX |
Win32 |
ANSI C |
ANSI C++ |
poly |
|
+ |
|
|
polyl |
|
+ |
|
|
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|