Horner's scheme
C++ Algorithms
polynomial evaluation
Flowchart (ISO 5807)
Source code
double horner(double a[], int n, double x) {
double res = a[0];
for (int i = 1; i < n; i++) {
res = res * x + a[i];
}
return res;
} polynomial evaluation
double horner(double a[], int n, double x) {
double res = a[0];
for (int i = 1; i < n; i++) {
res = res * x + a[i];
}
return res;
}