i'm making an application involving google maps and since they use a mercator transformation i need to change from pixel location to latitude .. the equation i have is y = ln|sec(lat)+tan(lat)|/constants .. i would like to get the latitude given the Y .. which is the oposite of this equation ... it would have 2 solutions but all i need is just one and ill make up for the different signs .. can some1 help me to simplify this .. or should i just do it numerically ?
-
I'm getting y = arcsin((e^(2x) - 1) / (e^2x + 1)), but let me double-check here, (absolute values always mess me up), and then I'll show you how I got it.
O.k., so to find the inverse, 'switch' x and y and then re-solve for y:
x = ln l sec(y) + tan(y) l, so e^x = l sec(y) + tan(y) l. Now
sec(y) + tan(y) = (1 + sin(y))/cos(y) = (1 + sin(y)) / sqrt(1 - sin^2(y)) =
(1 + sin(y)) / sqrt((1 - sin(y))(1 + sin(y))) = sqrt((1 + sin(y)) / (1 - sin(y)). So this gives us
e^x = sqrt((1 + sin(y)) / (1 - sin(y)) ---> e^(2x) = (1 + sin(y))/(1 - sin(y)) --->
e^(2x) * (1 - sin(y)) = 1 + sin(y) ---> e^(2x) - 1 = (e^(2x) + 1)*sin(y) --->
sin(y) = (e^(2x) - 1) / (e^(2x) + 1) ---> y = arcsin((e^(2x) - 1) / (e^(2x) + 1)).
Edit: Mathmom's answer is more elegant, but our two answers are equivalent, believe it or not. :)
O.k., so to find the inverse, 'switch' x and y and then re-solve for y:
x = ln l sec(y) + tan(y) l, so e^x = l sec(y) + tan(y) l. Now
sec(y) + tan(y) = (1 + sin(y))/cos(y) = (1 + sin(y)) / sqrt(1 - sin^2(y)) =
(1 + sin(y)) / sqrt((1 - sin(y))(1 + sin(y))) = sqrt((1 + sin(y)) / (1 - sin(y)). So this gives us
e^x = sqrt((1 + sin(y)) / (1 - sin(y)) ---> e^(2x) = (1 + sin(y))/(1 - sin(y)) --->
e^(2x) * (1 - sin(y)) = 1 + sin(y) ---> e^(2x) - 1 = (e^(2x) + 1)*sin(y) --->
sin(y) = (e^(2x) - 1) / (e^(2x) + 1) ---> y = arcsin((e^(2x) - 1) / (e^(2x) + 1)).
Edit: Mathmom's answer is more elegant, but our two answers are equivalent, believe it or not. :)
-
y = ln|sec(x) + tan(x)|
Switch x and y and solve for y:
x = ln|sec(y) + tan(y)|
e^x = sec(y) + tan(y)
e^(−x) = 1/e^x = 1/(sec(y) + tan(y))
. . . . . . = (sec(y) − tan(y)) / [(sec(y) + tan(y))(sec(y) − tan(y)]
. . . . . . = (sec(y) − tan(y)) / (sec²(y) − tan²(y))
. . . . . . = (sec(y) − tan(y)) / 1
. . . . . . = sec(y) − tan(y)
e^x + e^−x = sec(y) + tan(y) + sec(y) − tan(y)
e^x + e^−x = 2 sec(y)
sec(y) = (e^x + e^−x)/2
y = sec⁻¹ ((e^x + e^−x)/2)
Switch x and y and solve for y:
x = ln|sec(y) + tan(y)|
e^x = sec(y) + tan(y)
e^(−x) = 1/e^x = 1/(sec(y) + tan(y))
. . . . . . = (sec(y) − tan(y)) / [(sec(y) + tan(y))(sec(y) − tan(y)]
. . . . . . = (sec(y) − tan(y)) / (sec²(y) − tan²(y))
. . . . . . = (sec(y) − tan(y)) / 1
. . . . . . = sec(y) − tan(y)
e^x + e^−x = sec(y) + tan(y) + sec(y) − tan(y)
e^x + e^−x = 2 sec(y)
sec(y) = (e^x + e^−x)/2
y = sec⁻¹ ((e^x + e^−x)/2)
-
não sei.