Borland C++ reference

arg

raw OCR

Gives the angle of a number in the complex plane.

Defined in header <complex.h>

Syntax

#include <complex.h>
double arg(complex x);

Portability

DOSUNIXWindowsANSI CC++ only
■■■

Remarks

arg gives the angle, in radians, of the number in the complex plane.

The positive real axis has angle 0, and the positive imaginary axis has angle pi/2. If the argument passed to arg is complex 0 (zero), arg returns 0.

Return value

arg(x) returns atan2(imag(x), real(x)).

See also

Example

#include <complex.h>

int main(void)
{
   double x = 3.1, y = 4.2;
   complex z = complex(x,y);
   cout << "z = " «  z «  "\n";
   cout «  "  has real part = " «  real(z) «  "\n";
   cout «  "  and imaginary part = " «  imag(z) << "\n";
   cout «  "z has complex conjugate = " << conj(z) << "\n";

   double mag - sqrt(norm(z));
   double ang = arg(z);

   cout << "The polar form of z is:\n";
   cout «  "   magnitude = " «  mag «  "\n";
   cout «  "   angle (in radians) = " << ang «  "\n";
cout << "Reconstructing z from its polar form gives:\n";
cout << "   z = " << polar(mag,ang) «  "\n";
return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.