Borland C++ reference

polar

raw OCR

Returns a complex number with a given magnitude and angle.

Defined in header <complex.h>

Syntax

#include <complex.h>
complex  polar(double mag, double angle);

Portability

DOSUNIXWindowsANSI CC++ only
■■■

Remarks

polar (mag, angle) is the same as complex (mag*cos(angle), mag*sin (angle)

Return value

The complex number with the given magnitude (absolute value) and angle (argument).

See also

Example

#include <complex.h>

int mainO

   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 real part = " «  imag(z) << "\n";
   cout «  "z has complex conjugate = " << con](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.