Check the wiki. Basically, the range of the atan2 function is , whereas the atan function has a smaller range (approximately half that).
Go back and put the brackets in the correct places (I know that the article has a missing set of brackets but that is less important in properly typeset mathematics, in linear mathematical notation you have to put in the brackets as otherwise what you type does not mean what you think it does).
The article explains what atan2 is/does.For that particular formula read what wikipedia says and follow the link where it points to the tangent half angle formula.
When you have done that if you have any more questions about this post a follow up question in this thread.
CB