필터 지우기
필터 지우기

fzero returns complex result

조회 수: 7 (최근 30일)
xueqi
xueqi 2013년 3월 26일
Hi,
I am running this code
f4=@(x) 0.1*0.4*(0.1*x+100)^(-0.8)-0.1*0.5*(-0.1*x+100)^(-0.8)+0.5*0.1*(0.5*x+100)^(-0.8);
fzero(f4,3)
and it only returns my NaN
Exiting fzero: aborting search for an interval containing a sign change because complex function value encountered during search. (Function value at -230.705 is -0.0043742-0.0033056i.) Check function or try again with a different starting value.
ans =
NaN
But if I change that the start poin to 200 I can get the result I want which is 225.3938. My question is how can I get the real root in general case? Before I get the solution I can't tell where is it so I can't choose a proper start point. I can't just randomly try different start points every time when I solve a function like this...

답변 (1개)

Walter Roberson
Walter Roberson 2013년 3월 26일
Analyze the parts of your expression. You have
(-0.1*x+100)^(-0.8)
That is going to go complex if (-0.1*x+100) < 0, which is x > 1000. Likewise analyze the other subexpressions. You will be able to establish an upper and a lower bound on when the function goes complex. Then use the interval x0 form of fzero
fzero(f4, [-31415926, 2718285]) %for example
  댓글 수: 2
xueqi
xueqi 2013년 3월 26일
I need to pass different parameters to functions I want to solve so I can't do these analysis. Is there any routine can solve it automatically? I tried to use Maple. And if I use 'solve' it gives me the same complex result while 'fsolve' gives me the solution which is real. So I think in matlab there must be the same alternative routine.
xueqi
xueqi 2013년 3월 28일
Any other suggestion please?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by