Question: 3 . Write two function f ( x ) and fprime ( x ) as defined below ( functions must be written in C +

3. Write two function f(x) and fprime(x) as defined below (functions must be written in C++)
f(x)= xe-x +2cos(x)+2
f(x)=(1 x)e-x -2sin(x)
Now write a function to implement Newtons method, that has the following declaration
float Newton(float x0, int maxIter, float epsln);
The algorithm for Newtons method is given as below:
For iter =1 to maxIter
xnew = x0 f(x0)/fprime(x0)
error =|xnew x0|
if error <= epsln, return xnew
x0= xnew
close the loop
Display the iteration did not converge
Return xnew

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!