@danielsimonjr/mathts-functions 0.47.0 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cas-integration.d.ts +6 -0
- package/dist/cas-integration.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +357 -138
- package/dist/special/wave-functions.d.ts +123 -0
- package/dist/special/wave-functions.d.ts.map +1 -0
- package/dist/typed/algebra.d.ts +18 -6
- package/dist/typed/algebra.d.ts.map +1 -1
- package/dist/typed/cas.d.ts +31 -27
- package/dist/typed/cas.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -3,8 +3,14 @@
|
|
|
3
3
|
* returned as an expression string (without the constant of integration). If the
|
|
4
4
|
* integrand is outside the supported subset, returns `integral(expr, variable)`.
|
|
5
5
|
*
|
|
6
|
+
* The direct recursion is tried first; on failure, partial-fraction integration
|
|
7
|
+
* (for rational integrands) and tabular integration by parts (for
|
|
8
|
+
* polynomial·{exp,sin,cos}) are attempted before giving up with the marker.
|
|
9
|
+
*
|
|
6
10
|
* @example symbolicIntegral('x^3') // 'x^4 / 4'
|
|
7
11
|
* @example symbolicIntegral('cos(3*x + 1)') // 'sin(3 * x + 1) / 3'
|
|
12
|
+
* @example symbolicIntegral('1/(x^2 - 1)') // partial fractions → sum of logs
|
|
13
|
+
* @example symbolicIntegral('x * sin(x)') // by parts → 'sin(x) - x*cos(x)'
|
|
8
14
|
*/
|
|
9
15
|
export declare function symbolicIntegral(expr: string, variable?: string): string;
|
|
10
16
|
//# sourceMappingURL=cas-integration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cas-integration.d.ts","sourceRoot":"","sources":["../src/cas-integration.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cas-integration.d.ts","sourceRoot":"","sources":["../src/cas-integration.ts"],"names":[],"mappings":"AAoWA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,SAAM,GAAG,MAAM,CAWrE"}
|
package/dist/index.d.ts
CHANGED
|
@@ -106,6 +106,7 @@ export { jacobiSN, jacobiCN, jacobiDN } from './special/jacobi-elliptic.js';
|
|
|
106
106
|
export { rootsLegendre } from './numeric/gauss-nodes.js';
|
|
107
107
|
export type { RootsLegendreResult } from './numeric/gauss-nodes.js';
|
|
108
108
|
export { polylog, struveH, struveL, kelvinBer, kelvinBei, barnesG } from './special/niche.js';
|
|
109
|
+
export { siegelZ, riemannSiegelZ, lerchPhi, parabolicCylinderD, coulombF, } from './special/wave-functions.js';
|
|
109
110
|
export { bfs, dfs, floydWarshall, bellmanFord, closenessCentrality, harmonicCentrality, } from './graph/traversal-centrality.js';
|
|
110
111
|
export type { BellmanFordResult } from './graph/traversal-centrality.js';
|
|
111
112
|
export { maxFlow, minCut, astar, hungarian } from './graph/optimization.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,cAAc,kBAAkB,CAAC;AAKjC,cAAc,gBAAgB,CAAC;AAG/B,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAOzC,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAG7C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAGlG,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAMjC,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,WAAW,EACX,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,eAAe,GAChB,MAAM,yBAAyB,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,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAI1E,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAI1F,OAAO,EAAE,yBAAyB,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AACtF,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAI9F,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAChG,YAAY,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -10230,10 +10230,10 @@ function splitProductChain(term) {
|
|
|
10230
10230
|
return { nums, dens };
|
|
10231
10231
|
}
|
|
10232
10232
|
function expand(expr) {
|
|
10233
|
-
const
|
|
10234
|
-
if (
|
|
10233
|
+
const vars = variables(expr);
|
|
10234
|
+
if (vars.length >= 1) {
|
|
10235
10235
|
try {
|
|
10236
|
-
return polyToString(polyFromExpression(expr,
|
|
10236
|
+
return polyToString(polyFromExpression(expr, vars), vars);
|
|
10237
10237
|
} catch {
|
|
10238
10238
|
}
|
|
10239
10239
|
}
|
|
@@ -10256,8 +10256,71 @@ function expand(expr) {
|
|
|
10256
10256
|
}
|
|
10257
10257
|
return result;
|
|
10258
10258
|
}
|
|
10259
|
+
function monomialString(powers, vars) {
|
|
10260
|
+
return powers.map((e, i) => e === 0 ? "" : e === 1 ? vars[i] : `${vars[i]}^${e}`).filter(Boolean).join("*");
|
|
10261
|
+
}
|
|
10262
|
+
function perfectIntSqrt(n) {
|
|
10263
|
+
if (n < 0) return null;
|
|
10264
|
+
const r = Math.round(Math.sqrt(n));
|
|
10265
|
+
return r * r === n ? r : null;
|
|
10266
|
+
}
|
|
10267
|
+
function tryMonomialDiffOfSquares(poly, vars) {
|
|
10268
|
+
if (poly.length !== 2) return null;
|
|
10269
|
+
const [t1, t2] = poly;
|
|
10270
|
+
if (Math.sign(t1.coeff) === Math.sign(t2.coeff)) return null;
|
|
10271
|
+
const pos = t1.coeff > 0 ? t1 : t2;
|
|
10272
|
+
const neg = t1.coeff > 0 ? t2 : t1;
|
|
10273
|
+
const cp = perfectIntSqrt(Math.round(pos.coeff));
|
|
10274
|
+
const cn = perfectIntSqrt(Math.round(-neg.coeff));
|
|
10275
|
+
if (cp === null || cn === null) return null;
|
|
10276
|
+
if (!pos.powers.every((e) => e % 2 === 0) || !neg.powers.every((e) => e % 2 === 0)) return null;
|
|
10277
|
+
const half = (t) => t.powers.map((e) => e / 2);
|
|
10278
|
+
const term = (c, powers) => {
|
|
10279
|
+
const mon = monomialString(powers, vars);
|
|
10280
|
+
if (!mon) return String(c);
|
|
10281
|
+
return c === 1 ? mon : `${c}*${mon}`;
|
|
10282
|
+
};
|
|
10283
|
+
const A = term(cp, half(pos));
|
|
10284
|
+
const B = term(cn, half(neg));
|
|
10285
|
+
return [`(${A} - ${B})`, `(${A} + ${B})`];
|
|
10286
|
+
}
|
|
10287
|
+
function factorMultivariate(expr, vars) {
|
|
10288
|
+
let poly;
|
|
10289
|
+
try {
|
|
10290
|
+
poly = polyFromExpression(expr, vars);
|
|
10291
|
+
} catch {
|
|
10292
|
+
return null;
|
|
10293
|
+
}
|
|
10294
|
+
if (poly.length < 2 || !poly.every((t) => isNearInt(t.coeff))) return null;
|
|
10295
|
+
let content = 0;
|
|
10296
|
+
for (const t of poly) content = gcdNum(content, Math.abs(Math.round(t.coeff)));
|
|
10297
|
+
if (content === 0) return null;
|
|
10298
|
+
const nVars = vars.length;
|
|
10299
|
+
const monPow = new Array(nVars).fill(Infinity);
|
|
10300
|
+
for (const t of poly)
|
|
10301
|
+
for (let i = 0; i < nVars; i++) monPow[i] = Math.min(monPow[i], t.powers[i]);
|
|
10302
|
+
const hasMonomial = monPow.some((e) => e > 0);
|
|
10303
|
+
const cofactor = normalize(
|
|
10304
|
+
poly.map((t) => ({
|
|
10305
|
+
coeff: Math.round(t.coeff) / content,
|
|
10306
|
+
powers: t.powers.map((e, i) => e - monPow[i])
|
|
10307
|
+
}))
|
|
10308
|
+
);
|
|
10309
|
+
const dsq = tryMonomialDiffOfSquares(cofactor, vars);
|
|
10310
|
+
if (!hasMonomial && !dsq) return null;
|
|
10311
|
+
const parts = [];
|
|
10312
|
+
if (content > 1) parts.push(String(content));
|
|
10313
|
+
if (hasMonomial) parts.push(monomialString(monPow, vars));
|
|
10314
|
+
if (dsq) parts.push(dsq[0], dsq[1]);
|
|
10315
|
+
else parts.push(`(${polyToString(cofactor, vars)})`);
|
|
10316
|
+
return parts.join("*");
|
|
10317
|
+
}
|
|
10259
10318
|
function factor(expr) {
|
|
10260
10319
|
const univariateVars = variables(expr);
|
|
10320
|
+
if (univariateVars.length >= 2) {
|
|
10321
|
+
const mv = factorMultivariate(expr, univariateVars);
|
|
10322
|
+
if (mv !== null) return mv;
|
|
10323
|
+
}
|
|
10261
10324
|
if (univariateVars.length === 1) {
|
|
10262
10325
|
try {
|
|
10263
10326
|
const v = univariateVars[0];
|
|
@@ -31684,9 +31747,9 @@ var dependencies187 = ["typed", "factorial"];
|
|
|
31684
31747
|
var createPermutations = /* @__PURE__ */ factory(
|
|
31685
31748
|
name187,
|
|
31686
31749
|
dependencies187,
|
|
31687
|
-
({ typed: typed3, factorial:
|
|
31750
|
+
({ typed: typed3, factorial: factorial6 }) => {
|
|
31688
31751
|
return typed3(name187, {
|
|
31689
|
-
"number | BigNumber":
|
|
31752
|
+
"number | BigNumber": factorial6,
|
|
31690
31753
|
"number, number": function(n, k) {
|
|
31691
31754
|
if (!isInteger(n) || n < 0) {
|
|
31692
31755
|
throw new TypeError("Positive integer value expected in function permutations");
|
|
@@ -35910,7 +35973,7 @@ var dependencies224 = ["typed", "add", "divide", "multiply", "factorial", "isInt
|
|
|
35910
35973
|
var createMultinomial = /* @__PURE__ */ factory(
|
|
35911
35974
|
name224,
|
|
35912
35975
|
dependencies224,
|
|
35913
|
-
({ typed: typed3, add: add4, divide: divide2, multiply: multiply2, factorial:
|
|
35976
|
+
({ typed: typed3, add: add4, divide: divide2, multiply: multiply2, factorial: factorial6, isInteger: isInteger3, isPositive: isPositive2 }) => {
|
|
35914
35977
|
return typed3(name224, {
|
|
35915
35978
|
"Array | Matrix": function(a) {
|
|
35916
35979
|
let sum3 = 0;
|
|
@@ -35920,9 +35983,9 @@ var createMultinomial = /* @__PURE__ */ factory(
|
|
|
35920
35983
|
throw new TypeError("Positive integer value expected in function multinomial");
|
|
35921
35984
|
}
|
|
35922
35985
|
sum3 = add4(sum3, ai);
|
|
35923
|
-
denom = multiply2(denom,
|
|
35986
|
+
denom = multiply2(denom, factorial6(ai));
|
|
35924
35987
|
});
|
|
35925
|
-
return divide2(
|
|
35988
|
+
return divide2(factorial6(sum3), denom);
|
|
35926
35989
|
}
|
|
35927
35990
|
});
|
|
35928
35991
|
}
|
|
@@ -36979,7 +37042,7 @@ var createZeta = /* @__PURE__ */ factory(
|
|
|
36979
37042
|
multiply: multiply2,
|
|
36980
37043
|
pow: pow2,
|
|
36981
37044
|
divide: divide2,
|
|
36982
|
-
factorial:
|
|
37045
|
+
factorial: factorial6,
|
|
36983
37046
|
equal: equal2,
|
|
36984
37047
|
smallerEq: smallerEq2,
|
|
36985
37048
|
isBounded: isBounded2,
|
|
@@ -37057,8 +37120,8 @@ var createZeta = /* @__PURE__ */ factory(
|
|
|
37057
37120
|
let S = k;
|
|
37058
37121
|
for (let j = k; smallerEq2(j, n); j = add4(j, 1)) {
|
|
37059
37122
|
const factor2 = divide2(
|
|
37060
|
-
multiply2(
|
|
37061
|
-
multiply2(
|
|
37123
|
+
multiply2(factorial6(add4(n, subtract3(j, 1))), pow2(4, j)),
|
|
37124
|
+
multiply2(factorial6(subtract3(n, j)), factorial6(multiply2(2, j)))
|
|
37062
37125
|
);
|
|
37063
37126
|
S = add4(S, factor2);
|
|
37064
37127
|
}
|
|
@@ -43784,65 +43847,6 @@ function _combineLikeTerms(expr) {
|
|
|
43784
43847
|
if (parts.length === 0) return "0";
|
|
43785
43848
|
return parts.join(" + ").replace(/\+\s*-/g, "- ");
|
|
43786
43849
|
}
|
|
43787
|
-
function _casExpandOne(expr) {
|
|
43788
|
-
let result = expr;
|
|
43789
|
-
result = result.replace(/\(([^()]+)\)\^2/g, "($1)*($1)");
|
|
43790
|
-
const mulPattern = /\(([^()]+)\)\s*\*\s*\(([^()]+)\)/g;
|
|
43791
|
-
let match;
|
|
43792
|
-
let safetyCount = 0;
|
|
43793
|
-
while ((match = mulPattern.exec(result)) !== null && safetyCount++ < 20) {
|
|
43794
|
-
const leftTerms = match[1].split(/\s*\+\s*/);
|
|
43795
|
-
const rightTerms = match[2].split(/\s*\+\s*/);
|
|
43796
|
-
const products = [];
|
|
43797
|
-
for (const l of leftTerms) {
|
|
43798
|
-
for (const rv of rightTerms) {
|
|
43799
|
-
products.push(l.trim() + "*" + rv.trim());
|
|
43800
|
-
}
|
|
43801
|
-
}
|
|
43802
|
-
result = result.slice(0, match.index) + products.join(" + ") + result.slice(match.index + match[0].length);
|
|
43803
|
-
mulPattern.lastIndex = 0;
|
|
43804
|
-
}
|
|
43805
|
-
return result;
|
|
43806
|
-
}
|
|
43807
|
-
function _casFactorOne(expr) {
|
|
43808
|
-
function _gcd2(a, b) {
|
|
43809
|
-
a = Math.abs(a);
|
|
43810
|
-
b = Math.abs(b);
|
|
43811
|
-
while (b !== 0) {
|
|
43812
|
-
const tmp = b;
|
|
43813
|
-
b = a % b;
|
|
43814
|
-
a = tmp;
|
|
43815
|
-
}
|
|
43816
|
-
return a;
|
|
43817
|
-
}
|
|
43818
|
-
const normalized = expr.replace(/\s*-\s*/g, " + -");
|
|
43819
|
-
const terms = normalized.split(/\s*\+\s*/).filter((t) => t.trim() !== "");
|
|
43820
|
-
if (terms.length < 2) return expr;
|
|
43821
|
-
const coeffs = [];
|
|
43822
|
-
const varParts = [];
|
|
43823
|
-
for (const term of terms) {
|
|
43824
|
-
const numMatch = term.match(/^(-?\d+)\s*\*?\s*(.*)$/);
|
|
43825
|
-
if (numMatch) {
|
|
43826
|
-
coeffs.push(parseInt(numMatch[1], 10));
|
|
43827
|
-
varParts.push(numMatch[2] || "1");
|
|
43828
|
-
} else {
|
|
43829
|
-
return expr;
|
|
43830
|
-
}
|
|
43831
|
-
}
|
|
43832
|
-
let g = Math.abs(coeffs[0]);
|
|
43833
|
-
for (let i = 1; i < coeffs.length; i++) {
|
|
43834
|
-
g = _gcd2(g, Math.abs(coeffs[i]));
|
|
43835
|
-
}
|
|
43836
|
-
if (g <= 1) return expr;
|
|
43837
|
-
const inner = coeffs.map((c, i) => {
|
|
43838
|
-
const reduced = c / g;
|
|
43839
|
-
if (varParts[i] === "1") return String(reduced);
|
|
43840
|
-
if (reduced === 1) return varParts[i];
|
|
43841
|
-
if (reduced === -1) return "-" + varParts[i];
|
|
43842
|
-
return reduced + "*" + varParts[i];
|
|
43843
|
-
}).join(" + ");
|
|
43844
|
-
return g + "*(" + inner + ")";
|
|
43845
|
-
}
|
|
43846
43850
|
function _casDerivativeOne(expr, variable) {
|
|
43847
43851
|
const terms = expr.split(/\s*\+\s*/);
|
|
43848
43852
|
const derivedTerms = [];
|
|
@@ -44101,76 +44105,15 @@ function casDerivative(input, variable) {
|
|
|
44101
44105
|
}
|
|
44102
44106
|
function casExpand(input) {
|
|
44103
44107
|
if (!Array.isArray(input)) {
|
|
44104
|
-
return
|
|
44108
|
+
return expand(_nodeToStr(input));
|
|
44105
44109
|
}
|
|
44106
|
-
|
|
44107
|
-
if (strs.length < CAS_BATCH_THRESHOLD || !computePool12.isReady()) {
|
|
44108
|
-
return Promise.resolve(strs.map(_casExpandOne));
|
|
44109
|
-
}
|
|
44110
|
-
return computePool12.map(strs, (exprStr) => {
|
|
44111
|
-
let result = exprStr;
|
|
44112
|
-
result = result.replace(/\(([^()]+)\)\^2/g, "($1)*($1)");
|
|
44113
|
-
const mulPattern = /\(([^()]+)\)\s*\*\s*\(([^()]+)\)/g;
|
|
44114
|
-
let match;
|
|
44115
|
-
let safetyCount = 0;
|
|
44116
|
-
while ((match = mulPattern.exec(result)) !== null && safetyCount++ < 20) {
|
|
44117
|
-
const leftTerms = match[1].split(/\s*\+\s*/);
|
|
44118
|
-
const rightTerms = match[2].split(/\s*\+\s*/);
|
|
44119
|
-
const products = [];
|
|
44120
|
-
for (const l of leftTerms) {
|
|
44121
|
-
for (const rv of rightTerms) {
|
|
44122
|
-
products.push(l.trim() + "*" + rv.trim());
|
|
44123
|
-
}
|
|
44124
|
-
}
|
|
44125
|
-
result = result.slice(0, match.index) + products.join(" + ") + result.slice(match.index + match[0].length);
|
|
44126
|
-
mulPattern.lastIndex = 0;
|
|
44127
|
-
}
|
|
44128
|
-
return result;
|
|
44129
|
-
}).then((r) => r.result);
|
|
44110
|
+
return Promise.resolve(input.map((e) => expand(_nodeToStr(e))));
|
|
44130
44111
|
}
|
|
44131
44112
|
function casFactor(input) {
|
|
44132
44113
|
if (!Array.isArray(input)) {
|
|
44133
|
-
return
|
|
44134
|
-
}
|
|
44135
|
-
const strs = input.map(_nodeToStr);
|
|
44136
|
-
if (strs.length < CAS_BATCH_THRESHOLD || !computePool12.isReady()) {
|
|
44137
|
-
return Promise.resolve(strs.map(_casFactorOne));
|
|
44114
|
+
return factor(_nodeToStr(input));
|
|
44138
44115
|
}
|
|
44139
|
-
return
|
|
44140
|
-
function _gcdW(a, b) {
|
|
44141
|
-
a = Math.abs(a);
|
|
44142
|
-
b = Math.abs(b);
|
|
44143
|
-
while (b !== 0) {
|
|
44144
|
-
const tmp = b;
|
|
44145
|
-
b = a % b;
|
|
44146
|
-
a = tmp;
|
|
44147
|
-
}
|
|
44148
|
-
return a;
|
|
44149
|
-
}
|
|
44150
|
-
const normalized = exprStr.replace(/\s*-\s*/g, " + -");
|
|
44151
|
-
const terms = normalized.split(/\s*\+\s*/).filter((t) => t.trim() !== "");
|
|
44152
|
-
if (terms.length < 2) return exprStr;
|
|
44153
|
-
const coeffs = [];
|
|
44154
|
-
const varParts = [];
|
|
44155
|
-
for (const term of terms) {
|
|
44156
|
-
const numMatch = term.match(/^(-?\d+)\s*\*?\s*(.*)$/);
|
|
44157
|
-
if (numMatch) {
|
|
44158
|
-
coeffs.push(parseInt(numMatch[1], 10));
|
|
44159
|
-
varParts.push(numMatch[2] || "1");
|
|
44160
|
-
} else return exprStr;
|
|
44161
|
-
}
|
|
44162
|
-
let g = Math.abs(coeffs[0]);
|
|
44163
|
-
for (let i = 1; i < coeffs.length; i++) g = _gcdW(g, Math.abs(coeffs[i]));
|
|
44164
|
-
if (g <= 1) return exprStr;
|
|
44165
|
-
const inner = coeffs.map((c, i) => {
|
|
44166
|
-
const reduced = c / g;
|
|
44167
|
-
if (varParts[i] === "1") return String(reduced);
|
|
44168
|
-
if (reduced === 1) return varParts[i];
|
|
44169
|
-
if (reduced === -1) return "-" + varParts[i];
|
|
44170
|
-
return reduced + "*" + varParts[i];
|
|
44171
|
-
}).join(" + ");
|
|
44172
|
-
return g + "*(" + inner + ")";
|
|
44173
|
-
}).then((r) => r.result);
|
|
44116
|
+
return Promise.resolve(input.map((e) => factor(_nodeToStr(e))));
|
|
44174
44117
|
}
|
|
44175
44118
|
|
|
44176
44119
|
// src/config-api.ts
|
|
@@ -48326,7 +48269,9 @@ function isConst(n, x) {
|
|
|
48326
48269
|
const node = unwrap(n);
|
|
48327
48270
|
if (node.type === "SymbolNode") return node.name !== x;
|
|
48328
48271
|
if (node.type === "ConstantNode") return true;
|
|
48329
|
-
return [...node.args ?? [], ...node.content ? [node.content] : []].every(
|
|
48272
|
+
return [...node.args ?? [], ...node.content ? [node.content] : []].every(
|
|
48273
|
+
(a) => isConst(a, x)
|
|
48274
|
+
);
|
|
48330
48275
|
}
|
|
48331
48276
|
function num(v) {
|
|
48332
48277
|
return Number.isInteger(v) ? String(v) : String(Number(v.toPrecision(15)));
|
|
@@ -48422,12 +48367,126 @@ function integrateNode(raw, x) {
|
|
|
48422
48367
|
throw new NotIntegrable(node.type);
|
|
48423
48368
|
}
|
|
48424
48369
|
}
|
|
48370
|
+
var stripWs = (s) => s.replace(/\s+/g, "");
|
|
48371
|
+
function tryPartialFractions(expr, x) {
|
|
48372
|
+
const vars = variables(expr);
|
|
48373
|
+
if (vars.length !== 1 || vars[0] !== x) return null;
|
|
48374
|
+
let decomposed;
|
|
48375
|
+
try {
|
|
48376
|
+
decomposed = apart(expr);
|
|
48377
|
+
} catch {
|
|
48378
|
+
return null;
|
|
48379
|
+
}
|
|
48380
|
+
if (stripWs(decomposed) === stripWs(expr)) return null;
|
|
48381
|
+
try {
|
|
48382
|
+
return integrateNode(parse2(decomposed), x);
|
|
48383
|
+
} catch {
|
|
48384
|
+
return null;
|
|
48385
|
+
}
|
|
48386
|
+
}
|
|
48387
|
+
function flattenMul(raw) {
|
|
48388
|
+
const n = unwrap(raw);
|
|
48389
|
+
if (n.type === "OperatorNode" && n.op === "*") {
|
|
48390
|
+
return (n.args ?? []).flatMap(flattenMul);
|
|
48391
|
+
}
|
|
48392
|
+
return [n];
|
|
48393
|
+
}
|
|
48394
|
+
function polyDenseFromStr(s, x) {
|
|
48395
|
+
const poly = polyFromExpression(s, [x]);
|
|
48396
|
+
let maxPow = 0;
|
|
48397
|
+
for (const t of poly) maxPow = Math.max(maxPow, t.powers[0] ?? 0);
|
|
48398
|
+
const dense = new Array(maxPow + 1).fill(0);
|
|
48399
|
+
for (const t of poly) dense[t.powers[0]] += t.coeff;
|
|
48400
|
+
return dense;
|
|
48401
|
+
}
|
|
48402
|
+
function derivDense(c) {
|
|
48403
|
+
if (c.length <= 1) return [0];
|
|
48404
|
+
return c.slice(1).map((v, i) => v * (i + 1));
|
|
48405
|
+
}
|
|
48406
|
+
function densePolyToStr(coeffs, x) {
|
|
48407
|
+
const parts = [];
|
|
48408
|
+
for (let i = coeffs.length - 1; i >= 0; i--) {
|
|
48409
|
+
const c = coeffs[i];
|
|
48410
|
+
if (Math.abs(c) < 1e-12) continue;
|
|
48411
|
+
if (i === 0) parts.push(num(c));
|
|
48412
|
+
else {
|
|
48413
|
+
const v = i === 1 ? x : `${x}^${i}`;
|
|
48414
|
+
if (Math.abs(c - 1) < 1e-12) parts.push(v);
|
|
48415
|
+
else if (Math.abs(c + 1) < 1e-12) parts.push(`-${v}`);
|
|
48416
|
+
else parts.push(`${num(c)}*${v}`);
|
|
48417
|
+
}
|
|
48418
|
+
}
|
|
48419
|
+
if (parts.length === 0) return "0";
|
|
48420
|
+
return parts.join(" + ").replace(/\+ -/g, "- ");
|
|
48421
|
+
}
|
|
48422
|
+
var isZeroDense = (c) => c.every((v) => Math.abs(v) < 1e-12);
|
|
48423
|
+
function repeatedAntideriv(fn, u, m) {
|
|
48424
|
+
if (fn === "exp") return { str: `exp(${u})`, sign: 1 };
|
|
48425
|
+
const rem = ((m - 1) % 4 + 4) % 4;
|
|
48426
|
+
if (fn === "sin") {
|
|
48427
|
+
return [
|
|
48428
|
+
{ str: `cos(${u})`, sign: -1 },
|
|
48429
|
+
{ str: `sin(${u})`, sign: -1 },
|
|
48430
|
+
{ str: `cos(${u})`, sign: 1 },
|
|
48431
|
+
{ str: `sin(${u})`, sign: 1 }
|
|
48432
|
+
][rem];
|
|
48433
|
+
}
|
|
48434
|
+
return [
|
|
48435
|
+
{ str: `sin(${u})`, sign: 1 },
|
|
48436
|
+
{ str: `cos(${u})`, sign: -1 },
|
|
48437
|
+
{ str: `sin(${u})`, sign: -1 },
|
|
48438
|
+
{ str: `cos(${u})`, sign: 1 }
|
|
48439
|
+
][rem];
|
|
48440
|
+
}
|
|
48441
|
+
function tryByParts(expr, x) {
|
|
48442
|
+
let root2;
|
|
48443
|
+
try {
|
|
48444
|
+
root2 = unwrap(parse2(expr));
|
|
48445
|
+
} catch {
|
|
48446
|
+
return null;
|
|
48447
|
+
}
|
|
48448
|
+
if (root2.type !== "OperatorNode" || root2.op !== "*") return null;
|
|
48449
|
+
const factors = flattenMul(root2);
|
|
48450
|
+
const gFactors = factors.filter((f) => f.type === "FunctionNode");
|
|
48451
|
+
if (gFactors.length !== 1) return null;
|
|
48452
|
+
const g = gFactors[0];
|
|
48453
|
+
const fn = g.fn?.name ?? g.name ?? "";
|
|
48454
|
+
if (fn !== "exp" && fn !== "sin" && fn !== "cos") return null;
|
|
48455
|
+
const arg3 = (g.args ?? [])[0];
|
|
48456
|
+
if (!arg3) return null;
|
|
48457
|
+
const u = arg3.toString();
|
|
48458
|
+
const a = linearSlope(u, x);
|
|
48459
|
+
if (a === null) return null;
|
|
48460
|
+
const rest = factors.filter((f) => f !== g);
|
|
48461
|
+
const pStr = rest.length ? rest.map((f) => `(${f.toString()})`).join("*") : "1";
|
|
48462
|
+
let pk;
|
|
48463
|
+
try {
|
|
48464
|
+
pk = polyDenseFromStr(pStr, x);
|
|
48465
|
+
} catch {
|
|
48466
|
+
return null;
|
|
48467
|
+
}
|
|
48468
|
+
const terms = [];
|
|
48469
|
+
for (let k = 0; !isZeroDense(pk); k++) {
|
|
48470
|
+
const m = k + 1;
|
|
48471
|
+
const { str: gStr, sign: sign3 } = repeatedAntideriv(fn, u, m);
|
|
48472
|
+
const coeff = (k % 2 === 0 ? 1 : -1) * sign3 * Math.pow(1 / a, m);
|
|
48473
|
+
const polyStr = densePolyToStr(pk, x);
|
|
48474
|
+
if (polyStr !== "0") {
|
|
48475
|
+
const polyFactor = polyStr === "1" ? "" : `(${polyStr}) * `;
|
|
48476
|
+
terms.push(`${num(coeff)} * ${polyFactor}${gStr}`);
|
|
48477
|
+
}
|
|
48478
|
+
pk = derivDense(pk);
|
|
48479
|
+
if (k > 64) break;
|
|
48480
|
+
}
|
|
48481
|
+
if (terms.length === 0) return null;
|
|
48482
|
+
return terms.join(" + ").replace(/\+ -/g, "- ");
|
|
48483
|
+
}
|
|
48425
48484
|
function symbolicIntegral(expr, variable = "x") {
|
|
48426
48485
|
try {
|
|
48427
48486
|
return integrateNode(parse2(expr), variable);
|
|
48428
48487
|
} catch (e) {
|
|
48429
|
-
if (e instanceof NotIntegrable)
|
|
48430
|
-
|
|
48488
|
+
if (!(e instanceof NotIntegrable)) throw e;
|
|
48489
|
+
return tryPartialFractions(expr, variable) ?? tryByParts(expr, variable) ?? `integral(${expr}, ${variable})`;
|
|
48431
48490
|
}
|
|
48432
48491
|
}
|
|
48433
48492
|
|
|
@@ -51078,6 +51137,161 @@ function barnesG(z) {
|
|
|
51078
51137
|
return Math.exp(lnG);
|
|
51079
51138
|
}
|
|
51080
51139
|
|
|
51140
|
+
// src/special/wave-functions.ts
|
|
51141
|
+
var RELTOL3 = 1e-16;
|
|
51142
|
+
function cMul3(a, b) {
|
|
51143
|
+
return { re: a.re * b.re - a.im * b.im, im: a.re * b.im + a.im * b.re };
|
|
51144
|
+
}
|
|
51145
|
+
function cInv(a) {
|
|
51146
|
+
const d = a.re * a.re + a.im * a.im;
|
|
51147
|
+
return { re: a.re / d, im: -a.im / d };
|
|
51148
|
+
}
|
|
51149
|
+
function cLog(a) {
|
|
51150
|
+
return { re: 0.5 * Math.log(a.re * a.re + a.im * a.im), im: Math.atan2(a.im, a.re) };
|
|
51151
|
+
}
|
|
51152
|
+
function cSin(a) {
|
|
51153
|
+
return { re: Math.sin(a.re) * Math.cosh(a.im), im: Math.cos(a.re) * Math.sinh(a.im) };
|
|
51154
|
+
}
|
|
51155
|
+
var LANCZOS_G = 7;
|
|
51156
|
+
var LANCZOS_C = [
|
|
51157
|
+
0.9999999999998099,
|
|
51158
|
+
676.5203681218851,
|
|
51159
|
+
-1259.1392167224028,
|
|
51160
|
+
771.3234287776531,
|
|
51161
|
+
-176.6150291621406,
|
|
51162
|
+
12.507343278686905,
|
|
51163
|
+
-0.13857109526572012,
|
|
51164
|
+
9984369578019572e-21,
|
|
51165
|
+
15056327351493116e-23
|
|
51166
|
+
];
|
|
51167
|
+
function lnGammaComplex(z) {
|
|
51168
|
+
if (z.re < 0.5) {
|
|
51169
|
+
const sinPiZ = cSin({ re: Math.PI * z.re, im: Math.PI * z.im });
|
|
51170
|
+
const lnSin = cLog(sinPiZ);
|
|
51171
|
+
const rest = lnGammaComplex({ re: 1 - z.re, im: -z.im });
|
|
51172
|
+
return { re: Math.log(Math.PI) - lnSin.re - rest.re, im: -lnSin.im - rest.im };
|
|
51173
|
+
}
|
|
51174
|
+
const x = { re: z.re - 1, im: z.im };
|
|
51175
|
+
let sum3 = { re: LANCZOS_C[0], im: 0 };
|
|
51176
|
+
for (let i = 1; i < LANCZOS_G + 2; i++) {
|
|
51177
|
+
const dr = x.re + i;
|
|
51178
|
+
const di = x.im;
|
|
51179
|
+
const denom = dr * dr + di * di;
|
|
51180
|
+
sum3 = { re: sum3.re + LANCZOS_C[i] * dr / denom, im: sum3.im - LANCZOS_C[i] * di / denom };
|
|
51181
|
+
}
|
|
51182
|
+
const t = { re: x.re + LANCZOS_G + 0.5, im: x.im };
|
|
51183
|
+
const lnT = cLog(t);
|
|
51184
|
+
const lnSum = cLog(sum3);
|
|
51185
|
+
const half = { re: x.re + 0.5, im: x.im };
|
|
51186
|
+
const p = cMul3(half, lnT);
|
|
51187
|
+
return {
|
|
51188
|
+
re: 0.5 * Math.log(2 * Math.PI) + p.re - t.re + lnSum.re,
|
|
51189
|
+
im: p.im - t.im + lnSum.im
|
|
51190
|
+
};
|
|
51191
|
+
}
|
|
51192
|
+
function factorial5(n) {
|
|
51193
|
+
let r = 1;
|
|
51194
|
+
for (let i = 2; i <= n; i++) r *= i;
|
|
51195
|
+
return r;
|
|
51196
|
+
}
|
|
51197
|
+
function riemannSiegelTheta(t) {
|
|
51198
|
+
const lg = lnGammaComplex({ re: 0.25, im: t / 2 });
|
|
51199
|
+
return lg.im - t / 2 * Math.log(Math.PI);
|
|
51200
|
+
}
|
|
51201
|
+
function borweinD(k, n) {
|
|
51202
|
+
let S = k;
|
|
51203
|
+
for (let j = k; j <= n; j++) {
|
|
51204
|
+
S += factorial5(n + j - 1) * Math.pow(4, j) / (factorial5(n - j) * factorial5(2 * j));
|
|
51205
|
+
}
|
|
51206
|
+
return n * S;
|
|
51207
|
+
}
|
|
51208
|
+
function zetaCriticalLine(t) {
|
|
51209
|
+
const n = Math.round(1.3 * 20 + 0.9 * Math.abs(t));
|
|
51210
|
+
const ln2 = Math.LN2;
|
|
51211
|
+
const mag = Math.SQRT2;
|
|
51212
|
+
const den = { re: 1 - mag * Math.cos(t * ln2), im: mag * Math.sin(t * ln2) };
|
|
51213
|
+
const d0 = borweinD(0, n);
|
|
51214
|
+
const c = cInv(cMul3({ re: d0, im: 0 }, den));
|
|
51215
|
+
let Sr = 0;
|
|
51216
|
+
let Si = 0;
|
|
51217
|
+
for (let k = 1; k <= n; k++) {
|
|
51218
|
+
const sign3 = (k - 1) % 2 === 0 ? 1 : -1;
|
|
51219
|
+
const dk = borweinD(k, n);
|
|
51220
|
+
const lnk = Math.log(k);
|
|
51221
|
+
const kpow = 1 / Math.sqrt(k);
|
|
51222
|
+
Sr += sign3 * dk * kpow * Math.cos(t * lnk);
|
|
51223
|
+
Si += sign3 * dk * kpow * -Math.sin(t * lnk);
|
|
51224
|
+
}
|
|
51225
|
+
return cMul3(c, { re: Sr, im: Si });
|
|
51226
|
+
}
|
|
51227
|
+
function siegelZ(t) {
|
|
51228
|
+
const at = Math.abs(t);
|
|
51229
|
+
const z = zetaCriticalLine(at);
|
|
51230
|
+
const th = riemannSiegelTheta(at);
|
|
51231
|
+
return Math.cos(th) * z.re - Math.sin(th) * z.im;
|
|
51232
|
+
}
|
|
51233
|
+
function riemannSiegelZ(t) {
|
|
51234
|
+
return siegelZ(t);
|
|
51235
|
+
}
|
|
51236
|
+
var LERCH_MAX_TERMS = 2e5;
|
|
51237
|
+
function lerchPhi(z, s, a) {
|
|
51238
|
+
if (Math.abs(z) >= 1) {
|
|
51239
|
+
throw new Error("lerchPhi: only |z| < 1 is supported (analytic continuation not implemented)");
|
|
51240
|
+
}
|
|
51241
|
+
if (a <= 0) {
|
|
51242
|
+
throw new Error("lerchPhi: a must be > 0");
|
|
51243
|
+
}
|
|
51244
|
+
let sum3 = 0;
|
|
51245
|
+
let zk = 1;
|
|
51246
|
+
for (let k = 0; k < LERCH_MAX_TERMS; k++) {
|
|
51247
|
+
const term = zk / Math.pow(a + k, s);
|
|
51248
|
+
sum3 += term;
|
|
51249
|
+
if (k > 1 && Math.abs(term) < Math.abs(sum3) * RELTOL3) break;
|
|
51250
|
+
zk *= z;
|
|
51251
|
+
}
|
|
51252
|
+
return sum3;
|
|
51253
|
+
}
|
|
51254
|
+
function recipGamma(y) {
|
|
51255
|
+
if (y > 0) return Math.exp(-_lgamma(y));
|
|
51256
|
+
if (y === Math.floor(y)) return 0;
|
|
51257
|
+
return Math.sin(Math.PI * y) * Math.exp(_lgamma(1 - y)) / Math.PI;
|
|
51258
|
+
}
|
|
51259
|
+
function parabolicCylinderD(nu, x) {
|
|
51260
|
+
const z = x * x / 2;
|
|
51261
|
+
const even = recipGamma((1 - nu) / 2) * hyp1f1(-nu / 2, 0.5, z);
|
|
51262
|
+
const odd = recipGamma(-nu / 2) * hyp1f1((1 - nu) / 2, 1.5, z);
|
|
51263
|
+
return Math.pow(2, nu / 2) * Math.exp(-(x * x) / 4) * (Math.sqrt(Math.PI) * even - Math.sqrt(2 * Math.PI) * x * odd);
|
|
51264
|
+
}
|
|
51265
|
+
var COULOMB_MAX_TERMS = 5e3;
|
|
51266
|
+
function coulombC(L, eta) {
|
|
51267
|
+
const lg = lnGammaComplex({ re: L + 1, im: eta });
|
|
51268
|
+
const absGamma = Math.exp(lg.re);
|
|
51269
|
+
return Math.pow(2, L) * Math.exp(-Math.PI * eta / 2) * absGamma / Math.exp(_lgamma(2 * L + 2));
|
|
51270
|
+
}
|
|
51271
|
+
function coulombF(L, eta, rho) {
|
|
51272
|
+
if (rho < 0) {
|
|
51273
|
+
throw new Error("coulombF: rho must be >= 0");
|
|
51274
|
+
}
|
|
51275
|
+
if (L < 0) {
|
|
51276
|
+
throw new Error("coulombF: L must be >= 0");
|
|
51277
|
+
}
|
|
51278
|
+
if (rho === 0) return 0;
|
|
51279
|
+
let aPrev2 = 0;
|
|
51280
|
+
let aPrev1 = 1;
|
|
51281
|
+
let sum3 = 1;
|
|
51282
|
+
let rhoK = 1;
|
|
51283
|
+
for (let k = 1; k < COULOMB_MAX_TERMS; k++) {
|
|
51284
|
+
const ak = (2 * eta * aPrev1 - aPrev2) / (k * (k + 2 * L + 1));
|
|
51285
|
+
rhoK *= rho;
|
|
51286
|
+
const term = ak * rhoK;
|
|
51287
|
+
sum3 += term;
|
|
51288
|
+
aPrev2 = aPrev1;
|
|
51289
|
+
aPrev1 = ak;
|
|
51290
|
+
if (k > 2 && term !== 0 && Math.abs(term) < Math.abs(sum3) * RELTOL3) break;
|
|
51291
|
+
}
|
|
51292
|
+
return coulombC(L, eta) * Math.pow(rho, L + 1) * sum3;
|
|
51293
|
+
}
|
|
51294
|
+
|
|
51081
51295
|
// src/graph/traversal-centrality.ts
|
|
51082
51296
|
function bfs(adj, start) {
|
|
51083
51297
|
const n = adj.length;
|
|
@@ -52466,6 +52680,7 @@ export {
|
|
|
52466
52680
|
coth,
|
|
52467
52681
|
coulomb,
|
|
52468
52682
|
coulombConstant,
|
|
52683
|
+
coulombF,
|
|
52469
52684
|
count,
|
|
52470
52685
|
cov,
|
|
52471
52686
|
createUnit,
|
|
@@ -52855,6 +53070,7 @@ export {
|
|
|
52855
53070
|
leftShift,
|
|
52856
53071
|
legendreFit,
|
|
52857
53072
|
legendreP,
|
|
53073
|
+
lerchPhi,
|
|
52858
53074
|
levenbergMarquardt,
|
|
52859
53075
|
leveneTest,
|
|
52860
53076
|
lfilter,
|
|
@@ -52997,6 +53213,7 @@ export {
|
|
|
52997
53213
|
pacf,
|
|
52998
53214
|
padeApproximant,
|
|
52999
53215
|
pageRank,
|
|
53216
|
+
parabolicCylinderD,
|
|
53000
53217
|
parallelAutoCorr,
|
|
53001
53218
|
parallelConv,
|
|
53002
53219
|
parallelFFT,
|
|
@@ -53127,6 +53344,7 @@ export {
|
|
|
53127
53344
|
rfft,
|
|
53128
53345
|
rfftfreq,
|
|
53129
53346
|
ridge,
|
|
53347
|
+
riemannSiegelZ,
|
|
53130
53348
|
rightArithShift,
|
|
53131
53349
|
rightLogShift,
|
|
53132
53350
|
risingFactorial,
|
|
@@ -53169,6 +53387,7 @@ export {
|
|
|
53169
53387
|
shapiroWilkTest,
|
|
53170
53388
|
shortestPath,
|
|
53171
53389
|
shouldParallelize,
|
|
53390
|
+
siegelZ,
|
|
53172
53391
|
sigmoid,
|
|
53173
53392
|
sign,
|
|
53174
53393
|
simplify,
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Advanced niche special functions: the Riemann–Siegel Z-function, the Lerch
|
|
3
|
+
* transcendent, the parabolic-cylinder function D_ν, and the regular Coulomb
|
|
4
|
+
* wave function F_L.
|
|
5
|
+
*
|
|
6
|
+
* These follow the same plain-exported-function pattern as `niche.ts` and
|
|
7
|
+
* `hypergeometric.ts` — pure real-valued `number -> number` math with no
|
|
8
|
+
* typed-function array/WASM dispatch overloads. Each is oracle-pinned against
|
|
9
|
+
* `mpmath` (dps=30) in `functions/tests/gap-special-wave-oracle.test.ts`.
|
|
10
|
+
*
|
|
11
|
+
* The self-contained complex-arithmetic helpers here (complex log-gamma via
|
|
12
|
+
* Lanczos, and a critical-line Borwein ζ evaluator) exist so these functions
|
|
13
|
+
* stay pure `number`-in/`number`-out and do not need the factory `zeta`
|
|
14
|
+
* (which requires a full math instance with a Complex constructor).
|
|
15
|
+
*
|
|
16
|
+
* @packageDocumentation
|
|
17
|
+
*/
|
|
18
|
+
/** 64-bit float (default for decimals) */
|
|
19
|
+
type f64 = number;
|
|
20
|
+
/**
|
|
21
|
+
* Riemann–Siegel Z-function Z(t) = e^{iθ(t)} ζ(1/2 + it), the real-valued
|
|
22
|
+
* function on the critical line whose real zeros coincide with the imaginary
|
|
23
|
+
* parts of the non-trivial zeros of ζ. Z is even: Z(−t) = Z(t), and
|
|
24
|
+
* Z(0) = ζ(1/2) ≈ −1.4603545088.
|
|
25
|
+
*
|
|
26
|
+
* Computed by evaluating ζ(1/2 + it) via the Borwein-accelerated series and
|
|
27
|
+
* the theta function via the complex log-gamma, then taking the (real) product
|
|
28
|
+
* — i.e. Z(t) = cos θ · Re ζ − sin θ · Im ζ. This exact-theta approach is
|
|
29
|
+
* accurate for all t (the classical Riemann–Siegel asymptotic expansion, by
|
|
30
|
+
* contrast, is inaccurate for the small t of the first few zeros).
|
|
31
|
+
*
|
|
32
|
+
* Verified against `mpmath.siegelz` (dps=30): relative error < 1e-11 for
|
|
33
|
+
* O(1)-magnitude values and absolute error < 1e-9 near the first zeros
|
|
34
|
+
* (t ≈ 14.13, 21.02, 25.01), for |t| up to ~40.
|
|
35
|
+
*
|
|
36
|
+
* @param t - Height on the critical line (real; any sign)
|
|
37
|
+
* @returns Z(t)
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* siegelZ(15) // ~0.7199423913
|
|
41
|
+
* siegelZ(14.134725) // ~-1.12e-7 (near the first zeta zero)
|
|
42
|
+
*/
|
|
43
|
+
export declare function siegelZ(t: f64): f64;
|
|
44
|
+
/**
|
|
45
|
+
* Alias for {@link siegelZ} — the Riemann–Siegel Z-function Z(t).
|
|
46
|
+
*/
|
|
47
|
+
export declare function riemannSiegelZ(t: f64): f64;
|
|
48
|
+
/**
|
|
49
|
+
* Lerch transcendent Φ(z, s, a) = Σ_{k≥0} z^k / (a + k)^s, evaluated by its
|
|
50
|
+
* defining power series (DLMF 25.14.1), which converges for `|z| < 1` and any
|
|
51
|
+
* real `s`, provided `a > 0` (so no denominator vanishes).
|
|
52
|
+
*
|
|
53
|
+
* Analytic continuation to `|z| ≥ 1` is out of scope and throws. The boundary
|
|
54
|
+
* case Φ(1, s, a) = ζ(s, a) is the Hurwitz zeta, not implemented here.
|
|
55
|
+
*
|
|
56
|
+
* Cross-check: the polylogarithm satisfies `Li_s(z) = z · Φ(z, s, 1)`.
|
|
57
|
+
*
|
|
58
|
+
* Verified against `mpmath.lerchphi` (dps=30) to relative error < 1e-12 across
|
|
59
|
+
* real `z ∈ (−1, 1)` and assorted `s`, `a`.
|
|
60
|
+
*
|
|
61
|
+
* @param z - Argument, must satisfy `|z| < 1`
|
|
62
|
+
* @param s - Order (any real number)
|
|
63
|
+
* @param a - Offset (real, `a > 0`)
|
|
64
|
+
* @returns Φ(z, s, a)
|
|
65
|
+
* @throws {Error} If `|z| >= 1`, or if `a + k <= 0` for some term (a <= 0)
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* lerchPhi(0.5, 2, 1) // ~1.1644810529 (= 2·Li_2(0.5))
|
|
69
|
+
*/
|
|
70
|
+
export declare function lerchPhi(z: f64, s: f64, a: f64): f64;
|
|
71
|
+
/**
|
|
72
|
+
* Parabolic cylinder function D_ν(x) (Whittaker's form), via the confluent
|
|
73
|
+
* hypergeometric representation (Abramowitz & Stegun 19.3.1 / DLMF 12.4.1):
|
|
74
|
+
*
|
|
75
|
+
* D_ν(x) = 2^{ν/2} e^{−x²/4} [ √π / Γ((1−ν)/2) · M(−ν/2; 1/2; x²/2)
|
|
76
|
+
* − √(2π) x / Γ(−ν/2) · M((1−ν)/2; 3/2; x²/2) ]
|
|
77
|
+
*
|
|
78
|
+
* where M = ₁F₁ is Kummer's function (`hyp1f1`). The even/odd split makes this
|
|
79
|
+
* valid for any real order ν and any real x (D_ν is entire in x); accuracy is
|
|
80
|
+
* best for moderate |x| where the ₁F₁ series converges without heavy
|
|
81
|
+
* cancellation.
|
|
82
|
+
*
|
|
83
|
+
* Verified against `mpmath.pcfd` (dps=30) to relative error < 1e-10 on a corpus
|
|
84
|
+
* of real (ν, x) with |x| ≤ ~2.
|
|
85
|
+
*
|
|
86
|
+
* @param nu - Order (real)
|
|
87
|
+
* @param x - Argument (real)
|
|
88
|
+
* @returns D_ν(x)
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* parabolicCylinderD(0, 1) // ~0.7788007831 (= e^{-1/4})
|
|
92
|
+
*/
|
|
93
|
+
export declare function parabolicCylinderD(nu: f64, x: f64): f64;
|
|
94
|
+
/**
|
|
95
|
+
* Regular Coulomb wave function F_L(η, ρ), via its ascending power series
|
|
96
|
+
* (DLMF 33.6.1–33.6.2):
|
|
97
|
+
*
|
|
98
|
+
* F_L(η, ρ) = C_L(η) ρ^{L+1} Σ_{k≥0} A_k ρ^k,
|
|
99
|
+
* A_0 = 1, A_1 = η/(L+1), A_k = (2η A_{k−1} − A_{k−2}) / (k (k + 2L + 1)).
|
|
100
|
+
*
|
|
101
|
+
* The series is entire in ρ, so this converges for all ρ ≥ 0 (accuracy is best
|
|
102
|
+
* for small-to-moderate ρ before large-argument cancellation sets in). The
|
|
103
|
+
* *irregular* companion G_L is intentionally not implemented here — it requires
|
|
104
|
+
* a numerically-delicate asymptotic/continued-fraction treatment (see the
|
|
105
|
+
* module test and CHANGELOG for the surfaced design).
|
|
106
|
+
*
|
|
107
|
+
* Verified against `mpmath.coulombf` (dps=30) to relative error < 1e-6 (in
|
|
108
|
+
* practice < 1e-9 away from zeros) for L ∈ {0,1,2,3}, |η| ≤ 5, ρ ≤ 10.
|
|
109
|
+
*
|
|
110
|
+
* Special case: F_0(0, ρ) = sin ρ.
|
|
111
|
+
*
|
|
112
|
+
* @param L - Orbital angular momentum (real, `L >= 0`)
|
|
113
|
+
* @param eta - Sommerfeld parameter (real)
|
|
114
|
+
* @param rho - Radial variable (real, `rho >= 0`)
|
|
115
|
+
* @returns F_L(η, ρ)
|
|
116
|
+
* @throws {Error} If `rho < 0` or `L < 0`
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* coulombF(0, 0, 1) // ~0.8414709848 (= sin 1)
|
|
120
|
+
*/
|
|
121
|
+
export declare function coulombF(L: f64, eta: f64, rho: f64): f64;
|
|
122
|
+
export {};
|
|
123
|
+
//# sourceMappingURL=wave-functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wave-functions.d.ts","sourceRoot":"","sources":["../../src/special/wave-functions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,0CAA0C;AAC1C,KAAK,GAAG,GAAG,MAAM,CAAC;AAyIlB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,GAAG,GAAG,CAKnC;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,GAAG,GAAG,GAAG,CAE1C;AASD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,GAAG,CAiBpD;AAcD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,GAAG,CASvD;AAuBD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG,CAyBxD"}
|
package/dist/typed/algebra.d.ts
CHANGED
|
@@ -192,12 +192,16 @@ export declare function substitute(expr: string, vars: Record<string, string>):
|
|
|
192
192
|
/**
|
|
193
193
|
* Expand an expression string by distributing multiplication over addition.
|
|
194
194
|
*
|
|
195
|
-
* **
|
|
196
|
-
* powers, no function calls
|
|
197
|
-
*
|
|
195
|
+
* **Polynomials in one OR MORE variables** (integer/non-negative-integer
|
|
196
|
+
* powers, no function calls, division only by numeric constants) are expanded
|
|
197
|
+
* EXACTLY via `polyFromExpression` + `polyToString`, collecting like terms:
|
|
198
|
+
* `expand('(x+1)^3')` → `'1*x^3 + 3*x^2 + 3*x + 1'`;
|
|
199
|
+
* `expand('(x+y)^2')` → `'1*y^2 + 2*x*y + 1*x^2'`;
|
|
200
|
+
* `expand('(x+y)*(x-y)')` → `'-1*y^2 + 1*x^2'` (the `x*y` terms cancel).
|
|
198
201
|
*
|
|
199
|
-
* Everything else (
|
|
200
|
-
* the original regex-based distributor below
|
|
202
|
+
* Everything else (function calls like `sin`, non-integer exponents, division
|
|
203
|
+
* by a variable) falls back to the original regex-based distributor below,
|
|
204
|
+
* which does NOT collect like terms.
|
|
201
205
|
*
|
|
202
206
|
* @param expr - Expression string
|
|
203
207
|
* @returns Expanded expression string
|
|
@@ -206,6 +210,7 @@ export declare function substitute(expr: string, vars: Record<string, string>):
|
|
|
206
210
|
* ```typescript
|
|
207
211
|
* expand('(a+b)*(c+d)'); // 'a*c + a*d + b*c + b*d'
|
|
208
212
|
* expand('(x+1)^3'); // '1*x^3 + 3*x^2 + 3*x + 1'
|
|
213
|
+
* expand('(x+y)^2'); // '1*y^2 + 2*x*y + 1*x^2'
|
|
209
214
|
* ```
|
|
210
215
|
*/
|
|
211
216
|
export declare function expand(expr: string): string;
|
|
@@ -219,7 +224,14 @@ export declare function expand(expr: string): string;
|
|
|
219
224
|
* out exactly, and any irreducible remainder is left as-is:
|
|
220
225
|
* `factor('x^2-1')` → `'(x - 1)*(x + 1)'`.
|
|
221
226
|
*
|
|
222
|
-
*
|
|
227
|
+
* **Multivariate polynomials** get the tractable subset (see
|
|
228
|
+
* {@link factorMultivariate}): integer-content + common-monomial extraction
|
|
229
|
+
* and monomial difference-of-squares — `x^2*y + x*y^2 → 'x*y*(x + y)'`,
|
|
230
|
+
* `4*x^2 - 9*y^2 → '(2*x - 3*y)*(2*x + 3*y)'`. Full multivariate factorization
|
|
231
|
+
* into irreducible factors (Wang/Zassenhaus/EEZ) is OUT OF SCOPE and returns
|
|
232
|
+
* the partially-factored or unchanged expression rather than a wrong answer.
|
|
233
|
+
*
|
|
234
|
+
* Everything else (no rational root, no common factor) falls back to the
|
|
223
235
|
* original common-integer-factor extraction below.
|
|
224
236
|
*
|
|
225
237
|
* @param expr - Expression string
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"algebra.d.ts","sourceRoot":"","sources":["../../src/typed/algebra.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"algebra.d.ts","sourceRoot":"","sources":["../../src/typed/algebra.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAqBH,KAAK,GAAG,GAAG,MAAM,CAAC;AAkJlB;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,GAAG,GAAG,GAAG,CAOrD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAO1D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAgB1D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,GAAE,MAAU,GAAG,MAAM,EAAE,CAUjE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAgBhE;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAShE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAGrE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EA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,MAAM,EAAE,CA6BtE;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAmEhF;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOnD;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,CAgCvD;AAMD;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CxB,CAAC"}
|
package/dist/typed/cas.d.ts
CHANGED
|
@@ -640,29 +640,33 @@ export declare function casDerivative(expr: string | MathNode, variable: string)
|
|
|
640
640
|
*/
|
|
641
641
|
export declare function casDerivative(exprs: Array<string | MathNode>, variable: string): Promise<string[]>;
|
|
642
642
|
/**
|
|
643
|
-
* Expand
|
|
644
|
-
* (CAS batch-capable variant).
|
|
643
|
+
* Expand an expression, distributing products over sums and collecting like
|
|
644
|
+
* terms (CAS batch-capable variant).
|
|
645
645
|
*
|
|
646
|
-
*
|
|
647
|
-
* `algebra.ts
|
|
648
|
-
*
|
|
646
|
+
* Delegates to the real polynomial engine {@link algebraExpand} (`expand` from
|
|
647
|
+
* `algebra.ts`): polynomials in one OR MORE variables are expanded EXACTLY
|
|
648
|
+
* (`'(x+1)^2'` → `'1*x^2 + 2*x + 1'`, `'(x+y)^2'` → `'1*y^2 + 2*x*y + 1*x^2'`).
|
|
649
|
+
* Non-polynomial pieces fall back to that engine's regex distributor.
|
|
650
|
+
*
|
|
651
|
+
* (Formerly a crude string stub that emitted uncollected products like
|
|
652
|
+
* `'x*x + x*1 + 1*x + 1*1'`; now wired to the maintained engine.)
|
|
649
653
|
*
|
|
650
654
|
* @param expr - Expression string or parsed MathNode
|
|
651
655
|
* @returns Expanded expression string
|
|
652
656
|
*
|
|
653
657
|
* @example
|
|
654
|
-
* casExpand('(x+1)^2')
|
|
655
|
-
* casExpand('(
|
|
658
|
+
* casExpand('(x+1)^2') // => '1*x^2 + 2*x + 1'
|
|
659
|
+
* casExpand('(x+y)*(x-y)') // => '-1*y^2 + 1*x^2'
|
|
656
660
|
*/
|
|
657
661
|
export declare function casExpand(expr: string | MathNode): string;
|
|
658
662
|
/**
|
|
659
|
-
* Expand an array of expressions (batch overload
|
|
660
|
-
*
|
|
661
|
-
* Arrays shorter than {@link CAS_BATCH_THRESHOLD} (16) are processed
|
|
662
|
-
* synchronously in-process. Longer arrays are dispatched to the worker pool.
|
|
663
|
+
* Expand an array of expressions (batch overload).
|
|
663
664
|
*
|
|
664
|
-
*
|
|
665
|
-
*
|
|
665
|
+
* Each element is expanded via the real engine {@link algebraExpand}. Kept
|
|
666
|
+
* async (resolves to `string[]`) for API compatibility; because the engine
|
|
667
|
+
* relies on the polynomial parser it runs in-process rather than fanning out
|
|
668
|
+
* to workers (a worker cannot import it), so batch results are always
|
|
669
|
+
* identical to the per-element single-expression call.
|
|
666
670
|
*
|
|
667
671
|
* @param exprs - Array of expression strings (or MathNodes)
|
|
668
672
|
* @returns Promise resolving to an array of expanded expression strings
|
|
@@ -672,32 +676,32 @@ export declare function casExpand(expr: string | MathNode): string;
|
|
|
672
676
|
*/
|
|
673
677
|
export declare function casExpand(exprs: Array<string | MathNode>): Promise<string[]>;
|
|
674
678
|
/**
|
|
675
|
-
* Factor
|
|
676
|
-
* (CAS batch-capable variant).
|
|
679
|
+
* Factor an expression (CAS batch-capable variant).
|
|
677
680
|
*
|
|
678
|
-
*
|
|
679
|
-
* `algebra.ts
|
|
680
|
-
*
|
|
681
|
+
* Delegates to the real factoring engine {@link algebraFactor} (`factor` from
|
|
682
|
+
* `algebra.ts`): univariate polynomials are factored over ℚ via the
|
|
683
|
+
* rational-root theorem (`'x^2 - 1'` → `'(x - 1)*(x + 1)'`), multivariate
|
|
684
|
+
* polynomials get integer-content / common-monomial / difference-of-squares
|
|
685
|
+
* extraction (`'x^2*y + x*y^2'` → `'x*y*(x + y)'`), and anything else falls
|
|
686
|
+
* back to integer-GCD extraction (`'2*x + 4*y'` → `'2*(x + 2*y)'`).
|
|
681
687
|
*
|
|
682
|
-
*
|
|
683
|
-
* greater than 1 is found, or when terms do not follow the `c*var` pattern.
|
|
688
|
+
* (Formerly a crude integer-GCD-only stub; now wired to the maintained engine.)
|
|
684
689
|
*
|
|
685
690
|
* @param expr - Expression string or parsed MathNode
|
|
686
691
|
* @returns Factored expression string
|
|
687
692
|
*
|
|
688
693
|
* @example
|
|
689
694
|
* casFactor('2*x + 4*y') // => '2*(x + 2*y)'
|
|
690
|
-
* casFactor('x^2 - 1') // => 'x
|
|
695
|
+
* casFactor('x^2 - 1') // => '(x - 1)*(x + 1)'
|
|
691
696
|
*/
|
|
692
697
|
export declare function casFactor(expr: string | MathNode): string;
|
|
693
698
|
/**
|
|
694
|
-
* Factor an array of expressions (batch overload
|
|
699
|
+
* Factor an array of expressions (batch overload).
|
|
695
700
|
*
|
|
696
|
-
*
|
|
697
|
-
*
|
|
698
|
-
*
|
|
699
|
-
*
|
|
700
|
-
* before dispatch.
|
|
701
|
+
* Each element is factored via the real engine {@link algebraFactor}. Kept
|
|
702
|
+
* async (resolves to `string[]`) for API compatibility; runs in-process (the
|
|
703
|
+
* engine cannot be serialised to a worker), so batch results are always
|
|
704
|
+
* identical to the per-element single-expression call.
|
|
701
705
|
*
|
|
702
706
|
* @param exprs - Array of expression strings (or MathNodes)
|
|
703
707
|
* @returns Promise resolving to an array of factored expression strings
|
package/dist/typed/cas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cas.d.ts","sourceRoot":"","sources":["../../src/typed/cas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,KAAK,EAAY,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"cas.d.ts","sour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