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?
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