[Math] Using Newton-Raphson method to approximate the minimum value of the function

MATLABnewton raphson

I am trying to use seven iterations of Newton-Raphson formula to find the minimum value for the following function, with the initial condition x = 4:
$$f\left(x\right)=x^4-3x^3-1$$
For the Newton-Raphson method, the general formula is:
$$x_{n+1}=x_n-\frac{f\:\left(x_n\right)}{f\:'\left(x_n\right)}$$

And below is the Matlab code I wrote for this formula:

format long
clear x
x = [4];
iterations = 7;

for n = 1:iterations
    x(n+1) = x(n) - (x(n).^4 - 3*x(n).^3 - 1) ./ (4*x(n).^3 - 9*x(n).^2);
end

minimum = min(x)

But it seems my formula isn't correct because I didn't get the expected result, could anyone please point out what is my mistake ? Did I use a wrong formula to find the minimum value or am I supposed to use 'min(x)' to find the minimum value ?

Best Answer

Your code is for finding the root of $f(x)$, which is not what you want. In fact you should find the root of $$f'(x)=4x^3-9x^2$$ So the correct iteration formula should be $$x_{n+1}=x_n-\frac{f'(x_n)}{f''(x_n)}=x_n-\frac{4x_n^3-9x_n^2}{12x_n^2-18x_n}$$

And by the way, the problem can be solved analytically.