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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations