com.hedgehog.math
Class Complex

java.lang.Object
  extended by com.hedgehog.HObject
      extended by com.hedgehog.math.Complex
All Implemented Interfaces:
java.lang.Comparable, java.util.Comparator

public class Complex
extends HObject

Title: Complex - represents a complex number.

Description: Represents a complex number consisting of real and imaginary parts, c(re,im).

Copyright: Copyright (c) Hedgehog Software 2007-2009.

Company: Hedgehog Software.

Since:
1.0
Version:
1.1

Field Summary
protected  double mImag
          Imaginary parts of a complex number.
protected  double mReal
          Real part of a complex number.
static Complex NaN
          A complex number representing (NaN + NaNi).
static Complex ONE
          A complex number representing (1.0 + 0.0i).
static Complex ZERO
          A complex number representing (0.0 + 0.0i).
 
Fields inherited from class com.hedgehog.HObject
mID, mName
 
Constructor Summary
Complex()
          Default constructor.
Complex(Complex object)
          Copy constructor.
Complex(double real)
          Constructor.
Complex(java.lang.Double real)
          Sets the real part to the specified value and the imaginary part to 0.0.
Complex(double real, double imag)
          Constructor.
Complex(java.lang.Double real, java.lang.Double imag)
          Constructor.
Complex(HDouble real)
          Constructor.
Complex(HDouble real, HDouble imag)
          Constructor.
 
Method Summary
 double abs()
          Returns the absolute positive value of a complex number.
 Complex add(Complex c)
          Adds the specified number to this number and returns the resultant.
static Complex add(Complex c1, Complex c2)
          Addition (Complex,Complex)
static void add(Complex c1, Complex c2, Complex c1c2)
          Optimised complex-complex addition.
static Complex add(Complex c1, double c2)
          Addition (Complex,double)
 Complex add(double c)
          Adds the specified number to this number and returns the resultant.
static Complex add(double c1, Complex c2)
          Addition (Complex,double)
 void addTo(Complex c)
          Arithmetic addtion.
 void addTo(double c)
          Arithmetic addtion.
 Complex arcCos()
          Returns the arc cosine of a complex number.
 Complex arcCosh()
          Returns the inverse cosh.
 Complex arcCot(double tolerance)
          Returns the arc cotangent of a Complex object.
 Complex arcSin()
          Returns the arc sine of a complex number.
 Complex arcSinh()
          Returns the inverse sinh.
 Complex arcTan(double tolerance)
          Returns the arc tangent of a Complex object.
 Complex arcTanh()
          Returns the inverse tanh.
 double argument()
          Returns the complex argument.
 Complex conjugate()
          Returns the complex conjugate.
static Complex cos(Complex c)
          Returns the cosine of the specified complex number and implements the formula:
static Complex cosh(Complex c)
          Returns the hyperbolic cosine of the specified complex number and implements the formula:
static Complex cot(Complex c)
          Returns the cotangent of the specified complex number; ie cot(z) = 1/tan(z).
 Complex cubeRoot()
          Returns the complex cube root.
 Complex[] cubeRoots()
          Returns the 3 roots of this complex number.
static Complex divide(Complex c1, Complex c2, double tolerance)
          Division of two complex numbers.
static void divide(Complex c1, Complex c2, double tolerance, Complex c1c2)
          Divisions (Complex,Complex) with the resultant returned via the argument object.
 Complex divide(Complex c, double tolerance)
          Divides this number by the specified number and returns the resultant.
static Complex divide(Complex c1, double c2, double tolerance)
          Division of a complex number by a scalar.
static Complex divide(double c1, Complex c2, double tolerance)
          Division of a scalar by a complex number.
 Complex divide(double c, double tolerance)
          Divides this number by the specified number and returns the resultant.
 void divideBy(Complex c, double tolerance)
          Arithmetic division.
 void divideBy(double c, double tolerance)
          Arithmetic division.
 boolean equals(java.lang.Object object)
          Compares the specifieed object against this object.
 Complex exp()
          Returns the exponential of a complex number.
 double getImag()
          Returns the imaginary part of a complex number.
 double getReal()
          Returns the real part of a complex number.
 int hashCode()
          Returns a hash code for this complex number.
 Complex I()
          Returns the complex number, i.
 boolean isFullyImaginary(double tolerance)
          Tests whether or not a Complex object is fully imaginary; ie no real component relative to the specified tolerance.
 boolean isFullyReal(double tolerance)
          Tests whether or not a Complex object is fully real; ie no imaginary component relative to the specified tolerance.
 boolean isInfinite()
          Tests whether or not either the real or imaginary part of this complex number takes an infinite value (either Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY) and neither part is NaN.
 boolean isNaN()
          Tests whether or not both real and imaginary parts of this complex number are NaN.
 boolean isSameImag(Complex c, double tolerance)
          Tests whether or not the specified complex object has the same imaginary value as this object.
 boolean isSameReal(Complex c, double tolerance)
          Tests whether or not the specified complex object has the same real value as this object.
 boolean isSameRealImag(Complex c, double tolerance)
          Tests whether or not the specified complex object has the same real and imaginary values as this object.
 boolean isZero(double tolerance)
          Tests whether or not both the real and imaginary parts of this complex number are zero.
 Complex log()
          Returns the logarithm of a complex number.
 Complex multiply(Complex c)
          Multiples this number multiplied by the specified complex number.
static Complex multiply(Complex c1, Complex c2)
          Multiplication (Complex,Complex)
static void multiply(Complex c1, Complex c2, Complex c1c2)
          Multiplication (Complex,Complex) with the resultant returned via the argument object.
static Complex multiply(Complex c1, double c2)
          Multiplication (Complex,double)
 Complex multiply(double c)
          Multiples this number multiplied by the specified real number.
static Complex multiply(double c1, Complex c2)
          Multiplication (double,Complex)
 void multiplyBy(Complex c)
          Arithmetic multiplication.
 void multiplyBy(double c)
          Arithmetic multiplication.
 Complex negate()
          Negates a complex number.
 Complex negateImag()
          Negates the imaginary part of a complex number.
 Complex negateReal()
          Negates the real part of a complex number.
static Complex polar2Complex(double r, double theta)
          Returns the complex number from the given polar representation.
 Complex pow(double n)
          Complex number to a floating-point power n.
 java.util.Vector rationalPow(int n)
          Returns the rational power of a complex number.
 Complex reciprocal(double tolerance)
          Returns the reciprocal of a complex number.
 Complex rTheta()
          Returns the (r,theta) corresponding to (x,y).
 void set(Complex c)
          Sets this complex number to the specified object.
 void setImag(double newImag)
          Sets the imaginary part of a complex number.
 void setReal(double newReal)
          Sets the real part of a complex number.
 void setRealImag(double newReal, double newImag)
          Sets the real and imaginary parts of a complex number.
static Complex sin(Complex c)
          Returns the sine of the specified complex number and implements the formula:
static Complex sinh(Complex c)
          Returns the hyperbolic sine of the specified complex number and implements the formula:
 Complex sqrt()
          Returns the complex square root.
 Complex subtract(Complex c)
          Sbtracts the specified number from this number and returns the resultant.
static Complex subtract(Complex c1, Complex c2)
          Subtraction (Complex,Complex)
static void subtract(Complex c1, Complex c2, Complex c1c2)
          Optimised complex-complex subtraction.
static Complex subtract(Complex c1, double c2)
          Subtraction (Complex,double)
 Complex subtract(double c)
          Sbtracts the specified number from this number and returns the resultant.
static Complex subtract(double c1, Complex c2)
          Subtraction (double,Complex)
 void subtractFrom(Complex c)
          Arithmetic subtraction.
 void subtractFrom(double c)
          Arithmetic subtraction.
static Complex tan(Complex c)
          Returns the tangent of the specified complex number and implements the formula:
static Complex tanh(Complex c)
          Returns the hyperbolic tangent of the specified complex number and implements the formula:
 java.lang.String toString()
          Returns a String representation of a Complex object.
 
Methods inherited from class com.hedgehog.HObject
clone, compare, compareTo, copy, getID, getName, hasID, hasName, setID, setName
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

mReal

protected double mReal
Real part of a complex number.


mImag

protected double mImag
Imaginary parts of a complex number.


NaN

public static final Complex NaN
A complex number representing (NaN + NaNi).


ONE

public static final Complex ONE
A complex number representing (1.0 + 0.0i).


ZERO

public static final Complex ZERO
A complex number representing (0.0 + 0.0i).

Constructor Detail

Complex

public Complex()
Default constructor. Sets the real and maginary parts to zero.


Complex

public Complex(double real)
Constructor. Sets the real part to the specified value and the imaginary part to 0.0.

Parameters:
real - Real value.

Complex

public Complex(double real,
               double imag)
Constructor. Sets the real and imaginary parts of a complex number to the specified vlues.

Parameters:
real - The real part.
imag - The imaginary part.

Complex

public Complex(java.lang.Double real,
               java.lang.Double imag)
Constructor. Sets the real and imaginary parts of a complex number to the specified vlues.

Parameters:
real - The real part.
imag - The imaginary part.

Complex

public Complex(java.lang.Double real)
Sets the real part to the specified value and the imaginary part to 0.0.

Parameters:
real - Real value.

Complex

public Complex(HDouble real,
               HDouble imag)
Constructor. Sets the real and imaginary parts of a complex number to the specified vlues.

Parameters:
real - The real part.
imag - The imaginary part.

Complex

public Complex(HDouble real)
Constructor. Sets the real part to the specified value and the imaginary part to 0.0.

Parameters:
real - Real value.

Complex

public Complex(Complex object)
Copy constructor.

Parameters:
object - Complex number to copy.
Method Detail

abs

public double abs()
Returns the absolute positive value of a complex number.

Returns:
Absolute value of a complex number.

addTo

public void addTo(Complex c)
Arithmetic addtion. Adds c to the invoking Complex object.

Parameters:
c - Complex number to add.

addTo

public void addTo(double c)
Arithmetic addtion. Adds c to the invoking Complex object.

Parameters:
c - Real number to add.

add

public Complex add(Complex c)
Adds the specified number to this number and returns the resultant.

Parameters:
c - Complex number to add this number.
Returns:
Addition of this number and the specified number.

add

public Complex add(double c)
Adds the specified number to this number and returns the resultant.

Parameters:
c - Real number to add this number.
Returns:
Addition of this number and the specified number.

arcCos

public Complex arcCos()
Returns the arc cosine of a complex number.

Returns:
The arc cosine of a Complex number.

arcSin

public Complex arcSin()
Returns the arc sine of a complex number.

Returns:
The arc sine of a Complex number.

arcTan

public Complex arcTan(double tolerance)
               throws DivisionByZeroException
Returns the arc tangent of a Complex object.

Parameters:
tolerance - Value below which a number is assumed to be effectively equal to zero. Used for preventing division by zero and typically set to 1e-06.
Returns:
The arc tangent of a Complex number.
Throws:
DivisionByZeroException - Thrown to prevent a division by zero.

arcCot

public Complex arcCot(double tolerance)
               throws DivisionByZeroException
Returns the arc cotangent of a Complex object.

For further details refer to MathWorld.

Parameters:
tolerance - Value below which a number is assumed to be effectively equal to zero. Used for preventing division by zero and typically set to 1e-06.
Returns:
The arc cotangent of a Complex number.
Throws:
DivisionByZeroException - Thrown to prevent a division by zero.
Since:
1.1

arcCosh

public Complex arcCosh()
Returns the inverse cosh.

Returns:
The inverse cosh of a complex number.

arcSinh

public Complex arcSinh()
Returns the inverse sinh.

Returns:
The inverse sinh of a complex number.

arcTanh

public Complex arcTanh()
Returns the inverse tanh.

Returns:
The inverse tanh of a complex number.

argument

public double argument()
Returns the complex argument.

Returns:
The complex argument.

conjugate

public Complex conjugate()
Returns the complex conjugate.

Returns:
The complex conjugate.

divideBy

public void divideBy(Complex c,
                     double tolerance)
              throws DivisionByZeroException
Arithmetic division. Divides c to the invoking Complex object.

Parameters:
c - Complex number to divide this number by.
tolerance - Tolerance below which a number is assumed to be effectively equal to zero. Typically set to 1e-06.
Throws:
DivisionByZeroException - If a potential division by zero could occur.

divideBy

public void divideBy(double c,
                     double tolerance)
              throws DivisionByZeroException
Arithmetic division. Divides c to the invoking Complex object.

Parameters:
c - Real number to divide this number by.
tolerance - Tolerance below which a number is assumed to be effectively equal to zero. Typically set to 1e-06.
Throws:
DivisionByZeroException - If a potential division by zero could occur.

divide

public Complex divide(Complex c,
                      double tolerance)
               throws DivisionByZeroException
Divides this number by the specified number and returns the resultant.

Parameters:
c - Complex number to divide this number by.
tolerance - Required tolerance.
Returns:
Resultant of this number divided by c.
Throws:
DivisionByZeroException - Thrown if a division by zero would occur.

divide

public Complex divide(double c,
                      double tolerance)
               throws DivisionByZeroException
Divides this number by the specified number and returns the resultant.

Parameters:
c - Real number to divide this number by.
tolerance - Required tolerance.
Returns:
Resultant of this number divided by c.
Throws:
DivisionByZeroException - Thrown if a division by zero would occur.

equals

public boolean equals(java.lang.Object object)
Compares the specifieed object against this object.

If both the real and imaginary parts are equivalent, and neither is Double.NaN, the two objects are considered to be equal.

All NaN values are considered to be equal; ie if either (or both) real and imaginary parts of the complex number are equal to Double.NaN then the complex number is equal to Complex.NaN.

Specified by:
equals in interface java.util.Comparator
Overrides:
equals in class HObject
Parameters:
object - Object to compare.
Returns:
Logical-true if the specified object is equalt to this object.

hashCode

public int hashCode()
Returns a hash code for this complex number. Note that all NaN values have the same hash code of 7.

Overrides:
hashCode in class HObject
Returns:
The hash code for this object.

isNaN

public boolean isNaN()
Tests whether or not both real and imaginary parts of this complex number are NaN.

Returns:
Logical-true if either or both parts of this complex number is NaN, else logical-false.

isInfinite

public boolean isInfinite()
Tests whether or not either the real or imaginary part of this complex number takes an infinite value (either Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY) and neither part is NaN.

Returns:
Logical-true if one or both parts of this complex number are infinite and neither part is NaN.

exp

public Complex exp()
Returns the exponential of a complex number.

Returns:
The exponential of a complex number.

I

public Complex I()
Returns the complex number, i.

Returns:
The complex number (0,1).

isFullyReal

public boolean isFullyReal(double tolerance)
Tests whether or not a Complex object is fully real; ie no imaginary component relative to the specified tolerance.

Parameters:
tolerance - Tolerance to compare imaginary part of Complex object. If imagReturns:
Logical-true if no imaginary part, else logical-false.

isFullyImaginary

public boolean isFullyImaginary(double tolerance)
Tests whether or not a Complex object is fully imaginary; ie no real component relative to the specified tolerance.

Parameters:
tolerance - Tolerance to compare real part of Complex object. If realReturns:
Logical-true if no real part, else logical-false.

isZero

public boolean isZero(double tolerance)
Tests whether or not both the real and imaginary parts of this complex number are zero.

Parameters:
tolerance - Required tolerance.
Returns:
Logical-true if both the real and imaginary parts of this complex number are zero, else logical-false.

isSameReal

public boolean isSameReal(Complex c,
                          double tolerance)
Tests whether or not the specified complex object has the same real value as this object.

Parameters:
c - Other obejct.
tolerance - Required tolerance.
Returns:
Logical-true if the specified complex object has the same real value as this object, else logical-false.

isSameImag

public boolean isSameImag(Complex c,
                          double tolerance)
Tests whether or not the specified complex object has the same imaginary value as this object.

Parameters:
c - Other obejct.
tolerance - Required tolerance.
Returns:
Logical-true if the specified v object has the same imaginary value as this object, else logical-false.

isSameRealImag

public boolean isSameRealImag(Complex c,
                              double tolerance)
Tests whether or not the specified complex object has the same real and imaginary values as this object.

Parameters:
c - Other obejct.
tolerance - Required tolerance.
Returns:
Logical-true if the specified complex object has the same real and imaginary values as this object, else logical-false.

getImag

public double getImag()
Returns the imaginary part of a complex number.

Returns:
The imaginary part of a complex number.

setImag

public void setImag(double newImag)
Sets the imaginary part of a complex number.

Parameters:
newImag - New imaginary part of a complex number.

log

public Complex log()
Returns the logarithm of a complex number.

Returns:
The logarithm of a complex number.

negate

public Complex negate()
Negates a complex number.

Returns:
The negation of a complex number (-r,-i).

negateReal

public Complex negateReal()
Negates the real part of a complex number.

Returns:
Real-part negation of a complex number (-r,i).

negateImag

public Complex negateImag()
Negates the imaginary part of a complex number.

Returns:
Imaginary-part negation of a complex number (r,-i).

pow

public Complex pow(double n)
Complex number to a floating-point power n. Note: if n is rational then use rationalPow().

Parameters:
n - power.
Returns:
Complex number raised to power n.

reciprocal

public Complex reciprocal(double tolerance)
                   throws DivisionByZeroException
Returns the reciprocal of a complex number.

Parameters:
tolerance - Tolerance below which a number is assumed to be equal to zero. typically set to 1e-06.
Returns:
The reciprocal of a complex number.
Throws:
DivisionByZeroException - Thrown to prevent a potential division by zero.

rTheta

public Complex rTheta()
Returns the (r,theta) corresponding to (x,y).

Returns:
The Complex (r,theta) values corresponding to the (x,y) values.

rationalPow

public java.util.Vector rationalPow(int n)
Returns the rational power of a complex number.

Parameters:
n - Power n.
Returns:
Vector of complex numbers of the rational power.

getReal

public double getReal()
Returns the real part of a complex number.

Returns:
The real part of a complex number.

setReal

public void setReal(double newReal)
Sets the real part of a complex number.

Parameters:
newReal - New real part.

setRealImag

public void setRealImag(double newReal,
                        double newImag)
Sets the real and imaginary parts of a complex number.

Parameters:
newReal - New real part.
newImag - New imaginary part.

set

public void set(Complex c)
Sets this complex number to the specified object.

Parameters:
c - Complex object.

sqrt

public Complex sqrt()
Returns the complex square root.

Returns:
The complex square root.

cubeRoot

public Complex cubeRoot()
Returns the complex cube root.

Returns:
Cube root of this complex number.

cubeRoots

public Complex[] cubeRoots()
Returns the 3 roots of this complex number. Note that the 3 cube roots of 1 are: 1 -1/2 + 0.866i -1/2 - 0.866i where 0.866... is cuberoot(3)/2 implying that if the principal cube root is known then the other 2 roots follow immediately by multiplying it by (-1/2 + 0.866i) and (-1/2 - 0.866i).

Returns:
Array of the 3 roots.

multiplyBy

public void multiplyBy(Complex c)
Arithmetic multiplication. Multiplies the invoking Complex object by c.

Parameters:
c - Complex number to multiply.

multiplyBy

public void multiplyBy(double c)
Arithmetic multiplication. Multiplies the invoking Complex object by c.

Parameters:
c - Real number to multiply.

multiply

public Complex multiply(Complex c)
Multiples this number multiplied by the specified complex number.

Parameters:
c - Complex number to multiply this complex number by.
Returns:
Resultant of the multiplication of this complex number multiplied by c.

multiply

public Complex multiply(double c)
Multiples this number multiplied by the specified real number.

Parameters:
c - Real number to multiply this complex number by.
Returns:
Resultant of the multiplication of this complex number multiplied by c.

subtractFrom

public void subtractFrom(Complex c)
Arithmetic subtraction. Subtracts c from the invoking Complex object.

Parameters:
c - Complex number to subtract.

subtractFrom

public void subtractFrom(double c)
Arithmetic subtraction. Subtracts c from the invoking Complex object.

Parameters:
c - Real number to subtract.

subtract

public Complex subtract(Complex c)
Sbtracts the specified number from this number and returns the resultant.

Parameters:
c - Complex number to subtract from this number.
Returns:
Subtraction of the specified number from this number.

subtract

public Complex subtract(double c)
Sbtracts the specified number from this number and returns the resultant.

Parameters:
c - Real number to subtract from this number.
Returns:
Subtraction of the specified number from this number.

toString

public java.lang.String toString()
Returns a String representation of a Complex object.

Overrides:
toString in class java.lang.Object
Returns:
A String representation of a Complex object.

add

public static Complex add(Complex c1,
                          Complex c2)
Addition (Complex,Complex)

Parameters:
c1 - One complex number.
c2 - Second complex number.
Returns:
The addition of two complex numbers.

add

public static Complex add(Complex c1,
                          double c2)
Addition (Complex,double)

Parameters:
c1 - One complex number.
c2 - Second double number.
Returns:
The addition of one complex number and a double number.

add

public static Complex add(double c1,
                          Complex c2)
Addition (Complex,double)

Parameters:
c1 - Scalar number.
c2 - Complex number.
Returns:
The addition of one complex number and a double number.

add

public static void add(Complex c1,
                       Complex c2,
                       Complex c1c2)
Optimised complex-complex addition.

Parameters:
c1 - One complex number.
c2 - Second complex number.
c1c2 - Set upon return to the resultant.

divide

public static Complex divide(Complex c1,
                             Complex c2,
                             double tolerance)
                      throws DivisionByZeroException
Division of two complex numbers.

Parameters:
c1 - One complex number.
c2 - Second complex number.
tolerance - Tolerance below which a number is assumed to be effectively equal to zero. Typically set to 1e-06.
Returns:
The division of the two complex numbers.
Throws:
DivisionByZeroException - If a potential division by zero could occur.

divide

public static Complex divide(double c1,
                             Complex c2,
                             double tolerance)
                      throws DivisionByZeroException
Division of a scalar by a complex number.

Parameters:
c1 - Scalar .
c2 - Complex number.
tolerance - Tolerance below which a number is assumed to be effectively equal to zero. Typically set to 1e-06.
Returns:
The resultant.
Throws:
DivisionByZeroException - If a potential division by zero could occur.

divide

public static Complex divide(Complex c1,
                             double c2,
                             double tolerance)
                      throws DivisionByZeroException
Division of a complex number by a scalar.

Parameters:
c1 - Complex number.
c2 - Scalar.
tolerance - Tolerance below which a number is assumed to be effectively equal to zero. Typically set to 1e-06.
Returns:
The division of a two complex number by a scalar.
Throws:
DivisionByZeroException - If a potential division by zero could occur.

divide

public static void divide(Complex c1,
                          Complex c2,
                          double tolerance,
                          Complex c1c2)
                   throws DivisionByZeroException
Divisions (Complex,Complex) with the resultant returned via the argument object. Optimised complex-complex division.

Parameters:
c1 - One complex number.
c2 - Second complex number.
tolerance - Required tolerance.
c1c2 - Set upon return to the resultant.
Throws:
DivisionByZeroException - If a potential division by zero could occur.

multiply

public static Complex multiply(Complex c1,
                               Complex c2)
Multiplication (Complex,Complex)

Parameters:
c1 - One complex number.
c2 - Second complex number.
Returns:
The multiplication of two complex numbers.

multiply

public static Complex multiply(Complex c1,
                               double c2)
Multiplication (Complex,double)

Parameters:
c1 - One complex number.
c2 - Second double number.
Returns:
The multiplication of a complex number and a double number.

multiply

public static Complex multiply(double c1,
                               Complex c2)
Multiplication (double,Complex)

Parameters:
c1 - One double number.
c2 - Second complex number.
Returns:
The multiplication of a double number and a complex number.

multiply

public static void multiply(Complex c1,
                            Complex c2,
                            Complex c1c2)
Multiplication (Complex,Complex) with the resultant returned via the argument object. Optimised complex-complex multiplication.

Parameters:
c1 - One complex number.
c2 - Second complex number.
c1c2 - Set upon return to the resultant.

subtract

public static Complex subtract(Complex c1,
                               Complex c2)
Subtraction (Complex,Complex)

Parameters:
c1 - One complex number.
c2 - Second complex number.
Returns:
The multiplication of two complex numbers.

subtract

public static Complex subtract(Complex c1,
                               double c2)
Subtraction (Complex,double)

Parameters:
c1 - One complex number.
c2 - Second double number.
Returns:
The subtraction of a complex number and a double number.

subtract

public static Complex subtract(double c1,
                               Complex c2)
Subtraction (double,Complex)

Parameters:
c1 - One double number.
c2 - Second complex number.
Returns:
The subtraction of a double number and a complex number.

subtract

public static void subtract(Complex c1,
                            Complex c2,
                            Complex c1c2)
Optimised complex-complex subtraction.

Parameters:
c1 - One complex number.
c2 - Second complex number.
c1c2 - Set upon return to the resultant.

cos

public static Complex cos(Complex c)
Returns the cosine of the specified complex number and implements the formula:
 cos(a + bi) = cos(a)cosh(b) - sin(a)sinh(b)i
 

Parameters:
c - Complex number.
Returns:
Cosine of the specified complex number. Returns NaN if either the real or imaginary part of the input argument is NaN.

sin

public static Complex sin(Complex c)
Returns the sine of the specified complex number and implements the formula:
 sin(a + bi) = sin(a)cosh(b) - cos(a)sinh(b)i
 

Parameters:
c - Complex number.
Returns:
Sine of the specified complex number. Returns NaN if either the real or imaginary part of the input argument is NaN.

tan

public static Complex tan(Complex c)
Returns the tangent of the specified complex number and implements the formula:
 tan(a + bi) = sin(2a)/(cos(2a)+cosh(2b)) + [sinh(2b)/(cos(2a)+cosh(2b))]i
 

Parameters:
c - Complex number.
Returns:
Tangent of the specified complex number. Returns NaN if either the real or imaginary part of the input argument is NaN.

cot

public static Complex cot(Complex c)
                   throws DivisionByZeroException
Returns the cotangent of the specified complex number; ie cot(z) = 1/tan(z).

Parameters:
c - Complex number.
Returns:
Cotangent of c.
Throws:
DivisionByZeroException - Thrown to prevent potential division by zero.
Since:
1.1

cosh

public static Complex cosh(Complex c)
Returns the hyperbolic cosine of the specified complex number and implements the formula:
 cosh(a + bi) = cosh(a)cos(b) + sinh(a)sin(b)i
 

Parameters:
c - Complex number.
Returns:
Hyperbolic cosine of the specified complex number. Returns NaN if either the real or imaginary part of the input argument is NaN.

sinh

public static Complex sinh(Complex c)
Returns the hyperbolic sine of the specified complex number and implements the formula:
 sinh(a + bi) = sinh(a)cos(b)) + cosh(a)sin(b)i
 

Parameters:
c - Complex number.
Returns:
Hyperbolic sine of the specified complex number. Returns NaN if either the real or imaginary part of the input argument is NaN.

tanh

public static Complex tanh(Complex c)
Returns the hyperbolic tangent of the specified complex number and implements the formula:
 tanh(a + bi) = sinh(2a)/(cosh(2a)+cos(2b)) + [sin(2b)/(cosh(2a)+cos(2b))]i
 

Parameters:
c - Complex number.
Returns:
Hyperbolic tTangent of the specified complex number. Returns NaN if either the real or imaginary part of the input argument is NaN.

polar2Complex

public static Complex polar2Complex(double r,
                                    double theta)
Returns the complex number from the given polar representation.

The value returned is r·ei·theta, computed as r·cos(theta) + r·sin(theta)i

If either r or theta is NaN, or theta is infinite, NaN is returned.

Parameters:
r - Radius.
theta - Angle.
Returns:
Complex number corresponding to the specified (t,theta) position.