I need Arctan but only Arctan2 is supplied I'm a new programmer and I'm programming the projectile of a missile using the equation $\theta = \arctan(v^2\pm\sqrt{v^4-g(gx^2+2yv^2)}/gx)$ where


*

*$g$: the gravitational acceleration—usually taken to be $9.81$ m/s$^2$ near
the Earth's surface (9.8 in the game I'm using)

*$\theta$: the angle at which the projectile is launched (x, what I'm solving
for)

*$v$: the speed at which the projectile is launched ($35$ m/s)

*$y$: the initial height of the projectile (My position)

*$x$: the difference in distance (not including altitude-wise)


Now, the problem is the game I'm using this in only has Arctan2, which I've never seen or used before. And even if I did know it, this formula requires Arctan, not Arctan2. Does anyone know how to modify Arctan2 to work as Arctan?
 A: In programming, atan2 is used to determine the correct angle and quadrant. With $\arctan(x)$, the domain is $x\in(-\pi/2, \pi/2)$. This causes problems if $x = \frac{-a}{-b}$. With this case, you get an angle that is off by $\pi$. atan2 will come up with angle $- \pi$.

Here is the definition from Matlab:
atan2(Y,X) returns the Four-Quadrant Inverse Tangent (tan-1) of Y and X, which must be real. The atan2 function acts on Y and X element-wise to return P, which is the same size as Y and X.
The four-quadrant tangent inverse, atan2(Y,X), returns values in the closed interval [-pi,pi] based on the values of Y and X as shown in the graphic.
http://www.mathworks.com/help/matlab/ref/atan2.html#buct8h0-4

This why it is prevalent in programming. The programmer no longer has to read write code to check is results of $\arctan $ so their code works.
A: $\arctan y = atan2(y,1)$, using the definition at Wikipedia.
A: It's disappointing that dustin's excellent answer has not yet been accepted as I write this, but to apply the $\mathrm{atan2}(y,x)$ function directly to the specific problem in the question, one would write
$$
\theta = \mathrm{atan2}(v^2\pm\sqrt{v^4-g(gx^2+2yv^2)}, gx).
$$
Assuming that you would prefer to get an answer like $\theta = \frac34 \pi$
rather than something like $\theta = -\frac14 \pi$ 
for a projectile that is found at
$x = -100, y = 50$ some time after being launched, that is, the
missile was launched into the second quadrant (to the left of vertical),
then this formula using $\mathrm{atan2}$ will automatically give
you the answer you want.
The original formula with the ordinary arc tangent assumes that the
missile is fired into the first quadrant
(or that you check the results for plausibility and change the angle
in the answer by $180$ degrees if necessary).
A: Arctan2 is more general and better usage. You can forget the quadrant and get polar angle between 0 to $2 \pi$ directly, unmindful of which quadrant the moving point is situated. Atan is used for first quadrant only.
