Class Complex
Representation of a complex number
CKA NOTES:
· I added a few methods to this class as I need additional operations for complex numbers. These methods are clearly identified in case there are issues.· I changed class attribute names from
REAL
and
IMAGINARY
to dblReal
and dblImag
because Eclipse kept yelling at me for having capitalized variable names (a
violation of "convention"). There are no other compelling reasons to keep the
current names and should be switched back if seen fit.
- Version:
- Sep 30, 2015, Christopher Allen
- Author:
- tp6
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal Complex
complex conjugatestatic Complex
Compute and return the trigonometric cosine function of the given complex number s.static Complex
Compute and return the hyperbolic cosine function of the given complex number s.final Complex
divide
(double divisor) complex divisionfinal Complex
complex divisionstatic Complex
euler
(double ang) Computes and returns the complex number z on the unit circle corresponding to the mapping of the given real number by the Euler formula.static Complex
Compute and return the exponential of the given complex number s.final double
get the imaginary partstatic Complex
Compute and return the natural logarithm of the given complex number s.final Complex
minus
(double subtrahend) complex subtractionfinal Complex
complex subtractionfinal double
modulus()
modulus of this complex numberfinal double
modulus squared of this complex numberfinal Complex
negate()
calculate the negative of this complex numberfinal double
phase()
get the phasefinal Complex
plus
(double addend) complex additionfinal Complex
complex additionfinal double
real()
get the real partfinal Complex
calculate the reciprocal of this complex numberstatic Complex
Compute and return the trigonometric sine function of the given complex number s.static Complex
Compute and return the hyperbolic sine function of the given complex number s.static Complex
Computes the complex square root of this complex number s.final Complex
times
(double multiplier) complex multiplicationfinal Complex
complex multiplicationtoString()
Get a string representation of this complex number
-
Field Details
-
ZERO
The complex value zero -
ONE
the real unit -
IUNIT
the imaginary unit
-
-
Constructor Details
-
Complex
public Complex(double realPart, double imaginaryPart) Primary constructor -
Complex
public Complex(double realPart) Constructor with pure real number
-
-
Method Details
-
sqrt
Computes the complex square root of this complex number s.- Parameters:
s
- complex number on which to operate- Returns:
- value of √s
- Since:
- Sep 30, 2015, Christopher K. Allen
-
log
Compute and return the natural logarithm of the given complex number s. The value is given by
log(s) = ln(|s|) + i arg(s)
where ln is the real-valued natural logarithm function and arg is the angle of s in the complex plane.- Parameters:
s
- complex number on which to operate- Returns:
- the value of ln(s) ∈ ℂ
- Since:
- Sep 30, 2015, Christopher K. Allen
-
exp
Compute and return the exponential of the given complex number s. The value is given by the formula
exp(s) = exp(σ)[cos(ω) + i sin(ω)]
where s = σ + iω and σ, ω ∈ ℝ.- Parameters:
s
- complex number on which to operate- Returns:
- this result of exponentiating this complex number
- Since:
- Sep 30, 2015, Christopher K. Allen
-
euler
Computes and returns the complex number z on the unit circle corresponding to the mapping of the given real number by the Euler formula. The returned values is given by
z = cos θ + i sin θ ,
where θ is the real number given in the argument.- Parameters:
ang
- the real number θ (in radians)- Returns:
- the value of z described above
- Since:
- Oct 7, 2015, Christopher K. Allen
-
sin
Compute and return the trigonometric sine function of the given complex number s. The formula for the returned value is
sin(s) = sin(σ)cosh(ω) - i cos(σ)sinh(ω)
where where s = σ + iω and σ, ω ∈ ℝ.- Parameters:
s
- complex number on which to operate- Returns:
- the complex sine of the argument
- Since:
- Sep 30, 2015, Christopher K. Allen
-
sinh
Compute and return the hyperbolic sine function of the given complex number s. The formula for the returned value is
sinh(s) = sinh(σ)cos(ω) + i cosh(σ)sin(ω)
where where s = σ + iω and σ, ω ∈ ℝ.- Parameters:
s
- complex number on which to operate- Returns:
- the complex hyperbolic sine of the argument
- Since:
- Sep 30, 2015, Christopher K. Allen
-
cos
Compute and return the trigonometric cosine function of the given complex number s. The formula for the returned value is
cos(s) = cos(σ)cosh(ω) - i sin(σ)sinh(ω)
where where s = σ + iω and σ, ω ∈ ℝ.- Parameters:
s
- complex number on which to operate- Returns:
- the complex cosine of the argument
- Since:
- Sep 30, 2015, Christopher K. Allen
-
cosh
Compute and return the hyperbolic cosine function of the given complex number s. The formula for the returned value is
cosh(s) = cosh(σ)cos(ω) + i sinh(σ)sin(ω)
where where s = σ + iω and σ, ω ∈ ℝ.- Parameters:
s
- complex number on which to operate- Returns:
- the complex hyperbolic sine of the argument
- Since:
- Sep 30, 2015, Christopher K. Allen
-
toString
Get a string representation of this complex number -
real
public final double real()get the real part -
imaginary
public final double imaginary()get the imaginary part -
modulus
public final double modulus()modulus of this complex number -
phase
public final double phase()get the phase -
modulusSquared
public final double modulusSquared()modulus squared of this complex number -
conjugate
complex conjugate -
reciprocal
calculate the reciprocal of this complex number -
times
complex multiplication -
times
complex multiplication -
divide
complex division -
divide
complex division -
plus
complex addition -
plus
complex addition -
negate
calculate the negative of this complex number -
minus
complex subtraction -
minus
complex subtraction
-