Mathematica has functions ArcCos
, ArcSin
, and ArcTan
, but none of these does what I need, which is, given two real numbers a and b, at least one of them being nonzero, to find the angle x such that
{Cos[x], Sin[x]} == {a,b}/Sqrt[a^2+b^2]
.
Is there a simple way to build such a function? Thanks for any help.
Solve[{Cos[x] == a/Sqrt[a^2 + b^2], Sin[x] == b/Sqrt[a^2 + b^2]}, x]
$\endgroup$ArcTan[a, b]
does what you want. $\endgroup$