/** * Return the additive inverse of this complex number. Returns * <code>Complex.NaN</code> if either real or imaginary part of this Complex * number equals <code>Double.NaN</code>. * * @return the negation of this complex number */ public Complex negate() { if ( isNaN() ) { return NaN; } return createComplex( -real, -imaginary ); }
/** * Return the additive inverse of this complex number. * <p> * Returns <code>Complex.NaN</code> if either real or imaginary part of this * Complex number equals <code>Double.NaN</code>. * </p> * * @return the negation of this complex number */ public Complex negate() { if (isNaN()) { return NaN; } return createComplex(-real, -imaginary); }
/** * Return the conjugate of this complex number. The conjugate of "A + Bi" is * "A - Bi". {@link #NaN} is returned if either the real or imaginary part * of this Complex number equals <code>Double.NaN</code>. * * If the imaginary part is infinite, and the real part is not NaN, the * returned value has infinite imaginary part of the opposite sign - e.g. * the conjugate of <code>1 + POSITIVE_INFINITY i</code> is * <code>1 - NEGATIVE_INFINITY i</code> * * @return the conjugate of this Complex object */ public Complex conjugate() { if ( isNaN() ) { return NaN; } return createComplex( real, -imaginary ); }
/** * Return the conjugate of this complex number. The conjugate of "A + Bi" is * "A - Bi". * <p> * {@link #NaN} is returned if either the real or imaginary part of this * Complex number equals <code>Double.NaN</code>. * </p> * <p> * If the imaginary part is infinite, and the real part is not NaN, the * returned value has infinite imaginary part of the opposite sign - e.g. the * conjugate of <code>1 + POSITIVE_INFINITY i</code> is * <code>1 - NEGATIVE_INFINITY i</code> * </p> * * @return the conjugate of this Complex object */ public Complex conjugate() { if (isNaN()) { return NaN; } return createComplex(real, -imaginary); }
return createComplex( expReal * Math.cos( imaginary ), expReal * Math.sin( imaginary ) );
return createComplex( real * rhs.real - imaginary * rhs.imaginary, real * rhs.imaginary + imaginary * rhs.real );
/** * Return the sum of this complex number and the given complex number. Uses * the definitional formula * * <pre> * (a + bi) + (c + di) = (a+c) + (b+d)i * </pre> * * If either this or <code>rhs</code> has a NaN value in either part, * {@link #NaN} is returned; otherwise Inifinite and NaN values are returned * in the parts of the result according to the rules for * {@link java.lang.Double} arithmetic. * * @param rhs the other complex number * @return the complex number sum * @throws java.lang.NullPointerException if <code>rhs</code> is null */ public Complex add( Complex rhs ) { return createComplex( real + rhs.getReal(), imaginary + rhs.getImaginary() ); }
/** * Return the sum of this complex number and the given complex number. * <p> * Uses the definitional formula * * <pre> * (a + bi) + (c + di) = (a+c) + (b+d)i * </pre> * * </p> * <p> * If either this or <code>rhs</code> has a NaN value in either part, * {@link #NaN} is returned; otherwise Inifinite and NaN values are returned * in the parts of the result according to the rules for * {@link java.lang.Double} arithmetic. * </p> * * @param rhs * the other complex number * @return the complex number sum * @throws NullPointerException * if <code>rhs</code> is null */ public Complex add(Complex rhs) { return createComplex(real + rhs.getReal(), imaginary + rhs.getImaginary()); }
return createComplex( MathUtils.sinh( real ) * Math.cos( imaginary ), MathUtils.cosh( real ) * Math.sin( imaginary ) );
return createComplex( Math.cos( real ) * MathUtils.cosh( imaginary ), -Math.sin( real ) * MathUtils.sinh( imaginary ) );
return createComplex( Math.sin( real ) * MathUtils.cosh( imaginary ), Math.cos( real ) * MathUtils.sinh( imaginary ) );
/** * Compute the * <a href="http://mathworld.wolfram.com/SquareRoot.html" TARGET="_top"> * square root</a> of 1 - <code>this</code><sup>2</sup> for this complex * number. Computes the result directly as * <code>sqrt(Complex.ONE.subtract(z.multiply(z)))</code>. * * Returns {@link org.matheclipse.parser.client.math.Complex#NaN} if either * real or imaginary part of the input argument is <code>NaN</code>. * * Infinite values in real or imaginary parts of the input may result in * infinite or NaN values returned in parts of the result. * * @return the square root of 1 - <code>this</code><sup>2</sup> * @since 1.2 */ public Complex sqrt1z() { return createComplex( 1.0, 0.0 ).subtract( this.multiply( this ) ).sqrt(); }
return createComplex( MathUtils.cosh( real ) * Math.cos( imaginary ), MathUtils.sinh( real ) * Math.sin( imaginary ) );
return createComplex(MathUtils.sinh(real) * Math.cos(imaginary), MathUtils.cosh(real) * Math.sin(imaginary));
double d = Math.cos( real2 ) + MathUtils.cosh( imaginary2 ); return createComplex( Math.sin( real2 ) / d, MathUtils.sinh( imaginary2 ) / d );
/** * Compute the <a href="http://mathworld.wolfram.com/SquareRoot.html" * TARGET="_top"> square root</a> of 1 - <code>this</code><sup>2</sup> for * this complex number. * <p> * Computes the result directly as * <code>sqrt(Complex.ONE.subtract(z.multiply(z)))</code>. * </p> * <p> * Returns {@link Complex#NaN} if either real or imaginary part of the input * argument is <code>NaN</code>. * </p> * <p> * Infinite values in real or imaginary parts of the input may result in * infinite or NaN values returned in parts of the result. * </p> * * @return the square root of 1 - <code>this</code><sup>2</sup> * @since 1.2 */ public Complex sqrt1z() { return createComplex(1.0, 0.0).subtract(this.multiply(this)).sqrt(); }
/** * Return the difference between this complex number and the given complex * number. Uses the definitional formula * * <pre> * (a + bi) - (c + di) = (a-c) + (b-d)i * </pre> * * If either this or <code>rhs</code> has a NaN value in either part, * {@link #NaN} is returned; otherwise inifinite and NaN values are returned * in the parts of the result according to the rules for * {@link java.lang.Double} arithmetic. * * @param rhs the other complex number * @return the complex number difference * @throws java.lang.NullPointerException if <code>rhs</code> is null */ public Complex subtract( Complex rhs ) { if ( isNaN() || rhs.isNaN() ) { return NaN; } return createComplex( real - rhs.getReal(), imaginary - rhs.getImaginary() ); }
/** * Return the difference between this complex number and the given complex * number. * <p> * Uses the definitional formula * * <pre> * (a + bi) - (c + di) = (a-c) + (b-d)i * </pre> * * </p> * <p> * If either this or <code>rhs</code> has a NaN value in either part, * {@link #NaN} is returned; otherwise inifinite and NaN values are returned * in the parts of the result according to the rules for * {@link java.lang.Double} arithmetic. * </p> * * @param rhs * the other complex number * @return the complex number difference * @throws NullPointerException * if <code>rhs</code> is null */ public Complex subtract(Complex rhs) { if (isNaN() || rhs.isNaN()) { return NaN; } return createComplex(real - rhs.getReal(), imaginary - rhs.getImaginary()); }
/** * Compute the * <a href="http://mathworld.wolfram.com/InverseTangent.html" TARGET="_top"> * inverse tangent</a> of this complex number. Implements the formula: * * <pre> * <code> atan(z) = (i/2) log((i + z)/(i - z)) </code> * </pre> * * Returns {@link org.matheclipse.parser.client.math.Complex#NaN} if either * real or imaginary part of the input argument is <code>NaN</code> or * infinite. * * @return the inverse tangent of this complex number * @since 1.2 */ public Complex atan() { if ( isNaN() ) { return Complex.NaN; } return this.add( Complex.I ).divide( Complex.I.subtract( this ) ).log().multiply( Complex.I.divide( createComplex( 2.0, 0.0 ) ) ); }
/** * Compute the <a href="http://mathworld.wolfram.com/InverseTangent.html" * TARGET="_top"> inverse tangent</a> of this complex number. * <p> * Implements the formula: * * <pre> * <code> atan(z) = (i/2) log((i + z)/(i - z)) </code> * </pre> * * </p> * <p> * Returns {@link Complex#NaN} if either real or imaginary part of the input * argument is <code>NaN</code> or infinite. * </p> * * @return the inverse tangent of this complex number * @since 1.2 */ public Complex atan() { if (isNaN()) { return Complex.NaN; } return this.add(Complex.I).divide(Complex.I.subtract(this)).log().multiply(Complex.I.divide(createComplex(2.0, 0.0))); }