# Math Help - Need help writing a function

1. ## Need help writing a function

My math skills have lapsed and I am having a bit of trouble trying to reorganize the following formula so that I can get latitude2 OR longitude2 if all other values are known.

~distance in miles=3958.899 * acos((sin(latitude1*0.01745329252)*sin(latitude2*0 .01745329252)) + (cos(latitude1*0.01745329252)*cos(latitude2*0.0174 5329252)*cos((longitude1*0.01745329252) - (longitude2*0.01745329252))));

Any help on this would be greatly appreciated.

-Jeff

2. Hello, Jeff!

It's very difficult to interpret what you wrote, and there seems to be an omission.
. . And can't we get rid of those ugly decimals?

I'll use $T$ for latitude, $G$ for longitude.

Let $k = 3958.899,\;a = 0.01745329252$

And I think the problem goes like this . . .

. . Get $T_2$ OR $G_2$ if all other values are known.

. . $d \;=\;k\cdot\cos^{-1}[\sin(a\cdot T_1)\cdot\sin(a\cdot T_2) + \cos(a\cdot T_1)\cos(a\cdot T_2)\cos(a\cdot G_1) - \underbrace{\cos}_{\text{?}}(a\cdot G_2)]$

And the asymmetry of the right side makes me suspect even more typos.

I can't possibly work on it until I'm sure of the original statement.

3. Sorry, I'm converting this from a Javascript function and wasn't familiar with how things are typically written.

multiplying degrees by 0.01745329252 gives you radians

3958.899 is the radius (in miles) of the Earth

acos is arccosine

The '*' character is a multiplication symbol

The ((longitude1*a)-(longitude2*a)) at the end of the formula should be calculated before multiplying it to the other expression.