MATLAB Solving non-linear algebraic equation

232 views Asked by At

I am trying to solve a vectorial equation where vectors are in polar form

the equation is

100*exp((pi/3)*j) + 200*exp(x(1)j) - 300(x(2)*j) - 315 = 0;

as you can see there is two unknowns in this equation x(1) and x(2) and since it's a complex equation i should be able to get them by equation both the real and imaginary part to 0.

i tried to use fsolve but the accuracy is very bad and it doesn't get any better as i increase it

my script :

function F = myfun(x)
F = [real(100*exp((pi/3)*1i) + 200*exp(x(1)*1i) - 300*exp(x(2)*1i) - 315); imag(100*exp((pi/3)*1i) + 200*exp(x(1)*1i) - 300*exp(x(2)*1i) - 315)];

my matlab code :

x0 = [0,0];
options = optimset(optimset('fsolve'), 'TolFun', 1.0e-25, 'TolX',1.0e-25);
[x,fval] = fsolve(@myfun,x0,options);

the given answer for x(2) is 2.1246 however the real answer is 2.1237 and this difference is too big for me.

any ideas ?

Thanks in advance

1

There are 1 answers

0
MChawa On BEST ANSWER

Matlab works fine , I had a Typo in my code , the correct equation is

100*exp((pi/3)*j) + 200*exp(x(1)j) - 300(x(2)*j) - 315 = 0 with pi/3 not 3/pi

Thanks for everyone