Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please show me how to do question i and question iv. Thanks This problem concern

ID: 3781387 • Letter: P

Question

please show me how to do question i and question iv. Thanks

This problem concerns the computer implementation of Newton's method for finding the real roots (zeros) of a function f(x) of a single variable. Develop the steps in an algorithm to implement Newton's method of finding the real roots of f(x) = 0. You may assume that a function is available to calculate the value of the desired function f(x) and f'(x) at x. Your algorithm should provide appropriate error and convergence checks. (You may use C/C+ syntax to describe the algorithm.) Discuss the main advantages of Newton's method. Discuss the main disadvantages of Newton's method are. In calculating the value of a polynomial function f(x) = a_nx^n + a_n-1x^n_1 + ... + a_0 in C++ it is unwieldy to repeatedly calculate x^j. Develop an alternative formulation for calculating the polynomial expression that avoids the need for repeated power calculation and reduces the risk of numerical instability. (You may describe your formulation using C/C++ syntax if you wish.)

Explanation / Answer

#include<bits/stdc++.h>


using namespace std;
int degre,i=0,cnt=0,flag=0;
int coef[10]={0};
float x=0,x2=0,t=0;

bool CalcF(float& x,float &v,float&g)
{
printf(" ******************************************************");
printf(" ITERATION X FX F'X ");
printf(" **********************************************************");

do
{
cnt++;
v=g=0;
for(i=degre;i>=1;i--)
{
v+=coef[i] * (pow(x,i)) ;
}
v+=coef[0];
for(i=degre;i>=0;i--)
{
g+=coef[i]* (i*pow(x,(i-1)));
}
t=x2;
x2=(x-(v/g));

x=x2;

printf(" %d %.3f %.3f %.3f ",cnt,x2,v,g);

}while((fabs(t - x))>=0.0001);
printf(" THE ROOT OF EQUATION IS %f",x2);

if(g==0)
return false;
return true;

}

int main()
{

  

  

cout<<"Enter Highest degree of polynomial:::: ";
cin>>degre;

for(i=0;i<=degre;i++)
{
printf(" x^%d::",i);
cin>>coef[i];
}

cout<<" ";

printf(" polynomial is ");
for(i=degre;i>=0;i--)//printing coeff.
{
printf(" %dx^%d",coef[i],i);
}

cout<<" Enter X---->";
cin>>x;
float v=0,g=0;
CalcF(x,v,g);

  

  
}

=======================================================

Output:

akshay@akshay-Inspiron-3537:~/Chegg$ g++ newton.cpp
akshay@akshay-Inspiron-3537:~/Chegg$ ./a.out
Enter Highest degree of polynomial:::: 2

   x^0::6

   x^1::-5

   x^2::1


   polynomial is 1x^2 -5x^1 6x^0
Enter X---->2

******************************************************
ITERATION X FX F'X
**********************************************************
1 2.000 0.000 -1.000
2 2.000 0.000 -1.000
   THE ROOT OF EQUATION IS 2.000000