Search in sources :

Example 66 with Complex

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

the class GammaJS method fresnelS.

public static Complex fresnelS(Complex x) {
    Complex m1 = HypergeometricJS.hypergeometric1F1(new Complex(0.5), new Complex(1.5), new Complex(0, Math.PI / 2).multiply(x.multiply(x)));
    Complex m2 = HypergeometricJS.hypergeometric1F1(new Complex(0.5), new Complex(1.5), new Complex(0, -Math.PI / 2).multiply(x.multiply(x)));
    Complex result = x.multiply(m1.subtract(m2)).multiply(new Complex(0, -0.5));
    return result;
}
Also used : Complex(org.hipparchus.complex.Complex)

Example 67 with Complex

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

the class GammaJS method sinIntegral.

public static Complex sinIntegral(Complex x) {
    if (Complex.equals(x, Complex.ZERO, Config.SPECIAL_FUNCTIONS_TOLERANCE)) {
        return Complex.ZERO;
    }
    Complex ix = Complex.I.multiply(x);
    Complex result = new Complex(0, 0.5).multiply(gamma(Complex.ZERO, ix.negate()).add(gammaZero(ix).negate()).add(ix.negate().log()).add(ix.log().negate()));
    if (F.isZero(x.getImaginary())) {
        return new Complex(result.getReal());
    }
    // return result.re;
    return result;
}
Also used : Complex(org.hipparchus.complex.Complex)

Example 68 with Complex

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

the class GammaJS method fresnelC.

public static Complex fresnelC(Complex x) {
    Complex m1 = HypergeometricJS.hypergeometric1F1(new Complex(0.5), new Complex(1.5), new Complex(0, Math.PI / 2).multiply(x.multiply(x)));
    Complex m2 = HypergeometricJS.hypergeometric1F1(new Complex(0.5), new Complex(1.5), new Complex(0, -Math.PI / 2).multiply(x.multiply(x)));
    Complex result = x.multiply(m1.add(m2)).multiply(0.5);
    return result;
}
Also used : Complex(org.hipparchus.complex.Complex)

Example 69 with Complex

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

the class GammaJS method expIntegralEi.

public static Complex expIntegralEi(Complex x) {
    double useAsymptotic = 26.0;
    if (x.norm() > useAsymptotic) {
        Complex s = Complex.ONE;
        Complex p = Complex.ONE;
        int i = 1;
        Complex xInverse = x.reciprocal();
        while (Math.abs(p.getReal()) > Config.SPECIAL_FUNCTIONS_TOLERANCE || Math.abs(p.getImaginary()) > Config.SPECIAL_FUNCTIONS_TOLERANCE) {
            p = p.multiply(i).multiply(xInverse);
            s = s.add(p);
            i++;
        }
        // combination of logarithms adds/subtracts Complex(0,Pi)
        int sign = x.getImaginary() > 0 ? 1 : x.getImaginary() < 0 ? -1 : 0;
        return s.multiply(x.exp()).multiply(xInverse).add(new Complex(0.0, sign * Math.PI));
    }
    Complex s = Complex.ZERO;
    Complex p = Complex.ONE;
    int i = 1;
    while (Math.abs(p.getReal() / i) > Config.SPECIAL_FUNCTIONS_TOLERANCE || Math.abs(p.getImaginary() / i) > Config.SPECIAL_FUNCTIONS_TOLERANCE) {
        p = p.multiply(x).divide(i);
        s = s.add(p.divide(i));
        i++;
    }
    s = s.add(ConstantDefinitions.EULER_GAMMA).add(x.log());
    // real on negative real axis, set phase explicitly rather than log combo
    if (x.getReal() < 0.0 && F.isZero(x.getImaginary())) {
        return new Complex(s.getReal(), 0.0);
    }
    return s;
}
Also used : Complex(org.hipparchus.complex.Complex)

Example 70 with Complex

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

the class ZetaJS method complexSummation.

public static Complex complexSummation(java.util.function.DoubleFunction<Complex> f, double a, double b, int iterationLimit) {
    Complex s = Complex.ZERO;
    int counter = 0;
    for (double i = a; i <= b; i++) {
        if (counter++ > iterationLimit && iterationLimit > 0) {
            IterationLimitExceeded.throwIt(counter, S.Sum);
        }
        s = s.add(f.apply(i));
    }
    return s;
}
Also used : 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