Matlab Code Consider the following function We wish to find

[Matlab Code]

Consider the following function:

We wish to find the minimum of the above function in the given range of x.

1. Write a MATLAB code for the Newton-Raphson method. Use an appropriate stopping criterion.
2. Verify your results using fmincon. Make sure your code gives you the same solution as that given by fmincon. You might have to change your stopping criterion.
3. How many function evaluations does your code need? How many function evaluations does fmincon need? Use the same starting point for your code and fmincon.

Solution

1.The program is as mentioned below: clear all close all clc f=(-3)*x^3 + 12/(x^2)+2*e^(x^2); df=diff(f); a=0; b=1; x=a; for i=1:1:100 d=x-(f(x)/df(x)); x=d; end sol=x; fprintf(\'Approximate Root is %.15f\',sol) a=0;b=1; x=a; er(5)=0; for i=1:1:5 d=x-(f(x)/df(x)); x=d; er(i)=d-sol; end plot(er) title(\'Error Vs. Number of iterations\') xlabel(\'Number of iterations\') ylabel(\'Error\')
[Matlab Code] Consider the following function: We wish to find the minimum of the above function in the given range of x. 1. Write a MATLAB code for the Newton-

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site