Solving a system of Non-linear Equations with Complex numbers
21 次查看(过去 30 天)
显示 更早的评论
Hi all,
I would like to solve the following system of 3 non-linear equations in 3 unknowns :
function F= myfun(x)
F=[ x(1) + x(2) - 10000;
x(1)*exp(-1i*x(3)*5) + x(2)*exp(1i*x(3)*5) - 12000;
x(1)*exp(-1i*x(3)*10) + x(2)*exp(1i*x(3)*10) - 8000 ];
The fsolve command does not solve complex number roots. And splitting it up into real and imaginary also does not seem to work (I took the help of Euler's formulae to convert to cosine and sine).
Please help me out!
0 个评论
回答(4 个)
John D'Errico
2017-4-6
编辑:John D'Errico
2017-4-6
It appears there are two solutions. They are best found using solve, so a symbolic solution.
syms x1 x2 x3
eq1 = x1 + x2 - 10000;
eq2 = x1*exp(-1i*x3*5) + x2*exp(1i*x3*5) - 12000;
eq3 = x1*exp(-1i*x3*10) + x2*exp(1i*x3*10) - 8000;
result = solve(eq1,eq2,eq3,x1,x2,x3)
result =
struct with fields:
x1: [2×1 sym]
x2: [2×1 sym]
x3: [2×1 sym]
result.x1
ans =
5000 - (7^(1/2)*9000i)/7
(7^(1/2)*9000i)/7 + 5000
result.x2
ans =
(7^(1/2)*9000i)/7 + 5000
5000 - (7^(1/2)*9000i)/7
result.x3
ans =
-(log(3/4 - (7^(1/2)*1i)/4)*1i)/5
-(log((7^(1/2)*1i)/4 + 3/4)*1i)/5
vpa(result.x1)
ans =
5000.0 - 3401.6802570830450449306488261076i
5000.0 + 3401.6802570830450449306488261076i
vpa(result.x2)
ans =
5000.0 + 3401.6802570830450449306488261076i
5000.0 - 3401.6802570830450449306488261076i
vpa(result.x3)
ans =
-0.14454684956268312223567547052827
0.14454684956268312223567547052827
As you can see by simple tests to verify this is a solution...
result.x1 + result.x2
ans =
10000
10000
vpa(result.x1.*exp(-1i*result.x3*5) + result.x2.*exp(1i*result.x3*5) - 12000)
ans =
0
0
0 个评论
Star Strider
2014-7-1
‘The fsolve command does not solve complex number roots.’
It does for me!
Your function (as an anonymous function):
myfun = @(x) [ x(1) + x(2) - 10000;
x(1)*exp(-1i*x(3)*5) + x(2)*exp(1i*x(3)*5) - 12000;
x(1)*exp(-1i*x(3)*10) + x(2)*exp(1i*x(3)*10) - 8000 ];
X = fsolve(myfun, [1; 1; 1])
produced:
X =
2.3160e+000 - 33.3155e-003i
2.3160e+000 + 33.3155e-003i
1.2720e+000 + i
It wanted me to let it do more function evaluations, but I’ll leave that to you. (I’m running R2014a, but I doubt that makes a difference.)
2 个评论
Rubron
2017-4-6
Hi, do you know if the same can be applied to "lsqnonlin" solver? I have been struggling while trying to enter complex equations with that solver, it seems it does not accept them.
John D'Errico
2017-4-6
编辑:John D'Errico
2017-4-6
Sorry. lsqnonlin will definitely not work happily with complex variables, which explains your failure to get it working.
Hmm. I did just notice that the solution Star proposed does not actually solve the system of equations. For example, the sum x(1)+x(2) does not yield 10000. In fact, that sum is not even close to 10000. So I'm not too sure that fsolve is terribly happy at solving complex problems either.
Alex Sha
2022-11-18
There are much more solutions else:
x1: 5000+3401.68025708298i
x2: 5000-3401.68025708301i
x3: -3.62536433474507+0i
x1: 5000+3401.68025708298i
x2: 5000-3401.68025708301i
x3: 1.11209021187323+0i
x1: 5000+3401.68025708298i
x2: 5000-3401.68025708301i
x3: 2.36872727330915+0i
0 个评论
David Goodmanson
2022-11-18
编辑:David Goodmanson
2022-11-18
Hellol Aravindhan,
not solved by Matlab, but a bit of algebra shows that
with
x(1) = 2000*a
x(2) = 2000*b
x(3) = theta/5
then
theta = acos(3/4);
a = (5/2 +9*i/(2*sqrt(7)));
b = (5/2 -9*i/(2*sqrt(7)));
format long g
theta = acos(3/4)
x = [2000*a 2000*b theta/5]'
theta = 0.722734247813416
x = 5000 - 3401.68025708305i
5000 + 3401.68025708305i
0.144546849562683 + 0i
There are an infinite number of solutions to theta = acos(3/4). First of all there is the 2pi ambiguity, so theta = .7227 + 2*pi*n is a set of solutions. Then the negative angle, -.7227 (with its 2pi ambiguity) is a set of solutions as well. But note that the equations are symmetric under theta --> -theta, a<-->b
so the -.7227 set is the same thing with a and b swapped. Consequently there are only two possibilities for a and b.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!