In lecture we mentioned the atan2 function which helps us overcome ambiguities in inverse tangent functions. In this segment we'll elaborate more on the advantages of the atan2 function. First, let's examine the traditional atan function. Recall that the tangent of an angle, theta, is a ratio of sine theta over cosine theta. Let y equal the sine of theta, and x equal the cosine of theta. The inverse tangent function takes the scalar ratio y over x, and returns the angle theta for which tan theta equals y over x. For example, the tangent of the angle pi over 6 is 1 over the square root of 3. As a result, the inverse tangent of 1 over the square root of 3 is pi over 6. The inverse tangent function is implemented in programming languages as the atan function. This function takes a scalar variable as an input and returns the angle that is its inverse tangent. There are two shortcomings of this function. First, consider the angle pi over 4. The sine of this angle is root 2 over 2. The cosine is also root 2 over 2 and the tangent is 1. Now, consider the angle negative 3 pi over 4. Well the sign and cosign of negative 3 pi over 4 are different from pi over 4, the tangent is also 1. Thus, the atan function can not distinguish between these two angles. In fact, the atan function can not distinguish between any pair of points opposite from each other on the unit circle. A second problem with the atan function occurs at the angles negative pi over 2 and pi over 2. The cosine of these angles is 0. And as a result, the ratio of sine over cosine is undefined. Thus, the atan function fails at these points. To avoid these problems the atan function can only return angles in the range negative pi over 2, to pi over 2, non-inclusive. The atan2 function is an adaptation of the atan function that takes two inputs, y and x, and determines the resulting angle theta, based on the ratio, as well as the signs of y and x. Thus atan2 of 1 and 1 will return pie over 4, while atan2 of negative 1 and negative 1 will return negative 3 pi over 4. In addition, atan2 of 1 and 0 and negative 1 and 0, will successfully return the pi over 2 and negative pi over 2 respectively. As a result the atan2 function will return angles in the entire range of 0 to 2 pi.