The CABS function accepts a complex number and returns the absolute value of that number. The absolute value of a complex number z is defined to be ABS(r). Refer to “Definitions Used in Complex Function Descriptions” earlier in this section.
Therefore, given the following equation:
CABS(x + iy) = SQRT(x**2 + y**2)
If ABS(x) >= ABS(y), the following identity is used:
SQRT(1 + (y/x)**2)*ABS(x)
If ABS(x) < ABS(y), the following identity is used:
SQRT(1 + (x/y)**2)*ABS(y)
The following special function is evaluated using iterations similar to Newton-Raphson iterations.
F(z) = SQRT(1 + z) - 1
The final computation is
CABS = F(z)*w+w
The variables z equals (y/x)**2 or (x/y)**2 and w equals ABS(x) or ABS(y).