Class Complex

java.lang.Object
xal.tools.math.Complex

public class Complex extends Object

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
    Modifier and Type
    Field
    Description
    static final Complex
    the imaginary unit
    static final Complex
    the real unit
    static final Complex
    The complex value zero
  • Constructor Summary

    Constructors
    Constructor
    Description
    Complex(double realPart)
    Constructor with pure real number
    Complex(double realPart, double imaginaryPart)
    Primary constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    final Complex
    complex conjugate
    static 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 division
    final Complex
    divide(Complex divisor)
    complex division
    static 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 part
    static Complex
    Compute and return the natural logarithm of the given complex number s.
    final Complex
    minus(double subtrahend)
    complex subtraction
    final Complex
    minus(Complex subtrahend)
    complex subtraction
    final double
    modulus of this complex number
    final double
    modulus squared of this complex number
    final Complex
    calculate the negative of this complex number
    final double
    get the phase
    final Complex
    plus(double addend)
    complex addition
    final Complex
    plus(Complex addend)
    complex addition
    final double
    get the real part
    final Complex
    calculate the reciprocal of this complex number
    static 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 multiplication
    final Complex
    times(Complex multiplier)
    complex multiplication
    Get a string representation of this complex number

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • ZERO

      public static final Complex ZERO
      The complex value zero
    • ONE

      public static final Complex ONE
      the real unit
    • IUNIT

      public static final Complex 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

      public static Complex sqrt(Complex s)
      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

      public static Complex log(Complex s)

      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

      public static Complex exp(Complex s)

      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

      public static 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. 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

      public static Complex sin(Complex s)

      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

      public static Complex sinh(Complex s)

      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

      public static Complex cos(Complex s)

      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

      public static Complex cosh(Complex s)

      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

      public String toString()
      Get a string representation of this complex number
      Overrides:
      toString in class Object
    • 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

      public final Complex conjugate()
      complex conjugate
    • reciprocal

      public final Complex reciprocal()
      calculate the reciprocal of this complex number
    • times

      public final Complex times(Complex multiplier)
      complex multiplication
    • times

      public final Complex times(double multiplier)
      complex multiplication
    • divide

      public final Complex divide(Complex divisor)
      complex division
    • divide

      public final Complex divide(double divisor)
      complex division
    • plus

      public final Complex plus(Complex addend)
      complex addition
    • plus

      public final Complex plus(double addend)
      complex addition
    • negate

      public final Complex negate()
      calculate the negative of this complex number
    • minus

      public final Complex minus(Complex subtrahend)
      complex subtraction
    • minus

      public final Complex minus(double subtrahend)
      complex subtraction