CFLib.org – Common Function Library Project

ComplexNumAbs(ComplexNumber)

Last updated November 15, 2001

author

Matthew Walker

Version: 1 | Requires: CF5 | Library: MathLib

Description:
This function calculates the real number representing the absolute value of a complex number, where the complex number is a structure created earlier using the ComplexNum() UDF. If the real and imaginary parts of the number are the horizontal and vertical sides of a right triangle, the absolute value is the hypotenuse.

Return Values:
Returns a numeric value.

Example:

<cfoutput>
    | 3+4i | = #ComplexNumAbs(ComplexNum(3,4))#
</cfoutput>

Parameters:

Name Description Required
ComplexNumber Structure containing the complex number you want the absolute value for. Yes

Full UDF Source:

/**
 * Absolute value |z| of a complex number.
 * Note that this function uses complex numbers stored as structures by the ComplexNum() UDF also available in this library.
 * 
 * @param ComplexNumber      Structure containing the complex number you want the absolute value for. 
 * @return Returns a numeric value. 
 * @author Matthew Walker (matthew@electricsheep.co.nz) 
 * @version 1, November 15, 2001 
 */
function ComplexNumAbs(ComplexNumber){
  return Sqr(ComplexNumber.R^2 + ComplexNumber.I^2);
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson