us.ihmc.utilities.math.dataStructures
Class ComplexNumber

java.lang.Object
  extended by us.ihmc.utilities.math.dataStructures.ComplexNumber

public class ComplexNumber
extends java.lang.Object

Complex implements a complex number and defines complex arithmetic and mathematical functions Last Updated February 27, 2001 Copyright 1997-2001

Version:
1.0
Author:
Andrew G. Bennett

Constructor Summary
ComplexNumber(ComplexNumber complexNumber)
           
ComplexNumber(double real, double imag)
          Constructs the complex number z = u + i*v
 
Method Summary
 double angle()
          Argument of this Complex number (the angle in radians with the x-axis in polar coordinates).
 ComplexNumber changeSign()
          Negative of this ComplexNumber (chs stands for change sign).
 ComplexNumber conj()
          Complex conjugate of this Complex number (the conjugate of x+i*y is x-i*y).
 ComplexNumber cos()
          Cosine of this ComplexNumber (doesn't change this ComplexNumber).
 ComplexNumber cosh()
          Hyperbolic cosine of this ComplexNumber (doesn't change this ComplexNumber).
 ComplexNumber dividedBy(ComplexNumber w)
          Division of ComplexNumbers (doesn't change this ComplexNumber).
 boolean epsilonEquals(ComplexNumber complexNumber, double epsilon)
           
 boolean epsilonEquals(double realNumber, double epsilon)
           
 ComplexNumber exp()
          ComplexNumber exponential (doesn't change this ComplexNumber).
 double imag()
          imag part of this Complex number (the y-coordinate in rectangular coordinates).
 ComplexNumber log()
          Principal branch of the ComplexNumber logarithm of this ComplexNumber.
 double magnitude()
          Modulus of this Complex number (the distance from the origin in polar coordinates).
 double magnitudeSquared()
           
 ComplexNumber minus(ComplexNumber w)
          Subtraction of ComplexNumbers (doesn't change this ComplexNumber).
 ComplexNumber minus(double d)
           
 ComplexNumber plus(ComplexNumber w)
          Addition of ComplexNumbers (doesn't change this ComplexNumber).
 ComplexNumber plus(double d)
           
 double real()
          Real part of this Complex number (the x-coordinate in rectangular coordinates).
 ComplexNumber sin()
          Sine of this ComplexNumber (doesn't change this ComplexNumber).
 ComplexNumber sinh()
          Hyperbolic sine of this ComplexNumber (doesn't change this ComplexNumber).
 ComplexNumber sqrt()
          ComplexNumber square root (doesn't change this ComplexNumber).
 ComplexNumber tan()
          Tangent of this ComplexNumber (doesn't change this ComplexNumber).
 ComplexNumber times(ComplexNumber w)
          ComplexNumber multiplication (doesn't change this ComplexNumber).
 ComplexNumber times(double w)
          ComplexNumber multiplication by a real number (doesn't change this ComplexNumber).
 java.lang.String toString()
          String representation of this ComplexNumber.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ComplexNumber

public ComplexNumber(double real,
                     double imag)
Constructs the complex number z = u + i*v

Parameters:
u - Real part
v - imag part

ComplexNumber

public ComplexNumber(ComplexNumber complexNumber)
Method Detail

real

public double real()
Real part of this Complex number (the x-coordinate in rectangular coordinates).

Returns:
Re[z] where z is this Complex number.

imag

public double imag()
imag part of this Complex number (the y-coordinate in rectangular coordinates).

Returns:
Im[z] where z is this Complex number.

magnitude

public double magnitude()
Modulus of this Complex number (the distance from the origin in polar coordinates).

Returns:
|z| where z is this Complex number.

magnitudeSquared

public double magnitudeSquared()

angle

public double angle()
Argument of this Complex number (the angle in radians with the x-axis in polar coordinates).

Returns:
arg(z) where z is this Complex number.

conj

public ComplexNumber conj()
Complex conjugate of this Complex number (the conjugate of x+i*y is x-i*y).

Returns:
z-bar where z is this Complex number.

plus

public ComplexNumber plus(ComplexNumber w)
Addition of ComplexNumbers (doesn't change this ComplexNumber).
(x+i*y) + (s+i*t) = (x+s)+i*(y+t).

Parameters:
w - is the number to add.
Returns:
z+w where z is this ComplexNumber.

plus

public ComplexNumber plus(double d)

minus

public ComplexNumber minus(ComplexNumber w)
Subtraction of ComplexNumbers (doesn't change this ComplexNumber).
(x+i*y) - (s+i*t) = (x-s)+i*(y-t).

Parameters:
w - is the number to subtract.
Returns:
z-w where z is this ComplexNumber.

minus

public ComplexNumber minus(double d)

times

public ComplexNumber times(ComplexNumber w)
ComplexNumber multiplication (doesn't change this ComplexNumber).

Parameters:
w - is the number to multiply by.
Returns:
z*w where z is this ComplexNumber.

times

public ComplexNumber times(double w)
ComplexNumber multiplication by a real number (doesn't change this ComplexNumber).

Parameters:
w - is the number to multiply by.
Returns:
z*w where z is this ComplexNumber.

dividedBy

public ComplexNumber dividedBy(ComplexNumber w)
Division of ComplexNumbers (doesn't change this ComplexNumber).
(x+i*y)/(s+i*t) = ((x*s+y*t) + i*(y*s-y*t)) / (s^2+t^2)

Parameters:
w - is the number to divide by
Returns:
new ComplexNumber z/w where z is this ComplexNumber

exp

public ComplexNumber exp()
ComplexNumber exponential (doesn't change this ComplexNumber).

Returns:
exp(z) where z is this ComplexNumber.

log

public ComplexNumber log()
Principal branch of the ComplexNumber logarithm of this ComplexNumber. (doesn't change this ComplexNumber). The principal branch is the branch with -pi < arg <= pi.

Returns:
log(z) where z is this ComplexNumber.

sqrt

public ComplexNumber sqrt()
ComplexNumber square root (doesn't change this ComplexNumber). Computes the principal branch of the square root, which is the value with 0 <= arg < pi.

Returns:
sqrt(z) where z is this ComplexNumber.

sin

public ComplexNumber sin()
Sine of this ComplexNumber (doesn't change this ComplexNumber).
sin(z) = (exp(i*z)-exp(-i*z))/(2*i).

Returns:
sin(z) where z is this ComplexNumber.

cos

public ComplexNumber cos()
Cosine of this ComplexNumber (doesn't change this ComplexNumber).
cos(z) = (exp(i*z)+exp(-i*z))/ 2.

Returns:
cos(z) where z is this ComplexNumber.

sinh

public ComplexNumber sinh()
Hyperbolic sine of this ComplexNumber (doesn't change this ComplexNumber).
sinh(z) = (exp(z)-exp(-z))/2.

Returns:
sinh(z) where z is this ComplexNumber.

cosh

public ComplexNumber cosh()
Hyperbolic cosine of this ComplexNumber (doesn't change this ComplexNumber).
cosh(z) = (exp(z) + exp(-z)) / 2.

Returns:
cosh(z) where z is this ComplexNumber.

tan

public ComplexNumber tan()
Tangent of this ComplexNumber (doesn't change this ComplexNumber).
tan(z) = sin(z)/cos(z).

Returns:
tan(z) where z is this ComplexNumber.

changeSign

public ComplexNumber changeSign()
Negative of this ComplexNumber (chs stands for change sign). This produces a new ComplexNumber and doesn't change this ComplexNumber.
-(x+i*y) = -x-i*y.

Returns:
-z where z is this ComplexNumber.

epsilonEquals

public boolean epsilonEquals(double realNumber,
                             double epsilon)

epsilonEquals

public boolean epsilonEquals(ComplexNumber complexNumber,
                             double epsilon)

toString

public java.lang.String toString()
String representation of this ComplexNumber.

Overrides:
toString in class java.lang.Object
Returns:
x+i*y, x-i*y, x, or i*y as appropriate.