Arg¶
Status: Stable
documented, exercised by the test suite and/or worked examples, with no known limitations recorded.
Description¶
Arg[z] gives the argument (phase angle in (-Pi, Pi]) of numeric z; 0 for nonnegative reals, Pi for negative reals.
Examples¶
No verified examples yet for this function.
Implementation notes¶
builtin_arg returns the phase angle in (-Pi, Pi]. A pure MPFR real folds to exact 0 or Pi by sign. For a Complex[re, im] whose parts are exact (Integer/Rational), it recognises the special directions and returns exact multiples of Pi: 0 for positive reals, Pi for negatives, ±Pi/2 on the imaginary axis, and ±Pi/4, ±3Pi/4 on the diagonals; otherwise it returns the symbolic ArcTan[re, im]. When either component carries MPFR it evaluates mpfr_atan2 at the combined precision; an inexact machine Real falls through to the libm atan2(im, re). Symbolic inputs return NULL.
Attributes: Listable, NumericFunction, Protected.
Implementation status¶
Stable — documented, exercised by the test suite and/or worked examples, with no known limitations recorded.
References¶
- Source:
src/complex.c - Specification:
docs/spec/builtins/arithmetic.md
Notes & additional examples¶
Worked examples¶
Powers wrap the phase into the principal branch:
Stepping the argument of (1 + I)^k traces the unit circle and folds back at Pi:
In[1]:= Table[Arg[(1 + I)^k], {k, 0, 8}]
Out[1]= {0, 1/4 Pi, 1/2 Pi, 3/4 Pi, Pi, -3/4 Pi, -1/2 Pi, -1/4 Pi, 0}
Generic complex numbers evaluate to high precision:
Notes¶
Arg[z] gives the phase angle in the range (-Pi, Pi]: 0 for positive reals, Pi for negative reals.