Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

lsqnonlin with complex equation systems

183 views
Skip to first unread message

Rubron

unread,
Apr 6, 2017, 9:59:07 AM4/6/17
to
Hi, I have two complex-nonlinear equations with two complex variables (then four real variables). I have tried to use lsqnonlin instead of fsolve in order to define boundaries (lb, ub) to my unknown variables.

options=optimset('Display','iter','MaxFunEvals',1e6,'TolX',1e-16);
fun = @myfun;
x0 = [0,0,1000/2,100/2];
lb = [0,0,0,0];
ub = [1,1,1000,100];
x = lsqnonlin(fun,x0,lb,ub,options)

My function has this form:

function F=myfun(x)
F(1) = a*x(3)+b*x(4)*1i - G(x(1), x(2), x(3), x(4));
F(2) = c*x(3)+d*x(4)*1i - G(x(1), x(2), x(3), x(4));

where a, b, c, d are constant complex values, and G(x(1), x(2), x(3),x(4)) is a nonlinear function (with complex components too). After running lsqnonlin solver I got this error message: "The Levenberg-Marquardt algorithm does not handle bound constraints and the trust-region-reflective algorithm requires at least as many equations as variables; aborting."

First, I am not using Levenberg-Marquardt algorithm, so I dont think the error is because of that. Then, it makes me think that lsqnonlin cannot handle complex equation systems, and maybe it only sees two equations (althought these two complex equations give four real equations to solve my four real variables (x(1), x(2), x(3), x(4)).

Can I write complex equations system while using lsqnonlin? am I doing something wrong? I really would appreciate very much any help you can give me. Thanks a lot in advance))

Alan Weiss

unread,
Apr 6, 2017, 11:21:09 AM4/6/17
to
As clearly stated in the documentation section on using complex
variables with least-squares problems,
https://www.mathworks.com/help/optim/ug/complex-numbers-in-optimization-toolbox-solvers.html

There must be no constraints, not even bounds. Complex numbers are not
well ordered, so it is not clear what "bounds" might mean.

To use bounds, split the real and imaginary parts, and explicitly write
what you mean by "bounds" in this case.
https://www.mathworks.com/help/optim/ug/fit-model-to-complex-data.html#zmw57dd0e35565

Alan Weiss
MATLAB mathematical toolbox documentation

Rubron

unread,
Apr 10, 2017, 6:10:14 AM4/10/17
to
Alan Weiss <Alan....@mathworks.com> wrote in message <oc5md0$r9k$1...@newscl01ah.mathworks.com>...
Hi Alan, thanks for answering.

The bounds (or constrains) are applied to real variables (x(1), x(2), x(3), x(4)). The thing with lsqnonlin is that it does not accept complex equations, so it seems the only way to handle this is decompose each complex equation in two (one for real, and one for imag term). If you know other way to overcome this inconvenience, advice me please, because making that decomposition may be tough specially with nonlinear equations.

Best regards,
0 new messages