Package math.complex

Class 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
    • Constructor Detail

      • ComplexNumber

        public ComplexNumber​(double real,
                             double imag,
                             ComplexState state)
        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 POLAR
        state - The state of the ComplexNumber object, POLAR or CARTESIAN.
    • Method Detail

      • 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()
      • getAngle

        public double getAngle()
        Returns:
        the angle of this object
      • getRadius

        public double getRadius()
        Returns:
        the radius of this object
      • add

        public ComplexNumber add​(ComplexNumber complexNumber)
        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

        public ComplexNumber minus​(ComplexNumber complexNumber)
        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

        public ComplexNumber multiply​(ComplexNumber complexNumber)
        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

        public ComplexNumber divide​(ComplexNumber complexNumber)
        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

        public ComplexNumber scalarDivide​(double number)
        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

        public ComplexNumber scalarMultiply​(double number)
        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

        public ComplexNumber 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

        public ComplexNumber log()
        Returns:
        the natural logarithm of a ComplexNumber object and stores the result in a new object.
      • exp

        public ComplexNumber exp()
        Returns:
        the exponent of a CompleNumber object(e^Z) as a new ComplexNumber object.
      • inverse

        public ComplexNumber inverse()
        Returns:
        the inverse of this object
      • pow

        public ComplexNumber pow​(double n)
        Parameters:
        n - The power to raise the ComplexNumber object to.
        Returns:
        the nth power of the ComplexNumber object.
      • sin

        public ComplexNumber sin()
        Returns:
        the sin of the ComplexNumber object.
      • cos

        public ComplexNumber cos()
        Returns:
        the cosine of the ComplexNumber object.
      • tan

        public ComplexNumber tan()
        Returns:
        the tangent of this ComplexNumber object
      • sec

        public ComplexNumber sec()
        Returns:
        the secant of this ComplexNumber object
      • csc

        public ComplexNumber csc()
        Returns:
        the cosecant of this ComplexNumber object
      • cot

        public ComplexNumber cot()
        Returns:
        the cotangent of this ComplexNumber object
      • sinh

        public ComplexNumber sinh()
        Returns:
        the hyperbolic sine of this ComplexNumber object
      • cosh

        public ComplexNumber cosh()
        Returns:
        the hyperbolic cosine of this ComplexNumber object
      • tanh

        public ComplexNumber tanh()
        Returns:
        the hyperbolic tangent of this ComplexNumber object
      • sech

        public ComplexNumber sech()
        Returns:
        the hyperbolic secant of this ComplexNumber object
      • csch

        public ComplexNumber csch()
        Returns:
        the hyperbolic cosecant of this ComplexNumber object
      • coth

        public ComplexNumber coth()
        Returns:
        the hyperbolic cotangent of this ComplexNumber object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • main

        public static void main​(java.lang.String[] args)