Phil Lucht Math & Physics Archive
Home / Math and Physics Files / Math / trigonometry

arc tangent

DOCX · 74.7 KB
Open DOCX file

Personal note by Phil (signed PhL, 2.5.11) explaining the confusion over arctangent branches. It shows that tan^-1(y/x) needs the principal branch plus a quadrant-dependent adder q (0, π, π, 2π), as in Schaum. It gives a Maple procedure, arctan2Pi, returning an angle in (0,2π), a shifted version for ranges starting at u0, and how to recover θ from sinθ and cosθ.

AI-written summary; may contain errors.

Extracted text (machine-read; may contain errors)
Dealing with arctangent PhL 2.5.11 Motivation: Every time I encounter this confusion, I waste a whole day getting it straightened out again. So just maybe I can somehow "write it down" here where I can find it next time confusion strikes. tan(θ) π/2 π 3π/2 2π 0 An arctan function which returns θ in (0,2π) Consider this graphic: tan-1(x) As θ goes around the circle from 0 to 2π, we trace out the function tan(θ) as shown. No problem. Now the confusion comes with the arctangent. We can rotate and reflect the picture on the right to get the tan-1 picture and then we relabel it appropriately: You can see that the resulting graph involves three different "standard branches" of the tan-1(u) function. At the bottom we have one half of the "principle branch" as defined in Schaum. Given nothing but u = y/x, say, we cannot tell which of these three branches we are on! If we ignore the official principle branches, we could regard the above as just two branches. But things like Schaum and Maple want to use the official principle branch. So we have to do this: tan-1(y/x) = tan-1P(y/x) +q where P means principle branch. and the adder q comes from this table Quadrant q signx sign y I 0 1 1 II π -1 1 III π -1 -1 IV 2π 1 -1 A Maple implementation of this arctan function The Maple call arctan(y,x) does not do what I am describing here, it is intended for (-π,π) range of θ. So you have to roll your own function to do this. Here is my Maple code to do this: arctan2Pi := proc(x,y) local q; if x = 0 and y = 0 then print("arctan2Pi(0,0) error." ); RETURN(0) fi; if x = 0 and y > 0 then RETURN(Pi/2) fi; if x = 0 and y < 0 then RETURN(3*Pi/2) fi; if x > 0 and y = 0 then RETURN(0) fi; if x < 0 and y = 0 then RETURN(Pi) fi; if x > 0 and y > 0 then q := 0 fi; if x < 0 and y > 0 then q := Pi fi; if x < 0 and y < 0 then q := Pi fi; if x > 0 and y < 0 then q := 2*Pi fi; RETURN(arctan(y/x)+q) end; It seems to work. Now, suppose you want to use u which ranges from u0 to u0+2π as your angle. Then u = θ+u0 u = arctan2Pi(x,y) + u0 Here is a convincing test of the above routine: If you know sinθ and cosθ, how to you find θ in range (0,2π) ? Imagine a little unit radius circle on which we have X = cosθ and Y = sinθ. Then the answer to the question is this: θ = arctan2Pi(cosθ,sinθ) This requires the routine above to compute arctan(sinθ/cosθ) which is a division then tan-1, I guess that is not so bad.