Bur Nor
Bur Nor

Reputation: 1

lsqnonlin with complex equation systems

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 - G1(x(1), x(2), x(3), x(4));
F(2) = c*x(3)+d*x(4)*1i - G2(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))

Upvotes: 0

Views: 1172

Answers (1)

m7913d
m7913d

Reputation: 11072

As stated in the matlab documentation of lsqnonlin (Limitations: third point, or search for 'complex'), you can use it for complex-valued problems only without bound constraints. As suggested, you should split F into a real and imaginary part as you did for the complex variables.

Fc(1) = a*x(3)+b*x(4)*1i - G1(x(1), x(2), x(3), x(4));
Fc(2) = c*x(3)+d*x(4)*1i - G2(x(1), x(2), x(3), x(4));

F(1:2) = real(Fc);
F(3:4) = imag(Fc);

Upvotes: 0

Related Questions