Class Complex
- All Implemented Interfaces:
AbelianGroup<Complex>, AbelianMonoid<Complex>, Group<Complex>, Magma<Complex>, Monoid<Complex>, Field<Complex>, FieldElement<Complex>, Ring<Complex>, RingElement<Complex>, Semiring<Complex>, Set<Complex>
Complex numbers form a Field under addition and multiplication.
* @author Silvere Martin-Michiellot- Since:
- 1.0
- Author:
- Gemini AI (Google DeepMind)
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionabs()acos()Returns the arccosine of this complex number. acos(z) = -i * log(z + i*sqrt(1 - z^2))acosh()Returns the inverse hyperbolic cosine of this complex number. acosh(z) = log(z + sqrt(z^2 - 1))Returns the sum of this element and another.Returns the sum of two elements (additive notation).arg()asin()Returns the arcsine of this complex number. asin(z) = -i * log(iz + sqrt(1 - z^2))asinh()Returns the inverse hyperbolic sine of this complex number. asinh(z) = log(z + sqrt(z^2 + 1))atan()Returns the arctangent of this complex number. atan(z) = (i/2) * log((1-iz)/(1+iz))atanh()Returns the inverse hyperbolic tangent of this complex number. atanh(z) = 0.5 * log((1 + z) / (1 - z))cbrt()Returns the cube root of this complex number. cbrt(z) = z^(1/3)intReturns the characteristic of this field.booleanTests whether this set contains the specified element.cos()Returns the cosine of this complex number. cos(a + bi) = cos(a)cosh(b) - i*sin(a)sinh(b)cosh()Returns the hyperbolic cosine of this complex number. cosh(z) = (exp(z) + exp(-z)) / 2Returns a human-readable description of this set.Returns this element divided by another.Returns the quotient of two elements (division).booleanexp()Returns e raised to this complex number. exp(a + bi) = e^a * (cos(b) + i*sin(b))getReal()inthashCode()doubleReturns the imaginary part as a double.inverse()Returns the multiplicative inverse of this element.Returns the multiplicative inverse of a non-zero element.booleanisEmpty()Returnstrueif this set contains no elements.booleanFields always have commutative multiplication.booleanisNaN()log()Returns the natural logarithm of this complex number. log(z) = ln(|z|) + i*arg(z)log10()Returns the base-10 logarithm of this complex number. log10(z) = log(z) / log(10)Returns the product of this element and another.Returns the product of two elements.negate()Returns the additive inverse of this element.Returns the additive inverse (negation) of an element.static Complexof(double real) static Complexof(double real, double imaginary) static Complexof(float real) static Complexof(float real, float imaginary) static Complexstatic Complexstatic ComplexofPolar(double magnitude, double phase) one()Returns the multiplicative identity (one element).Performs the binary operation on two elements.pow(double exponent) Returns this complex number raised to a double power.Returns this complex number raised to a complex power. z^w = exp(w * log(z))doublereal()Returns the real part as a double.Alias for inverse() to satisfy certain matrix operation requirements.ring()Returns the ring structure for complex numbers.sin()Returns the sine of this complex number. sin(a + bi) = sin(a)cosh(b) + i*cos(a)sinh(b)sinh()Returns the hyperbolic sine of this complex number. sinh(z) = (exp(z) - exp(-z)) / 2sqrt()Returns the difference of this element and another.Returns the difference of two elements.tan()Returns the tangent of this complex number. tan(z) = sin(z) / cos(z)tanh()Returns the hyperbolic tangent of this complex number. tanh(z) = sinh(z) / cosh(z)toString()static Complexstatic Complexzero()Returns the additive identity (zero element).Methods inherited from interface AbelianGroup
isCommutativeMethods inherited from interface AbelianMonoid
identity, isCommutativeMethods inherited from interface Monoid
isAssociativeMethods inherited from interface RingElement
isOne, isZero
-
Field Details
-
ZERO
-
ONE
-
I
-
-
Method Details
-
of
-
of
-
of
-
of
-
of
-
of
-
ofPolar
-
valueOf
-
valueOf
-
getReal
-
getImaginary
-
isNaN
public boolean isNaN() -
real
public double real()Returns the real part as a double.- Returns:
- the real part
-
imaginary
public double imaginary()Returns the imaginary part as a double.- Returns:
- the imaginary part
-
operate
Description copied from interface:MagmaPerforms the binary operation on two elements.This is the fundamental operation of a magma. The result must be an element of this magma (closure property).
Properties: None required (not necessarily associative or commutative)
-
add
Description copied from interface:AbelianMonoidReturns the sum of two elements (additive notation).Delegates to
Magma.operate(Object, Object).- Specified by:
addin interfaceAbelianMonoid<Complex>- Parameters:
a- the first addendb- the second addend- Returns:
- a + b
-
add
Description copied from interface:RingElementReturns the sum of this element and another.- Specified by:
addin interfaceRingElement<Complex>- Parameters:
other- the element to add- Returns:
- this + other
-
zero
Description copied from interface:AbelianMonoidReturns the additive identity (zero element).Delegates to
AbelianMonoid.identity().- Specified by:
zeroin interfaceAbelianMonoid<Complex>- Specified by:
zeroin interfaceRingElement<Complex>- Returns:
- the zero element
-
negate
Description copied from interface:AbelianGroupReturns the additive inverse (negation) of an element.Satisfies: a + (-a) = (-a) + a = 0
- Specified by:
negatein interfaceAbelianGroup<Complex>- Parameters:
a- the element to negate- Returns:
- -element
- See Also:
-
negate
Description copied from interface:RingElementReturns the additive inverse of this element.- Specified by:
negatein interfaceRingElement<Complex>- Returns:
- -this
-
subtract
Description copied from interface:AbelianGroupReturns the difference of two elements.Defined as: a - b = a + (-b)
- Specified by:
subtractin interfaceAbelianGroup<Complex>- Parameters:
a- the minuendb- the subtrahend- Returns:
- a - b
- See Also:
-
subtract
Description copied from interface:RingElementReturns the difference of this element and another.Default implementation:
this.add(other.negate())- Specified by:
subtractin interfaceRingElement<Complex>- Parameters:
other- the element to subtract- Returns:
- this - other
-
multiply
Description copied from interface:SemiringReturns the product of two elements.Multiplication must be associative and distribute over addition.
-
multiply
Description copied from interface:RingElementReturns the product of this element and another.- Specified by:
multiplyin interfaceRingElement<Complex>- Parameters:
other- the element to multiply- Returns:
- this * other
-
one
Description copied from interface:SemiringReturns the multiplicative identity (one element).Satisfies: 1 × a = a × 1 = a for all elements a.
-
isMultiplicationCommutative
public boolean isMultiplicationCommutative()Description copied from interface:FieldFields always have commutative multiplication.- Specified by:
isMultiplicationCommutativein interfaceField<Complex>- Specified by:
isMultiplicationCommutativein interfaceSemiring<Complex>- Returns:
- always
true
-
inverse
Description copied from interface:FieldReturns the multiplicative inverse of a non-zero element.For element a ≠0, returns a⻹ such that: a × a⻹ = a⻹ × a = 1
Examples:
- In ℚ: inverse(2/3) = 3/2
- In â„Â: inverse(5.0) = 0.2
- In â„‚: inverse(3+4i) = (3-4i)/25
-
inverse
Description copied from interface:FieldElementReturns the multiplicative inverse of this element.For any non-zero element e: e.multiply(e.inverse()) = e.one()
- Specified by:
inversein interfaceFieldElement<Complex>- Returns:
- 1/this
-
reciprocal
Alias for inverse() to satisfy certain matrix operation requirements.- Returns:
- 1/this
-
divide
Description copied from interface:FieldReturns the quotient of two elements (division).Defined as: a ÷ b = a × b⻹
-
divide
Description copied from interface:FieldElementReturns this element divided by another.Default implementation:
this.multiply(other.inverse())- Specified by:
dividein interfaceFieldElement<Complex>- Parameters:
other- the divisor- Returns:
- this / other
-
conjugate
-
abs
-
sqrt
-
arg
-
exp
Returns e raised to this complex number. exp(a + bi) = e^a * (cos(b) + i*sin(b))- Returns:
- e^this
-
log
Returns the natural logarithm of this complex number. log(z) = ln(|z|) + i*arg(z)- Returns:
- ln(this)
-
pow
-
pow
Returns this complex number raised to a double power.- Parameters:
exponent- the exponent- Returns:
- this^exponent
-
sin
Returns the sine of this complex number. sin(a + bi) = sin(a)cosh(b) + i*cos(a)sinh(b)- Returns:
- sin(this)
-
cos
Returns the cosine of this complex number. cos(a + bi) = cos(a)cosh(b) - i*sin(a)sinh(b)- Returns:
- cos(this)
-
tan
Returns the tangent of this complex number. tan(z) = sin(z) / cos(z)- Returns:
- tan(this)
-
asin
Returns the arcsine of this complex number. asin(z) = -i * log(iz + sqrt(1 - z^2))- Returns:
- asin(this)
-
acos
Returns the arccosine of this complex number. acos(z) = -i * log(z + i*sqrt(1 - z^2))- Returns:
- acos(this)
-
atan
Returns the arctangent of this complex number. atan(z) = (i/2) * log((1-iz)/(1+iz))- Returns:
- atan(this)
-
sinh
Returns the hyperbolic sine of this complex number. sinh(z) = (exp(z) - exp(-z)) / 2- Returns:
- sinh(this)
-
cosh
Returns the hyperbolic cosine of this complex number. cosh(z) = (exp(z) + exp(-z)) / 2- Returns:
- cosh(this)
-
tanh
Returns the hyperbolic tangent of this complex number. tanh(z) = sinh(z) / cosh(z)- Returns:
- tanh(this)
-
asinh
Returns the inverse hyperbolic sine of this complex number. asinh(z) = log(z + sqrt(z^2 + 1))- Returns:
- asinh(this)
-
acosh
Returns the inverse hyperbolic cosine of this complex number. acosh(z) = log(z + sqrt(z^2 - 1))- Returns:
- acosh(this)
-
atanh
Returns the inverse hyperbolic tangent of this complex number. atanh(z) = 0.5 * log((1 + z) / (1 - z))- Returns:
- atanh(this)
-
log10
Returns the base-10 logarithm of this complex number. log10(z) = log(z) / log(10)- Returns:
- log10(this)
-
cbrt
Returns the cube root of this complex number. cbrt(z) = z^(1/3)- Returns:
- cube root of this
-
toString
-
equals
-
hashCode
-
characteristic
public int characteristic()Description copied from interface:FieldReturns the characteristic of this field.The characteristic is the smallest positive integer n such that:
1 + 1 + ... + 1 (n times) = 0
If no such n exists, the characteristic is 0.Examples:
- char(ℚ) = char(â„Â) = char(â„‚) = 0
- char(ðÂâ€Â½Ã¢â€šÅ¡) = p (for prime p)
- Specified by:
characteristicin interfaceField<Complex>- Returns:
- the characteristic (0 for infinite fields, p for finite fields)
-
contains
Description copied from interface:SetTests whether this set contains the specified element.This is the fundamental operation of a set - membership testing.
-
description
Description copied from interface:SetReturns a human-readable description of this set.Examples:
- "â„ (Real Numbers)"
- "ℤ/12ℤ (Integers modulo 12)"
- "{1, 2, 3, 4, 5}"
- Specified by:
descriptionin interfaceSet<Complex>- Returns:
- a description of this set
-
isEmpty
public boolean isEmpty()Description copied from interface:SetReturnstrueif this set contains no elements.The empty set (∅) is a fundamental concept in set theory. It is the unique set containing no elements.
-
ring
-
getScalarRing
-