poly, polyl

Aus RAD Studio
Wechseln zu: Navigation, Suche

Nach oben zu math.h - Index


Header-Datei

math.h

Kategorie

Mathematische Routinen

Prototyp

double poly(double x, int degree, double coeffs[]);

long double polyl(long double x, int degree, long double coeffs[]);

Beschreibung

Erstellt aus den Argumenten ein Polynom.

poly erzeugt ein Polynom bei x mit degree Grad und den Koeffizienten coeffs[0], coeffs[1], ..., coeffs[degree]. Wenn beispielsweise n = 4, wird folgendes Polynom erzeugt:

polyl ist die long double-Version. Sie benötigt ein Argument vom Typ long double und gibt ein Ergebnis vom Typ long double zurück.

Rückgabewert

poly und polyl geben den Wert des Polynoms zurück, das für das gegebene x ausgewertet wurde.

Beispiel



 #include <stdio.h>
 #include <math.h>
 /* Polynom:  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;
 }



Portabilität



POSIX Win32 ANSI C ANSI C++

poly

+

polyl

+