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!

 Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 12 Mai 2016

2 Stimmen

>>fun0 = @(x) 1 - 3/4*x;
>> fzero(fun0,1)
ans = 1.3333
>>

2 Kommentare

Britt
Britt am 12 Mai 2016
hey, thanks! Are you able to tell me why the .^(1/3) isn't necessary in the code please?
our equation:
(1 - 3/4*x).^(1/3) = 0
((1 - 3/4*x).^(1/3))^3 = 0^3
1 - 3/4*x = 0

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 12 Mai 2016

1 Stimme

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);

2 Kommentare

Andrei Bobrov
Andrei Bobrov am 12 Mai 2016
+1
Britt
Britt am 12 Mai 2016
I know it's not suitable, I have to still write the code for it (which I've done) and plot it to 50 iterations (still trying to figure that out) and then explain why it isn't suitable.

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 12 Mai 2016

Kommentiert:

am 12 Mai 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by