/** * Returns of value of this complex number raised to the power of {@code x}. * * @param x exponent to which this {@code Complex} is to be raised. * @return <code>this<sup>x</sup></code>. * @see #pow(Complex) */ public Complex pow(double x) { return this.log().multiply(x).exp(); }
/** * Compute the * <a href="http://mathworld.wolfram.com/InverseCosine.html" TARGET="_top"> * inverse cosine</a> of this complex number. * Implements the formula: * <p> * {@code acos(z) = -i (log(z + i (sqrt(1 - z<sup>2</sup>))))} * </p> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN} or infinite. * * @return the inverse cosine of this complex number. * @since 1.2 */ public Complex acos() { if (isNaN) { return NaN; } return this.add(this.sqrt1z().multiply(I)).log().multiply(I.negate()); }
/** * Compute the * <a href="http://mathworld.wolfram.com/InverseSine.html" TARGET="_top"> * inverse sine</a> of this complex number. * Implements the formula: * <p> * {@code asin(z) = -i (log(sqrt(1 - z<sup>2</sup>) + iz))} * </p><p> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN} or infinite.</p> * * @return the inverse sine of this complex number. * @since 1.2 */ public Complex asin() { if (isNaN) { return NaN; } return sqrt1z().add(this.multiply(I)).log().multiply(I.negate()); }
/** * Compute the * <a href="http://mathworld.wolfram.com/SquareRoot.html" TARGET="_top"> * square root</a> of <code>1 - this<sup>2</sup></code> for this complex * number. * Computes the result directly as * {@code sqrt(ONE.subtract(z.multiply(z)))}. * <p> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. * </p> * 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 <code>1 - this<sup>2</sup></code>. * @since 1.2 */ public Complex sqrt1z() { return createComplex(1.0, 0.0).subtract(this.multiply(this)).sqrt(); }
/** * Returns of value of this complex number raised to the power of {@code x}. * Implements the formula: * <pre> * <code> * y<sup>x</sup> = exp(x·log(y)) * </code> * </pre> * where {@code exp} and {@code log} are {@link #exp} and * {@link #log}, respectively. * <p> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN} or infinite, or if {@code y} * equals {@link Complex#ZERO}.</p> * * @param x exponent to which this {@code Complex} is to be raised. * @return <code> this<sup>x</sup></code>. * @throws NullArgumentException if x is {@code null}. * @since 1.2 */ public Complex pow(Complex x) throws NullArgumentException { MathUtils.checkNotNull(x); return this.log().multiply(x).exp(); }
oldc = c[j]; c[j] = newc; newc = oldc.add(newc.multiply(root[i]));
/** * Compute the * <a href="http://mathworld.wolfram.com/InverseTangent.html" TARGET="_top"> * inverse tangent</a> of this complex number. * Implements the formula: * <p> * {@code atan(z) = (i/2) log((i + z)/(i - z))} * </p><p> * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN} or infinite.</p> * * @return the inverse tangent of this complex number * @since 1.2 */ public Complex atan() { if (isNaN) { return NaN; } return this.add(I).divide(I.subtract(this)).log() .multiply(I.divide(createComplex(2.0, 0.0))); }
Complex d2v = Complex.ZERO; for (int j = n-1; j >= 0; j--) { d2v = dv.add(z.multiply(d2v)); dv = pv.add(z.multiply(dv)); pv = coefficients[j].add(z.multiply(pv)); d2v = d2v.multiply(new Complex(2.0, 0.0)); final Complex G2 = G.multiply(G); final Complex H = G2.subtract(d2v.divide(pv)); final Complex delta = n1C.multiply((nC.multiply(H)).subtract(G2));
private void multiply(double[] t, Complex[] c) { for (int i = 0; i < c.length; i++) { c[i] = c[i].multiply(t[i]); } }
private void multiply(Complex[] c, double multiply) { for (int i = 0; i < c.length; i++) { c[i] = c[i].multiply(multiply); } }
for (Complex aP : p) temp = temp.multiply(aP.negate());
private Complex[] multiply(double[] t, Complex c) { Complex[] ret = new Complex[t.length]; for (int i = 0; i < ret.length; i++) { ret[i] = c.multiply(t[i]); } return ret; }
public Quadripole cascade(Quadripole q2) { Quadripole q1 = this; Quadripole qr = new Quadripole(); qr.a = q1.a.multiply(q2.a).add(q1.b.multiply(q2.c)); qr.b = q1.a.multiply(q2.b).add(q1.b.multiply(q2.d)); qr.c = q1.c.multiply(q2.a).add(q1.d.multiply(q2.c)); qr.d = q1.c.multiply(q2.b).add(q1.d.multiply(q2.d)); return qr; }
/** * @param that * @return */ public ComplexNum multiply(final ComplexNum that) { return newInstance(fComplex.multiply(that.fComplex)); }
private static Complex[] multiplyWithConjugateInPlace(Complex[] complexNumbers) { for (int i = 0; i < complexNumbers.length; i++) { complexNumbers[i] = complexNumbers[i].multiply(complexNumbers[i].conjugate()); } return complexNumbers; }
/** * Returns of value of this complex number raised to the power of {@code x}. * * @param x exponent to which this {@code Complex} is to be raised. * @return <code>this<sup>x</sup></code>. * @see #pow(Complex) */ public Complex pow(double x) { return this.log().multiply(x).exp(); }
/** * Returns of value of this complex number raised to the power of {@code x}. * * @param x exponent to which this {@code Complex} is to be raised. * @return <code>this<sup>x</sup></code>. * @see #pow(Complex) */ public Complex pow(double x) { return this.log().multiply(x).exp(); }
/** * @param that * @return */ @Override public IExpr times(final IExpr that) { if (that instanceof ComplexNum) { return newInstance(fComplex.multiply(((ComplexNum) that).fComplex)); } return super.times(that); }