Re: finding complex root from nonlinear equations




"Mars creature" <jinbow@xxxxxxxxx> wrote in message
news:f5f45956-b72f-4637-abec-c6ad168c231c@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Jan 3, 5:49 pm, "Roger Stafford"
<ellieandrogerxy...@xxxxxxxxxxxxxxxxxxxxxx> wrote:
Mars creature <jin...@xxxxxxxxx> wrote in message
<046c08c7-878f-4967-bab1-41273a92b...@xxxxxxxxxxxxxxxxxxxxxxxxxxx>...
Hi Matlab users,
I know fsolve can find the real roots from polynomial equations, but
I don't know how to find complex roots, like x^2+1=0. Also I have a
complicated nonlinear equation with complex coefficients to solve
numerically, anyone give me a hint where to find the instruction?
Thank you very much!
JB wang

For polynomial equations the matlab function 'roots' will find all
roots, complex or real. For general nonlinear equations, Mathworks'
advice in their 'fsolve' documentation is "fsolve only handles real
variables. When x has complex variables, the variables must be split into
real and imaginary parts." Presumably this splitting would also apply to
the values in the function F(x) to be zero-ed. Its real and imaginary
parts could be brought to zero as separate elements of the F(x) vector.
In effect you would be doubling the number of unknowns and the number of
equations.

As to finding all possible roots, 'fsolve' only promises to find one
root. However that can be manipulated by selecting differing starting
values on different calls to 'fsolve'. That might be easier said than
done, though.

Roger Stafford

Thanks Roger,
This is helpful. I can see that polynomial equations can be split
into two equations containing the real and imag parts. However, it
might be a problem for more complicated nonlinear equations, like
including sin/cos and sqrt of x and even more complicated cases, when
the whole equation is not easy to split. I was wondering if there's
solver like fsolve, and can find the complex roots without splitting
the equation. I googled but can not find very useful information.
Thank you very much!!
JB wang



Splitting it up isn't that difficult a problem.


x = fsolve(@myfunction7, [1; 1]);
complexSolution = complex(x(1:2:end), x(2:2:end))


where myfunction7 is:


function y = myfunction7(x)
complexX = complex(x(1:2:end), x(2:2:end));
complexY = complexX.^2 + 1; % to solve x.^2 + 1
y = [real(complexY); imag(complexY)];


using an "interleaved" storage for x, the parameter for which FSOLVE solves,
and [real; imaginary] for y, the output from myfunction7, the function to be
solved.

--
Steve Lord
slord@xxxxxxxxxxxxx


.



Relevant Pages

  • Re: fsolve problems
    ... The roots will not be complex or negative if they ... I may not help you with fsolve, which is in that toolbox, ... x is a column vextor, w1, w2 are big enough scalar ... weights or columns of vector weights. ...
    (comp.soft-sys.matlab)
  • Re: finding complex root from nonlinear equations
    ... I know fsolve can find the real roots from polynomial equations, ... I don't know how to find complex roots, ... As to finding all possible roots, 'fsolve' only promises to find one root. ...
    (comp.soft-sys.matlab)
  • Re: finding complex root from nonlinear equations
    ... I know fsolve can find the real roots from polynomial equations, ... I don't know how to find complex roots, ... As to finding all possible roots, 'fsolve' only promises to find one root. ... I can see that polynomial equations can be split ...
    (comp.soft-sys.matlab)
  • Re: Solving non linear equations
    ... I tried to solve these equations using 'fsolve' command, ... This is a problem for 'roots'. ... Then substitute the left hand expression in this equation for z in the third ...
    (comp.soft-sys.matlab)
  • Re: fsolve problems
    ... force fsolve to only look for real roots. ... The roots will not be complex or negative if they ... While fsolve will not accept explicit constraints, ... use a transformation of variables. ...
    (comp.soft-sys.matlab)