Filter löschen
Filter löschen

fzero returns complex result

7 Ansichten (letzte 30 Tage)
xueqi
xueqi am 26 Mär. 2013
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...

Antworten (1)

Walter Roberson
Walter Roberson am 26 Mär. 2013
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 Kommentare
xueqi
xueqi am 26 Mär. 2013
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 am 28 Mär. 2013
Any other suggestion please?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Systems of Nonlinear Equations finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by