Search in sources :

Example 21 with Complex

use of org.hipparchus.complex.Complex in project symja_android_library by axkr.

the class EllipticFunctionsJS method weierstrassPPrime.

public static Complex weierstrassPPrime(Complex x, Complex g2, Complex g3) {
    // if ( !isComplex(x) ) x = complex(x);
    Complex[] sol = weierstrassRoots(g2, g3);
    Complex e1 = sol[0];
    Complex e2 = sol[1];
    Complex e3 = sol[2];
    // Whittaker & Watson, Section 22.351
    Complex m = e2.subtract(e3).divide(e1.subtract(e3));
    Complex argument = x.multiply(e1.subtract(e3).sqrt());
    return e1.subtract(e3).pow(1.5).multiply(jacobiCN(argument, m)).multiply(jacobiDN(argument, m)).multiply(jacobiSN(argument, m).pow(-3)).multiply(-2);
}
Also used : Complex(org.hipparchus.complex.Complex)

Example 22 with Complex

use of org.hipparchus.complex.Complex in project symja_android_library by axkr.

the class EllipticFunctionsJS method inverseWeierstrassP.

public static Complex inverseWeierstrassP(Complex x, Complex g2, Complex g3) {
    Complex[] sol = weierstrassRoots(g2, g3);
    Complex e1 = sol[0];
    Complex e2 = sol[1];
    Complex e3 = sol[2];
    return EllipticIntegralsJS.carlsonRF(x.subtract(e1), x.subtract(e2), x.subtract(e3));
}
Also used : Complex(org.hipparchus.complex.Complex)

Example 23 with Complex

use of org.hipparchus.complex.Complex in project symja_android_library by axkr.

the class GammaJS method coshIntegral.

public static Complex coshIntegral(Complex x) {
    // complex for negative real argument
    Complex xNegate = x.negate();
    Complex gamma1 = gammaZero(x);
    Complex gamma2 = gammaZero(xNegate);
    Complex result = gamma1.add(gamma2.add(x.log().negate()).add(xNegate.log())).multiply(-0.5);
    return result;
}
Also used : Complex(org.hipparchus.complex.Complex)

Example 24 with Complex

use of org.hipparchus.complex.Complex in project symja_android_library by axkr.

the class GammaJS method cosIntegral.

public static Complex cosIntegral(Complex x) {
    // complex for negative real argument
    Complex ix = Complex.I.multiply(x);
    Complex result = x.log().subtract(gammaZero(ix.negate()).add(gammaZero(ix)).add(ix.negate().log()).add(ix.log()).multiply(0.5));
    return result;
}
Also used : Complex(org.hipparchus.complex.Complex)

Example 25 with Complex

use of org.hipparchus.complex.Complex in project symja_android_library by axkr.

the class GammaJS method logGamma.

public static Complex logGamma(Complex x) {
    if (F.isNumIntValue(x.getReal()) && x.getReal() <= 0 && F.isZero(x.getImaginary())) {
        throw new ArgumentTypeException("Gamma function pole");
    }
    // reflection formula with modified Hare correction to imaginary part
    if (x.getReal() < 0.0) {
        Complex t = new Complex(Math.PI).divide(x.multiply(Math.PI).sin()).log().subtract(logGamma(x.negate().add(1.0)));
        double s = x.getImaginary() < 0.0 ? -1.0 : 1.0;
        double d = F.isZero(x.getImaginary()) ? 0.25 : 0;
        double k = Math.ceil(x.getReal() / 2.0 - 0.75 + d);
        return t.add(new Complex(0.0, 2.0 * s * k * Math.PI));
    }
    Complex t = x.add(5.24218750000000000);
    t = x.add(0.5).multiply(t.log()).subtract(t);
    Complex s = new Complex(0.999999999999997092);
    for (int j = 0; j < 14; j++) {
        s = s.add(x.add(j + 1).reciprocal().multiply(c[j]));
    }
    Complex u = t.add(s.divide(x).multiply(2.5066282746310005).log());
    // adjustment to keep imaginary part on same sheet
    if (s.getReal() < 0.0) {
        if (x.getImaginary() < 0.0 && s.divide(x).getImaginary() < 0) {
            u = u.add(new Complex(0.0, Math.PI + Math.PI));
        }
        if (x.getImaginary() > 0 && s.divide(x).getImaginary() > 0) {
            u = u.add(new Complex(0.0, -Math.PI + Math.PI));
        }
    }
    return u;
}
Also used : ArgumentTypeException(org.matheclipse.core.eval.exception.ArgumentTypeException) Complex(org.hipparchus.complex.Complex)

Aggregations

Complex (org.hipparchus.complex.Complex)74 ArgumentTypeException (org.matheclipse.core.eval.exception.ArgumentTypeException)12 EvalEngine (org.matheclipse.core.eval.EvalEngine)8 IExpr (org.matheclipse.core.interfaces.IExpr)6 Config (org.matheclipse.core.basic.Config)4 F (org.matheclipse.core.expression.F)4 IAST (org.matheclipse.core.interfaces.IAST)4 Gamma (org.hipparchus.special.Gamma)3 Arithmetic (org.matheclipse.core.builtin.Arithmetic)3 IterationLimitExceeded (org.matheclipse.core.eval.exception.IterationLimitExceeded)3 ValidateException (org.matheclipse.core.eval.exception.ValidateException)3 S (org.matheclipse.core.expression.S)3 IComplex (org.matheclipse.core.interfaces.IComplex)3 ISymbol (org.matheclipse.core.interfaces.ISymbol)3 Math.abs (java.lang.Math.abs)2 ArrayList (java.util.ArrayList)2 Function (java.util.function.Function)2 IntFunction (java.util.function.IntFunction)2 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)2 FiniteDifferencesDifferentiator (org.hipparchus.analysis.differentiation.FiniteDifferencesDifferentiator)2