While trying to evaulate polynomials using Horner's Rule I have a sample code segment like so:
int Horner( int a[], int n, int x )
{
int result = a[n];
for(int i=n-1; i >= 0 ; --i)
result = result * x + a[i];
return result;
}
I understand that a
is an array of coefficients and that x
is the value that I would like to evaluate at. My question is what is the n
for?
n is the degree of the polynome (and a polynome of degree n, aside from 0 which is kind of special, has n+1 coefficients, so size of array = n+1, n = size of array - 1)
n is the size of the array
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With