MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / jacobiTheta

Function jacobiTheta

src/compute-engine/numerics/numeric-complex.ts:956–1001  ·  view source on GitHub ↗
(
  j: 1 | 2 | 3 | 4,
  z: Complex,
  tau: Complex
)

Source from the content-addressed store, hash-verified

954 const aTerm = isNonPositiveIntegerC(a) ? -a.re : Infinity;
955 const bTerm = isNonPositiveIntegerC(b) ? -b.re : Infinity;
956 const nTerms = Math.min(aTerm, bTerm);
957 if (isNonPositiveIntegerC(c)) {
958 if (nTerms === Infinity || nTerms > -c.re) return C_NAN;
959 }
960 if (nTerms !== Infinity) return gauss2F1SeriesC(a, b, c, z, nTerms + 1);
961
962 if (z.isZero()) return C_ONE;
963
964 const one = C_ONE;
965 const s = c.sub(a).sub(b); // c − a − b
966 const d = b.sub(a); // b − a
967
968 if (z.equals(one)) {
969 // Gauss summation: Γ(c)Γ(c−a−b)/(Γ(c−a)Γ(c−b)), requires Re(c−a−b) > 0
970 if (s.re <= 0) return C_NAN; // divergent (or log-divergent at s = 0)
971 return gammaRatioC([c, s], [c.sub(a), c.sub(b)]);
972 }
973
974 // Principal branch on the cut [1, ∞): the z − i0 convention (limit from
975 // below). Forcing im = −0 makes atan2 yield Arg(1−z) = Arg(−z) = +π for
976 // real z > 1, which is exactly the z − i0 limit.
977 if (z.im === 0) z = new Complex(z.re, -0);
978
979 const sIsDegenerate = distToIntegerC(s) <= DEGENERATE_TOL;
980 const dIsDegenerate = distToIntegerC(d) <= DEGENERATE_TOL;
981
982 // The six Kummer maps, by transformed argument. `degenerate` marks maps
983 // whose connection formula breaks down for the current parameters.
984 const candidates: {
985 kind:
986 | 'direct'
987 | 'pfaff'
988 | 'one-minus-z'
989 | 'inv-z'
990 | 'inv-one-minus-z'
991 | 'one-minus-inv-z';
992 w: Complex;
993 degenerate: boolean;
994 }[] = [
995 { kind: 'direct', w: z, degenerate: false },
996 { kind: 'pfaff', w: z.div(z.sub(1)), degenerate: false },
997 { kind: 'one-minus-z', w: one.sub(z), degenerate: sIsDegenerate },
998 { kind: 'inv-z', w: one.div(z), degenerate: dIsDegenerate },
999 {
1000 kind: 'inv-one-minus-z',
1001 w: one.div(one.sub(z)),
1002 degenerate: dIsDegenerate,
1003 },
1004 {

Callers 1

Calls 9

nomePowerFunction · 0.85
sinMethod · 0.80
cosMethod · 0.80
absMethod · 0.65
mulMethod · 0.65
negMethod · 0.65
addMethod · 0.65
expMethod · 0.65
isNaNMethod · 0.45

Tested by

no test coverage detected