Borrar filtros
Borrar filtros

fsolve and complex solution?

4 visualizaciones (últimos 30 días)
John Miller
John Miller el 18 de Jun. de 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 comentarios
Walter Roberson
Walter Roberson el 18 de Jun. de 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 el 18 de Jun. de 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; ?

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 18 de Jun. de 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.

Más respuestas (0)

Categorías

Más información sobre Systems of Nonlinear Equations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by