/** {@inheritDoc} */ @Override public IExpr dec() { return add(MINUS_ONE); }
/** {@inheritDoc} */ @Override public IExpr inc() { return add(ONE); }
/** * 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)); }
@Override public IExpr plus(final IExpr that) { if (that instanceof ApfloatNum) { return add(ApfloatNum.valueOf(fDouble, ((ApfloatNum) that).fApfloat.precision())); } if (that instanceof Num) { return valueOf(fDouble + ((Num) that).fDouble); } if (that instanceof ApcomplexNum) { return ApcomplexNum.valueOf(fDouble, ((ApcomplexNum) that).fApcomplex.precision()).add((ApcomplexNum) that); } if (that instanceof ComplexNum) { return ComplexNum.valueOf(fDouble).add((ComplexNum) that); } return INum.super.plus(that); }
/** * @param that * @return */ @Override public IExpr plus(final IExpr that) { if (that instanceof ComplexNum) { return newInstance(fComplex.add(((ComplexNum) that).fComplex)); } if (that instanceof ApcomplexNum) { ApcomplexNum acn = (ApcomplexNum) that; return ApcomplexNum.valueOf(getRealPart(), getImaginaryPart(), acn.fApcomplex.precision()).add(acn); } if (that instanceof ApfloatNum) { ApfloatNum afn = (ApfloatNum) that; return ApcomplexNum.valueOf(getRealPart(), getImaginaryPart(), afn.fApfloat.precision()) .add(ApcomplexNum.valueOf(afn.fApfloat, Apcomplex.ZERO)); } if (that instanceof Num) { return add(ComplexNum.valueOf(((Num) that).getRealPart())); } return IComplexNum.super.plus(that); }