norm
raw OCR
Returns the square of the absolute value.
Defined in header <complex.h>
Syntax
#include <complex.h>
double norm(complex x);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ | ■ |
Remarks
norm can overflow if either the real or imaginary part is sufficiently large.
Return value
norm(x) returns the magnitude real(x) * real(x) + imag(x) * imag(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 real 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"; e
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.
Stable link: /3.1/complex.h/norm/
· short form /3.1/norm/