MATLAB: How can i solve this problem


I am trying to find the roots of the equation f(x) = 2x^3 – 6x – 1 = 0 Numerically by using FPI ( Fixed – Point – Iteration ) Method with Matlab , the first root is x = -1.641783527 and the 2nd root is x = 1.810037929 , the iteration form for this equation which make it converge to the 1st root is g(x) = (3*x + 0.5 )^(1/3) , i have took the initial value for the 1st root as x = -1.8 , after running the program i do not know why the Matlab leave the 1st root and jump to the 2nd root ? i could not find any logical reason for that ? could any one help me to find where is the problem ? the code of the program is :
clear ; clc ; close all x(1) = -1.8 ; n = 50 ; r = -1.641783527 ; for i=1:n x(i+1) = (3*x(i)+0.5)^(1/3) ; if ( abs(x(i+1) – r )>0.5e-8) x(i) = x(i+1) ; root = x ; iteration(i) = i ; error = abs(root-r); else end end root=root(:) , iteration=iteration(:) , error=error(:) plot(x,'*') , grid xlabel('iteration : n') ylabel('root')

Best Answer

  • Hello Razi, The problem occurs in the statement
    x(i+1) = (3*x(i)+0.5)^(1/3)
    The (3x+1/2) part is negative for x < -1/6. When you take that negative quantity to the 1/3 power, you get complex numbers. For whatever reason, iteration eventually ends up at the +1.81 root. If you start with any initial guess x > -1/6, you will converge nicely in terms of real numbers and end up at +1.81.
    To find the root at -1.64 you need to plan the iteration in advance. Letting x --> -x gives the iteration
    x(i+1) = -(-3*x(i)+0.5)^(1/3) % works for initial guess < -1/6
    which converges with real numbers to -1.64.
    There is also the third root, at -.17. Right now your iteration essentially solves for x^3 in terms of x and a constant. To get the last root you have to express x in terms of x^3 and a constant and iterate. Depending on your initial guess, this either goes to -.17 or to +-infinity.