Newton's Method to find polynomial solution

Hi everyone,

this is my first post and I am new to C++. I am trying to figure out how to do this project. Newton’s method is an algorithm that can be used to solve an equation of the form f(x) = 0 using a sequence of approximations. Here’s how it works: You make a reasonable guess for a solution, x0.

You should create a function which calculates the value of the polynomial at a specific x value (the inputs for the function should be the array representing the polynomial, its size, and the x-value to evaluate at), and a function which calculates the value of the derivative at a specific x value (same inputs as the previous function).

I have been trying to figure this out for 4 hours already but can't go past cout statements. Please help! this is urgent!

here is what I have done so far. However i am having so much trouble with the functions.

```
#include<iostream>
#include<cmath>
using namespace std;
double Newtonf(double[], int);
double Newtonf(double polynomial[], int order)
{
double b;
double constant;
double total;
double x;
for(int b=1; b<=order; b++)
{
total+=polynomial[b]*pow(x, b)+ constant;
return total;
}
}
double Newtonfd(double[], int);
double Newtonfd(double polynomial[], int order)
{
double b;
int c;
double total;
double x;
for(int b=1; b<=order; b++)
{
total+=polynomial[b]*c*pow(x,c-1);
return total;
}
}
int main()
{
double guess;
int n;
cout << "What is the degree of the polynomial equation of the form f(x)=0? ";
cin >> n;
int i=1;
double polynomial[n];
while(i<=n)
{
cout << "Enter the coefficient of the x^" << i << " term: ";
cin >> polynomial[n-1];
i++;
}
double constant;
cout << "Enter the constant term: ";
cin >> constant;
cout << "Enter a guess for the solution: ";
cin >> guess;
cout << Newtonf(polynomial, n) << endl;
cout << Newtonfd (polynomial, n) << endl;
system ("pause");
return 1;
}
```