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!

 採用された回答

Andrei Bobrov
Andrei Bobrov 2016 年 5 月 12 日

2 投票

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

2 件のコメント

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

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 5 月 12 日

1 投票

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 件のコメント

Andrei Bobrov
Andrei Bobrov 2016 年 5 月 12 日
+1
Britt
Britt 2016 年 5 月 12 日
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.

サインインしてコメントする。

質問済み:

2016 年 5 月 12 日

コメント済み:

2016 年 5 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by