use of org.hipparchus.complex.Complex in project symja_android_library by axkr.
the class BesselJS method airyAiPrime.
public static Complex airyAiPrime(Complex x) {
if (F.isZero(x)) {
return new Complex(-1.0 / Math.pow(3.0, 1.0 / 3.0) / GammaJS.gamma(1.0 / 3.0));
}
if (x.getReal() < 0) {
Complex xMinus = x.negate();
Complex z = xMinus.pow(1.5).multiply(2.0 / 3.0);
return x.divide(3.0).multiply(besselJ(-2.0 / 3.0, z).subtract(besselJ(2.0 / 3.0, z)));
}
Complex z = x.pow(1.5).multiply(2.0 / 3.0);
return besselK(2.0 / 3.0, z).multiply(x).multiply(-1.0 / Math.PI / Math.sqrt(3.0));
}
use of org.hipparchus.complex.Complex in project symja_android_library by axkr.
the class EllipticIntegralsJS method carlsonRF.
private static Complex carlsonRF(Complex x, Complex y, Complex z, double tolerance) {
// if ( isComplex(x) || isComplex(y) || isComplex(z) ) {
// if (y.getImaginary()==0.0) {
// y = new Complex(y.getReal());
// }
Complex xm = x;
Complex ym = y;
Complex zm = z;
Complex A0 = x.add(y).add(z).divide(3.0);
Complex Am = A0;
double Q = Math.pow(3.0 * tolerance, -1.0 / 6.0) * Math.max(A0.subtract(x).norm(), Math.max(A0.subtract(y).norm(), A0.subtract(z).norm()));
double g = 0.25;
double pow4 = 1.0;
while (true) {
double absAm = Am.norm();
if (Double.isNaN(absAm) || Double.isInfinite(absAm)) {
throw new ArgumentTypeException("carlsonRF: Am is undefined");
}
Complex xs = xm.sqrt();
Complex ys = ym.sqrt();
Complex zs = zm.sqrt();
Complex lm = xs.multiply(ys).add(xs.multiply(zs)).add(ys.multiply(zs));
// Complex Am1 = Am.add(lm).multiply(g);
xm = xm.add(lm).multiply(g);
ym = ym.add(lm).multiply(g);
zm = zm.add(lm).multiply(g);
if (pow4 * Q < absAm) {
break;
}
// Am=Am1;
Am = Am.add(lm).multiply(g);
pow4 *= g;
}
Complex t = new Complex(pow4).divide(Am);
Complex X = A0.subtract(x).multiply(t);
Complex Y = A0.subtract(y).multiply(t);
Complex Z = X.add(Y).negate();
Complex E2 = X.multiply(Y).subtract(Z.multiply(Z));
Complex E3 = X.multiply(Y).multiply(Z);
// Am.pow(-0.5)
Complex AmPow = Am.pow(-0.5);
return AmPow.multiply(E2.multiply(-924.0).add(E2.multiply(E2).multiply(385.0)).add(E3.multiply(660.0)).add(E2.multiply(E3).multiply(-630.0)).add(9240.0)).multiply(1.0 / 9240.0);
}
use of org.hipparchus.complex.Complex in project symja_android_library by axkr.
the class EllipticIntegralsJS method kleinJ.
public static Complex kleinJ(Complex x) {
// from mpmath / elliptic.py
Complex q = new Complex(0, Math.PI).multiply(x).exp();
// TODO add Chop()
Complex t2 = EllipticFunctionsJS.jacobiTheta(2, Complex.ZERO, q);
Complex t3 = EllipticFunctionsJS.jacobiTheta(3, Complex.ZERO, q);
Complex t4 = EllipticFunctionsJS.jacobiTheta(4, Complex.ZERO, q);
Complex P = t2.pow(8.0).add(t3.pow(8.0)).add(t4.pow(8)).pow(3.0);
Complex Q = t2.multiply(t3).multiply(t4).pow(8.0).multiply(54.0);
return P.divide(Q);
}
use of org.hipparchus.complex.Complex in project symja_android_library by axkr.
the class EllipticIntegralsJS method ellipticPi.
public static Complex ellipticPi(Complex n, Complex x, Complex m) {
// return LegendreEllipticIntegral.bigPi(n, x, m);
Complex period = Complex.ZERO;
if (Math.abs(x.getReal()) > Math.PI / 2.0) {
long p = Math.round(x.getReal() / Math.PI);
x = new Complex(x.getReal() - p * Math.PI, x.getImaginary());
period = ellipticPi(n, new Complex(Math.PI / 2.0), m).multiply(p + p);
}
Complex sinX = x.sin();
Complex cosX = x.cos();
Complex sqrSinX = sinX.multiply(sinX);
Complex sqrCosX = cosX.multiply(cosX);
Complex p3SinX = sqrSinX.multiply(sinX);
Complex a2;
if (sinX.equals(Complex.ZERO)) {
a2 = Complex.ONE;
} else {
a2 = Complex.ONE.subtract(m.multiply(sqrSinX));
}
return sinX.multiply(carlsonRF(sqrCosX, a2, Complex.ONE)).add(n.multiply(1.0 / 3.0).multiply(p3SinX).multiply(carlsonRJ(sqrCosX, Complex.ONE.subtract(m.multiply(sqrSinX)), Complex.ONE, Complex.ONE.subtract(n.multiply(sqrSinX))))).add(period);
}
use of org.hipparchus.complex.Complex in project symja_android_library by axkr.
the class EllipticIntegralsJS method ellipticF.
// elliptic integrals
public static Complex ellipticF(Complex x, Complex m) {
// https://github.com/Hipparchus-Math/hipparchus/issues/151
// return LegendreEllipticIntegral.bigF(x, m);
Complex period = Complex.ZERO;
if (Math.abs(x.getReal()) > (Math.PI / 2)) {
long p = Math.round(x.getReal() / Math.PI);
x = new Complex(x.getReal() - p * Math.PI, x.getImaginary());
period = ellipticK(m).multiply(p + p);
}
Complex sinX = x.sin();
Complex cosX = x.cos();
if (cosX.getImaginary() == 0.0) {
cosX = new Complex(cosX.getReal());
}
Complex sqrSinX = sinX.multiply(sinX);
Complex sqrCosX = cosX.multiply(cosX);
return sinX.multiply(carlsonRF(sqrCosX, Complex.ONE.subtract(m.multiply(sqrSinX)), Complex.ONE)).add(period);
}
Aggregations