if (z.isNaN()) { return ComplexNum.NaN;
if (z.isNaN()) { return ComplexNum.NaN;
if (z.isNaN()) { return ComplexNum.NaN;
if (z.isNaN()) { return ComplexNum.NaN;
if (z.isNaN()) { return ComplexNum.NaN;
if (z.isNaN()) { return ComplexNum.NaN;
if (z.isNaN()) { return ComplexNum.NaN;
if (z.isNaN()) { return ComplexNum.NaN;
if (z.isNaN()) { return ComplexNum.NaN;
if (z.isNaN()) { return ComplexNum.NaN;
if (z.isNaN()) { return ComplexNum.NaN;
if (z.isNaN()) { return ComplexNum.NaN;
if (z.isNaN()) { return ComplexNum.NaN;
/** * Return the absolute value of this complex number. * <p> * Returns <code>NaN</code> if either real or imaginary part is * <code>NaN</code> and <code>Double.POSITIVE_INFINITY</code> if neither part * is <code>NaN</code>, but at least one part takes an infinite value. * * @return the absolute value */ public double dabs() { if (isNaN()) { return Double.NaN; } if (isInfinite()) { return Double.POSITIVE_INFINITY; } if (Math.abs(getReal()) < Math.abs(getImaginary())) { if (getImaginary() == 0.0) { return Math.abs(getReal()); } final double q = getReal() / getImaginary(); return (Math.abs(getImaginary()) * Math.sqrt(1 + q * q)); } else { if (getReal() == 0.0) { return Math.abs(getImaginary()); } final double q = getImaginary() / getReal(); return (Math.abs(getReal()) * Math.sqrt(1 + q * q)); } }
/** * Compute the * <a href="http://mathworld.wolfram.com/InverseCosine.html" TARGET="_top"> * inverse cosine</a> for the given complex argument. * <p> * Implements the formula: <pre> * <code> acos(z) = -i (log(z + i (sqrt(1 - z<sup>2</sup>))))</code></pre> * <p> * Returns {@link ComplexNum#NaN} if either real or imaginary part of the * input argument is <code>NaN</code> or infinite. * * @param z the value whose inverse cosine is to be returned * @return the inverse cosine of <code>z</code> * @throws NullPointerException if <code>z</code> is null */ public static ComplexNum acos(final ComplexNum z) { if (z.isNaN()) { return ComplexNum.NaN; } return ComplexNum.I.negate().multiply(log(z.add( ComplexNum.I.multiply(sqrt1z(z))))); }
/** * Compute the * <a href="http://mathworld.wolfram.com/InverseCosine.html" TARGET="_top"> * inverse cosine</a> for the given complex argument. * <p> * Implements the formula: <pre> * <code> acos(z) = -i (log(z + i (sqrt(1 - z<sup>2</sup>))))</code></pre> * <p> * Returns {@link ComplexNum#NaN} if either real or imaginary part of the * input argument is <code>NaN</code> or infinite. * * @param z the value whose inverse cosine is to be returned * @return the inverse cosine of <code>z</code> * @throws NullPointerException if <code>z</code> is null */ public static ComplexNum acos(final ComplexNum z) { if (z.isNaN()) { return ComplexNum.NaN; } return ComplexNum.I.negate().multiply(log(z.add( ComplexNum.I.multiply(sqrt1z(z))))); }
/** * Compute the * <a href="http://mathworld.wolfram.com/InverseSine.html" TARGET="_top"> * inverse sine</a> for the given complex argument. * <p> * Implements the formula: <pre> * <code> asin(z) = -i (log(sqrt(1 - z<sup>2</sup>) + iz)) </code></pre> * <p> * Returns {@link ComplexNum#NaN} if either real or imaginary part of the * input argument is <code>NaN</code> or infinite. * * @param z the value whose inverse sine is to be returned. * @return the inverse sine of <code>z</code>. * @throws NullPointerException if <code>z</code> is null */ public static ComplexNum asin(final ComplexNum z) { if (z.isNaN()) { return ComplexNum.NaN; } return ComplexNum.I.negate().multiply(log(sqrt1z(z).add( ComplexNum.I.multiply(z)))); }
/** * Compute the * <a href="http://mathworld.wolfram.com/InverseSine.html" TARGET="_top"> * inverse sine</a> for the given complex argument. * <p> * Implements the formula: <pre> * <code> asin(z) = -i (log(sqrt(1 - z<sup>2</sup>) + iz)) </code></pre> * <p> * Returns {@link ComplexNum#NaN} if either real or imaginary part of the * input argument is <code>NaN</code> or infinite. * * @param z the value whose inverse sine is to be returned. * @return the inverse sine of <code>z</code>. * @throws NullPointerException if <code>z</code> is null */ public static ComplexNum asin(final ComplexNum z) { if (z.isNaN()) { return ComplexNum.NaN; } return ComplexNum.I.negate().multiply(log(sqrt1z(z).add( ComplexNum.I.multiply(z)))); }
/** * Compute the * <a href="http://mathworld.wolfram.com/InverseTangent.html" TARGET="_top"> * inverse tangent</a> for the given complex argument. * <p> * Implements the formula: <pre> * <code> atan(z) = (i/2) log((i + z)/(i - z)) </code></pre> * <p> * Returns {@link ComplexNum#NaN} if either real or imaginary part of the * input argument is <code>NaN</code> or infinite. * * @param z the value whose inverse tangent is to be returned * @return the inverse tangent of <code>z</code> * @throws NullPointerException if <code>z</code> is null */ public static ComplexNum atan(final ComplexNum z) { if (z.isNaN()) { return ComplexNum.NaN; } return ComplexNum.I.multiply( log(ComplexNum.I.add(z).divide(ComplexNum.I.subtract(z)))) .divide(ComplexNum.valueOf(2.0, 0.0)); }
/** * Compute the * <a href="http://mathworld.wolfram.com/InverseTangent.html" TARGET="_top"> * inverse tangent</a> for the given complex argument. * <p> * Implements the formula: <pre> * <code> atan(z) = (i/2) log((i + z)/(i - z)) </code></pre> * <p> * Returns {@link ComplexNum#NaN} if either real or imaginary part of the * input argument is <code>NaN</code> or infinite. * * @param z the value whose inverse tangent is to be returned * @return the inverse tangent of <code>z</code> * @throws NullPointerException if <code>z</code> is null */ public static ComplexNum atan(final ComplexNum z) { if (z.isNaN()) { return ComplexNum.NaN; } return ComplexNum.I.multiply( log(ComplexNum.I.add(z).divide(ComplexNum.I.subtract(z)))) .divide(ComplexNum.valueOf(2.0, 0.0)); }