I have forgotten

• https://me.yahoo.com

# abs

Absolute value of a complex number
View other versions (3)

## Interface

#include <complex> double abs (complex<T> z)

## Description

The abs function returns the absolute value of the complex number . The result is the real number denoted by and defined through:

Example:
##### Example - Abs
Problem
This program returns the absolute value of the complex number z=0.5+2i.
Workings
#include <stdio.h>
#include <complex>

using std::complex;

int main()
{
complex<double> z;
z=0.5+2i;
printf("|0.5 + 2 i| = %.4lf\n", abs(z));
return 0;
}
Solution
Output:

|0.5 + 2 i| = 2.0616

## Note

The function is actually an alias for hypot(a, b) = .