/** * 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(); }
/** * Return the log value of the given complex number * * @param num the number to getScalar the absolute value for * @return the absolute value of this complex number */ public static IComplexNumber log(IComplexNumber num) { Complex c = new Complex(num.realComponent().doubleValue(), num.imaginaryComponent().doubleValue()).log(); return Nd4j.createDouble(c.getReal(), c.getImaginary()); }
/** * 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(); }
/** * 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/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/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))); }
/** * 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(); }
/** * Return the log value of the given complex number * * @param num the number to getScalar the absolute value for * @return the absolute value of this complex number */ public static IComplexNumber log(IComplexNumber num) { Complex c = new Complex(num.realComponent().doubleValue(), num.imaginaryComponent().doubleValue()).log(); return Nd4j.createDouble(c.getReal(), c.getImaginary()); }
Complex first = new Complex(1.0, 3.0); Complex second = new Complex(2.0, 5.0); Complex answer = first.log(); // natural logarithm. answer = first.cos(); // cosine answer = first.pow(second); // first raised to the power of second
private Complex[][] complex(Complex[] v, double[] t) { Complex[][] complex = new Complex[v.length][t.length]; for (int i = 0; i < v.length; i++) { for (int j = 0; j < t.length; j++) { complex[i][j] = v[i].multiply(t[j]).add(new Complex(1, 0)).log().multiply(-0.5); } } return complex; }
/** * c = natural log(a) Michael Borcherds 2009-03-10 * * @param a * a * @param c * logaritmus of a */ public static void complexLog(GeoVec2D a, GeoVec2D c) { Complex out = new Complex(a.x, a.y); out = out.log(); c.x = out.getReal(); c.y = out.getImaginary(); c.setMode(Kernel.COORD_COMPLEX); }
public ValueType log(CalculatedValue g) { if (g.isComplex() || g.real <= 0.0) { return setComplexValue(g.getComplex().log()); } else { return setValue(FastMath.log(g.real)); } }
/** * 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/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 (notDefined) { 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 (notDefined) { return NaN; } return sqrt1z().add(this.multiply(I)).log().multiply(I.negate()); }
public ValueType log10(CalculatedValue g) { if (g.isComplex() || g.real <= 0.0) { return setComplexValue(g.getComplex().log().divide(FastMath.log(10.0))); } else { return setValue(FastMath.log10(g.real)); } }
ComplexFormat cf = new ComplexFormat(); Complex c = cf.parse("1.110 + 2.222i"); Complex second = new Complex(2.0, 5.0); Complex answer = c.log(); // natural logarithm. answer = c.cos(); // cosine answer = c.pow(second); // first raised to the power of second ComplexFormat format = new ComplexFormat(); // default format String s1 = format.format(c); // s1 contains "1.110 + 2.222i" String s2 = format.format(second); // s2 contains "2.0 + 5.0i"
/** * c = a ^ b Michael Borcherds 2009-03-10 * * @param a * base * @param b * power * @param c * result */ public static void complexPower(GeoVec2D a, NumberValue b, GeoVec2D c) { if (a.x == 0 && a.y == 0 && b.getDouble() > 0) { c.x = 0; c.y = 0; } else { Complex out = new Complex(a.x, a.y); out = out.log().multiply(b.getDouble()).exp(); c.x = out.getReal(); c.y = out.getImaginary(); } c.setMode(Kernel.COORD_COMPLEX); }
/** * Numerical natural logarithm. * * @param complex argument * @return natural logarithm */ public static Complex log(Complex complex) { if (complex.isReal()) { double x = complex.getReal().doubleValue(); if (x >= 0) return new Complex(FastMath.log(complex.getReal().doubleValue())); } return new Complex(new org.apache.commons.math3.complex.Complex(complex.getReal().doubleValue(), complex.getImaginary().doubleValue()).log()); }