0

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

MChawa
  • 45
  • 5
  • 1
    I evaluated `F` at using `x(1)` equal to the result from `fsolve`, and `x(2)=2.1237` and the function value was roughly `[-0.241,-0.149]`, but evaluating `F` at the solution given by `fsolve` gave the results `1e-10*[-.0694,0.565]` which is much, much smaller. Why do you think `fsolve` is wrong and you are right? – David Nov 27 '14 at 22:31
  • I have the exact solution for the equation, try x(1) = 0.8931116058 and x(2) 2.123746846 and you will know what i mean – MChawa Nov 27 '14 at 22:48
  • 1
    For those values I got a result of `[25.724928248606034,-17.860980634387658]`. – David Nov 27 '14 at 23:16
  • "since it's a complex equation i should be able to get them by equation both the real and imaginary part to 0." - no. You may be able to solve for something, but you need to supply some sort of additional constraint or additional information about `x(1)` and `x(2)` if you want a unique solution. Your supposed "real answer" isn't a root of your initial function. Your equation is simple enough that it can be solved symbolically. You might try `solve`. All above the above still stands though. – horchler Nov 28 '14 at 00:10
  • sorry David , i gave you wrong points , try x(1) = 1.003683025 and x(2) = 2.123746846 , the thing is is problem can be solved graphically and i solved it on a cad software this is why i know the solution but i need to solve it with matlab as well and confirm it – MChawa Nov 28 '14 at 06:59
  • David , sorry again , I was solving another equations :) , I worte 3/pi and it's pi/3 now matlab gives correct answer , my bad , thanks for your help – MChawa Nov 28 '14 at 07:14

1 Answers1

0

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

MChawa
  • 45
  • 5