0

I am simply trying to find the values of the two variables X and Y using the following system of two equations, in Python:

z = arccos [(sin(a) * sin(X)) + (cos(a) * cos(X) * cos(Y - b))]


Az = arctan2[(cos(X) * sin(Y - b)) , (cos(a) * sin(X)) - (sin(a) * cos(X) * cos(Y-b))]

where the values for the variables z, Az, a, and b are already known. The only unknown variables are X and Y.

How can I do this, using Python?

Ben
  • 51,770
  • 36
  • 127
  • 149
  • How would you do it with pen and paper? Figure that out and replicate. – pstatix Jan 09 '18 at 15:24
  • I think you have to create two equations expliciting both variables X and Y – Luca Jan 09 '18 at 15:25
  • 2
    Neerja, welcome to StackOveflow! 1)Those formulas look complicated enough to not have a closed form solution. Even if there is one, it is really hard to find it out. You might try to post your **_real problem_** to https://math.stackexchange.com/ and someone might have some good geometric intuition to solve it without this monstrous equations 2)No closed form solution means you need to use some numerical method. And if you expect that some will write the whole code for you for free - this is not how the StackOverflow works. SO users tend to help people how showed some effort in the questions – SergGr Jan 09 '18 at 15:41
  • Ok, thanks for letting me know! – Neeraj Sirdeshmukh Jan 09 '18 at 15:57
  • A couple of things to try. First, I'd write the first equation as `cos(z) = ...` instead of `z = arccos(...)`. I'd look at contour plots of the right-hand sides of the two equations -- the solution to the system of two equation is just the intersection of the contour cos(z) = of the first one and the contour Az = of the second one. You can estimate solutions by inspecting the plots. You can get a more precise estimate with a numerical method. Newton's method is a standard approach; remember you have to be "close enough" for the iteration to converge. – Robert Dodier Jan 09 '18 at 17:16

0 Answers0