Roots of function - Fzero error
이전 댓글 표시
I'm trying to find the root of this function: f(x) = (1 - 3/4x)^(1/3) to then apply newton's method, but I don't know the initial guess. This is the code I'm trying:
>> fun = @(x) (1 - (3/4*x)).^(1/3);
>> x0 = 1;
>> x = fzero(fun, x0)
The error I'm receiving is: "Exiting fzero: aborting search for an interval containing a sign change because complex function value encountered during search. (Function value at 1.45255 is 0.22358+0.38725i.) Check function or try again with a different starting value."
I've tried other starting guesses, but then I get the error: "Function value at starting guess must be finite and real."
Any tips of how to overcome these errors/find the initial guess? Thanks!
채택된 답변
추가 답변 (1개)
Walter Roberson
2016년 5월 12일
That function is not suitable for newton's method.
The .^(1/3) is not going to add any roots, but it will cause problems when the expression before it is negative. But you need it to go negative in order to find a sign change.
The problem is that the MATLAB A.^B operator is defined as
exp(B * ln(A))
and if A is negative then ln(A) is complex and the overall result is likely to be complex.
I suggest you use
fun = @(x) nthroot((1 - (3/4*x)), 3);
카테고리
도움말 센터 및 File Exchange에서 Numeric Solvers에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!