How can i solve this problem ?
4 次查看(过去 30 天)
显示 更早的评论
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')
2 个评论
Roger Stafford
2017-4-28
The “fixed point iteration” method you used is by no means a reliable method for finding roots. It might succeed - it might not. Also in cases where there is more than one root, such as yours, there is no telling which root an initial estimate will eventually lead to (if any.)
My recommendation is to use a superior algorithm such as the newton-raphson or the bisection methods. Also with matlab you can use the ‘fzero’ function.
采纳的回答
David Goodmanson
2017-4-28
编辑:David Goodmanson
2017-4-28
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.
2 个评论
David Goodmanson
2017-4-28
编辑:David Goodmanson
2017-4-28
Hello Razi, you are right, on that line I had intended to put
x(i+1) = -(-3*x(i)-0.5)^(1/3)
but I didn't. Thanks for catching the error.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!