65.9K
CodeProject is changing. Read more.
Home

Complex class - Working with complex numbers, improved version

starIconstarIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIcon

2.40/5 (2 votes)

Oct 30, 2007

CPOL
viewsIcon

18490

downloadIcon

137

This is a new ComplexMath class. The new version supports much more functions and it is much better.

Screenshot - net_complexmath.jpg

Introduction

This is a new ComplexMath class. The new version supports much more functions and is much better. It has support for trigonometric functions, inverse trigonometric functions, hyperbolic functions, inverse hyperbolic functions, log, exp, ln functions, and more.

Example usage

Here is a list of all the available functions. You can see how easy it is to use. Just like the Math class.

Dim z1 As Complex, z2 As Complex

z1 = ComplexMath.CreateComplex(1, 2)
z2 = ComplexMath.CreateComplex(3, 7)

.
.
.


.Add("Values:")
.Add("Z1 = " & z1.ToString)
.Add("Z2 = " & z2.ToString)

.Add("")
.Add("Operations:")
.Add("Z1 + Z2 = " & ComplexMath.OperatorAdd(z1, z2).ToString)
.Add("Z1 - Z2 = " & ComplexMath.OperatorSub(z1, z2).ToString)
.Add("Z1 * Z2 = " & ComplexMath.OperatorMul(z1, z2).ToString)
.Add("Z1 / Z2 = " & ComplexMath.OperatorDiv(z1, z2).ToString)

.Add("")
.Add("Functions 1:")

.Add("EXP (z1) = " & ComplexMath.FunctionExp(z1).ToString)
.Add("LN (z1) = " & ComplexMath.FunctionLn(z1).ToString)
.Add("LOG (z1 , 10) = " & ComplexMath.FunctionLog(z1, 10).ToString)
.Add("POW (z1 , 2) = " & ComplexMath.FunctionPowN(z1, 2).ToString)
.Add("POW (z1 , z2) = " & ComplexMath.FunctionPowZ(z1, z2).ToString)
.Add("SQR (z1) = " & ComplexMath.FunctionSqr(z1).ToString)

.Add("")
.Add("CONJUGATE (z1) = " & ComplexMath.FunctionConjugate(z1).ToString)
.Add("INVERT (z1) = " & ComplexMath.FunctionInverse(z1).ToString)
.Add("ANGLE (z1) = " & ComplexMath.PropertyAngle(z1).ToString)
.Add("ABS (z1) = " & ComplexMath.PropertyAbs(z1).ToString)

.Add("")
.Add("Functions 2:")

.Add("COS (z1) = " & ComplexMath.FunctionCos(z1).ToString)
.Add("SIN (z1) = " & ComplexMath.FunctionSin(z1).ToString)
.Add("TAN (z1) = " & ComplexMath.FunctionTan(z1).ToString)
.Add("COT(z1) = " & ComplexMath.FunctionCot(z1).ToString)

.Add("")
.Add("COSH (z1) = " & ComplexMath.FunctionCosh(z1).ToString)
.Add("SINH (z1) = " & ComplexMath.FunctionSinh(z1).ToString)
.Add("TANH (z1) = " & ComplexMath.FunctionTanh(z1).ToString)
.Add("COZH (z1) = " & ComplexMath.FunctionCoth(z1).ToString)

.Add("")
.Add("ACOS (z1) = " & ComplexMath.FunctionAcos(z1).ToString)
.Add("ASIN (z1) = " & ComplexMath.FunctionAsin(z1).ToString)
.Add("ATAN (z1) = " & ComplexMath.FunctionAtan(z1).ToString)
.Add("ACOT (z1) = " & ComplexMath.FunctionAcot(z1).ToString)

.Add("")
.Add("ACOSH (z1) = " & ComplexMath.FunctionAcosh(z1).ToString)
.Add("ASINH (z1) = " & ComplexMath.FunctionAsinh(z1).ToString)
.Add("ATANH (z1) = " & ComplexMath.FunctionAtanh(z1).ToString)
.Add("ACOTH (z1) = " & ComplexMath.FunctionAcoth(z1).ToString)