NMath User's Guide

TOC |  Previous |  Next |  Index

3.5 Functions of Complex Numbers (.NET, C#, CSharp, Visual Basic, VB.NET)

NMath provides a variety of functions that take complex numbers as arguments.

Conjugate, Norm, and Argument

NMath provides static functions on FloatComplex and DoubleComplex for common complex number functions:

For instance:

FloatComplex c = new FloatComplex( -8.2, 3.4 );
FloatComplex conj = FloatComplex.Conj( c );
float norm = FloatComplex.Norm( c );
float arg = FloatComplex.Arg( c );

Trigonometric Functions

NMath extends standard trigonometric functions Sin(), Cos(), Sinh(), Cosh(), Tan(), and Tanh() to take complex number arguments. Class NMathFunctions provides these functions as static methods; all take a single complex number as an argument and return a complex number as a result:

DoubleComplex c = new DoubleComplex( 1.0, -3.9 );
DoubleComplex sin = NMathFunctions.Sin( c );
DoubleComplex cos = NMathFunctions.Cos( c );

Transcendental Functions

NMath extends standard transcendental functions Exp() and Log() to take complex arguments. Class NMathFunctions provides these functions as static methods. For example:

FloatComplex c = new FloatComplex( -8.11, 3.04 );
FloatComplex exp = NMathFunctions.Exp( c );
FloatComplex log = NMathFunctions.Log( c );

Class NMathFunctions also provides several static overloads of the exponential function Pow(). Versions exist to:

All return a complex number. For instance:

DoubleComplex c1 = new DoubleComplex( 12.932, -4.0 );
DoubleComplex c2 = NMathFunctions.Pow( c1, 3 );
DoubleComplex c3 = NMathFunctions.Pow( c1, 1.12 );
DoubleComplex c4 = NMathFunctions.Pow( c1, c3 );
DoubleComplex c5 = NMathFunctions.Pow( 5.2, c1 );

Absolute Value and Square Root

The static Abs() function on class NMathFunctions returns the absolute value of a complex number, which is simply equal to the norm:

DoubleComplex c = new DoubleComplex( 7.99, 0.3 );
double abs = NMathFunctions.Abs( c );

NMath also extends the standard Sqrt() function to take a complex argument, again as a static method on class NMathFunctions. For example:

FloatComplex c = new FloatComplex( -8.11, 3.04 );
FloatComplex sqrt = NMathFunctions.Sqrt( c );

TOC |  Previous |  Next |  Index