Filter löschen
Filter löschen

fsolve and complex solution?

4 Ansichten (letzte 30 Tage)
John Miller
John Miller am 18 Jun. 2012
Hello,
my test function is f=x^2+1 the slution is easy : x1=i orx2=-i (both are imaginary)
fsolve is not finding these values...why? fsolve returns 0 for a solution??
Thank you.
  4 Kommentare
Walter Roberson
Walter Roberson am 18 Jun. 2012
And you are not getting any warning message about it not being able to solve the problem?
I take it you overlooked this line in the documentation:
"fsolve only handles real variables. When x has complex variables, the variables must be split into real and imaginary parts."
John Miller
John Miller am 18 Jun. 2012
fsolve returns the following message:
No solution found.
fsolve stopped because the problem appears regular as measured by the gradient,
but the vector of function values is not near zero as measured by the
default value of the function tolerance.
<stopping criteria details>
x =0
fval =1
I should split x in real and imaginary? Like this:
F = (r+i*s)^2+1; ?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 18 Jun. 2012
function F = myfun(ripair)
x = ripair(1) + ripair(2)*1i;
F = x^2+1;
if imag(F) ~= 0; F = 10^5; end %you need to emit finite real value from myfun
end
and make sure your x0 has a pair of values.

Weitere Antworten (0)

Kategorien

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

Community Treasure Hunt

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

Start Hunting!

Translated by