Package math.complex
Class ComplexNumber
java.lang.Object
math.complex.ComplexNumber
public class ComplexNumber
extends java.lang.Object
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.
- Author:
- JIBOYE Oluwagbemiro Olaoluwa
-
Field Summary
Fields Modifier and Type Field Description static java.lang.Stringradical -
Constructor Summary
Constructors Constructor Description ComplexNumber(double real, double imag, ComplexState state)The 2 double arguments have interpretations that vary with the state argument. -
Method Summary
Modifier and Type Method Description doubleabs()Finds the absolute value of this objectComplexNumberadd(ComplexNumber complexNumber)Adds two ComplexNumber objectsComplexNumbercos()ComplexNumbercosh()ComplexNumbercot()ComplexNumbercoth()ComplexNumbercsc()ComplexNumbercsch()ComplexNumberdivide(ComplexNumber complexNumber)Divides this ComplexNumber object by the parameter ComplexNumber object.ComplexNumberexp()doublegetAngle()ComplexNumbergetConjugate()doublegetImag()static java.lang.StringgetRadical()doublegetRadius()doublegetReal()ComplexStategetState()ComplexNumberinverse()ComplexNumberlog()static voidmain(java.lang.String[] args)ComplexNumberminus(ComplexNumber complexNumber)Subtracts the parameter ComplexNumber object from this ComplexNumber object.ComplexNumbermultiply(ComplexNumber complexNumber)Multiplies this ComplexNumber object by the parameter ComplexNumber object.ComplexNumberpow(double n)ComplexNumberscalarDivide(double number)Divides this ComplexNumber object by the number.ComplexNumberscalarMultiply(double number)Multiplies this ComplexNumber object by the number.ComplexNumbersec()ComplexNumbersech()voidsetImag(double imag)voidsetReal(double real)voidsetState(ComplexState state)ComplexNumbersin()ComplexNumbersinh()ComplexNumbertan()ComplexNumbertanh()java.lang.StringtoString()
-
Field Details
-
radical
public static final java.lang.String radical- See Also:
- Constant Field Values
-
-
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
public static java.lang.String 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
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
main
public static void main(java.lang.String[] args)
-