Roots of function - Fzero error
Show older comments
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!
Accepted Answer
More Answers (1)
Walter Roberson
on 12 May 2016
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);
Categories
Find more on Numeric Solvers in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!