Top Description Fields Constructors Methods
org.apache.commons.math3.complex

public Class Complex

extends Object
implements FieldElement<Complex>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.apache.commons.math3.FieldElement
Imports
java.io.Serializable, java.util.ArrayList, .List, org.apache.commons.math3.FieldElement, org.apache.commons.math3.exception.NotPositiveException, .NullArgumentException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.util.FastMath, .MathUtils, .Precision

Representation of a Complex number, i.e. a number which has both a real and imaginary part.

Implementations of arithmetic operations handle NaN and infinite values according to the rules for java.lang.Double, i.e. equals is an equivalence relation for all instances that have a NaN in either real or imaginary part, e.g. the following are considered equal:

Note that this contradicts the IEEE-754 standard for floating point numbers (according to which the test x == x must fail if x is NaN). The method equals for primitive double in org.apache.commons.math3.util.Precision conforms with IEEE-754 while this class conforms with the standard behavior for Java object types.

Field Summary

Modifier and TypeField and Description
public static final Complex
I

The square root of -1.

private final double
imaginary

The imaginary part.

public static final Complex
INF

A complex number representing "+INF + INFi"

private final transient boolean
isInfinite

Record whether this complex number is infinite.

private final transient boolean
isNaN

Record whether this complex number is equal to NaN.

public static final Complex
NaN

A complex number representing "NaN + NaNi"

public static final Complex
ONE

A complex number representing "1.0 + 0.0i"

private final double
real

The real part.

private static final long
serialVersionUID

Serializable version identifier

public static final Complex
ZERO

A complex number representing "0.0 + 0.0i"

Constructor Summary

AccessConstructor and Description
public
Complex(double
Real part.
real
)

Create a complex number given only the real part.

public
Complex(double
Real part.
real
,
double
Imaginary part.
imaginary
)

Create a complex number given the real and imaginary parts.

Method Summary

Modifier and TypeMethod and Description
public double

Returns:

the absolute value.
abs
()

Return the absolute value of this complex number.

public Complex

Returns:

the inverse cosine of this complex number.
acos
()

Compute the inverse cosine of this complex number.

public Complex

Returns:

this + addend.
add
(Complex
Value to be added to this Complex.
addend
)

Implements org.apache.commons.math3.FieldElement.add.

Returns a Complex whose value is (this + addend).

public Complex

Returns:

this + addend.
add
(double
Value to be added to this Complex.
addend
)

Implements org.apache.commons.math3.FieldElement.add.

Returns a Complex whose value is (this + addend), with addend interpreted as a real number.

public Complex

Returns:

the inverse sine of this complex number.
asin
()

Compute the inverse sine of this complex number.

public Complex

Returns:

the inverse tangent of this complex number
atan
()

Compute the inverse tangent of this complex number.

public Complex

Returns:

the conjugate of this Complex object.
conjugate
()

Returns the conjugate of this complex number.

public Complex

Returns:

the cosine of this complex number.
cos
()

Compute the cosine of this complex number.

public Complex

Returns:

the hyperbolic cosine of this complex number.
cosh
()

Compute the hyperbolic cosine of this complex number.

protected Complex

Returns:

a new complex number instance.
createComplex
(double
Real part.
realPart
,
double
Imaginary part.
imaginaryPart
)

Create a complex number given the real and imaginary parts.

public Complex

Returns:

this / divisor.
divide
(Complex
Value by which this Complex is to be divided.
divisor
)

Implements org.apache.commons.math3.FieldElement.divide.

Returns a Complex whose value is (this / divisor).

public Complex

Returns:

this / divisor.
divide
(double
Value by which this Complex is to be divided.
divisor
)

Implements org.apache.commons.math3.FieldElement.divide.

Returns a Complex whose value is (this / divisor), with divisor interpreted as a real number.

public boolean

Returns:

true if the objects are equal, false if object is null, not an instance of Complex, or not equal to this instance.
equals
(Object
Object to test for equality with this instance.
other
)

Overrides java.lang.Object.equals.

Test for equality with another object.

public static boolean

Returns:

true if there are fewer than maxUlps floating point values between the real (resp. imaginary) parts of x and y.
equals
(Complex
First value (cannot be null).
x
,
Complex
Second value (cannot be null).
y
,
int
(maxUlps - 1) is the number of floating point values between the real (resp. imaginary) parts of x and y.
maxUlps
)

Test for the floating-point equality between Complex objects.

public static boolean

Returns:

true if the values are equal.
equals
(Complex
First value (cannot be null).
x
,
Complex
Second value (cannot be null).
y
)

Returns true iff the values are equal as defined by equals(x, y, 1).

public static boolean

Returns:

true if the values are two adjacent floating point numbers or they are within range of each other.
equals
(Complex
First value (cannot be null).
x
,
Complex
Second value (cannot be null).
y
,
double
Amount of allowed absolute error.
eps
)

Returns true if, both for the real part and for the imaginary part, there is no double value strictly between the arguments or the difference between them is within the range of allowed error (inclusive).

public static boolean

Returns:

true if the values are two adjacent floating point numbers or they are within range of each other.
equalsWithRelativeTolerance
(Complex
First value (cannot be null).
x
,
Complex
Second value (cannot be null).
y
,
double
Amount of allowed relative error.
eps
)

Returns true if, both for the real part and for the imaginary part, there is no double value strictly between the arguments or the relative difference between them is smaller or equal to the given tolerance.

public Complex

Returns:

ethis.
exp
()

Compute the exponential function of this complex number.

public double

Returns:

the argument of this.
getArgument
()

Compute the argument of this complex number.

public ComplexField
getField()

Implements org.apache.commons.math3.FieldElement.getField.

Get the Field to which the instance belongs.

public double

Returns:

the imaginary part.
getImaginary
()

Access the imaginary part.

public double

Returns:

the real part.
getReal
()

Access the real part.

public int

Returns:

a hash code value for this object.
hashCode
()

Overrides java.lang.Object.hashCode.

Get a hashCode for the complex number.

public boolean

Returns:

true if one or both parts of this complex number are infinite and neither part is NaN.
isInfinite
()

Checks whether 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.

public boolean

Returns:

true if either or both parts of this complex number is NaN; false otherwise.
isNaN
()

Checks whether either or both parts of this complex number is NaN.

public Complex

Returns:

the value ln   this, the natural logarithm of this.
log
()

Compute the natural logarithm of this complex number.

public Complex

Returns:

this * factor.
multiply
(Complex
value to be multiplied by this Complex.
factor
)

Implements org.apache.commons.math3.FieldElement.multiply.

Returns a Complex whose value is this * factor.

public Complex

Returns:

this * factor.
multiply
(final int
value to be multiplied by this Complex.
factor
)

Implements org.apache.commons.math3.FieldElement.multiply, org.apache.commons.math3.FieldElement.multiply.

Returns a Complex whose value is this * factor, with factor interpreted as a integer number.

public Complex

Returns:

this * factor.
multiply
(double
value to be multiplied by this Complex.
factor
)

Implements org.apache.commons.math3.FieldElement.multiply.

Returns a Complex whose value is this * factor, with factor interpreted as a real number.

public Complex

Returns:

-this.
negate
()

Implements org.apache.commons.math3.FieldElement.negate.

Returns a Complex whose value is (-this).

public List<Complex>

Returns:

a List of all n-th roots of this.
nthRoot
(int
Degree of root.
n
)

Computes the n-th roots of this complex number.

public Complex

Returns:

thisx.
pow
(Complex
exponent to which this Complex is to be raised.
x
)

Returns of value of this complex number raised to the power of x.

public Complex

Returns:

thisx.
pow
(double
exponent to which this Complex is to be raised.
x
)

Returns of value of this complex number raised to the power of x.

protected final Object

Returns:

A Complex instance with all fields resolved.
readResolve
()

Resolve the transient fields in a deserialized Complex Object.

public Complex
reciprocal()

Implements org.apache.commons.math3.FieldElement.reciprocal.

Returns the multiplicative inverse of this element.

public Complex

Returns:

the sine of this complex number.
sin
()

Compute the sine of this complex number.

public Complex

Returns:

the hyperbolic sine of this.
sinh
()

Compute the hyperbolic sine of this complex number.

public Complex

Returns:

the square root of this.
sqrt
()

Compute the square root of this complex number.

public Complex

Returns:

the square root of 1 - this2.
sqrt1z
()

Compute the square root of 1 - this2 for this complex number.

public Complex

Returns:

this - subtrahend.
subtract
(Complex
value to be subtracted from this Complex.
subtrahend
)

Implements org.apache.commons.math3.FieldElement.subtract.

Returns a Complex whose value is (this - subtrahend).

public Complex

Returns:

this - subtrahend.
subtract
(double
value to be subtracted from this Complex.
subtrahend
)

Implements org.apache.commons.math3.FieldElement.subtract.

Returns a Complex whose value is (this - subtrahend).

public Complex

Returns:

the tangent of this.
tan
()

Compute the tangent of this complex number.

public Complex

Returns:

the hyperbolic tangent of this.
tanh
()

Compute the hyperbolic tangent of this complex number.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public static Complex

Returns:

a Complex instance.
valueOf
(double
Real part.
realPart
,
double
Imaginary part.
imaginaryPart
)

Create a complex number given the real and imaginary parts.

public static Complex

Returns:

a Complex instance.
valueOf
(double
Real part.
realPart
)

Create a complex number given only the real part.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

Iback to summary
public static final Complex I

The square root of -1. A number representing "0.0 + 1.0i"

imaginaryback to summary
private final double imaginary

The imaginary part.

INFback to summary
public static final Complex INF

A complex number representing "+INF + INFi"

isInfiniteback to summary
private final transient boolean isInfinite

Record whether this complex number is infinite.

isNaNback to summary
private final transient boolean isNaN

Record whether this complex number is equal to NaN.

NaNback to summary
public static final Complex NaN

A complex number representing "NaN + NaNi"

ONEback to summary
public static final Complex ONE

A complex number representing "1.0 + 0.0i"

realback to summary
private final double real

The real part.

serialVersionUIDback to summary
private static final long serialVersionUID

Serializable version identifier

ZEROback to summary
public static final Complex ZERO

A complex number representing "0.0 + 0.0i"

Constructor Detail

Complexback to summary
public Complex(double real)

Create a complex number given only the real part.

Parameters
real:double

Real part.

Complexback to summary
public Complex(double real, double imaginary)

Create a complex number given the real and imaginary parts.

Parameters
real:double

Real part.

imaginary:double

Imaginary part.

Method Detail

absback to summary
public double abs()

Return the absolute value of this complex number. Returns NaN if either real or imaginary part is NaN and Double.POSITIVE_INFINITY if neither part is NaN, but at least one part is infinite.

Returns:double

the absolute value.

acosback to summary
public Complex acos()

Compute the inverse cosine of this complex number. Implements the formula:

acos(z) = -i (log(z + i (sqrt(1 - z<sup>2</sup>))))

Returns Complex#NaN if either real or imaginary part of the input argument is NaN or infinite.
Returns:Complex

the inverse cosine of this complex number.

Since
1.2
addback to summary
public Complex add(Complex addend) throws NullArgumentException

Implements org.apache.commons.math3.FieldElement.add.

Returns a Complex whose value is (this + addend). Uses the definitional formula

(a + bi) + (c + di) = (a+c) + (b+d)i

If either this or addend has a NaN value in either part, NaN is returned; otherwise Infinite and NaN values are returned in the parts of the result according to the rules for java.lang.Double arithmetic.
Parameters
addend:Complex

Value to be added to this Complex.

Returns:Complex

this + addend.

Exceptions
NullArgumentException:
if addend is null.
addback to summary
public Complex add(double addend)

Implements org.apache.commons.math3.FieldElement.add.

Returns a Complex whose value is (this + addend), with addend interpreted as a real number.

Parameters
addend:double

Value to be added to this Complex.

Returns:Complex

this + addend.

See Also
add(Complex)
asinback to summary
public Complex asin()

Compute the inverse sine of this complex number. Implements the formula:

asin(z) = -i (log(sqrt(1 - z<sup>2</sup>) + iz))

Returns Complex#NaN if either real or imaginary part of the input argument is NaN or infinite.

Returns:Complex

the inverse sine of this complex number.

Since
1.2
atanback to summary
public Complex atan()

Compute the inverse tangent of this complex number. Implements the formula:

atan(z) = (i/2) log((i + z)/(i - z))

Returns Complex#NaN if either real or imaginary part of the input argument is NaN or infinite.

Returns:Complex

the inverse tangent of this complex number

Since
1.2
conjugateback to summary
public Complex conjugate()

Returns the conjugate of this complex number. The conjugate of a + bi is a - bi.

NaN is returned if either the real or imaginary part of this Complex number equals Double.NaN.

If the imaginary part is infinite, and the real part is not NaN, the returned value has infinite imaginary part of the opposite sign, e.g. the conjugate of 1 + POSITIVE_INFINITY i is 1 - NEGATIVE_INFINITY i.

Returns:Complex

the conjugate of this Complex object.

cosback to summary
public Complex cos()

Compute the cosine of this complex number. Implements the formula:

cos(a + bi) = cos(a)cosh(b) - sin(a)sinh(b)i

where the (real) functions on the right-hand side are FastMath#sin, FastMath#cos, FastMath#cosh and FastMath#sinh.

Returns Complex#NaN if either real or imaginary part of the input argument is NaN.

Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result.

 Examples:
 
  cos(1 ± INFINITY i) = 1 ∓ INFINITY i
  cos(±INFINITY + i) = NaN + NaN i
  cos(±INFINITY ± INFINITY i) = NaN + NaN i
 
Returns:Complex

the cosine of this complex number.

Since
1.2
coshback to summary
public Complex cosh()

Compute the hyperbolic cosine of this complex number. Implements the formula:

 
  cosh(a + bi) = cosh(a)cos(b) + sinh(a)sin(b)i
 
where the (real) functions on the right-hand side are FastMath#sin, FastMath#cos, FastMath#cosh and FastMath#sinh.

Returns Complex#NaN if either real or imaginary part of the input argument is NaN.

Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result.
 Examples:
 
  cosh(1 ± INFINITY i) = NaN + NaN i
  cosh(±INFINITY + i) = INFINITY ± INFINITY i
  cosh(±INFINITY ± INFINITY i) = NaN + NaN i
 
Returns:Complex

the hyperbolic cosine of this complex number.

Since
1.2
createComplexback to summary
protected Complex createComplex(double realPart, double imaginaryPart)

Create a complex number given the real and imaginary parts.

Parameters
realPart:double

Real part.

imaginaryPart:double

Imaginary part.

Returns:Complex

a new complex number instance.

Since
1.2
See Also
valueOf(double, double)
divideback to summary
public Complex divide(Complex divisor) throws NullArgumentException

Implements org.apache.commons.math3.FieldElement.divide.

Returns a Complex whose value is (this / divisor). Implements the definitional formula

 
   a + bi          ac + bd + (bc - ad)i
   ----------- = -------------------------
   c + di         c2 + d2
 
but uses prescaling of operands to limit the effects of overflows and underflows in the computation.

Infinite and NaN values are handled according to the following rules, applied in the order presented:

  • If either this or divisor has a NaN value in either part, NaN is returned.
  • If divisor equals ZERO, NaN is returned.
  • If this and divisor are both infinite, NaN is returned.
  • If this is finite (i.e., has no Infinite or NaN parts) and divisor is infinite (one or both parts infinite), ZERO is returned.
  • If this is infinite and divisor is finite, NaN values are returned in the parts of the result if the java.lang.Double rules applied to the definitional formula force NaN results.
Parameters
divisor:Complex

Value by which this Complex is to be divided.

Returns:Complex

this / divisor.

Exceptions
NullArgumentException:
if divisor is null.
divideback to summary
public Complex divide(double divisor)

Implements org.apache.commons.math3.FieldElement.divide.

Returns a Complex whose value is (this / divisor), with divisor interpreted as a real number.

Parameters
divisor:double

Value by which this Complex is to be divided.

Returns:Complex

this / divisor.

See Also
divide(Complex)
equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Test for equality with another object. If both the real and imaginary parts of two complex numbers are exactly the same, and neither is Double.NaN, the two Complex objects are considered to be equal. The behavior is the same as for JDK's Double:

  • All NaN values are considered to be equal, i.e, if either (or both) real and imaginary parts of the complex number are equal to Double.NaN, the complex number is equal to NaN.
  • Instances constructed with different representations of zero (i.e. either "0" or "-0") are not considered to be equal.
Parameters
other:Object

Object to test for equality with this instance.

Returns:boolean

true if the objects are equal, false if object is null, not an instance of Complex, or not equal to this instance.

Annotations
@Override
equalsback to summary
public static boolean equals(Complex x, Complex y, int maxUlps)

Test for the floating-point equality between Complex objects. It returns true if both arguments are equal or within the range of allowed error (inclusive).

Parameters
x:Complex

First value (cannot be null).

y:Complex

Second value (cannot be null).

maxUlps:int

(maxUlps - 1) is the number of floating point values between the real (resp. imaginary) parts of x and y.

Returns:boolean

true if there are fewer than maxUlps floating point values between the real (resp. imaginary) parts of x and y.

Since
3.3
See Also
Precision#equals(double, double, int)
equalsback to summary
public static boolean equals(Complex x, Complex y)

Returns true iff the values are equal as defined by equals(x, y, 1).

Parameters
x:Complex

First value (cannot be null).

y:Complex

Second value (cannot be null).

Returns:boolean

true if the values are equal.

Since
3.3
equalsback to summary
public static boolean equals(Complex x, Complex y, double eps)

Returns true if, both for the real part and for the imaginary part, there is no double value strictly between the arguments or the difference between them is within the range of allowed error (inclusive). Returns false if either of the arguments is NaN.

Parameters
x:Complex

First value (cannot be null).

y:Complex

Second value (cannot be null).

eps:double

Amount of allowed absolute error.

Returns:boolean

true if the values are two adjacent floating point numbers or they are within range of each other.

Since
3.3
See Also
Precision#equals(double, double, double)
equalsWithRelativeToleranceback to summary
public static boolean equalsWithRelativeTolerance(Complex x, Complex y, double eps)

Returns true if, both for the real part and for the imaginary part, there is no double value strictly between the arguments or the relative difference between them is smaller or equal to the given tolerance. Returns false if either of the arguments is NaN.

Parameters
x:Complex

First value (cannot be null).

y:Complex

Second value (cannot be null).

eps:double

Amount of allowed relative error.

Returns:boolean

true if the values are two adjacent floating point numbers or they are within range of each other.

Since
3.3
See Also
Precision#equalsWithRelativeTolerance(double, double, double)
expback to summary
public Complex exp()

Compute the exponential function of this complex number. Implements the formula:

 
  exp(a + bi) = exp(a)cos(b) + exp(a)sin(b)i
 
where the (real) functions on the right-hand side are FastMath#exp, FastMath#cos, and FastMath#sin.

Returns Complex#NaN if either real or imaginary part of the input argument is NaN.

Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result.
 Examples:
 
  exp(1 ± INFINITY i) = NaN + NaN i
  exp(INFINITY + i) = INFINITY + INFINITY i
  exp(-INFINITY + i) = 0 + 0i
  exp(±INFINITY ± INFINITY i) = NaN + NaN i
 
Returns:Complex

ethis.

Since
1.2
getArgumentback to summary
public double getArgument()

Compute the argument of this complex number. The argument is the angle phi between the positive real axis and the point representing this number in the complex plane. The value returned is between -PI (not inclusive) and PI (inclusive), with negative values returned for numbers with negative imaginary parts.

If either real or imaginary part (or both) is NaN, NaN is returned. Infinite parts are handled as Math.atan2 handles them, essentially treating finite parts as zero in the presence of an infinite coordinate and returning a multiple of pi/4 depending on the signs of the infinite parts. See the javadoc for Math.atan2 for full details.

Returns:double

the argument of this.

getFieldback to summary
public ComplexField getField()

Implements org.apache.commons.math3.FieldElement.getField.

Doc from org.apache.commons.math3.FieldElement.getField.

Get the Field to which the instance belongs.

Returns:ComplexField

Field to which the instance belongs

getImaginaryback to summary
public double getImaginary()

Access the imaginary part.

Returns:double

the imaginary part.

getRealback to summary
public double getReal()

Access the real part.

Returns:double

the real part.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Get a hashCode for the complex number. Any Double.NaN value in real or imaginary part produces the same hash code 7.

Returns:int

a hash code value for this object.

Annotations
@Override
isInfiniteback to summary
public boolean isInfinite()

Checks whether 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:boolean

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

isNaNback to summary
public boolean isNaN()

Checks whether either or both parts of this complex number is NaN.

Returns:boolean

true if either or both parts of this complex number is NaN; false otherwise.

logback to summary
public Complex log()

Compute the natural logarithm of this complex number. Implements the formula:

 
  log(a + bi) = ln(|a + bi|) + arg(a + bi)i
 
where ln on the right hand side is FastMath#log, |a + bi| is the modulus, Complex#abs, and arg(a + bi) = FastMath#atan2(b, a).

Returns Complex#NaN if either real or imaginary part of the input argument is NaN.

Infinite (or critical) values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result.
 Examples:
 
  log(1 ± INFINITY i) = INFINITY ± (π/2)i
  log(INFINITY + i) = INFINITY + 0i
  log(-INFINITY + i) = INFINITY + πi
  log(INFINITY ± INFINITY i) = INFINITY ± (π/4)i
  log(-INFINITY ± INFINITY i) = INFINITY ± (3π/4)i
  log(0 + 0i) = -INFINITY + 0i
 
Returns:Complex

the value ln   this, the natural logarithm of this.

Since
1.2
multiplyback to summary
public Complex multiply(Complex factor) throws NullArgumentException

Implements org.apache.commons.math3.FieldElement.multiply.

Returns a Complex whose value is this * factor. Implements preliminary checks for NaN and infinity followed by the definitional formula:

(a + bi)(c + di) = (ac - bd) + (ad + bc)i

Returns NaN if either this or factor has one or more NaN parts.

Returns INF if neither this nor factor has one or more NaN parts and if either this or factor has one or more infinite parts (same result is returned regardless of the sign of the components).

Returns finite values in components of the result per the definitional formula in all remaining cases.

Parameters
factor:Complex

value to be multiplied by this Complex.

Returns:Complex

this * factor.

Exceptions
NullArgumentException:
if factor is null.
multiplyback to summary
public Complex multiply(final int factor)

Implements org.apache.commons.math3.FieldElement.multiply, org.apache.commons.math3.FieldElement.multiply.

Returns a Complex whose value is this * factor, with factor interpreted as a integer number.

Parameters
factor:int

value to be multiplied by this Complex.

Returns:Complex

this * factor.

See Also
multiply(Complex)
multiplyback to summary
public Complex multiply(double factor)

Implements org.apache.commons.math3.FieldElement.multiply.

Returns a Complex whose value is this * factor, with factor interpreted as a real number.

Parameters
factor:double

value to be multiplied by this Complex.

Returns:Complex

this * factor.

See Also
multiply(Complex)
negateback to summary
public Complex negate()

Implements org.apache.commons.math3.FieldElement.negate.

Returns a Complex whose value is (-this). Returns NaN if either real or imaginary part of this Complex number is Double.NaN.

Returns:Complex

-this.

nthRootback to summary
public List<Complex> nthRoot(int n) throws NotPositiveException

Computes the n-th roots of this complex number. The nth roots are defined by the formula:

 
  zk = abs1/n (cos(phi + 2πk/n) + i (sin(phi + 2πk/n))
 
for k=0, 1, ..., n-1, where abs and phi are respectively the modulus and argument of this complex number.

If one or both parts of this complex number is NaN, a list with just one element, NaN is returned. if neither part is NaN, but at least one part is infinite, the result is a one-element list containing INF.

Parameters
n:int

Degree of root.

Returns:List<Complex>

a List of all n-th roots of this.

Exceptions
NotPositiveException:
if n <= 0.
Since
2.0
powback to summary
public Complex pow(Complex x) throws NullArgumentException

Returns of value of this complex number raised to the power of x. Implements the formula:

 
  yx = exp(x·log(y))
 
where exp and log are exp and log, respectively.

Returns Complex#NaN if either real or imaginary part of the input argument is NaN or infinite, or if y equals Complex#ZERO.

Parameters
x:Complex

exponent to which this Complex is to be raised.

Returns:Complex

thisx.

Exceptions
NullArgumentException:
if x is null.
Since
1.2
powback to summary
public Complex pow(double x)

Returns of value of this complex number raised to the power of x.

Parameters
x:double

exponent to which this Complex is to be raised.

Returns:Complex

thisx.

See Also
pow(Complex)
readResolveback to summary
protected final Object readResolve()

Resolve the transient fields in a deserialized Complex Object. Subclasses will need to override createComplex to deserialize properly.

Returns:Object

A Complex instance with all fields resolved.

Since
2.0
reciprocalback to summary
public Complex reciprocal()

Implements org.apache.commons.math3.FieldElement.reciprocal.

Doc from org.apache.commons.math3.FieldElement.reciprocal.

Returns the multiplicative inverse of this element.

Returns:Complex

the inverse of this.

sinback to summary
public Complex sin()

Compute the sine of this complex number. Implements the formula:

 
  sin(a + bi) = sin(a)cosh(b) - cos(a)sinh(b)i
 
where the (real) functions on the right-hand side are FastMath#sin, FastMath#cos, FastMath#cosh and FastMath#sinh.

Returns Complex#NaN if either real or imaginary part of the input argument is NaN.

Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result.

 Examples:
 
  sin(1 ± INFINITY i) = 1 ± INFINITY i
  sin(±INFINITY + i) = NaN + NaN i
  sin(±INFINITY ± INFINITY i) = NaN + NaN i
 
Returns:Complex

the sine of this complex number.

Since
1.2
sinhback to summary
public Complex sinh()

Compute the hyperbolic sine of this complex number. Implements the formula:

 
  sinh(a + bi) = sinh(a)cos(b)) + cosh(a)sin(b)i
 
where the (real) functions on the right-hand side are FastMath#sin, FastMath#cos, FastMath#cosh and FastMath#sinh.

Returns Complex#NaN if either real or imaginary part of the input argument is NaN.

Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result.

 Examples:
 
  sinh(1 ± INFINITY i) = NaN + NaN i
  sinh(±INFINITY + i) = ± INFINITY + INFINITY i
  sinh(±INFINITY ± INFINITY i) = NaN + NaN i
 
Returns:Complex

the hyperbolic sine of this.

Since
1.2
sqrtback to summary
public Complex sqrt()

Compute the square root of this complex number. Implements the following algorithm to compute sqrt(a + bi):

  1. Let t = sqrt((|a| + |a + bi|) / 2)
  2. if a ≥ 0 return t + (b/2t)i
     else return |b|/2t + sign(b)t i 
where

Returns Complex#NaN if either real or imaginary part of the input argument is NaN.

Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result.
 Examples:
 
  sqrt(1 ± INFINITY i) = INFINITY + NaN i
  sqrt(INFINITY + i) = INFINITY + 0i
  sqrt(-INFINITY + i) = 0 + INFINITY i
  sqrt(INFINITY ± INFINITY i) = INFINITY + NaN i
  sqrt(-INFINITY ± INFINITY i) = NaN ± INFINITY i
 
Returns:Complex

the square root of this.

Since
1.2
sqrt1zback to summary
public Complex sqrt1z()

Compute the square root of 1 - this2 for this complex number. Computes the result directly as sqrt(ONE.subtract(z.multiply(z))).

Returns Complex#NaN if either real or imaginary part of the input argument is NaN.

Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result.
Returns:Complex

the square root of 1 - this2.

Since
1.2
subtractback to summary
public Complex subtract(Complex subtrahend) throws NullArgumentException

Implements org.apache.commons.math3.FieldElement.subtract.

Returns a Complex whose value is (this - subtrahend). Uses the definitional formula

(a + bi) - (c + di) = (a-c) + (b-d)i

If either this or subtrahend has a NaN] value in either part, NaN is returned; otherwise infinite and NaN values are returned in the parts of the result according to the rules for java.lang.Double arithmetic.
Parameters
subtrahend:Complex

value to be subtracted from this Complex.

Returns:Complex

this - subtrahend.

Exceptions
NullArgumentException:
if subtrahend is null.
subtractback to summary
public Complex subtract(double subtrahend)

Implements org.apache.commons.math3.FieldElement.subtract.

Returns a Complex whose value is (this - subtrahend).

Parameters
subtrahend:double

value to be subtracted from this Complex.

Returns:Complex

this - subtrahend.

See Also
subtract(Complex)
tanback to summary
public Complex tan()

Compute the tangent of this complex number. Implements the formula:

 
  tan(a + bi) = sin(2a)/(cos(2a)+cosh(2b)) + [sinh(2b)/(cos(2a)+cosh(2b))]i
 
where the (real) functions on the right-hand side are FastMath#sin, FastMath#cos, FastMath#cosh and FastMath#sinh.

Returns Complex#NaN if either real or imaginary part of the input argument is NaN.

Infinite (or critical) values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result.
 Examples:
 
  tan(a ± INFINITY i) = 0 ± i
  tan(±INFINITY + bi) = NaN + NaN i
  tan(±INFINITY ± INFINITY i) = NaN + NaN i
  tan(±π/2 + 0 i) = ±INFINITY + NaN i
 
Returns:Complex

the tangent of this.

Since
1.2
tanhback to summary
public Complex tanh()

Compute the hyperbolic tangent of this complex number. Implements the formula:

 
  tan(a + bi) = sinh(2a)/(cosh(2a)+cos(2b)) + [sin(2b)/(cosh(2a)+cos(2b))]i
 
where the (real) functions on the right-hand side are FastMath#sin, FastMath#cos, FastMath#cosh and FastMath#sinh.

Returns Complex#NaN if either real or imaginary part of the input argument is NaN.

Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result.
 Examples:
 
  tanh(a ± INFINITY i) = NaN + NaN i
  tanh(±INFINITY + bi) = ±1 + 0 i
  tanh(±INFINITY ± INFINITY i) = NaN + NaN i
  tanh(0 + (π/2)i) = NaN + INFINITY i
 
Returns:Complex

the hyperbolic tangent of this.

Since
1.2
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
valueOfback to summary
public static Complex valueOf(double realPart, double imaginaryPart)

Create a complex number given the real and imaginary parts.

Parameters
realPart:double

Real part.

imaginaryPart:double

Imaginary part.

Returns:Complex

a Complex instance.

valueOfback to summary
public static Complex valueOf(double realPart)

Create a complex number given only the real part.

Parameters
realPart:double

Real part.

Returns:Complex

a Complex instance.