Help Center
Help CenterAfxNovaNumeric Datatypes

Complex Numbers Procedures

Members (100)

acoshCalculates the inverse hyperbolic cosine.asinhCalculates the inverse hyperbolic sine.atanhCalculates the inverse hyperbolic tangent of a number.CAbsReturns the magnitude of a complex number.CAbs2Returns the squared magnitude of a complex number, otherwise known as the complex norm.CAbsSqrReturns the absolute square (squared norm) of a complex number.CACosReturns the complex arccosine of a complex number.CACosHReturns the complex hyperbolic arccosine of a complex number. The branch cut is on the real axis, less than 1.CACosHRealReturns the complex arccosine of a complex number.CACosRealReturns the complex arccosine of a real number.CACotReturns the complex arccotangent of a complex number.CACotHReturns the complex hyperbolic arccotangent of a complex number.CACscReturns the complex arccosecant of a complex number.CACscHReturns the complex hyperbolic arccosecant of a complex number.CACscRealReturns the complex arccosecant of a real number.CAddImagAdds an imaginary number.CAddRealAdds a real number.CArcCosReturns the complex arccosine of a complex number.CArcCosHReturns the complex hyperbolic arccosine of a complex number.CArcCosHRealReturns the complex arccosine of a complex number.CArcCosRealReturns the complex arccosine of a real number.CArcCotReturns the complex arccotangent of a complex number.CArcCotHReturns the complex hyperbolic arccotangent of a complex number.CArcCscReturns the complex arccosecant of a complex number.CArcCscHReturns the complex hyperbolic arccosecant of a complex number.CArcCscRealReturns the complex arccosecant of a real number.CArcSecReturns the complex arcsecant of a complex number.CArcSecHReturns the complex hyperbolic arcsecant of a complex number.CArcSecRealReturns the complex arcsecant of a real number.CArcSinReturns the complex arcsine of a complex number.CArcSinHReturns the complex hyperbolic arcsine of a complex number.CArcSinRealReturns the complex arcsine of a real number.CArcTanReturns the complex arctangent of a complex number.CArcTanHReturns the complex hyperbolic arctangent of a complex number.CArcTanHRealReturns the complex hyperbolic arctangent of a real number.CArgReturns the argument of a complex number.CArgumentReturns the argument of a complex number.CASecReturns the complex arcsecant of a complex number.CASecHReturns the complex hyperbolic arcsecant of a complex number.CASecRealReturns the complex arcsecant of a real number.CASinReturns the complex arcsine of a complex number.CASinHReturns the complex hyperbolic arcsine of a complex number.CASinRealReturns the complex arcsine of a real number.CATanReturns the complex arctangent of a complex number.CATanHReturns the complex hyperbolic arctangent of a complex number.CATanHRealReturns the complex hyperbolic arctangent of a real number.CConjReturns the complex conjugate of a complex number.CConjugateReturns the complex conjugate of a complex number.CCosReturns the complex cosine of a complex number.CCosHReturns the complex hyperbolic cosine of a complex number.CCotReturns the complex cotangent of a complex number.CCotHReturns the complex hyperbolic cotangent of a complex number.CCscReturns the complex cosecant of this complex number.CCscHReturns the complex hyperbolic cosecant of a complex number.CDivImagDivides by an imaginary number.CDivRealDivides by a real number.CExpReturns the complex exponential of this complex number.CGetImagReturns the imaginary part of a complex number.CGetRealReturns the real part of a complex number.CInverseReturns the inverse, or reciprocal, of a complex number.CLogReturns the complex natural logarithm (base e) of this complex number.CLog10Returns the complex base-10 logarithm of a complex number.CLogAbsReturns the natural logarithm of the magnitude of a complex number.CMagnitudeReturns the magnitude of a complex number.CModReturns the modulus of a complex number.CModulusReturns the modulus of a complex number.CMulImagMultiplies by an imaginary number.CMulRealMultiplies by a real number.CNegNegates a complex number.CNegateNegates a complex number.CNegativeNegates the complex number.CNormReturns the squared magnitude of a complex number, otherwise known as the complex norm.CNthRootReturns the kth nth root of a complex number where k = 0, 1, 2, 3,...,n - 1.Comparison operatorsCompares complex numbers.CPhaseReturns the argument of a complex number.CPolarSets the complex number from the polar representation.CPowReturns this complex number raised to a complex power or to a real number.CReciprocalReturns the inverse, or reciprocal, of a complex number.CRectUses the cartesian components (x,y) to set the real and imaginary parts of the complex number.CRetCSecReturns the complex secant of a complex number.CSecHReturns the complex hyperbolic secant of a complex number.CSetUses the cartesian components (x,y) to set the real and imaginary parts of a complex number.CSetImagSets the imaginary part of a complex number.CSetRealSets the real part of a complex number.CSgnReturns the sign of a complex number.CSinReturns the complex sine of a complex number.CSinHReturns the complex hyperbolic sine of a complex number.CSqrReturns the square root of a complex.CSqrRealReturns the complex square root of a real number.CSqrtReturns the square root of a complex number.CSubImagSubtracts an imaginary number.CSubRealSubtracts a real number.CSwapExchanges the contents of two complex numbers.CTanReturns the complex tangent of a complex number.CTanHReturns the complex hyperbolic tangent of a complex number.hypot3Computes the value of sqr(x^2 + y^2 + z^2).IsInfIsInfinityDetermines whether the argument is an infinity.Math operatorsAdd, subtract, multiply or divide complex numbers.

Documentation

Complex Numbers Procedures

Procedures to work with complex numbers. Complex numbers are represented using the type _complex. The real and imaginary part are stored in the members x and y.

TYPE _complex
   x AS DOUBLE   ' real part
   y AS DOUBLE   ' imaginary part
END TYPE

Include file: AfxNova/AfxComplex.inc.

Operators

NameDescription
Comparison operatorsCompares complex numbers.
Math operatorsAdd, subtract, multiply or divide complex numbers.

Methods and Properties

NameDescription
CAbsReturns the magnitude of a complex number.
CAbs2Returns the squared magnitude of a complex number, otherwise known as the complex norm.
CAbsSqrReturns the absolute square (squared norm) of a complex number.
CACosReturns the complex arccosine of a complex number.
CACosHReturns the complex hyperbolic arccosine of a complex number. The branch cut is on the real axis, less than 1.
CACosHRealReturns the complex arccosine of a complex number.
CACosRealReturns the complex arccosine of a real number.
CACotReturns the complex arccotangent of a complex number.
CACotHReturns the complex hyperbolic arccotangent of a complex number.
CACscReturns the complex arccosecant of a complex number.
CACscHReturns the complex hyperbolic arccosecant of a complex number.
CACscRealReturns the complex arccosecant of a real number.
CAddImagAdds an imaginary number.
CAddRealAdds a real number.
CArcCosReturns the complex arccosine of a complex number.
CArcCosHReturns the complex hyperbolic arccosine of a complex number.
CArcCosHRealReturns the complex arccosine of a complex number.
CArcCosRealReturns the complex arccosine of a real number.
CArcCotReturns the complex arccotangent of a complex number.
CArcCotHReturns the complex hyperbolic arccotangent of a complex number.
CArcCscReturns the complex arccosecant of a complex number.
CArcCscHReturns the complex hyperbolic arccosecant of a complex number.
CArcCscRealReturns the complex arccosecant of a real number.
CArcSecReturns the complex arcsecant of a complex number.
CArcSecHReturns the complex hyperbolic arcsecant of a complex number.
CArcSecRealReturns the complex arcsecant of a real number.
CArcSinReturns the complex arcsine of a complex number.
CArcSinHReturns the complex hyperbolic arcsine of a complex number.
CArcSinRealReturns the complex arcsine of a real number.
CArcTanReturns the complex arctangent of a complex number.
CArcTanHReturns the complex hyperbolic arctangent of a complex number.
CArcTanHRealReturns the complex hyperbolic arctangent of a real number.
CArgReturns the argument of a complex number.
CArgumentReturns the argument of a complex number.
CASecReturns the complex arcsecant of a complex number.
CASecHReturns the complex hyperbolic arcsecant of a complex number.
CASecRealReturns the complex arcsecant of a real number.
CASinReturns the complex arcsine of a complex number.
CASinHReturns the complex hyperbolic arcsine of a complex number.
CASinRealReturns the complex arcsine of a real number.
CATanReturns the complex arctangent of a complex number.
CATanHReturns the complex hyperbolic arctangent of a complex number.
CATanHRealReturns the complex hyperbolic arctangent of a real number.
CConjReturns the complex conjugate of a complex number.
CConjugateReturns the complex conjugate of a complex number.
CCosReturns the complex cosine of a complex number.
CCosHReturns the complex hyperbolic cosine of a complex number.
CCotReturns the complex cotangent of a complex number.
CCotHReturns the complex hyperbolic cotangent of a complex number.
CCscReturns the complex cosecant of this complex number.
CCscHReturns the complex hyperbolic cosecant of a complex number.
CDivImagDivides by an imaginary number.
CDivRealDivides by a real number.
CExpReturns the complex exponential of this complex number.
CGetImagReturns the imaginary part of a complex number.
CGetRealReturns the real part of a complex number.
CInverseReturns the inverse, or reciprocal, of a complex number.
CLogReturns the complex natural logarithm (base e) of this complex number.
CLog10Returns the complex base-10 logarithm of a complex number.
CLogAbsReturns the natural logarithm of the magnitude of a complex number.
CMagnitudeReturns the magnitude of a complex number.
CModReturns the modulus of a complex number.
CModulusReturns the modulus of a complex number.
CMulImagMultiplies by an imaginary number.
CMulRealMultiplies by a real number.
CNegNegates a complex number.
CNegateNegates a complex number.
CNegativeNegates the complex number.
CNormReturns the squared magnitude of a complex number, otherwise known as the complex norm.
CNthRootReturns the kth nth root of a complex number where k = 0, 1, 2, 3,...,n - 1.
CPhaseReturns the argument of a complex number.
CPolarSets the complex number from the polar representation.
CPowReturns this complex number raised to a complex power or to a real number.
CRectUses the cartesian components (x,y) to set the real and imaginary parts of the complex number.
CReciprocalReturns the inverse, or reciprocal, of a complex number.
CSecReturns the complex secant of a complex number.
CSecHReturns the complex hyperbolic secant of a complex number.
CSetUses the cartesian components (x,y) to set the real and imaginary parts of a complex number.
CSetImagSets the imaginary part of a complex number.
CSetRealSets the real part of a complex number.
CSgnReturns the sign of a complex number.
CSinReturns the complex sine of a complex number.
CSinHReturns the complex hyperbolic sine of a complex number.
CSqrReturns the square root of a complex.
CSqrtReturns the square root of a complex number.
CSqrRealReturns the complex square root of a real number.
CSubImagSubtracts an imaginary number.
CSubRealSubtracts a real number.
CSwapExchanges the contents of two complex numbers.
CTanReturns the complex tangent of a complex number.
CTanHReturns the complex hyperbolic tangent of a complex number.

Helper Procedures

NameDescription
acoshCalculates the inverse hyperbolic cosine.
asinhCalculates the inverse hyperbolic sine.
atanhCalculates the inverse hyperbolic tangent of a number.
hypot3Computes the value of sqr(x^2 + y^2 + z^2).
IsInfinityDetermines whether the argument is an infinity.

Comparison operators

Compares complex numbers for equality or inequality.

OPERATOR = (BYREF z1 AS _complex, BYREF z2 AS _complex) AS BOOLEAN
OPERATOR <> (BYREF z1 AS _complex, BYREF z2 AS _complex) AS BOOLEAN
Example
DIM c1 AS _complex = (1, 2)
DIM c2 AS _complex = (3, 4)
IF c1 = c2 THEN PRINT "equal" ELSE PRINT "different"

Math operators

OPERATOR + (BYREF z1 AS _complex, BYREF z2 AS _complex) AS _complex
OPERATOR + (BYVAL a AS DOUBLE, BYREF z AS _complex) AS _complex
OPERATOR + (BYREF z AS _complex, BYVAL a AS DOUBLE) AS _complex
OPERATOR - (BYREF z1 AS _complex, BYREF z2 AS _complex) AS _complex
OPERATOR - (BYVAL a AS DOUBLE, BYREF z AS _complex) AS _complex
OPERATOR - (BYREF z AS _complex, BYVAL a AS DOUBLE) AS _complex
OPERATOR * (BYREF z1 AS _complex, BYREF z2 AS _complex) AS _complex
OPERATOR * (BYVAL a AS DOUBLE, BYREF z AS _complex) AS _complex
OPERATOR * (BYREF z AS _complex, BYVAL a AS DOUBLE) AS _complex
OPERATOR / (BYREF leftside AS _complex, BYREF rightside AS _complex) AS _complex
OPERATOR / (BYVAL a AS DOUBLE, BYREF z AS _complex) AS _complex
OPERATOR / (BYREF z AS _complex, BYVAL a AS DOUBLE) AS _complex
OPERATOR - (BYREF z AS _complex, BYVAL a AS DOUBLE) AS _complex
OPERATOR ^ (BYREF value AS _complex, BYREF power AS _complex) AS _complex
OPERATOR ^ (BYREF value AS _complex, BYVAL power AS DOUBLE) AS _complex
Examples
DIM c1 AS _complex = (3, 4)
DIM c2 AS _complex = (5, 6)
c2 = c1 + c2
print CStr(c2)
DIM c1 AS _complex = (3, 4)
DIM c2 AS _complex = (5, 6)
c2 = c1 + 11
print CStr(c2)
DIM c1 AS _complex = (3, 4)
DIM c2 AS _complex = (5, 6)
c2 = 11 + c1
print CStr(c2)
DIM c1 AS _complex = (3, 4)
DIM c2 AS _complex = (5, 6)
c2 = c1 - c2
print CStr(c2)
DIM c1 AS _complex = (3, 4)
DIM c2 AS _complex = c1 - 11
print CStr(c2)
DIM c1 AS _complex = (3, 4)
DIM c2 AS _complex = 11 - c1
print CStr(c2)
DIM c1 AS _complex = (3, 4)
DIM c2 AS _complex = (5, 6)
c2 = c1 * c2
print CStr(c2)
DIM c1 AS _complex = (3, 4)
DIM c2 AS _complex = c1 * 11
print CStr(c2)
DIM c1 AS _complex = (3, 4)
DIM c2 AS _complex = 11 * c1
print CStr(c2)
DIM c1 AS _complex = (3, 4)
DIM c2 AS _complex = (5, 6)
c2 = c1 / c2
print CStr(c2)
DIM c1 AS _complex = (3, 4)
DIM c2 AS _complex = c1 / 11
print CStr(c2)
DIM cpx1 AS _complex = (5, 6)
DIM cpx2 AS _complex
cpx2 = 11 / cpx1
DIM c1 AS _complex = (3, 4)
DIM c2 AS _complex = 11 * c1
print CStr(c2)
DIM c1 AS _complex = (3, 4)
DIM c2 AS _complex = (5, 6)
c2 -= c1
print CStr(c2)
DIM c1 AS _complex = (3, 4)
DIM c2 AS _complex = (5, 6)
c1 *= c2
print CStr(c2)
DIM c1 AS _complex = (3, 4)
DIM c2 AS _complex = (5, 6)
c1 /= c2
print CStr(c2)
DIM c1 AS _complex = (3, 4)
DIM c2 AS _complex = -c1
print CStr(c2)

CAbs / CMagnitude

Returns the magnitude of a complex number.

FUNCTION CAbs (BYREF z AS _complex) AS DOUBLE
FUNCTION CMagnitude (BYREF z AS _complex) AS DOUBLE
Example
DIM c AS _complex = (2, 3)
PRINT CAbs(c)
Output: 3.60555127546399

CAbs2 / CNorm

Returns the squared magnitude of a complex number, otherwise known as the complex norm.

FUNCTION CAbs2 () AS DOUBLE
FUNCTION CNorm () AS DOUBLE
Example
DIM z AS _complex = (2, 3)
DIM d AS DOUBLE = CAbs2(z)
PRINT d
Output: 13
--or--
DIM z AS _complex = (2, 3)
DIM d AS DOUBLE = CNorm(z)
PRINT d
Output: 13

CAbsSqr

Returns the absolute square (squared norm) of a complex number.

FUNCTION CAbsSqr (BYREF z AS _complex) AS DOUBLE
Example
DIM z AS _complex = (1.2345, -2.3456)
print CAbsSqr(z)
Output: 7.025829610000001

CAddImag

Adds an imaginary number.

FUNCTION CAddImag (BYREF z AS _complex, BYVAL y AS DOUBLE) AS _complex
ParameterDescription
yA double value.
Example
DIM c AS _complex = (5, 6)
c = CAddImag(c, 10)
print CStr(c)

CAddReal

Adds a real number.

FUNCTION CAddReal (BYREF z AS _complex, BYVAL x AS DOUBLE) AS _complex
ParameterDescription
xA double value.
Examples
DIM c AS _complex = (5, 6)
c = CAddReal(c, 10)
print CStr(c)

CArcCos / CACos

Returns the complex arccosine of a complex number.

FUNCTION CArcCos (BYREF value AS _complex) AS _complex
FUNCTION CACos (BYREF value AS _complex) AS _complex
Example
DIM c AS _complex = (1, 1)
print CStr(CArcCos(c))
Output: 0.9045568943023814 -1.061275061905036 * i

CArcCosH / CACosH

Returns the complex hyperbolic arccosine of a complex number. The branch cut is on the real axis, less than 1.

FUNCTION CArcCosH (BYREF value AS _complex) AS _complex
FUNCTION CACosH (BYREF value AS _complex) AS _complex
Example
DIM c AS _complex = (1, 1)
print CStr(CArcCosH(c))
Output: 1.061275061905036 +0.9045568943023813 * i

CArcCosHReal / CACosHReal

Returns the complex hyperbolic arccosine of a real number.

FUNCTION CArcCosHReal (BYVAL value AS DOUBLE) AS _complex
FUNCTION CACosHReal (BYVAL value AS DOUBLE) AS _complex
ParameterDescription
valueA double value representing the real part of a complex number.

CArcCosReal / CACosReal

Returns the complex arccosine of a real number.
For a between -1 and 1, the function returns a real value in the range \[0, pi].
For a less than -1 the result has a real part of pi and a negative imaginary part.
For a greater than 1 the result is purely imaginary and positive.

FUNCTION CArcCosReal (BYVAL value AS DOUBLE) AS _complex
FUNCTION CACosReal (BYVAL value AS DOUBLE) AS _complex
ParameterDescription
valueA double value representing the real part of a complex number.
Example
print CStr(CArcCosReal(1)) ' = 0 0 * i
print CStr(CArcCosReal(-1)) ' = 3.141592653589793 0 * i
print CStr(CArcCosReal(2)) ' = 0 +1.316957896924817 * i

CArcCot / CACot

Returns the complex arccotangent of a complex number.

FUNCTION CArcCot (BYREF value AS _complex) AS _complex
FUNCTION CACot (BYREF value AS _complex) AS _complex
Example
DIM z AS _complex = (1, 1)
z = CArcCot(z)
PRINT CStr(z)
Output: 0.5535743588970452 -0.4023594781085251 * i

CArcCotH / CACotH

Returns the complex hyperbolic arccotangent of a complex number.

FUNCTION CArcCotH (BYREF value AS _complex) AS _complex
FUNCTION CACotH (BYREF value AS _complex) AS _complex
Example
DIM c AS _complex = (1, 1)
print CStr(CArcCotH(c))
Output: 0.4023594781085251 -0.5535743588970452 * i

CArcCsc / CACsc

Returns the complex arccosecant of a complex number.

FUNCTION CArcCsc (BYREF value AS _complex) AS _complex
FUNCTION CACsc (BYREF value AS _complex) AS _complex
Example
DIM c AS _complex = (1, 1)
print CStr(CArcCsc(c))
Output: 0.4522784471511907 -0.5306375309525178 * i

CArcCscH / CACscH

Returns the complex hyperbolic arccosecant of a complex number.

FUNCTION CArcCscH (BYREF value AS _complex) AS _complex
FUNCTION CACscH (BYREF value AS _complex) AS _complex
Example
DIM c AS _complex = (1, 1)
print CStr(CArcCscH(c))
Output: 0.5306375309525179 -0.4522784471511906 * i

CArcCscReal / CACscReal

Returns the complex arccosecant of a real number.

FUNCTION CArcCscReal (BYVAL value AS DOUBLE) AS _complex
FUNCTION CACscReal (BYVAL value AS DOUBLE) AS _complex
Example
print CStr(CArcCscReal(1))
Output: 1.570796326794897 0 * i

CArcSec / CASec

Returns the complex arcsecant of a complex number.

FUNCTION CArcSec (BYREF value AS _complex) AS _complex
FUNCTION CASec (BYREF value AS _complex) AS _complex
Example
DIM z AS _complex = (1, 1)
z = CArcSec(z)
PRINT CStr(z)
Output: 1.118517879643706 +0.5306375309525176 * i

CArcSecH / CASecH

Returns the complex hyperbolic arcsecant of a complex number.

FUNCTION CArcSecH (BYREF value AS _complex) AS _complex
FUNCTION CASecH (BYREF value AS _complex) AS _complex
Example
DIM z AS _complex = (1, 1)
z = CArcSecH(z)
PRINT CStr(z)
Output: 0.5306375309525178 -1.118517879643706 * i

CArcSecReal / CASecReal

Returns the complex arcsecant of a real number.

FUNCTION CArcSecReal (BYVAL value AS DOUBLE) AS _complex
FUNCTION CASecReal (BYVAL value AS DOUBLE) AS _complex
ParameterDescription
valueA double value representing the real part of a complex number.
Example
print CStr(CArcSecReal(1.1))
Output: 0.4296996661514246 0 * i

CArcSin / CASin

Returns the complex arcsine of a complex number. The branch cuts are on the real axis, less than -1 and greater than 1.

FUNCTION CArcSin (BYREF value AS _complex) AS _complex
FUNCTION CASin (BYREF value AS _complex) AS _complex
Example
DIM z AS _complex = (1, 1)
z = CArcSin(z)
PRINT CStr(z)
Output: 0.6662394324925152 +1.061275061905036 * i

CArcSinH / CASinH

Returns the complex hyperbolic arcsine of a complex number. The branch cuts are on the imaginary axis, below -i and above i.

FUNCTION CArcSinH (BYREF value AS _complex) AS _complex
FUNCTION CASinH (BYREF value AS _complex) AS _complex
Example
DIM z AS _complex = (1, 1)
z = CArcSinH(z)
PRINT CStr(z)
Output: 1.061275061905036 +0.6662394324925153 * i

CArcSinReal / CASinReal

Returns the complex arcsine of a real number.
For a between -1 and 1, the function returns a real value in the range \[-pi/2, pi/2].
For a less than -1 the result has a real part of -pi/2 and a positive imaginary part.
For a greater than 1 the result has a real part of pi/2 and a negative imaginary part.

FUNCTION CArcSinReal (BYVAL value AS DOUBLE) AS _complex
FUNCTION CASinReal (BYVAL value AS DOUBLE) AS _complex
ParameterDescription
valueA double value representing the real part of a complex number.
Example
DIM z AS _complex = CArcSinReal(1)
PRINT CStr(z)
Output: 1.570796326794897 +0 * i

CArcTan / CATan

Returns the complex arctangent of a complex number. The branch cuts are on the imaginary axis, below -i and above i.

FUNCTION CArcTan (BYREF value AS _complex) AS _complex
FUNCTION CATan (BYREF value AS _complex) AS _complex
Example
DIM z AS _complex = (1, 1)
z = CArcTan(z)
PRINT CStr(z)
Output: 1.017221967897851 +0.4023594781085251 * i

CArcTanH / CATanH

Returns the complex hyperbolic arctangent of a complex number. The branch cuts are on the real axis, less than -1 and greater than 1.

FUNCTION CArcTanH (BYREF value AS _complex) AS _complex
FUNCTION CATanH (BYREF value AS _complex) AS _complex
Example
DIM z AS _complex = (1, 1)
z = CArcTanH(z)
PRINT CStr(z)
Output: 0.4023594781085251 +1.017221967897851 * i

CArcTanHReal / CATanHReal

Returns the complex hyperbolic arctangent of a real number.

FUNCTION CArcTanhReal (BYVAL value AS DOUBLE) AS _complex
FUNCTION CATanhReal (BYVAL value AS DOUBLE) AS _complex
ParameterDescription
valueA double value representing the real part of a complex number.

CArg / CArgument / CPhase

Returns the argument of this complex number.

FUNCTION CArg (BYREF z AS _complex) AS DOUBLE
FUNCTION CArgument (BYREF z AS _complex) AS DOUBLE
FUNCTION CPhase (BYREF z AS _complex) AS DOUBLE
Example
DIM z AS _complex = (1, 0)
DIM d AS DOUBLE = CArg(z)
PRINT d
Output: 0
DIM z AS _complex = (0, 1)
DIM d AS DOUBLE = CArg(z)
PRINT d
Output: 1.570796326794897
DIM z AS _complex = (0, -1)
DIM d AS DOUBLE = CArg(z)
PRINT d
Output: -1.570796326794897
DIM z AS _complex = (-1, 0)
DIM d AS DOUBLE = CArg(z)
PRINT d
Output: 3.141592653589793

CConjugate / CConj

Returns the complex conjugate of a complex number.

FUNCTION CConjugate (BYREF z AS _complex) AS _complex
FUNCTION CConj (BYREF z AS _complex) AS _complex
Example
DIM z AS _complex = (2, 3)
z = CConj(z)
PRINT CStr(z)
Output: 2 - 3 * i

CCos

Returns the complex cosine of a complex number.

FUNCTION CCos (BYREF value AS _complex) AS _complex
Example
DIM z AS _complex = (1, 1)
z = CCos(z)
PRINT CStr(z)
Output: 0.8337300251311491 -0.9888977057628651 * i

CCosH

Returns the complex hyperbolic cosine of a complex number.

FUNCTION CCosH (BYREF value AS _complex) AS _complex
Example
DIM z AS _complex = (1, 1)
z = CCosH(z)
PRINT CStr(z)
Output: 0.8337300251311491 +0.9888977057628651 * i

CCot

Returns the complex cotangent of a complex number.

FUNCTION CCot (BYREF value AS _complex) AS _complex
Example
DIM z AS _complex = (1, 1)
z = CCot(z)
PRINT CStr(z)
Output: 0.2176215618544027 -0.8680141428959249 * i

CCotH

Returns the complex hyperbolic cotangent of a complex number.

FUNCTION CCotH (BYREF value AS _complex) AS _complex
Example
DIM z AS _complex = (1, 1)
z = CCotH(z)
PRINT CStr(z)
Output: 0.8680141428959249 -0.2176215618544029 * i

CCsc

Returns the complex cosecant of a complex number.

FUNCTION CCsc (BYREF value AS _complex) AS _complex
Example
DIM z AS _complex = (1, 1)
z = CCsc(z)
PRINT CStr(z)
Output: 0.6215180171704285 -0.3039310016284265 * i

CCscH

Returns the complex hyperbolic cosecant of a complex number.

FUNCTION CCscH (BYREF value AS _complex) AS _complex
Example
DIM z AS _complex = (1, 1)
z = CCscH(z)
PRINT CStr(z)
Output: 0.3039310016284265 -0.6215180171704285 * i

CDivImag

Divides by an imaginary number.

FUNCTION CDivImag (BYREF z AS _complex, BYVAL y AS DOUBLE) AS _complex
ParameterDescription
yA double value.

CDivReal

Divides by a real number.

FUNCTION CDivReal (BYREF z AS _complex, BYVAL x AS DOUBLE) AS _complex
ParameterDescription
xA double value.

CExp

Returns the complex exponential of a complex number.

FUNCTION CExp (BYREF value AS _complex) AS _complex
Example
DIM z AS _complex = (1, 1)
z = CExp(z)
PRINT CStr(z)
Output: 1.468693939915885 +2.287355287178842 * i

CGetImag

Returns the imaginary part of a complex number.

FUNCTION CGetImag (BYREF z AS _complex) AS DOUBLE

CGetReal

Returns the real part of a complex number.

FUNCTION CGetReal (BYREF z AS _complex) AS DOUBLE

CLog

Returns the complex natural logarithm (base e) of a complex number. The branch cut is the negative real axis.

FUNCTION CLog OVERLOAD (BYREF value AS _complex) AS _complex
FUNCTION CLog OVERLOAD (BYREF value AS _complex, BYVAL baseValue AS DOUBLE) AS _complex
ParameterDescription
baseValueA double value.
Examples
DIM z AS _complex = (1, 1)
z = CLog(z)
PRINT CStr(z)
Output: 0.3465735902799727 +0.7853981633974483 * i
DIM z AS _complex = (0, 0)
z = CLog(z)
PRINT CStr(z)
Output: -1.#INF
DIM z AS _complex = (1, 1)
z = CLog(z, 10)
PRINT CStr(z)
Output: 0.1505149978319906 +0.3410940884604603 * i

CLog10

Returns the complex base-10 logarithm of a complex number.

FUNCTION CLog10 (BYREF value AS _complex) AS _complex
Example
DIM z AS _complex = (1, 1)
z = CLog10(z)
PRINT CStr(z)
Output: 0.1505149978319906 +0.3410940884604603 * i

CLogAbs

Returns the natural logarithm of the magnitude of the complex number z, log|z|. It allows an accurate evaluation of \log|z| when |z| is close to one. The direct evaluation of log(CAbs(z)) would lead to a loss of precision in this case.

FUNCTION CLogAbs (BYREF value AS _complex) AS DOUBLE
Example
DIM z AS _complex = (1.1, 0.1)
DIM d AS DOUBLE = CLogAbs(z)
print d
Output: 0.09942542937258279

CModulus / CMod

Returns the modulus of a complex number.

FUNCTION CModulus (BYREF z AS _complex) AS DOUBLE
FUNCTION CMod (BYREF z AS _complex) AS DOUBLE
Example
DIM z AS _complex = (2.3, -4.5)
print CModulus(z)
Output: 5.053711507397311
DIM z AS _complex = CPolar(0.2938, -0.5434)
print CModulus(z)
Output: 0.2938

CMulImag

Multiplies by an imaginary number.

FUNCTION CMulImag (BYREF z AS _complex, BYVAL y AS DOUBLE) AS _complex
ParameterDescription
yA double value.
Example
DIM z AS _complex = (5, 6)
z = CMulImag(z, 3)
PRINT CStr(z)

CMulReal

Multiplies by a real number.

FUNCTION CMulReal (BYREF z AS _complex, BYVAL x AS DOUBLE) AS _complex
ParameterDescription
xA double value.
Example
DIM z AS _complex = (5, 6)
z = CMulReal(z, 3)
PRINT CStr(z)

CNegate / CNeg / CNegative

Negates the complex number.

FUNCTION CNeg (BYREF z AS _complex) AS _complex
FUNCTION CNegate (BYREF z AS _complex) AS _complex
FUNCTION CNegative (BYREF z AS _complex) AS _complex

CNthRoot

Returns the kth nth root of a complex number where k = 0, 1, 2, 3,...,n - 1.
De Moivre's formula states that for any complex number x and integer n it holds that
cos(x)+ isin(x))^n = cos(nx) + isin(nx)
where i is the imaginary unit (i2 = -1).
Since z = re^(it) = r * (cos(t) + i sin(t))
where
z = (a, ib)
r = modulus of z
t = argument of z
i = sqrt(-1.0)
we can calculate the nth root of z by the formula:
z^(1/n) = r^(1/n) * (cos(x/n) + i sin(x/n))
by using log division.

FUNCTION CNthRoot (BYREF z AS _complex, BYVAL n AS LONG, BYVAL k AS LONG = 0) AS _complex
Example
DIM z AS _complex = (2.3, -4.5)
DIM n AS LONG = 5
FOR i AS LONG = 0 TO n - 1
   print CStr(CNthRoot(z, n, i))
NEXT
Output:
 1.349457704883236  -0.3012830564679053 * i
 0.7035425781022545 +1.190308959128094 * i
-0.9146444790833151 +1.036934450322577 * i
-1.268823953798186  -0.5494482247230521 * i
 0.1304681498960107 -1.376512128259714 * i

CPolar

Sets the complex number from the polar representation.

FUNCTION CPolar (BYVAL r AS DOUBLE, BYVAL theta AS DOUBLE) AS _complex
ParameterDescription
rThe modulus of complex number.
thetaThe angle with the positive direction of x-axis.
Example
DIM z AS _complex = CPolar(3, 4)

CPow

Returns this complex number raised to a complex power.
Returns this complex number raised to a real number.

FUNCTION CPow OVERLOAD (BYREF value AS _complex, BYREF power AS _complex) AS _complex
FUNCTION CPow OVERLOAD (BYREF value AS _complex, BYVAL power AS DOUBLE) AS _complex
ParameterDescription
powerA complex or a double number.
Examples
DIM z AS _complex = (1, 1)
DIM b AS _complex = (2, 2)
print CStr(CPow(z, b))
Output: -0.2656539988492412 +0.3198181138561362 * i
DIM z AS _complex = (1, 1)
PRINT CStr(CPow(z, 2))
Output: 1.224606353822378e-016 +2 * i

CReciprocal / CInverse

Returns the inverse, or reciprocal, of a complex number.

FUNCTION CReciprocal (BYREF value AS _complex) AS _complex
FUNCTION CInverse (BYREF value AS _complex) AS _complex
Example
DIM z AS _complex = (1, 1)
z = CReciprocal(z)
PRINT CStr(z)
Output: 0.5 -0.5 * i

CSec

Returns the complex secant of a complex number.

FUNCTION CSec (BYREF value AS _complex) AS _complex
Example
DIM z AS _complex = (1, 1)
z = CSec(z)
PRINT CStr(z)
Output: 0.4983370305551869 +0.591083841721045 * i

CSecH

Returns the complex hyperbolic secant of a complex number.

FUNCTION CSecH (BYREF value AS _complex) AS _complex
Example
DIM z AS _complex = (1, 1)
z = CSecH(z)
PRINT CStr(z)
Output: 0.4983370305551869 -0.591083841721045 * i

CSet / CRect

Uses the cartesian components (x,y) to set the real and imaginary parts of the complex number.

FUNCTION CSet (BYVAL x AS DOUBLE, BYVAL y AS DOUBLE) AS _complex
FUNCTION CRet (BYVAL x AS DOUBLE, BYVAL y AS DOUBLE) AS _complex
ParameterDescription
x, yDouble values.
Example
DIM z AS _complex = CSet(3, 4)

CSetImag

Sets the imaginary part of a complex number.

SUB CSetImag (BYREF z AS _complex, BYVAL y AS DOUBLE)
ParameterDescription
zThe complex number.
yA double value.

CSetReal

Sets the real part of a complex number.

SUB CSetReal (BYREF z AS _complex, BYVAL y AS DOUBLE)
ParameterDescription
zThe complex number.
yA double value.

CSgn

Returns the sign of this complex number.
If number is greater than zero, then CSgn returns 1.
If number is equal to zero, then CSgn returns 0.
If number is less than zero, then CSgn returns -1.

FUNCTION CSgn (BYREF z AS _complex) AS LONG

CSin

Returns the complex sine of a complex number.

FUNCTION CSin (BYREF value AS _complex) AS _complex
Example
DIM z AS _complex = (1, 1)
z = CSin(z)
PRINT CStr(z)
Output: 1.298457581415977 +0.6349639147847361 * i

CSinH

Returns the complex hyperbolic sine of a complex number.

FUNCTION CSinH (BYREF value AS _complex) AS _complex
Example
DIM z AS _complex = (1, 1)
z = CSinH(z)
PRINT CStr(z)
Output: 0.6349639147847361 +1.298457581415977 * i

CSqr / CSqrt

Returns the square root of the complex number z. The branch cut is the negative real axis. The result always lies in the right half of the complex plane.

FUNCTION CSqr (BYREF value AS _complex) AS _complex
FUNCTION CSqrt (BYREF value AS _complex) AS _complex
ParameterDescription
valueA complex number.
Examples
DIM z AS _complex = (2, 3)
z = CSqr(z)
PRINT CStr(z)
Output: 1.67414922803554 +0.895977476129838 * i

Compute the square root of -1:

DIM z AS _complex = (-1)
z = CSqr(z)
PRINT CStr(z)
Output: 0 +1.0 * i

CSqrReal

Returns the complex square root of the real number x, where x may be negative.

FUNCTION CSqrReal (BYVAL value AS DOUBLE) AS _complex
ParameterDescription
valueA double value representing a real number.

CSubImag

Subtracts an imaginary number.

FUNCTION CSubImag (BYREF z AS _complex, BYVAL y AS DOUBLE) AS _complex
ParameterDescription
yA double value.
Example
DIM z AS _complex = (5, 6)
z = CSubImag(z, 3)
PRINT CStr(z)
Output:  5 +3 * i

CSubReal

Subtracts a real number.

FUNCTION CSubReal (BYREF z AS _complex, BYVAL x AS DOUBLE) AS _complex
ParameterDescription
xA double value.
Example
DIM z AS _complex = (5, 6)
z = CSubReal(z, 2)
PRINT CStr(z)
Output: 3 +6 * i

CSwap

Exchanges the contents of two complex numbers.

SUB CSwap (BYREF z1 AS _complex, BYREF z2 AS _complex)
ParameterDescription
z1 / z2The complex numbers to swap.

CTan

Returns the complex tangent of a complex number.

FUNCTION CTan (BYREF value AS _complex) AS _complex
Example
DIM z AS _complex = (1, 1)
z = CTan(z)
PRINT CStr(z)
Output: 0.2717525853195117 +1.083923327338695 * i

CTanH

Returns the complex hyperbolic tangent of a complex number.

FUNCTION CTanH (BYREF value AS _complex) AS _complex
Example
DIM z AS _complex = (1, 1)
z = CTanH(z)
PRINT CStr(z)
Output: 1.083923327338695 +0.2717525853195119 * i

acosh

Calculates the inverse hyperbolic cosine.

FUNCTION acosh (BYVAL x AS DOUBLE) AS DOUBLE
ParameterDescription
xA double value.

asinh

Calculates the inverse hyperbolic sine.

FUNCTION asinh (BYVAL x AS DOUBLE) AS DOUBLE
ParameterDescription
xA double value.

atanh

Returns the inverse hyperbolic tangent of a number.

FUNCTION atanh (BYVAL x AS DOUBLE) AS DOUBLE
ParameterDescription
xA double value.

hypot3

Computes the value of sqr(x^2 + y^2 + z^2).

FUNCTION hypot3 (BYVAL x AS DOUBLE, BYVAL y AS DOUBLE, BYVAL z AS DOUBLE) AS DOUBLE
ParameterDescription
x, y, zDouble values.

IsInfinity / IsInf

Determines whether the argument is an infinity.

FUNCTION IsInfinity (BYVAL x AS DOUBLE) AS LONG
FUNCTION IsInf (BYVAL x AS DOUBLE) AS LONG
ParameterDescription
xA double value.
Remarks

Returns +1 if x is positive infinity, -1 if x is negative infinity and 0 otherwise.