Package com.singularsys.jep.standard

# Class ImmutableComplex

java.lang.Object
com.singularsys.jep.standard.Complex
com.singularsys.jep.standard.Complex.NonPropagatingImmutableComplex
com.singularsys.jep.standard.ImmutableComplex

All Implemented Interfaces:
  `Serializable`

public class ImmutableComplex extends Complex.NonPropagatingImmutableComplex
An Immutable version of the Complex numbers. In this class the values of complex numbers can never be changed, further any operation like `conj()` or `add(Complex)` will also return an ImmutableComplex.

Since:
  Jep 4.0
See Also:
  - Serialized Form

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class com.singularsys.jep.standard.Complex

  `Complex.NonPropagatingImmutableComplex`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final Complex`
  `U_I`
  Unmodifiable constant 0+1 i
  `static final Complex`
  `U_MINUS_I`
  Unmodifiable constant 0-1 i
  `static final Complex`
  `U_MINUS_ONE`
  Unmodifiable constant -1+0 i
  `static final Complex`
  `U_ONE`
  Unmodifiable constant 1+0 i
  `static final Complex`
  `U_ZERO`
  Unmodifiable constant 0+0 i

  ### Fields inherited from class com.singularsys.jep.standard.Complex

  `I, MINUS_I, MINUS_ONE, ONE, ZERO`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ImmutableComplex()`
  `ImmutableComplex(double x)`
  `ImmutableComplex(double x, double y)`
  `ImmutableComplex(Complex z)`
  `ImmutableComplex(Number x)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ImmutableComplex`
  `acos()`
  Returns the arccos of this complex number.
  `ImmutableComplex`
  `acosh()`
  Returns the inverse hyperbolic cosine of this complex number.
  `ImmutableComplex`
  `add(Complex z)`
  Adds the complex number with another complex value.
  `ImmutableComplex`
  `asin()`
  Returns the arcsin of this complex number.
  `ImmutableComplex`
  `asinh()`
  Returns the inverse hyperbolic sine of this complex number.
  `ImmutableComplex`
  `atan()`
  Returns the arc tangent of this complex number.
  `ImmutableComplex`
  `atanh()`
  Returns the inverse hyperbolic tangent of this complex number.
  `ImmutableComplex`
  `conj()`
  Returns the complex conjugate.
  `ImmutableComplex`
  `cos()`
  Returns the cosine of this complex number.
  `ImmutableComplex`
  `cosh()`
  Returns the hyperbolic cosine of this complex number.
  `ImmutableComplex`
  `div(Complex z)`
  Returns the result of dividing this complex number by the parameter.
  `ImmutableComplex`
  `fastPower(int n)`
  Calculate integer powers by repeated multiplications.
  `ImmutableComplex`
  `log()`
  Returns the logarithm of this complex number.
  `ImmutableComplex`
  `mul(double b)`
  Multiply the complex number with a double value.
  `ImmutableComplex`
  `mul(Complex z)`
  Multiply the complex number with another complex value.
  `ImmutableComplex`
  `neg()`
  Returns the negative value of this complex number.
  `static ImmutableComplex`
  `polarValueOf(Number r, Number theta)`
  `ImmutableComplex`
  `power(double exponent)`
  Returns this complex number raised to a double argument.
  `ImmutableComplex`
  `power(int n)`
  Raise this complex to an integer power.
  `ImmutableComplex`
  `power(Complex exponent)`
  Returns the value of this complex number raised to the power of a complex exponent If this is zero return this.
  `ImmutableComplex`
  `powerD(double exponent)`
  Returns the value of this complex number raised to the power of a real component (in double precision).
  `ImmutableComplex`
  `powerI(int n)`
  Raise a complex number to an integer power.
  `ImmutableComplex`
  `reciprocal()`
  Returns the reciprocal of a complex number 1/z.
  `ImmutableComplex`
  `sin()`
  Returns the sine of this complex number.
  `ImmutableComplex`
  `sinh()`
  Returns the hyperbolic sine of this complex number.
  `ImmutableComplex`
  `sqrt()`
  Calculates the square root of this object.
  `ImmutableComplex`
  `sub(Complex z)`
  Subtracts a complex number from this
  `ImmutableComplex`
  `tan()`
  Returns the tangent of this complex number.
  `ImmutableComplex`
  `tanh()`
  Returns the hyperbolic tangent of this complex number.

  ### Methods inherited from class com.singularsys.jep.standard.Complex.NonPropagatingImmutableComplex

  `set, set, setIm, setRe`

  ### Methods inherited from class com.singularsys.jep.standard.Complex

  `abs, abs2, arg, doubleValue, eq, equals, equals, floatValue, hashCode, im, intValue, isInfinite, isNaN, longValue, re, toString, toString, toString, toString`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### U_ZERO

    public static final Complex U_ZERO
    Unmodifiable constant 0+0 i

  - ### U_ONE

    public static final Complex U_ONE
    Unmodifiable constant 1+0 i

  - ### U_MINUS_ONE

    public static final Complex U_MINUS_ONE
    Unmodifiable constant -1+0 i

  - ### U_I

    public static final Complex U_I
    Unmodifiable constant 0+1 i

  - ### U_MINUS_I

    public static final Complex U_MINUS_I
    Unmodifiable constant 0-1 i

- ## Constructor Details

  - ### ImmutableComplex

    public ImmutableComplex()

  - ### ImmutableComplex

    public ImmutableComplex(Complex z)

  - ### ImmutableComplex

    public ImmutableComplex(double x, double y)

  - ### ImmutableComplex

    public ImmutableComplex(double x)

  - ### ImmutableComplex

    public ImmutableComplex(Number x)

- ## Method Details

  - ### polarValueOf

    public static ImmutableComplex polarValueOf(Number r, Number theta)

  - ### neg

    public ImmutableComplex neg()
    Description copied from class: `Complex`
    Returns the negative value of this complex number.
    Overrides:
      `neg` in class `Complex`
    Returns:
      -(x+i y)

  - ### mul

    public ImmutableComplex mul(double b)
    Description copied from class: `Complex`
    Multiply the complex number with a double value.
    Overrides:
      `mul` in class `Complex`
    Parameters:
      `b` - real number to multiply by
    Returns:
      The result of the multiplication

  - ### add

    public ImmutableComplex add(Complex z)
    Description copied from class: `Complex`
    Adds the complex number with another complex value.
    Overrides:
      `add` in class `Complex`
    Parameters:
      `z` - complex number to add
    Returns:
      The result of the addition

  - ### sub

    public ImmutableComplex sub(Complex z)
    Description copied from class: `Complex`
    Subtracts a complex number from this
    Overrides:
      `sub` in class `Complex`
    Parameters:
      `z` - complex number to subtract
    Returns:
      (this) - z

  - ### mul

    public ImmutableComplex mul(Complex z)
    Description copied from class: `Complex`
    Multiply the complex number with another complex value.
    Overrides:
      `mul` in class `Complex`
    Parameters:
      `z` - complex number to multiply
    Returns:
      The result of the multiplication

  - ### div

    public ImmutableComplex div(Complex z)
    Description copied from class: `Complex`
    Returns the result of dividing this complex number by the parameter. Algorithm adapted from Numerical Recipes in C - The Art of Scientific Computing ISBN 0-521-43108-5
    Overrides:
      `div` in class `Complex`
    Parameters:
      `z` - complex number to divide by
    Returns:
      (this)/z

  - ### reciprocal

    public ImmutableComplex reciprocal()
    Description copied from class: `Complex`
    Returns the reciprocal of a complex number 1/z. This was broken in version < 4.0.
    Overrides:
      `reciprocal` in class `Complex`
    Returns:
      1/(this)

  - ### power

    public ImmutableComplex power(int n)
    Description copied from class: `Complex`
    Raise this complex to an integer power. For small power use the `Complex.fastPower(int)` method which does not do repeated multiplication and is generally faster. For larger power use `Complex.powerI(int)` which can be more accurate.
    Overrides:
      `power` in class `Complex`
    Parameters:
      `n` - the power
    Returns:
      (this)^n

  - ### powerI

    public ImmutableComplex powerI(int n)
    Description copied from class: `Complex`
    Raise a complex number to an integer power. Uses the polar form `[r;th]^n -> [r^n;n th]` and the efficient power method from `Power.power(double, int)` Slower than
    Overrides:
      `powerI` in class `Complex`
    Parameters:
      `n` -
    Returns:

  - ### fastPower

    public ImmutableComplex fastPower(int n)
    Description copied from class: `Complex`
    Calculate integer powers by repeated multiplications. So `z^5 = z*(z*z)*(z*z)`. This routine is generally faster but can accumulate errors for large exponents.
    Overrides:
      `fastPower` in class `Complex`
    Parameters:
      `n` -
    Returns:

  - ### powerD

    public ImmutableComplex powerD(double exponent)
    Description copied from class: `Complex`
    Returns the value of this complex number raised to the power of a real component (in double precision).

    This method considers special cases where a simpler algorithm would return "ugly" results.
    For example when the expression (-1e40)^0.5 is evaluated without considering the special case, the argument of the base is the double number closest to pi. When sin and cos are used for the final evaluation of the result, the slight difference of the argument from pi causes a non-zero value for the real component of the result. Because the value of the base is so high, the error is magnified. Although the error is normal for floating point calculations, the consideration of commonly occurring special cases improves the accuracy and aesthetics of the results.

    If you know a more elegant way to solve this problem, please let me know at nathanfunk@hotmail.com .

    Testing with roots of unity show errors are typically within 128 * ulp, so |actual-result|/|actual| < 1e-13.

    Overrides:
      `powerD` in class `Complex`
    Parameters:
      `exponent` - exponent
    Returns:
      (this)^exponent

  - ### power

    public ImmutableComplex power(double exponent)
    Description copied from class: `Complex`
    Returns this complex number raised to a double argument. If the exponent is an integer returns `Complex.power(int)` otherwise calls `Complex.powerD(double)`.
    Overrides:
      `power` in class `Complex`
    Parameters:
      `exponent` -
    Returns:
      this^exponent

  - ### power

    public ImmutableComplex power(Complex exponent)
    Description copied from class: `Complex`
    Returns the value of this complex number raised to the power of a complex exponent If this is zero return this. If the exponent has zero imaginary part use
    Overrides:
      `power` in class `Complex`
    Parameters:
      `exponent` - exponent
    Returns:
      (this)^exponent

  - ### conj

    public ImmutableComplex conj()
    Description copied from class: `Complex`
    Returns the complex conjugate.
    Overrides:
      `conj` in class `Complex`
    Returns:
      (x-i y)

  - ### log

    public ImmutableComplex log()
    Description copied from class: `Complex`
    Returns the logarithm of this complex number. The real part is Math.log(this.abs()) and the complex part is this.arg(), in the range -pi .. pi.
    Overrides:
      `log` in class `Complex`
    Returns:
      ln(z) = ln(r) + i th

  - ### sqrt

    public ImmutableComplex sqrt()
    Description copied from class: `Complex`
    Calculates the square root of this object. Adapted from Numerical Recipes in C - The Art of Scientific Computing (ISBN 0-521-43108-5)
    Overrides:
      `sqrt` in class `Complex`
    Returns:
      sqrt(z)

  - ### sin

    public ImmutableComplex sin()
    Description copied from class: `Complex`
    Returns the sine of this complex number.
    Overrides:
      `sin` in class `Complex`
    Returns:
      sin(this)

  - ### cos

    public ImmutableComplex cos()
    Description copied from class: `Complex`
    Returns the cosine of this complex number.
    Overrides:
      `cos` in class `Complex`
    Returns:
      cos(this)

  - ### tan

    public ImmutableComplex tan()
    Description copied from class: `Complex`
    Returns the tangent of this complex number.
    Overrides:
      `tan` in class `Complex`
    Returns:
      tan(this)

  - ### asin

    public ImmutableComplex asin()
    Description copied from class: `Complex`
    Returns the arcsin of this complex number.
    Overrides:
      `asin` in class `Complex`
    Returns:
      asin(this)

  - ### acos

    public ImmutableComplex acos()
    Description copied from class: `Complex`
    Returns the arccos of this complex number.
    Overrides:
      `acos` in class `Complex`
    Returns:
      acos(this)

  - ### atan

    public ImmutableComplex atan()
    Description copied from class: `Complex`
    Returns the arc tangent of this complex number.
    Overrides:
      `atan` in class `Complex`
    Returns:
      atan(this)

  - ### sinh

    public ImmutableComplex sinh()
    Description copied from class: `Complex`
    Returns the hyperbolic sine of this complex number.
    Overrides:
      `sinh` in class `Complex`
    Returns:
      sinh(this)

  - ### cosh

    public ImmutableComplex cosh()
    Description copied from class: `Complex`
    Returns the hyperbolic cosine of this complex number.
    Overrides:
      `cosh` in class `Complex`
    Returns:
      cosh(this)

  - ### tanh

    public ImmutableComplex tanh()
    Description copied from class: `Complex`
    Returns the hyperbolic tangent of this complex number.
    Overrides:
      `tanh` in class `Complex`
    Returns:
      tanh(this)

  - ### asinh

    public ImmutableComplex asinh()
    Description copied from class: `Complex`
    Returns the inverse hyperbolic sine of this complex number.
    Overrides:
      `asinh` in class `Complex`
    Returns:
      asinh(this)

  - ### acosh

    public ImmutableComplex acosh()
    Description copied from class: `Complex`
    Returns the inverse hyperbolic cosine of this complex number.
    Overrides:
      `acosh` in class `Complex`
    Returns:
      acosh(this)

  - ### atanh

    public ImmutableComplex atanh()
    Description copied from class: `Complex`
    Returns the inverse hyperbolic tangent of this complex number.
    Overrides:
      `atanh` in class `Complex`
    Returns:
      atanh(this)