I have a problem to solve the following excercise:
*Be given the special polynomial:
and the input: coefficients a[n], a[n-1], ..., a[0], argument x
Create an algorithm in C# or Pseudocode which will use Horner's method to solve the special polynomial for x.*
I created an algorithm to solve default polynomial functions with Horner's method, but it doesn't work for the special function, because the exponents are squared. I don't know how to modify the algorithm to respect the squared exponents, because as far as I know, Horner's method doesn't use exponents. This is my code:
int[] a = new int[] { 0, 3, 2, 1};//a[0] - a[n]
int n = 3;
int x = 2;
double r = a[n];
for (int i = n - 1; i >= 0; i--)
{
r = r * x + a[i];
}
Console.WriteLine(r);
I'm thankful for any help!