Package math.complex
Class ComplexNumber
java.lang.Object
math.complex.ComplexNumber
Objects of this class model complex numbers.
Before creation, the object data could be in polar, rectangular(cartesian) or exponential
form, but once created, all states revert to cartesian.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionComplexNumber
(double real, double imag, ComplexState state) The 2 double arguments have interpretations that vary with the state argument. -
Method Summary
Modifier and TypeMethodDescriptiondouble
abs()
Finds the absolute value of this objectadd
(ComplexNumber complexNumber) Adds two ComplexNumber objectscos()
cosh()
cot()
coth()
csc()
csch()
divide
(ComplexNumber complexNumber) Divides this ComplexNumber object by the parameter ComplexNumber object.exp()
double
getAngle()
double
getImag()
static String
double
double
getReal()
getState()
inverse()
log()
static void
minus
(ComplexNumber complexNumber) Subtracts the parameter ComplexNumber object from this ComplexNumber object.multiply
(ComplexNumber complexNumber) Multiplies this ComplexNumber object by the parameter ComplexNumber object.pow
(double n) scalarDivide
(double number) Divides this ComplexNumber object by the number.scalarMultiply
(double number) Multiplies this ComplexNumber object by the number.sec()
sech()
void
setImag
(double imag) void
setReal
(double real) void
setState
(ComplexState state) sin()
sinh()
tan()
tanh()
toString()
-
Field Details
-
real
private double real -
imag
private double imag -
radical
- See Also:
-
state
-
-
Constructor Details
-
ComplexNumber
The 2 double arguments have interpretations that vary with the state argument. If state = POLAR , then the first double argument represents the radius or absolute value of the ComplexNumber and the second double argument represents its angle. If state = CARTESIAN , then the first double argument represents the real part of the complex number and the second one represents its imaginary part. If state = EXPONENTIAL, then the first argument represents the radius or absolute value of the ComplexNumber and the second double argument represents its angle just as in the Polar form.- Parameters:
real
- The real part in CARTESIAN and the radius in POLAR.imag
- The imaginary part in CARTESIAN and the angle in POLARstate
- The state of the ComplexNumber object, POLAR or CARTESIAN.
-
-
Method Details
-
getImag
public double getImag() -
setImag
public void setImag(double imag) -
getReal
public double getReal() -
setReal
public void setReal(double real) -
getRadical
-
setState
-
getState
-
getAngle
public double getAngle()- Returns:
- the angle of this object
-
getRadius
public double getRadius()- Returns:
- the radius of this object
-
add
Adds two ComplexNumber objects- Parameters:
complexNumber
- The ComplexNumber object to add to this one.- Returns:
- the sum of the two objects as a new ComplexNumber object.
-
minus
Subtracts the parameter ComplexNumber object from this ComplexNumber object.- Parameters:
complexNumber
- The ComplexNumber object to subtract from this one.- Returns:
- the difference of the two objects as a new ComplexNumber object.
-
multiply
Multiplies this ComplexNumber object by the parameter ComplexNumber object.- Parameters:
complexNumber
- The ComplexNumber object to be employed in multiplying this one.- Returns:
- the product of the two objects as a new ComplexNumber object.
-
divide
Divides this ComplexNumber object by the parameter ComplexNumber object.- Parameters:
complexNumber
- The ComplexNumber object to be employed in dividing this one.- Returns:
- the division of the two objects as a new ComplexNumber object.
-
scalarDivide
Divides this ComplexNumber object by the number.- Parameters:
number
- The scalar to be used in dividing this object- Returns:
- a scaled version of this object stored in a new object.
-
scalarMultiply
Multiplies this ComplexNumber object by the number.- Parameters:
number
- The scalar to be used in multiplying this object- Returns:
- a magnified version of this object stored in a new object.
-
getConjugate
- Returns:
- the conjugate of this object.
-
abs
public double abs()Finds the absolute value of this object- Returns:
- the absolute value of this objet.
-
log
- Returns:
- the natural logarithm of a ComplexNumber object and stores the result in a new object.
-
exp
- Returns:
- the exponent of a CompleNumber object(e^Z) as a new ComplexNumber object.
-
inverse
- Returns:
- the inverse of this object
-
pow
- Parameters:
n
- The power to raise the ComplexNumber object to.- Returns:
- the nth power of the ComplexNumber object.
-
sin
- Returns:
- the sin of the ComplexNumber object.
-
cos
- Returns:
- the cosine of the ComplexNumber object.
-
tan
- Returns:
- the tangent of this ComplexNumber object
-
sec
- Returns:
- the secant of this ComplexNumber object
-
csc
- Returns:
- the cosecant of this ComplexNumber object
-
cot
- Returns:
- the cotangent of this ComplexNumber object
-
sinh
- Returns:
- the hyperbolic sine of this ComplexNumber object
-
cosh
- Returns:
- the hyperbolic cosine of this ComplexNumber object
-
tanh
- Returns:
- the hyperbolic tangent of this ComplexNumber object
-
sech
- Returns:
- the hyperbolic secant of this ComplexNumber object
-
csch
- Returns:
- the hyperbolic cosecant of this ComplexNumber object
-
coth
- Returns:
- the hyperbolic cotangent of this ComplexNumber object
-
toString
-
main
-