math.complex
Class ComplexBusted

java.lang.Object
  extended by java.lang.Number
      extended by math.complex.ComplexBusted
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable

public class ComplexBusted
extends java.lang.Number
implements java.lang.Cloneable, java.io.Serializable, java.lang.Comparable

The class Complex defines a complex data type, and implements operations with that data type. The methods in this class fall into two categories--instance methods and static methods. The instance methods are mostly designed to work on Complex objects and to return references to Complex objects, so that they can be strung together in expressions. For example, a Complex expression such as

   z3 = z1 * z2 + z3
 
can be implemented as
   z3 = z1.mul(z2).add(z3)
 
However, these methods are always evaluated from left to right, so if the order of operations is not purely left-to-right, you will have to use parentheses or re-arrange the order of the methods to get the order of operations right. For example, a Complex expression such as
   z3 = z1 + z2 * z3
 
requires that the multiplication occur before the addition. This can be implemented as
   z3 = z1.add( z2.mul(z3) );
 
or alternatively as
   z3 = z2.mul(z3).add(z1);
 
The instance methods in this class that can be used to build such expressions include add, sub, mul, div, pow, inv, neg, abs, arg, cong, re, and im.

This class also contains many static methods that accept Complex arguments and return appropriate values. In general, the static methods in this class qre similar to the static methods in class java.lang.Math. Examples include sin(z), cos(z), tan(z), log(z), etc.

Class Complex is a subclass of Number, and it overrides all of the abstract methods in that class. The overridden methods in class Complex work with the real part of the Complex number only.

This class also implements the java.lang.Comparable interface. In this case, the comparisons are between the absolute values of the two Complex numbers.

Version:
1.00, 07/15/98
Author:
S. J. Chapman
See Also:
Serialized Form

Field Summary
static ComplexBusted I
          Constant representing i, the square root of -1.
 double im
          imaginary part of Complex number.
static ComplexBusted J
          Constant representing i, the square root of -1.
 double re
          Real part of Complex number.
 
Constructor Summary
ComplexBusted()
          Constructs a Complex object representing the number zero.
ComplexBusted(ComplexBusted z)
          Constructs a new Complex object from an existing Complex object.
ComplexBusted(double re)
          Constructs a Complex from a real number.
ComplexBusted(double re, double im)
          Constructs a Complex object from real and imaginary parts.
 
Method Summary
 double abs()
          Returns the absolute value (magnitude) of a Complex object.
static double abs(ComplexBusted z)
          Returns the absolute value (magnitude) of a Complex number.
static ComplexBusted acos(ComplexBusted z)
          Returns the principal inverse cosine of a Complex number.
static ComplexBusted acosh(ComplexBusted z)
          Returns the principal inverse hyperbolic cosine of a Complex number.
 ComplexBusted add(ComplexBusted z)
          Returns the sum of two Complex values.
 ComplexBusted add(double d)
          Returns the sum of a Complex and a double value.
 void addImaginary(double _i)
           
 void addReal(double _x)
           
 double arg()
          Returns the principal angle of a Complex number, in radians, measured counter-clockwise from the real axis.
static double arg(ComplexBusted z)
          Returns the principal angle of a Complex number, in radians, measured counter-clockwise from the real axis.
static ComplexBusted asin(ComplexBusted z)
          Returns the principal inverse sine of a Complex number.
static ComplexBusted asinh(ComplexBusted z)
          Returns the principal inverse hyperbolic sine of a Complex number.
static ComplexBusted atan(ComplexBusted z)
          Returns the principal inverse tangent of a Complex number.
static ComplexBusted atanh(ComplexBusted z)
          Returns the principal inverse hyperbolic tangent of a Complex number.
 byte byteValue()
          Returns the value of the real part of the specified number as a byte.
 int compareTo(ComplexBusted anotherComplex)
          Compares two Complex values numerically according to their absolute values.
 int compareTo(java.lang.Object o)
          Compares this Complex to another Object.
static ComplexBusted complex(double re)
          Creates a new Complex number from a double.
static ComplexBusted complex(double re, double im)
          Creates a new Complex from real and imaginary parts.
 ComplexBusted conj()
          Returns the Complex conjugate of a Complex object.
static ComplexBusted conj(ComplexBusted z)
          Returns the Complex conjugate of a Complex number.
 ComplexBusted copy()
           
static ComplexBusted cos(ComplexBusted z)
          Returns the cosine of a Complex number.
static ComplexBusted cosh(ComplexBusted z)
          Returns the hyperbolic cosine of a Complex number.
 ComplexBusted div(ComplexBusted z)
          Returns the division of two Complex values.
 ComplexBusted div(double d)
          Returns the division of a Complex value by a double value.
 double doubleValue()
          Returns the value of the real part of the specified number as a double.
 boolean equals(ComplexBusted z)
          Decides if two Complex numbers are "sufficiently" alike to be considered equal.
 boolean equals(ComplexBusted z, double tol)
          Decides if two Complex numbers are "sufficiently" alike to be considered equal.
static ComplexBusted exp(ComplexBusted z)
          Returns the exponential number e (i.e., 2.718...) raised to the power of the Complex value z.
 float floatValue()
          Returns the value of the real part of the specified number as a float.
 double getIm()
           
 double getRe()
           
 double im()
          Extracts the imaginary part of a Complex object as a double.
static double im(ComplexBusted z)
          Returns the imaginary part of a Complex as a double.
 int intValue()
          Returns the value of the real part of the specified number as an int.
 ComplexBusted inv()
          Returns the reciprocal of a Complex number (1/z).
static ComplexBusted inv(ComplexBusted z)
          Returns the reciprocal of a Complex number (1/z).
 ComplexBusted inverse()
           
 boolean isInfinite()
          Returns true if either the real or imaginary component of this Complex has an infinite value.
 boolean isNaN()
          Returns true if either the real or the imaginary component of this Complex is a Not-a-Number (NaN) value.
static ComplexBusted log(ComplexBusted z)
          Returns the principal natural logarithm of a Complex number.
 long longValue()
          Returns the value of the real part of the specified number as a long.
 double magnitude()
           
 ComplexBusted minus(ComplexBusted b)
           
 ComplexBusted mul(ComplexBusted z)
          Returns the product of two Complex values.
 ComplexBusted mul(double d)
          Returns the product of a Complex and a double value.
 ComplexBusted neg()
          Returns the negative of a Complex value.
static double norm(ComplexBusted z)
          Returns the L2 norm of a Complex number, which is the sum of the squares of the real and imaginary parts.
 double phase()
          Returns the phase of a Complex object.
static double phase(ComplexBusted c)
          Returns the phase of a Complex value.
 ComplexBusted plus(ComplexBusted b)
           
static ComplexBusted polar(double r, double theta)
          Returns a new Complex from a magnitude and angle.
 ComplexBusted pow(ComplexBusted exponent)
          Returns the Complex base raised to the power of the Complex exponent.
static ComplexBusted pow(ComplexBusted base, ComplexBusted exponent)
          Returns the Complex base raised to the power of the Complex exponent.
static ComplexBusted pow(ComplexBusted base, double exponent)
          Returns the Complex base raised to the power of the double exponent.
 ComplexBusted pow(double exponent)
          Returns the Complex value raised to the power of the double exponent.
static ComplexBusted pow(double base, ComplexBusted exponent)
          Returns the double base raised to the power of the Complex exponent.
 void print()
           
 void print(java.lang.String msg)
           
 double re()
          Extracts the real part of a Complex object as a double.
static double re(ComplexBusted z)
          Returns the real part of a Complex as a double.
 void setIm(double im)
          Sets a double value into the imaginary part of a Complex object.
 void setRe(double re)
          Sets a double value into the real part of a Complex object.
 void setZ(double re, double im)
          Sets two double values into the real and imaginary parts of a Complex object.
 short shortValue()
          Returns the value of the real part of the specified number as a short.
static ComplexBusted sin(ComplexBusted z)
          Returns the sine of a Complex number.
static ComplexBusted sinh(ComplexBusted z)
          Returns the hyperbolic sine of a Complex number.
static ComplexBusted sqrt(ComplexBusted z)
          Returns the square root of a Complex value.
 double square()
           
 ComplexBusted sub(ComplexBusted z)
          Returns the difference of two Complex values.
 ComplexBusted sub(double d)
          Returns the difference between a Complex and a double value.
static ComplexBusted tan(ComplexBusted z)
          Returns the tangent of a Complex number.
static ComplexBusted tanh(ComplexBusted z)
          Returns the hyperbolic tangent of a Complex number.
 ComplexBusted times(ComplexBusted b)
           
 java.lang.String toString()
          Converts a Complex value into a String of the form (re + iim).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

I

public static final ComplexBusted I
Constant representing i, the square root of -1.


J

public static final ComplexBusted J
Constant representing i, the square root of -1. (For electrical engineers...)


re

public double re
Real part of Complex number.


im

public double im
imaginary part of Complex number.

Constructor Detail

ComplexBusted

public ComplexBusted()
Constructs a Complex object representing the number zero.


ComplexBusted

public ComplexBusted(double re)
Constructs a Complex from a real number. The imaginary part is zero.

Parameters:
re - The real number

See Also:
complex(double)

ComplexBusted

public ComplexBusted(ComplexBusted z)
Constructs a new Complex object from an existing Complex object.

Parameters:
z - A Complex value


ComplexBusted

public ComplexBusted(double re,
                     double im)
Constructs a Complex object from real and imaginary parts.

Parameters:
re - Real part
im - Imaginary part

See Also:
complex(double, double)
Method Detail

byteValue

public byte byteValue()
Returns the value of the real part of the specified number as a byte. This may involve rounding.

Overrides:
byteValue in class java.lang.Number
Returns:
the numeric value represented by the real part this object after conversion to type byte.

doubleValue

public double doubleValue()
Returns the value of the real part of the specified number as a double.

Specified by:
doubleValue in class java.lang.Number
Returns:
the numeric value represented by the real part this object after conversion to type double.

floatValue

public float floatValue()
Returns the value of the real part of the specified number as a float. This may involve rounding.

Specified by:
floatValue in class java.lang.Number
Returns:
the numeric value represented by the real part this object after conversion to type float.

intValue

public int intValue()
Returns the value of the real part of the specified number as an int. This may involve rounding.

Specified by:
intValue in class java.lang.Number
Returns:
the numeric value represented by the real part this object after conversion to type int.

longValue

public long longValue()
Returns the value of the real part of the specified number as a long. This may involve rounding.

Specified by:
longValue in class java.lang.Number
Returns:
the numeric value represented by the real part this object after conversion to type long.

shortValue

public short shortValue()
Returns the value of the real part of the specified number as a short. This may involve rounding.

Overrides:
shortValue in class java.lang.Number
Returns:
the numeric value represented by the real part this object after conversion to type short.

toString

public java.lang.String toString()
Converts a Complex value into a String of the form (re + iim).

Overrides:
toString in class java.lang.Object
Returns:
String containing the rectangular coordinate representation of the number

abs

public static double abs(ComplexBusted z)
Returns the absolute value (magnitude) of a Complex number.

Parameters:
z - a Complex number
Returns:
a double containing the absoulute value of the Complex number
See Also:
abs()

arg

public static double arg(ComplexBusted z)
Returns the principal angle of a Complex number, in radians, measured counter-clockwise from the real axis. The method arg(z) always returns a double between -PI and +PI.

Parameters:
z - Complex number
Returns:
a double containing the principal angle of the Complex value
See Also:
arg()

acos

public static ComplexBusted acos(ComplexBusted z)
Returns the principal inverse cosine of a Complex number.
     acos(z) = -i * log( z + i * sqrt(1 - z*z) )
 

Parameters:
z - a Complex number
Returns:
the Complex result
See Also:
cos(ComplexBusted)

acosh

public static ComplexBusted acosh(ComplexBusted z)
Returns the principal inverse hyperbolic cosine of a Complex number.
     acosh(z) = log(z + sqrt(z*z - 1))
 

Parameters:
z - a Complex number
Returns:
the Complex result
See Also:
cosh(ComplexBusted)

asin

public static ComplexBusted asin(ComplexBusted z)
Returns the principal inverse sine of a Complex number.
     asin(z) = -i * log(i*z + sqrt(1 - z*z))
 

Parameters:
z - a Complex number
Returns:
the Complex result
See Also:
sin(ComplexBusted)

asinh

public static ComplexBusted asinh(ComplexBusted z)
Returns the principal inverse hyperbolic sine of a Complex number.
     asinh(z) = log(z + sqrt(z*z + 1))
 

Parameters:
z - a Complex number
Returns:
the Complex result
See Also:
sinh(ComplexBusted)

atan

public static ComplexBusted atan(ComplexBusted z)
Returns the principal inverse tangent of a Complex number.
     atan(z) = -i/2 * log( (i-z)/(i+z) )
 

Parameters:
z - a Complex number
Returns:
the Complex result
See Also:
tan(ComplexBusted)

atanh

public static ComplexBusted atanh(ComplexBusted z)
Returns the principal inverse hyperbolic tangent of a Complex number.
     atanh(z) = 1/2 * log( (1+z)/(1-z) )
 

Parameters:
z - a Complex number
Returns:
the Complex result
See Also:
tanh(ComplexBusted)

complex

public static ComplexBusted complex(double re)
Creates a new Complex number from a double. The imaginary part of the Complex number is initialized to zero.

Parameters:
re - real part
Returns:
Complex of the form (re + i*0)
See Also:
complex(double, double)

complex

public static ComplexBusted complex(double re,
                                    double im)
Creates a new Complex from real and imaginary parts.

Parameters:
re - Real part
im - Imaginary part
Returns:
Complex number from Rectangular coordinates
See Also:
complex(double)

conj

public static ComplexBusted conj(ComplexBusted z)
Returns the Complex conjugate of a Complex number. The Complex conjugate of a number is the complex number having the same real component and the negative of the imaginary component.

Parameters:
z - Complex input parameter
Returns:
Complex conjugate of z.

cos

public static ComplexBusted cos(ComplexBusted z)
Returns the cosine of a Complex number.
     cos(z) = ( exp(i*z) + exp(-i*z) ) / (2*i)
 

Parameters:
z - an Complex angle
Returns:
the Complex cosine
See Also:
acos(ComplexBusted)

cosh

public static ComplexBusted cosh(ComplexBusted z)
Returns the hyperbolic cosine of a Complex number.
     cosh(z) = ( exp(z) + exp(-z) ) / 2
 

Parameters:
z - a Complex value
Returns:
the Complex hyperbolic cosine
See Also:
acosh(ComplexBusted)

exp

public static ComplexBusted exp(ComplexBusted z)
Returns the exponential number e (i.e., 2.718...) raised to the power of the Complex value z.

Parameters:
z - a double value.
Returns:
the value ez, where e is the base of the natural logarithms.
See Also:
log(ComplexBusted)

im

public static double im(ComplexBusted z)
Returns the imaginary part of a Complex as a double.

Parameters:
z - Complex number
Returns:
double containing the imaginary part of z

See Also:
im()

inv

public static ComplexBusted inv(ComplexBusted z)
Returns the reciprocal of a Complex number (1/z).

Parameters:
z - Complex number
Returns:
The Complex reciprocal

log

public static ComplexBusted log(ComplexBusted z)
Returns the principal natural logarithm of a Complex number.

Parameters:
z - a Complex number.
Returns:
the value ln z, the natural logarithm of z.
See Also:
exp(ComplexBusted)

norm

public static double norm(ComplexBusted z)
Returns the L2 norm of a Complex number, which is the sum of the squares of the real and imaginary parts.

Parameters:
z - a Complex number
Returns:
a double containing the norm of the Complex number

phase

public static double phase(ComplexBusted c)
Returns the phase of a Complex value. Note that this method duplicates the functionality of the arg method.

Returns:
Phase of Complex value in radians

polar

public static ComplexBusted polar(double r,
                                  double theta)
Returns a new Complex from a magnitude and angle.

Parameters:
r - Magnitude
theta - Angle (in radians)
Returns:
Complex from Polar coordinates

pow

public static ComplexBusted pow(ComplexBusted base,
                                double exponent)
Returns the Complex base raised to the power of the double exponent.

Parameters:
base - The Complex base value
exponent - The double exponent
Returns:
Complex base raised to the power of the exponent.
See Also:
pow(double, ComplexBusted), pow(ComplexBusted , ComplexBusted)

pow

public static ComplexBusted pow(double base,
                                ComplexBusted exponent)
Returns the double base raised to the power of the Complex exponent.

Parameters:
base - The double base value
exponent - The Complex exponent
Returns:
base raised to the power of the Complex exponent.
See Also:
pow(ComplexBusted , double), pow(ComplexBusted , ComplexBusted)

pow

public static ComplexBusted pow(ComplexBusted base,
                                ComplexBusted exponent)
Returns the Complex base raised to the power of the Complex exponent.

Parameters:
base - The Complex base value
exponent - The Complex exponent
Returns:
Complex base raised to the power of the Complex exponent.
See Also:
pow(double, ComplexBusted), pow(ComplexBusted , double)

re

public static double re(ComplexBusted z)
Returns the real part of a Complex as a double.

Parameters:
z - Complex number
Returns:
double containing the real part of z
See Also:
re()

sin

public static ComplexBusted sin(ComplexBusted z)
Returns the sine of a Complex number.
     sin(z) = ( exp(i*z) - exp(-i*z) ) / (2*i)
 

Parameters:
z - an angle, in radians.
Returns:
the Complex sine
See Also:
asin(ComplexBusted)

sinh

public static ComplexBusted sinh(ComplexBusted z)
Returns the hyperbolic sine of a Complex number.
     sinh(z) = ( exp(z) - exp(-z) ) / 2
 

Parameters:
z - a Complex value
Returns:
the Complex hyperbolic sine
See Also:
asinh(ComplexBusted)

sqrt

public static ComplexBusted sqrt(ComplexBusted z)
Returns the square root of a Complex value.

Parameters:
z - a Complex value.
Returns:
the square root of z.

tan

public static ComplexBusted tan(ComplexBusted z)
Returns the tangent of a Complex number.
     tan(z) = sin(z) / cos(z)
 

Parameters:
z - a Complex angle
Returns:
the Complex tangent
See Also:
atan(ComplexBusted)

tanh

public static ComplexBusted tanh(ComplexBusted z)
Returns the hyperbolic tangent of a Complex number.
     tanh(z) = sinh(z) / cosh(z)
 

Parameters:
z - a Complex value
Returns:
the Complex hyperbolic tangent
See Also:
atanh(ComplexBusted)

re

public double re()
Extracts the real part of a Complex object as a double.

Returns:
double containing the real part of the ComplexSee Also:
re(ComplexBusted)

im

public double im()
Extracts the imaginary part of a Complex object as a double.

Returns:
double containing the imaginary part of the ComplexSee Also:
im(ComplexBusted)

setIm

public void setIm(double im)
Sets a double value into the imaginary part of a Complex object.

See Also:
im(), setRe(double), setZ(double,double)

setRe

public void setRe(double re)
Sets a double value into the real part of a Complex object.

See Also:
re(), setIm(double), setZ(double,double)

setZ

public void setZ(double re,
                 double im)
Sets two double values into the real and imaginary parts of a Complex object.

See Also:
re(), setRe(double), setIm(double)

abs

public double abs()
Returns the absolute value (magnitude) of a Complex object.

Returns:
double containing the absoulute value of the ComplexSee Also:
abs(ComplexBusted), arg(), arg(ComplexBusted)

arg

public double arg()
Returns the principal angle of a Complex number, in radians, measured counter-clockwise from the real axis. arg() always returns a double between -PI and +PI.

Returns:
double containing the principal angle of the ComplexSee Also:
arg(ComplexBusted)

conj

public ComplexBusted conj()
Returns the Complex conjugate of a Complex object. The Complex conjugate of a number is the complex number having the same real component and the negative of the imaginary component.

Returns:
Complex conjugate.
See Also:
conj(ComplexBusted)

add

public ComplexBusted add(ComplexBusted z)
Returns the sum of two Complex values. To perform z1 + z2, write z1.add(z2). Note that this method returns a Complex object, so calls to these methods can be chained. For example,
     z1 + z2 + z3 == z1.add(z2).add(z3)
 

Parameters:
z - A Complex number
Returns:
Complex sum z1 + z2
See Also:
add(double), sub(ComplexBusted), sub(double), mul(ComplexBusted), mul(double), div(ComplexBusted), div(double)

add

public ComplexBusted add(double d)
Returns the sum of a Complex and a double value. To perform z1 + d2, write z1.add(d2).

Parameters:
d - A double value
Returns:
Complex sum z1 + d2
See Also:
add(ComplexBusted), sub(ComplexBusted), sub(double), mul(ComplexBusted), mul(double), div(ComplexBusted), div(double)

sub

public ComplexBusted sub(ComplexBusted z)
Returns the difference of two Complex values. To perform z1 - z2, write z1.sub(z2). Note that this method returns a Complex object, so calls to these methods can be chained. For example,
     z1 - z2 + z3 == z1.sub(z2).add(z3)
 

Parameters:
z - A Complex number
Returns:
Complex difference z1 - z2
See Also:
add(ComplexBusted), add(double), sub(double), mul(ComplexBusted), mul(double), div(ComplexBusted), div(double)

sub

public ComplexBusted sub(double d)
Returns the difference between a Complex and a double value. To perform z1 - d2, write z1.sub(d2).

Parameters:
d - A double value
Returns:
Complex difference z1 - d2
See Also:
add(ComplexBusted), add(double), sub(ComplexBusted), mul(ComplexBusted), mul(double), div(ComplexBusted), div(double)

mul

public ComplexBusted mul(ComplexBusted z)
Returns the product of two Complex values. To perform z1 * z2, write z1.mul(z2). Note that this method returns a Complex object, so calls to these methods can be chained. For example,
     z1 * z2 / z3 == z1.mul(z2).div(z3)
 

Parameters:
z - A Complex number
Returns:
Complex product z1 * z2
See Also:
add(ComplexBusted), add(double), sub(ComplexBusted), sub(double), mul(double), div(ComplexBusted), div(double)

mul

public ComplexBusted mul(double d)
Returns the product of a Complex and a double value. To perform z1 * d2, write z1.mul(d2).

Parameters:
d - A double value
Returns:
Complex product z1 * d2
See Also:
add(ComplexBusted), add(double), sub(ComplexBusted), sub(double), mul(ComplexBusted), div(ComplexBusted), div(double)

div

public ComplexBusted div(ComplexBusted z)
Returns the division of two Complex values. To perform z1 / z2, write z1.div(z2). Note that this method returns a Complex object, so calls to these methods can be chained. For example,
     z1 * z2 / z3 == z1.mul(z2).div(z3)
 

Parameters:
z - A Complex number
Returns:
Complex result of z1 / z2
See Also:
add(ComplexBusted), add(double), sub(ComplexBusted), sub(double), mul(ComplexBusted), mul(double), div(double)

div

public ComplexBusted div(double d)
Returns the division of a Complex value by a double value. To perform z1 / d2, write z1.div(d2).

Parameters:
d - A double number
Returns:
Complex result of z1 / d2
See Also:
add(ComplexBusted), add(double), sub(ComplexBusted), sub(double), mul(ComplexBusted), mul(double), div(ComplexBusted)

inv

public ComplexBusted inv()
Returns the reciprocal of a Complex number (1/z).

Returns:
The Complex reciprocal

neg

public ComplexBusted neg()
Returns the negative of a Complex value.

Returns:
Negative of Complex value

phase

public double phase()
Returns the phase of a Complex object. Note that this method duplicates the functionality of the arg() method.

Returns:
Phase of Complex object in radians

pow

public ComplexBusted pow(double exponent)
Returns the Complex value raised to the power of the double exponent.

Parameters:
exponent - The double exponent
Returns:
Complex base raised to the power of the exponent.
See Also:
pow(ComplexBusted), pow(ComplexBusted , double), pow(double, ComplexBusted), pow(ComplexBusted , ComplexBusted)

pow

public ComplexBusted pow(ComplexBusted exponent)
Returns the Complex base raised to the power of the Complex exponent. The Complex base value

Parameters:
exponent - The Complex exponent
Returns:
Complex base raised to the power of the Complex exponent.
See Also:
pow(double), pow(ComplexBusted , double), pow(double, ComplexBusted), pow(ComplexBusted , ComplexBusted)

isInfinite

public boolean isInfinite()
Returns true if either the real or imaginary component of this Complex has an infinite value.

Returns:
true if either component of the Complex object is infinite; false, otherwise.

isNaN

public boolean isNaN()
Returns true if either the real or the imaginary component of this Complex is a Not-a-Number (NaN) value.

Returns:
true if either component of the Complex object is NaN; false, otherwise.

equals

public boolean equals(ComplexBusted z)
Decides if two Complex numbers are "sufficiently" alike to be considered equal. This test should be used cautiously because of the inexact nature of floating-point representations on computers. This test takes the form z1.equals(z2). The tolerance for this comparison is scaled automatically based on the sizes of the numbers being compared.

Parameters:
z - A Complex number
Returns:
true if equal; false otherwise
See Also:
equals(ComplexBusted ,double)

equals

public boolean equals(ComplexBusted z,
                      double tol)
Decides if two Complex numbers are "sufficiently" alike to be considered equal. This test should be used cautiously because of the inexact nature of floating-point representations on computers. This test takes the form z1.equals(z2,tol). The argument tol is a scale factor used to determine the maximum magnitude of the difference between them before they are considered not equal. This value is multiplied by the absolute value of the first of the two numbers being compared to make the tolerance relative to the magnitude of the numbers being compared.

Parameters:
z - A Complex number
tol - The tolerance with which to comapare the two numbers
Returns:
true if equal; false otherwise
See Also:
equals(ComplexBusted)

compareTo

public int compareTo(ComplexBusted anotherComplex)
Compares two Complex values numerically according to their absolute values.

Parameters:
anotherComplex - the Complex to be compared.
Returns:
the value 0 if the absolute value of the argument anotherComplex is equal to the absolute value of this Complex; a value less than 0 if the absolute value of this Complex is numerically less than the Complex argument; and a the absolute value of this Complex is numerically greater than the Complex argument. (signed comparison).
See Also:
Comparable

compareTo

public int compareTo(java.lang.Object o)
Compares this Complex to another Object. If the Object is a Complex, this function behaves like compareTo(Complex). Otherwise, it throws a ClassCastException (as Complex values are comparable only to other Complex values).

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - the Object to be compared.
Returns:
the value 0 if the absolute value of the argument Object is equal to the absolute value of this Complex; a value less than 0 if the absolute value of this Complex is numerically less than the Object argument; and a the absolute value of this Complex is numerically greater than the Object argument. (signed comparison).
Throws:
ClassCastException - if the argument is not a Complex.
See Also:
Comparable

addReal

public void addReal(double _x)

addImaginary

public void addImaginary(double _i)

getRe

public double getRe()

getIm

public double getIm()

plus

public ComplexBusted plus(ComplexBusted b)

minus

public ComplexBusted minus(ComplexBusted b)

times

public ComplexBusted times(ComplexBusted b)

inverse

public ComplexBusted inverse()

square

public double square()

magnitude

public double magnitude()

copy

public ComplexBusted copy()

print

public void print()

print

public void print(java.lang.String msg)