MATLAB: Multiple roots formula with Matlab

MATLABmultiple roots formula

f(x)= x^4- 6x^3 + 12x^2 – 10x +3
Starting point x0=0
Find x1,x2,x3
I need the find these points with the multiple roots formula = fi+1 = fi – (f(xi)*f '(xi)) / ([f '(xi)]^2 – f(xi)* f ''(xi))
Can anyone understand this and help us out, thanks a lot.

Best Answer

I think your formula shoud be
First define your function and its first two derivatives in Matlab
f = @(x) x.^4- 6*x.^3 + 12*x.^2 - 10*x +3; % function
fp = @(x) ...; % first derivative here
fpp = @(x) ...; % second derivative here
Set an initial guess for x and a tolerance. Initialise an error measure and an iteration number. e.g:
x = 5; %initial guess
tol = 10^-6;
err = 1;
its = 0;
Then use a while loop
while err>tol && its<100
xold = x;
x = ... put your iteration formua here
err = abs(x-xold);
its=its+1;
end
Display your result
disp(x)
Be careful not to use an initial guess that makes fp equal zero, or the routine will fail!