Question: Please write c++ program to slove question 5. Question 5 is based on question 3a and I have solved the question 3a. Please follow the

Please write c++ program to slove question 5. Question 5 is based on question 3a and I have solved the question 3a. Please follow the requirements of question 5. Thanks in advance!
Following is my answer for question 3a:
#include
#include
using namespace std;
double fun(double x)
{
return pow(x*x*x*x,1.0/3.0);
}
int main()
{
double x=0,h1,h2,h3,e1=1000,e2=1000,e3=1000;
for(int p=3;p
{
double h=pow(10,-p);
double M=(fun(x+h)-fun(x))/h;
if(fabs(M)
{
h1=h;
e1=M;
}
cout
M=(fun(x+h)-fun(x-h))/(2.0*h);
if(fabs(M)
{
h2=h;
e2=M;
}
cout
M=(-fun(x+2.0*h)+4.0*fun(x+h)-3.0*fun(x))/(2.0*h);
cout
if(fabs(M)
{
h3=h;
e3=M;
}
}
cout
cout
cout
return 0;
}
Please write c++ program to slove question 5. Question 5 is based
on question 3a and I have solved the question 3a. Please follow
the requirements of question 5. Thanks in advance! Following is my answer
5. (extra credit) 10 points repeat problem 3a except using "complex step differentiation." 3. a. (i) Compare the accuracy of the following three formulas for approxi- mating the derivative, f'(x): Mi(n) = f(x + h) f(x) h ) Mach)-f(x+h)-f( x 2h Mach) -f(x + 2h) + 4f (x + h) - 3f (x) 2h In particular, test the above approximations when f(x) = x/3, x = 0 or r = 1, and h = 10-P, p = 3, 4, 5,..., 20. (ii) As his decreased, the error becomes smaller, until a critical value of h is reached, after which point the error starts to increase as h decreases. Find the critical h, herit, experimentally. Note: in order to avoid problems in evaluating 24/3 when r

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!