@danielsimonjr/mathts-functions 0.28.0 → 0.29.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/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +361 -65
- package/dist/linalg-svd-extra.d.ts +21 -0
- package/dist/linalg-svd-extra.d.ts.map +1 -0
- package/dist/numeric/adaptive-quad.d.ts +56 -0
- package/dist/numeric/adaptive-quad.d.ts.map +1 -0
- package/dist/numeric/fsolve.d.ts +45 -0
- package/dist/numeric/fsolve.d.ts.map +1 -0
- package/dist/numeric/minimize-scalar.d.ts +56 -0
- package/dist/numeric/minimize-scalar.d.ts.map +1 -0
- package/dist/numeric/numeric-jacobian.d.ts +28 -0
- package/dist/numeric/numeric-jacobian.d.ts.map +1 -0
- package/dist/numeric/open-root-finders.d.ts +95 -0
- package/dist/numeric/open-root-finders.d.ts.map +1 -0
- package/dist/typed/cas.d.ts +13 -4
- package/dist/typed/cas.d.ts.map +1 -1
- package/dist/typed/numeric.d.ts +7 -3
- package/dist/typed/numeric.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,20 @@ export { fTest, jarqueBera, kruskalWallis, wilcoxon, fisherExact, studentizedRan
|
|
|
25
25
|
export type { FTestResult, JarqueBeraResult, KruskalResult, WilcoxonResult, FisherExactResult, TukeyComparison, } from './hypothesis-extra.js';
|
|
26
26
|
export { tril, triu, vander, toeplitz, circulant, companion, logdet, laplacianMatrix, generalizedEig, qz, } from './linalg-extra.js';
|
|
27
27
|
export { hessian, gradient } from './calculus-extra.js';
|
|
28
|
+
export { svd } from '@danielsimonjr/mathts-matrix';
|
|
29
|
+
export type { SVDResult, SVDOptions } from '@danielsimonjr/mathts-matrix';
|
|
30
|
+
export { orth } from './linalg-svd-extra.js';
|
|
31
|
+
export type { OrthOptions } from './linalg-svd-extra.js';
|
|
32
|
+
export { numericJacobian } from './numeric/numeric-jacobian.js';
|
|
33
|
+
export type { VectorField, NumericJacobianOptions } from './numeric/numeric-jacobian.js';
|
|
34
|
+
export { newton, secant, halley } from './numeric/open-root-finders.js';
|
|
35
|
+
export type { NewtonOptions, SecantOptions, HalleyOptions } from './numeric/open-root-finders.js';
|
|
36
|
+
export { fsolve, root } from './numeric/fsolve.js';
|
|
37
|
+
export type { FsolveOptions } from './numeric/fsolve.js';
|
|
38
|
+
export { minimizeScalar } from './numeric/minimize-scalar.js';
|
|
39
|
+
export type { MinimizeScalarOptions, MinimizeScalarResult } from './numeric/minimize-scalar.js';
|
|
40
|
+
export { quad } from './numeric/adaptive-quad.js';
|
|
41
|
+
export type { QuadOptions, QuadResult } from './numeric/adaptive-quad.js';
|
|
28
42
|
export { movingAverage, ewma, detrend, acf } from './timeseries-extra.js';
|
|
29
43
|
export { linearRegression } from './regression-extra.js';
|
|
30
44
|
export type { LinregressResult } from './regression-extra.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;AAGjC,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACnF,YAAY,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EACL,KAAK,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AqB,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAKhG,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAG1E,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAG1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAG9D,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC1F,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAGxE,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACnE,YAAY,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAG1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGxD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGxF,OAAO,EACL,SAAS,EACT,eAAe,EACf,KAAK,EACL,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,gBAAgB,EAChB,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5510,15 +5510,15 @@ function modNumber(x, y) {
|
|
|
5510
5510
|
return y === 0 ? x : x - y * Math.floor(x / y);
|
|
5511
5511
|
}
|
|
5512
5512
|
modNumber.signature = n2;
|
|
5513
|
-
function nthRootNumber(a,
|
|
5514
|
-
const inv2 =
|
|
5513
|
+
function nthRootNumber(a, root2 = 2) {
|
|
5514
|
+
const inv2 = root2 < 0;
|
|
5515
5515
|
if (inv2) {
|
|
5516
|
-
|
|
5516
|
+
root2 = -root2;
|
|
5517
5517
|
}
|
|
5518
|
-
if (
|
|
5518
|
+
if (root2 === 0) {
|
|
5519
5519
|
throw new Error("Root must be non-zero");
|
|
5520
5520
|
}
|
|
5521
|
-
if (a < 0 && Math.abs(
|
|
5521
|
+
if (a < 0 && Math.abs(root2) % 2 !== 1) {
|
|
5522
5522
|
throw new Error("Root must be odd when a is negative.");
|
|
5523
5523
|
}
|
|
5524
5524
|
if (a === 0) {
|
|
@@ -5527,7 +5527,7 @@ function nthRootNumber(a, root = 2) {
|
|
|
5527
5527
|
if (!isFinite(a)) {
|
|
5528
5528
|
return inv2 ? 0 : a;
|
|
5529
5529
|
}
|
|
5530
|
-
let x = Math.pow(Math.abs(a), 1 /
|
|
5530
|
+
let x = Math.pow(Math.abs(a), 1 / root2);
|
|
5531
5531
|
x = a < 0 ? -x : x;
|
|
5532
5532
|
return inv2 ? 1 / x : x;
|
|
5533
5533
|
}
|
|
@@ -8852,9 +8852,9 @@ function kdTree(points) {
|
|
|
8852
8852
|
}
|
|
8853
8853
|
return build(indexed, 0);
|
|
8854
8854
|
}
|
|
8855
|
-
function kdTreeNearest(
|
|
8856
|
-
if (!
|
|
8857
|
-
let best = { point:
|
|
8855
|
+
function kdTreeNearest(root2, target) {
|
|
8856
|
+
if (!root2) return null;
|
|
8857
|
+
let best = { point: root2.point, index: root2.index, distance: distanceNDSq(root2.point, target) };
|
|
8858
8858
|
function search(node) {
|
|
8859
8859
|
if (!node) return;
|
|
8860
8860
|
const d = distanceNDSq(node.point, target);
|
|
@@ -8869,7 +8869,7 @@ function kdTreeNearest(root, target) {
|
|
|
8869
8869
|
search(second);
|
|
8870
8870
|
}
|
|
8871
8871
|
}
|
|
8872
|
-
search(
|
|
8872
|
+
search(root2);
|
|
8873
8873
|
best.distance = Math.sqrt(best.distance);
|
|
8874
8874
|
return best;
|
|
8875
8875
|
}
|
|
@@ -8921,8 +8921,8 @@ function nearestNeighbor(points, query) {
|
|
|
8921
8921
|
}
|
|
8922
8922
|
}
|
|
8923
8923
|
}
|
|
8924
|
-
const
|
|
8925
|
-
return kdTreeNearest(
|
|
8924
|
+
const root2 = kdTree(points);
|
|
8925
|
+
return kdTreeNearest(root2, query);
|
|
8926
8926
|
}
|
|
8927
8927
|
function convexHull3D(points) {
|
|
8928
8928
|
const n = points.length;
|
|
@@ -11843,6 +11843,81 @@ var createSolveODE = /* @__PURE__ */ factory(
|
|
|
11843
11843
|
}
|
|
11844
11844
|
);
|
|
11845
11845
|
|
|
11846
|
+
// src/numeric/adaptive-quad.ts
|
|
11847
|
+
var XGK = [
|
|
11848
|
+
0.991455371120813,
|
|
11849
|
+
0.949107912342759,
|
|
11850
|
+
0.864864423359769,
|
|
11851
|
+
0.741531185599394,
|
|
11852
|
+
0.586087235467691,
|
|
11853
|
+
0.405845151377397,
|
|
11854
|
+
0.207784955007898,
|
|
11855
|
+
0
|
|
11856
|
+
];
|
|
11857
|
+
var WGK = [
|
|
11858
|
+
0.022935322010529,
|
|
11859
|
+
0.063092092629979,
|
|
11860
|
+
0.10479001032225,
|
|
11861
|
+
0.140653259715525,
|
|
11862
|
+
0.169004726639267,
|
|
11863
|
+
0.190350578064785,
|
|
11864
|
+
0.204432940075298,
|
|
11865
|
+
0.209482141084728
|
|
11866
|
+
];
|
|
11867
|
+
var WG = [0.12948496616887, 0.27970539148928, 0.38183005050512, 0.41795918367347];
|
|
11868
|
+
var KRONROD_NODES = [];
|
|
11869
|
+
var KRONROD_WEIGHTS = [];
|
|
11870
|
+
var GAUSS_WEIGHTS = [];
|
|
11871
|
+
for (let i = 0; i < 7; i++) {
|
|
11872
|
+
KRONROD_NODES.push(-XGK[i]);
|
|
11873
|
+
KRONROD_WEIGHTS.push(WGK[i]);
|
|
11874
|
+
GAUSS_WEIGHTS.push(0);
|
|
11875
|
+
}
|
|
11876
|
+
KRONROD_NODES.push(0);
|
|
11877
|
+
KRONROD_WEIGHTS.push(WGK[7]);
|
|
11878
|
+
GAUSS_WEIGHTS.push(0);
|
|
11879
|
+
for (let i = 6; i >= 0; i--) {
|
|
11880
|
+
KRONROD_NODES.push(XGK[i]);
|
|
11881
|
+
KRONROD_WEIGHTS.push(WGK[i]);
|
|
11882
|
+
GAUSS_WEIGHTS.push(0);
|
|
11883
|
+
}
|
|
11884
|
+
GAUSS_WEIGHTS[1] = WG[0];
|
|
11885
|
+
GAUSS_WEIGHTS[3] = WG[1];
|
|
11886
|
+
GAUSS_WEIGHTS[5] = WG[2];
|
|
11887
|
+
GAUSS_WEIGHTS[7] = WG[3];
|
|
11888
|
+
GAUSS_WEIGHTS[9] = WG[2];
|
|
11889
|
+
GAUSS_WEIGHTS[11] = WG[1];
|
|
11890
|
+
GAUSS_WEIGHTS[13] = WG[0];
|
|
11891
|
+
function gaussKronrod15(f, a, b) {
|
|
11892
|
+
const halfWidth = (b - a) / 2;
|
|
11893
|
+
const mid = (a + b) / 2;
|
|
11894
|
+
let k = 0;
|
|
11895
|
+
let g = 0;
|
|
11896
|
+
for (let i = 0; i < 15; i++) {
|
|
11897
|
+
const fx = f(halfWidth * KRONROD_NODES[i] + mid);
|
|
11898
|
+
k += KRONROD_WEIGHTS[i] * fx;
|
|
11899
|
+
g += GAUSS_WEIGHTS[i] * fx;
|
|
11900
|
+
}
|
|
11901
|
+
return { k: halfWidth * k, g: halfWidth * g };
|
|
11902
|
+
}
|
|
11903
|
+
var ABS_FLOOR = 1e-14;
|
|
11904
|
+
function quad(f, a, b, opts) {
|
|
11905
|
+
const tol = opts?.tol ?? 1e-10;
|
|
11906
|
+
const maxDepth = opts?.maxDepth ?? 50;
|
|
11907
|
+
function panel(a2, b2, depth) {
|
|
11908
|
+
const { k, g } = gaussKronrod15(f, a2, b2);
|
|
11909
|
+
const panelError = Math.abs(k - g);
|
|
11910
|
+
if (depth >= maxDepth || panelError <= Math.max(tol * Math.abs(k), ABS_FLOOR)) {
|
|
11911
|
+
return { value: k, error: panelError };
|
|
11912
|
+
}
|
|
11913
|
+
const mid = (a2 + b2) / 2;
|
|
11914
|
+
const left = panel(a2, mid, depth + 1);
|
|
11915
|
+
const right = panel(mid, b2, depth + 1);
|
|
11916
|
+
return { value: left.value + right.value, error: left.error + right.error };
|
|
11917
|
+
}
|
|
11918
|
+
return panel(a, b, 0);
|
|
11919
|
+
}
|
|
11920
|
+
|
|
11846
11921
|
// src/typed/numeric.ts
|
|
11847
11922
|
var NUMERIC_WASM_THRESHOLD = 16;
|
|
11848
11923
|
function findRoot(f, a, b, opts) {
|
|
@@ -12072,37 +12147,7 @@ function leastSquares(A, b) {
|
|
|
12072
12147
|
return linsolve(AtA, Atb);
|
|
12073
12148
|
}
|
|
12074
12149
|
function nintegrate(f, a, b, opts) {
|
|
12075
|
-
|
|
12076
|
-
const maxDepth = opts?.maxDepth ?? 30;
|
|
12077
|
-
function adaptiveQuad(a2, b2, depth) {
|
|
12078
|
-
const mid = (a2 + b2) / 2;
|
|
12079
|
-
const whole = gaussLegendre5(f, a2, b2);
|
|
12080
|
-
const left = gaussLegendre5(f, a2, mid);
|
|
12081
|
-
const right = gaussLegendre5(f, mid, b2);
|
|
12082
|
-
const refined = left + right;
|
|
12083
|
-
if (depth >= maxDepth || Math.abs(refined - whole) < 15 * tol) {
|
|
12084
|
-
return refined + (refined - whole) / 15;
|
|
12085
|
-
}
|
|
12086
|
-
return adaptiveQuad(a2, mid, depth + 1) + adaptiveQuad(mid, b2, depth + 1);
|
|
12087
|
-
}
|
|
12088
|
-
return adaptiveQuad(a, b, 0);
|
|
12089
|
-
}
|
|
12090
|
-
function gaussLegendre5(f, a, b) {
|
|
12091
|
-
const nodes = [-0.906179845938664, -0.5384693101056831, 0, 0.5384693101056831, 0.906179845938664];
|
|
12092
|
-
const weights = [
|
|
12093
|
-
0.2369268850561891,
|
|
12094
|
-
0.4786286704993665,
|
|
12095
|
-
0.5688888888888889,
|
|
12096
|
-
0.4786286704993665,
|
|
12097
|
-
0.2369268850561891
|
|
12098
|
-
];
|
|
12099
|
-
const hw = (b - a) / 2;
|
|
12100
|
-
const mid = (a + b) / 2;
|
|
12101
|
-
let sum3 = 0;
|
|
12102
|
-
for (let i = 0; i < 5; i++) {
|
|
12103
|
-
sum3 += weights[i] * f(hw * nodes[i] + mid);
|
|
12104
|
-
}
|
|
12105
|
-
return hw * sum3;
|
|
12150
|
+
return quad(f, a, b, opts).value;
|
|
12106
12151
|
}
|
|
12107
12152
|
function simpsons(f, a, b, n = 100) {
|
|
12108
12153
|
if (n % 2 !== 0) n += 1;
|
|
@@ -15137,9 +15182,9 @@ function multivariateNormal(mean6, cov2) {
|
|
|
15137
15182
|
for (let j = 0; j < i; j++) s -= L[i][j] * z[j];
|
|
15138
15183
|
z[i] = s / L[i][i];
|
|
15139
15184
|
}
|
|
15140
|
-
let
|
|
15141
|
-
for (let i = 0; i < k; i++)
|
|
15142
|
-
return Math.exp(-0.5 * (k * Math.log(2 * Math.PI) + logDet +
|
|
15185
|
+
let quad2 = 0;
|
|
15186
|
+
for (let i = 0; i < k; i++) quad2 += z[i] * z[i];
|
|
15187
|
+
return Math.exp(-0.5 * (k * Math.log(2 * Math.PI) + logDet + quad2));
|
|
15143
15188
|
}
|
|
15144
15189
|
};
|
|
15145
15190
|
}
|
|
@@ -25038,10 +25083,10 @@ var createNthRoots = /* @__PURE__ */ factory(
|
|
|
25038
25083
|
return new Complex12(0, -val);
|
|
25039
25084
|
}
|
|
25040
25085
|
];
|
|
25041
|
-
function _nthComplexRoots(a,
|
|
25042
|
-
if (
|
|
25043
|
-
if (
|
|
25044
|
-
if (
|
|
25086
|
+
function _nthComplexRoots(a, root2) {
|
|
25087
|
+
if (root2 < 0) throw new Error("Root must be greater than zero");
|
|
25088
|
+
if (root2 === 0) throw new Error("Root must be non-zero");
|
|
25089
|
+
if (root2 % 1 !== 0) throw new Error("Root must be an integer");
|
|
25045
25090
|
if (a === 0 || a.abs() === 0) return [new Complex12(0, 0)];
|
|
25046
25091
|
const aIsNumeric = typeof a === "number";
|
|
25047
25092
|
let offset = NaN;
|
|
@@ -25057,14 +25102,14 @@ var createNthRoots = /* @__PURE__ */ factory(
|
|
|
25057
25102
|
const arg3 = a.arg();
|
|
25058
25103
|
const abs2 = a.abs();
|
|
25059
25104
|
const roots = [];
|
|
25060
|
-
const r = Math.pow(abs2, 1 /
|
|
25061
|
-
for (let k = 0; k <
|
|
25062
|
-
const halfPiFactor = (offset + 4 * k) /
|
|
25105
|
+
const r = Math.pow(abs2, 1 / root2);
|
|
25106
|
+
for (let k = 0; k < root2; k++) {
|
|
25107
|
+
const halfPiFactor = (offset + 4 * k) / root2;
|
|
25063
25108
|
if (halfPiFactor === Math.round(halfPiFactor)) {
|
|
25064
25109
|
roots.push(_calculateExactResult[halfPiFactor % 4](r));
|
|
25065
25110
|
continue;
|
|
25066
25111
|
}
|
|
25067
|
-
roots.push(new Complex12({ r, phi: (arg3 + 2 * Math.PI * k) /
|
|
25112
|
+
roots.push(new Complex12({ r, phi: (arg3 + 2 * Math.PI * k) / root2 }));
|
|
25068
25113
|
}
|
|
25069
25114
|
return roots;
|
|
25070
25115
|
}
|
|
@@ -28117,19 +28162,19 @@ var createNthRoot = /* @__PURE__ */ factory(
|
|
|
28117
28162
|
sS: false
|
|
28118
28163
|
})
|
|
28119
28164
|
);
|
|
28120
|
-
function _bigNthRoot(a,
|
|
28165
|
+
function _bigNthRoot(a, root2) {
|
|
28121
28166
|
const precision = BigNumber9.precision;
|
|
28122
28167
|
const Big = BigNumber9.clone({ precision: precision + 2 });
|
|
28123
28168
|
const zero = new BigNumber9(0);
|
|
28124
28169
|
const one = new Big(1);
|
|
28125
|
-
const inv2 =
|
|
28170
|
+
const inv2 = root2.isNegative();
|
|
28126
28171
|
if (inv2) {
|
|
28127
|
-
|
|
28172
|
+
root2 = root2.neg();
|
|
28128
28173
|
}
|
|
28129
|
-
if (
|
|
28174
|
+
if (root2.isZero()) {
|
|
28130
28175
|
throw new Error("Root must be non-zero");
|
|
28131
28176
|
}
|
|
28132
|
-
if (a.isNegative() && !
|
|
28177
|
+
if (a.isNegative() && !root2.abs().mod(2).equals(1)) {
|
|
28133
28178
|
throw new Error("Root must be odd when a is negative.");
|
|
28134
28179
|
}
|
|
28135
28180
|
if (a.isZero()) {
|
|
@@ -28138,7 +28183,7 @@ var createNthRoot = /* @__PURE__ */ factory(
|
|
|
28138
28183
|
if (!a.isFinite()) {
|
|
28139
28184
|
return inv2 ? zero : a;
|
|
28140
28185
|
}
|
|
28141
|
-
let x = a.abs().pow(one.div(
|
|
28186
|
+
let x = a.abs().pow(one.div(root2));
|
|
28142
28187
|
x = a.isNeg() ? x.neg() : x;
|
|
28143
28188
|
return new BigNumber9((inv2 ? one.div(x) : x).toPrecision(precision));
|
|
28144
28189
|
}
|
|
@@ -42149,6 +42194,31 @@ function reviver(_key, value) {
|
|
|
42149
42194
|
// src/typed/cas.ts
|
|
42150
42195
|
import { computePool as computePool12 } from "@danielsimonjr/mathts-parallel";
|
|
42151
42196
|
import { Complex as Complex10 } from "@danielsimonjr/mathts-core";
|
|
42197
|
+
|
|
42198
|
+
// src/numeric/numeric-jacobian.ts
|
|
42199
|
+
function numericJacobian(f, x0, opts = {}) {
|
|
42200
|
+
const n = x0.length;
|
|
42201
|
+
const base = Array.from(x0);
|
|
42202
|
+
const f0 = f(base);
|
|
42203
|
+
const m = f0.length;
|
|
42204
|
+
const cbrtEps = Math.cbrt(222e-18);
|
|
42205
|
+
const J = Array.from({ length: m }, () => new Array(n).fill(0));
|
|
42206
|
+
for (let j = 0; j < n; j++) {
|
|
42207
|
+
const h = opts.h ?? Math.max(1, Math.abs(base[j])) * cbrtEps;
|
|
42208
|
+
const xPlus = base.slice();
|
|
42209
|
+
xPlus[j] += h;
|
|
42210
|
+
const fPlus = f(xPlus);
|
|
42211
|
+
const xMinus = base.slice();
|
|
42212
|
+
xMinus[j] -= h;
|
|
42213
|
+
const fMinus = f(xMinus);
|
|
42214
|
+
for (let i = 0; i < m; i++) {
|
|
42215
|
+
J[i][j] = (fPlus[i] - fMinus[i]) / (2 * h);
|
|
42216
|
+
}
|
|
42217
|
+
}
|
|
42218
|
+
return J;
|
|
42219
|
+
}
|
|
42220
|
+
|
|
42221
|
+
// src/typed/cas.ts
|
|
42152
42222
|
function _evalNumeric(exprStr) {
|
|
42153
42223
|
let pos = 0;
|
|
42154
42224
|
const s = exprStr.replace(/\s+/g, "");
|
|
@@ -42409,6 +42479,9 @@ function gradientSymbolic(expr, vars, scope) {
|
|
|
42409
42479
|
return vars.map((v) => partialDerivative(expr, v, scope));
|
|
42410
42480
|
}
|
|
42411
42481
|
function jacobian(exprs, vars, scope) {
|
|
42482
|
+
if (typeof exprs === "function") {
|
|
42483
|
+
return numericJacobian(exprs, vars);
|
|
42484
|
+
}
|
|
42412
42485
|
return exprs.map((expr) => vars.map((v) => partialDerivative(expr, v, scope)));
|
|
42413
42486
|
}
|
|
42414
42487
|
function laplacian(expr, vars, scope) {
|
|
@@ -43149,8 +43222,8 @@ function toRadicals(expr) {
|
|
|
43149
43222
|
const a_lin = f1 - f0;
|
|
43150
43223
|
if (Math.abs(a_lin * 2 + b_lin - f2) < 1e-8 && Math.abs(-a_lin + b_lin - fm1) < 1e-8) {
|
|
43151
43224
|
if (Math.abs(a_lin) < 1e-12) return [];
|
|
43152
|
-
const
|
|
43153
|
-
return [formatCoeff(
|
|
43225
|
+
const root2 = -b_lin / a_lin;
|
|
43226
|
+
return [formatCoeff(root2)];
|
|
43154
43227
|
}
|
|
43155
43228
|
const c = f0;
|
|
43156
43229
|
const a_plus_b = f1 - c;
|
|
@@ -44789,6 +44862,219 @@ function hessian(f, x, h = 1e-4) {
|
|
|
44789
44862
|
return H;
|
|
44790
44863
|
}
|
|
44791
44864
|
|
|
44865
|
+
// src/index.ts
|
|
44866
|
+
import { svd as svd3 } from "@danielsimonjr/mathts-matrix";
|
|
44867
|
+
|
|
44868
|
+
// src/linalg-svd-extra.ts
|
|
44869
|
+
import { svd as svd2 } from "@danielsimonjr/mathts-matrix";
|
|
44870
|
+
function orth(A, opts = {}) {
|
|
44871
|
+
const { U, S } = svd2(A);
|
|
44872
|
+
const m = A.length;
|
|
44873
|
+
const n = A[0]?.length ?? 0;
|
|
44874
|
+
const s0 = S[0] ?? 0;
|
|
44875
|
+
const tol = opts.tol ?? Math.max(m, n) * s0 * 222e-18;
|
|
44876
|
+
const rank2 = S.filter((s) => s > tol).length;
|
|
44877
|
+
return U.map((row2) => row2.slice(0, rank2));
|
|
44878
|
+
}
|
|
44879
|
+
|
|
44880
|
+
// src/numeric/open-root-finders.ts
|
|
44881
|
+
var EPS_CBRT = Math.cbrt(2220446049250313e-31);
|
|
44882
|
+
function centralDiff1(f, x) {
|
|
44883
|
+
const h = Math.max(1, Math.abs(x)) * EPS_CBRT;
|
|
44884
|
+
return (f(x + h) - f(x - h)) / (2 * h);
|
|
44885
|
+
}
|
|
44886
|
+
function centralDiff2(f, x) {
|
|
44887
|
+
const h = Math.max(1, Math.abs(x)) * EPS_CBRT;
|
|
44888
|
+
return (f(x + h) - 2 * f(x) + f(x - h)) / (h * h);
|
|
44889
|
+
}
|
|
44890
|
+
function newton(f, x0, opts) {
|
|
44891
|
+
const fprime = opts?.fprime;
|
|
44892
|
+
const tol = opts?.tol ?? 1e-12;
|
|
44893
|
+
const maxIter = opts?.maxIter ?? 100;
|
|
44894
|
+
let x = x0;
|
|
44895
|
+
for (let iter = 0; iter < maxIter; iter++) {
|
|
44896
|
+
const fx = f(x);
|
|
44897
|
+
if (Math.abs(fx) < tol) return x;
|
|
44898
|
+
const dfx = fprime ? fprime(x) : centralDiff1(f, x);
|
|
44899
|
+
if (Math.abs(dfx) < 1e-300) {
|
|
44900
|
+
throw new Error("newton: derivative near zero \u2014 cannot continue");
|
|
44901
|
+
}
|
|
44902
|
+
const dx = fx / dfx;
|
|
44903
|
+
const xNext = x - dx;
|
|
44904
|
+
if (Math.abs(dx) < tol) return xNext;
|
|
44905
|
+
x = xNext;
|
|
44906
|
+
}
|
|
44907
|
+
throw new Error(`newton: failed to converge within ${maxIter} iterations`);
|
|
44908
|
+
}
|
|
44909
|
+
function secant(f, x0, x1, opts) {
|
|
44910
|
+
const tol = opts?.tol ?? 1e-12;
|
|
44911
|
+
const maxIter = opts?.maxIter ?? 100;
|
|
44912
|
+
let xPrev = x0;
|
|
44913
|
+
let x = x1;
|
|
44914
|
+
let fPrev = f(xPrev);
|
|
44915
|
+
for (let iter = 0; iter < maxIter; iter++) {
|
|
44916
|
+
const fx = f(x);
|
|
44917
|
+
if (Math.abs(fx) < tol) return x;
|
|
44918
|
+
const denom = fx - fPrev;
|
|
44919
|
+
if (Math.abs(denom) < 1e-300) {
|
|
44920
|
+
throw new Error("secant: f(x_k) - f(x_{k-1}) near zero \u2014 cannot continue");
|
|
44921
|
+
}
|
|
44922
|
+
const dx = fx * (x - xPrev) / denom;
|
|
44923
|
+
const xNext = x - dx;
|
|
44924
|
+
if (Math.abs(dx) < tol) return xNext;
|
|
44925
|
+
xPrev = x;
|
|
44926
|
+
fPrev = fx;
|
|
44927
|
+
x = xNext;
|
|
44928
|
+
}
|
|
44929
|
+
throw new Error(`secant: failed to converge within ${maxIter} iterations`);
|
|
44930
|
+
}
|
|
44931
|
+
function halley(f, x0, opts) {
|
|
44932
|
+
const fprime = opts?.fprime;
|
|
44933
|
+
const fprime2 = opts?.fprime2;
|
|
44934
|
+
const tol = opts?.tol ?? 1e-12;
|
|
44935
|
+
const maxIter = opts?.maxIter ?? 100;
|
|
44936
|
+
let x = x0;
|
|
44937
|
+
for (let iter = 0; iter < maxIter; iter++) {
|
|
44938
|
+
const fx = f(x);
|
|
44939
|
+
if (Math.abs(fx) < tol) return x;
|
|
44940
|
+
const dfx = fprime ? fprime(x) : centralDiff1(f, x);
|
|
44941
|
+
const d2fx = fprime2 ? fprime2(x) : centralDiff2(f, x);
|
|
44942
|
+
const denom = 2 * dfx * dfx - fx * d2fx;
|
|
44943
|
+
if (Math.abs(denom) < 1e-300) {
|
|
44944
|
+
throw new Error("halley: denominator near zero \u2014 cannot continue");
|
|
44945
|
+
}
|
|
44946
|
+
const dx = 2 * fx * dfx / denom;
|
|
44947
|
+
const xNext = x - dx;
|
|
44948
|
+
if (Math.abs(dx) < tol) return xNext;
|
|
44949
|
+
x = xNext;
|
|
44950
|
+
}
|
|
44951
|
+
throw new Error(`halley: failed to converge within ${maxIter} iterations`);
|
|
44952
|
+
}
|
|
44953
|
+
|
|
44954
|
+
// src/numeric/fsolve.ts
|
|
44955
|
+
function maxNorm(v) {
|
|
44956
|
+
let m = 0;
|
|
44957
|
+
for (const vi of v) m = Math.max(m, Math.abs(vi));
|
|
44958
|
+
return m;
|
|
44959
|
+
}
|
|
44960
|
+
function norm24(v) {
|
|
44961
|
+
let s = 0;
|
|
44962
|
+
for (const vi of v) s += vi * vi;
|
|
44963
|
+
return Math.sqrt(s);
|
|
44964
|
+
}
|
|
44965
|
+
function fsolve(F, x0, opts = {}) {
|
|
44966
|
+
const tol = opts.tol ?? 1e-10;
|
|
44967
|
+
const maxIter = opts.maxIter ?? 100;
|
|
44968
|
+
let x = Array.from(x0);
|
|
44969
|
+
let Fx = F(x);
|
|
44970
|
+
for (let iter = 0; iter < maxIter; iter++) {
|
|
44971
|
+
if (maxNorm(Fx) < tol) return x;
|
|
44972
|
+
const J = numericJacobian(F, x);
|
|
44973
|
+
const rhs = Fx.map((v) => -v);
|
|
44974
|
+
let delta;
|
|
44975
|
+
try {
|
|
44976
|
+
delta = linsolve(J, rhs);
|
|
44977
|
+
} catch (err) {
|
|
44978
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
44979
|
+
throw new Error(`fsolve: singular Jacobian at iteration ${iter} (${msg})`);
|
|
44980
|
+
}
|
|
44981
|
+
const residualNorm = norm24(Fx);
|
|
44982
|
+
let xNext = x.map((xi, i) => xi + delta[i]);
|
|
44983
|
+
let FxNext = F(xNext);
|
|
44984
|
+
if (norm24(FxNext) >= residualNorm) {
|
|
44985
|
+
let trialLambda = 1;
|
|
44986
|
+
for (let halving = 0; halving < 20; halving++) {
|
|
44987
|
+
trialLambda /= 2;
|
|
44988
|
+
const xTrial = x.map((xi, i) => xi + trialLambda * delta[i]);
|
|
44989
|
+
const FxTrial = F(xTrial);
|
|
44990
|
+
if (norm24(FxTrial) < residualNorm) {
|
|
44991
|
+
xNext = xTrial;
|
|
44992
|
+
FxNext = FxTrial;
|
|
44993
|
+
break;
|
|
44994
|
+
}
|
|
44995
|
+
}
|
|
44996
|
+
}
|
|
44997
|
+
x = xNext;
|
|
44998
|
+
Fx = FxNext;
|
|
44999
|
+
}
|
|
45000
|
+
if (maxNorm(Fx) < tol) return x;
|
|
45001
|
+
throw new Error(`fsolve: failed to converge within ${maxIter} iterations`);
|
|
45002
|
+
}
|
|
45003
|
+
var root = fsolve;
|
|
45004
|
+
|
|
45005
|
+
// src/numeric/minimize-scalar.ts
|
|
45006
|
+
var GOLD = (3 - Math.sqrt(5)) / 2;
|
|
45007
|
+
var EPS2 = 2220446049250313e-31;
|
|
45008
|
+
function minimizeScalar(f, opts) {
|
|
45009
|
+
const [a0, b0] = opts?.bracket ?? [-10, 10];
|
|
45010
|
+
const tol = opts?.tol ?? 1e-8;
|
|
45011
|
+
const maxIter = opts?.maxIter ?? 100;
|
|
45012
|
+
let a = Math.min(a0, b0);
|
|
45013
|
+
let b = Math.max(a0, b0);
|
|
45014
|
+
let x = a + GOLD * (b - a);
|
|
45015
|
+
let w = x;
|
|
45016
|
+
let v = x;
|
|
45017
|
+
let fx = f(x);
|
|
45018
|
+
let fw = fx;
|
|
45019
|
+
let fv = fx;
|
|
45020
|
+
let e = 0;
|
|
45021
|
+
let d = 0;
|
|
45022
|
+
for (let iter = 0; iter < maxIter; iter++) {
|
|
45023
|
+
const xm = 0.5 * (a + b);
|
|
45024
|
+
const tol1 = tol * Math.abs(x) + EPS2;
|
|
45025
|
+
const tol2 = 2 * tol1;
|
|
45026
|
+
if (Math.abs(x - xm) <= tol2 - 0.5 * (b - a)) break;
|
|
45027
|
+
let useGolden = true;
|
|
45028
|
+
if (Math.abs(e) > tol1) {
|
|
45029
|
+
const r = (x - w) * (fx - fv);
|
|
45030
|
+
let q = (x - v) * (fx - fw);
|
|
45031
|
+
let p = (x - v) * q - (x - w) * r;
|
|
45032
|
+
q = 2 * (q - r);
|
|
45033
|
+
if (q > 0) p = -p;
|
|
45034
|
+
q = Math.abs(q);
|
|
45035
|
+
const eTemp = e;
|
|
45036
|
+
e = d;
|
|
45037
|
+
if (Math.abs(p) < Math.abs(0.5 * q * eTemp) && p > q * (a - x) && p < q * (b - x)) {
|
|
45038
|
+
d = p / q;
|
|
45039
|
+
const u2 = x + d;
|
|
45040
|
+
if (u2 - a < tol2 || b - u2 < tol2) {
|
|
45041
|
+
d = xm - x >= 0 ? tol1 : -tol1;
|
|
45042
|
+
}
|
|
45043
|
+
useGolden = false;
|
|
45044
|
+
}
|
|
45045
|
+
}
|
|
45046
|
+
if (useGolden) {
|
|
45047
|
+
e = x >= xm ? a - x : b - x;
|
|
45048
|
+
d = GOLD * e;
|
|
45049
|
+
}
|
|
45050
|
+
const u = Math.abs(d) >= tol1 ? x + d : x + (d >= 0 ? tol1 : -tol1);
|
|
45051
|
+
const fu = f(u);
|
|
45052
|
+
if (fu <= fx) {
|
|
45053
|
+
if (u >= x) a = x;
|
|
45054
|
+
else b = x;
|
|
45055
|
+
v = w;
|
|
45056
|
+
fv = fw;
|
|
45057
|
+
w = x;
|
|
45058
|
+
fw = fx;
|
|
45059
|
+
x = u;
|
|
45060
|
+
fx = fu;
|
|
45061
|
+
} else {
|
|
45062
|
+
if (u < x) a = u;
|
|
45063
|
+
else b = u;
|
|
45064
|
+
if (fu <= fw || w === x) {
|
|
45065
|
+
v = w;
|
|
45066
|
+
fv = fw;
|
|
45067
|
+
w = u;
|
|
45068
|
+
fw = fu;
|
|
45069
|
+
} else if (fu <= fv || v === x || v === w) {
|
|
45070
|
+
v = u;
|
|
45071
|
+
fv = fu;
|
|
45072
|
+
}
|
|
45073
|
+
}
|
|
45074
|
+
}
|
|
45075
|
+
return { x, fval: fx };
|
|
45076
|
+
}
|
|
45077
|
+
|
|
44792
45078
|
// src/timeseries-extra.ts
|
|
44793
45079
|
var arr4 = (x) => Array.isArray(x) ? x : Array.from(x);
|
|
44794
45080
|
var mean4 = (x) => mean(x);
|
|
@@ -44987,7 +45273,7 @@ function levenbergMarquardt(residual, x0, opts = {}) {
|
|
|
44987
45273
|
let x = Array.from(x0);
|
|
44988
45274
|
let lambda = 1e-3;
|
|
44989
45275
|
const h = 1e-7;
|
|
44990
|
-
const
|
|
45276
|
+
const norm25 = (v) => v.reduce((s, c) => s + c * c, 0);
|
|
44991
45277
|
const jacobian2 = (xc, r0) => {
|
|
44992
45278
|
const m = r0.length;
|
|
44993
45279
|
const J = Array.from({ length: m }, () => new Array(n).fill(0));
|
|
@@ -45000,7 +45286,7 @@ function levenbergMarquardt(residual, x0, opts = {}) {
|
|
|
45000
45286
|
return J;
|
|
45001
45287
|
};
|
|
45002
45288
|
let r = residual(x);
|
|
45003
|
-
let cost =
|
|
45289
|
+
let cost = norm25(r);
|
|
45004
45290
|
let iter = 0;
|
|
45005
45291
|
for (; iter < maxIter; iter++) {
|
|
45006
45292
|
const J = jacobian2(x, r);
|
|
@@ -45031,7 +45317,7 @@ function levenbergMarquardt(residual, x0, opts = {}) {
|
|
|
45031
45317
|
}
|
|
45032
45318
|
const xNew = x.map((v, i) => v + delta[i]);
|
|
45033
45319
|
const rNew = residual(xNew);
|
|
45034
|
-
const costNew =
|
|
45320
|
+
const costNew = norm25(rNew);
|
|
45035
45321
|
if (costNew < cost) {
|
|
45036
45322
|
x = xNew;
|
|
45037
45323
|
r = rNew;
|
|
@@ -45794,6 +46080,7 @@ export {
|
|
|
45794
46080
|
fresnelC,
|
|
45795
46081
|
fresnelS,
|
|
45796
46082
|
friedmanTest,
|
|
46083
|
+
fsolve,
|
|
45797
46084
|
fsum,
|
|
45798
46085
|
fullSimplify,
|
|
45799
46086
|
functionExpand,
|
|
@@ -45833,6 +46120,7 @@ export {
|
|
|
45833
46120
|
groebnerBasis,
|
|
45834
46121
|
groupDelay,
|
|
45835
46122
|
gumbelDist,
|
|
46123
|
+
halley,
|
|
45836
46124
|
harmonicNumber,
|
|
45837
46125
|
hartreeEnergy,
|
|
45838
46126
|
hasNumericValue,
|
|
@@ -45988,6 +46276,7 @@ export {
|
|
|
45988
46276
|
minSelect,
|
|
45989
46277
|
minimalPolynomial,
|
|
45990
46278
|
minimize,
|
|
46279
|
+
minimizeScalar,
|
|
45991
46280
|
minimumSpanningTree,
|
|
45992
46281
|
minkowskiDistance,
|
|
45993
46282
|
mod,
|
|
@@ -46010,6 +46299,7 @@ export {
|
|
|
46010
46299
|
negativeBinomialDist,
|
|
46011
46300
|
nelderMead,
|
|
46012
46301
|
neutronMass,
|
|
46302
|
+
newton,
|
|
46013
46303
|
newtonInterp,
|
|
46014
46304
|
nextPrime,
|
|
46015
46305
|
nintegrate,
|
|
@@ -46031,11 +46321,13 @@ export {
|
|
|
46031
46321
|
nullspace,
|
|
46032
46322
|
number,
|
|
46033
46323
|
numeric,
|
|
46324
|
+
numericJacobian,
|
|
46034
46325
|
oct,
|
|
46035
46326
|
odeAdaptiveStep,
|
|
46036
46327
|
odeGeneral,
|
|
46037
46328
|
ones,
|
|
46038
46329
|
or,
|
|
46330
|
+
orth,
|
|
46039
46331
|
outer,
|
|
46040
46332
|
padeApproximant,
|
|
46041
46333
|
pageRank,
|
|
@@ -46117,6 +46409,7 @@ export {
|
|
|
46117
46409
|
protonMass,
|
|
46118
46410
|
ptp,
|
|
46119
46411
|
qr,
|
|
46412
|
+
quad,
|
|
46120
46413
|
quadprog,
|
|
46121
46414
|
quantileSeq,
|
|
46122
46415
|
quantumOfCirculation,
|
|
@@ -46154,6 +46447,7 @@ export {
|
|
|
46154
46447
|
rightLogShift,
|
|
46155
46448
|
risingFactorial,
|
|
46156
46449
|
romberg,
|
|
46450
|
+
root,
|
|
46157
46451
|
rotate,
|
|
46158
46452
|
rotateVector2D,
|
|
46159
46453
|
rotateVector3D,
|
|
@@ -46165,6 +46459,7 @@ export {
|
|
|
46165
46459
|
sackurTetrode,
|
|
46166
46460
|
schur,
|
|
46167
46461
|
sec,
|
|
46462
|
+
secant,
|
|
46168
46463
|
sech,
|
|
46169
46464
|
secondRadiation,
|
|
46170
46465
|
seedProbabilityRng,
|
|
@@ -46241,6 +46536,7 @@ export {
|
|
|
46241
46536
|
subtractScalar,
|
|
46242
46537
|
sum,
|
|
46243
46538
|
summation,
|
|
46539
|
+
svd3 as svd,
|
|
46244
46540
|
sylvester,
|
|
46245
46541
|
symbolicEqual,
|
|
46246
46542
|
symbolicIntegral,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Options for {@link orth}. */
|
|
2
|
+
export interface OrthOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Rank-determination tolerance. Singular values `> tol` count toward the
|
|
5
|
+
* rank. Default: `max(m, n) * S[0] * 2.22e-16` (machine epsilon scaled by
|
|
6
|
+
* matrix size and the largest singular value).
|
|
7
|
+
*/
|
|
8
|
+
tol?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Orthonormal basis for the column space of `A`.
|
|
12
|
+
*
|
|
13
|
+
* Computes `{ U, S } = svd(A)` and returns the first `r` columns of `U`,
|
|
14
|
+
* where `r` is the number of singular values above `tol`. For the all-zero
|
|
15
|
+
* matrix (`r = 0`), returns an `m x 0` matrix (each row an empty array).
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* orth([[1,0,1],[0,1,1],[1,1,2]]) // rank 2 -> 3x2 matrix, U^T U = I
|
|
19
|
+
*/
|
|
20
|
+
export declare function orth(A: number[][], opts?: OrthOptions): number[][];
|
|
21
|
+
//# sourceMappingURL=linalg-svd-extra.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linalg-svd-extra.d.ts","sourceRoot":"","sources":["../src/linalg-svd-extra.ts"],"names":[],"mappings":"AAWA,gCAAgC;AAChC,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,GAAE,WAAgB,GAAG,MAAM,EAAE,EAAE,CAQtE"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adaptive Gauss-Kronrod (G7-K15) quadrature.
|
|
3
|
+
*
|
|
4
|
+
* QUADPACK-style adaptive numerical integration: on each subinterval, a
|
|
5
|
+
* 15-point Kronrod estimate `K` is compared against the embedded 7-point
|
|
6
|
+
* Gauss estimate `G` (both reuse the same 15 evaluation points, so `G` is
|
|
7
|
+
* "free" once `K` is computed). `|K - G|` is the panel's error estimate; if
|
|
8
|
+
* it exceeds tolerance the interval is bisected and each half is refined
|
|
9
|
+
* recursively. This adapts naturally to endpoint singularities and peaked
|
|
10
|
+
* integrands, unlike a fixed-order Gauss-Legendre rule (see `gaussLegendre5`
|
|
11
|
+
* in `../typed/numeric.ts`, whose Richardson-extrapolation adaptivity still
|
|
12
|
+
* converges slowly on e.g. `x^-1/2` near 0).
|
|
13
|
+
*
|
|
14
|
+
* @packageDocumentation
|
|
15
|
+
*/
|
|
16
|
+
type f64 = number;
|
|
17
|
+
type i32 = number;
|
|
18
|
+
/** Options for {@link quad}. */
|
|
19
|
+
export interface QuadOptions {
|
|
20
|
+
/** Relative tolerance on each panel's `|K - G|` vs `|K|` (default 1e-10). */
|
|
21
|
+
tol?: f64;
|
|
22
|
+
/** Maximum bisection recursion depth per panel (default 50). */
|
|
23
|
+
maxDepth?: i32;
|
|
24
|
+
}
|
|
25
|
+
/** Result of {@link quad}. */
|
|
26
|
+
export interface QuadResult {
|
|
27
|
+
/** The estimated integral. */
|
|
28
|
+
value: f64;
|
|
29
|
+
/** Sum of the absolute per-panel `|K - G|` error estimates. */
|
|
30
|
+
error: f64;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Adaptive Gauss-Kronrod (G7-K15) numerical integration of `f` over `[a, b]`.
|
|
34
|
+
*
|
|
35
|
+
* Each subinterval is evaluated with the 15-point Kronrod rule and its
|
|
36
|
+
* embedded 7-point Gauss rule; `|K - G|` is the panel's error estimate. A
|
|
37
|
+
* panel whose error exceeds `tol * |K|` (or the absolute floor, for panels
|
|
38
|
+
* near zero) is bisected and each half refined recursively, up to
|
|
39
|
+
* `maxDepth`. This adapts naturally to endpoint singularities and sharply
|
|
40
|
+
* peaked integrands.
|
|
41
|
+
*
|
|
42
|
+
* @param f - Function to integrate
|
|
43
|
+
* @param a - Lower bound
|
|
44
|
+
* @param b - Upper bound
|
|
45
|
+
* @param opts - Options (tol, maxDepth)
|
|
46
|
+
* @returns `{ value, error }` — the estimated integral and summed panel error
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* quad((x) => 4 / (1 + x * x), 0, 1).value; // ~pi
|
|
51
|
+
* quad((x) => 1 / Math.sqrt(x), 0, 1).value; // ~2, despite the endpoint singularity
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function quad(f: (x: f64) => f64, a: f64, b: f64, opts?: QuadOptions): QuadResult;
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=adaptive-quad.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adaptive-quad.d.ts","sourceRoot":"","sources":["../../src/numeric/adaptive-quad.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,KAAK,GAAG,GAAG,MAAM,CAAC;AAClB,KAAK,GAAG,GAAG,MAAM,CAAC;AAElB,gCAAgC;AAChC,MAAM,WAAW,WAAW;IAC1B,6EAA6E;IAC7E,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,gEAAgE;IAChE,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB;AAED,8BAA8B;AAC9B,MAAM,WAAW,UAAU;IACzB,8BAA8B;IAC9B,KAAK,EAAE,GAAG,CAAC;IACX,+DAA+D;IAC/D,KAAK,EAAE,GAAG,CAAC;CACZ;AAgED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,UAAU,CAmBvF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nonlinear system solver: `fsolve` (damped Newton with a backtracking line
|
|
3
|
+
* search) for `F: R^n -> R^n`. Complements the scalar open root-finders
|
|
4
|
+
* (`./open-root-finders.ts`) and reuses the two Phase 1 foundations:
|
|
5
|
+
* `numericJacobian` (Task 1, central-difference Jacobian) and `linsolve`
|
|
6
|
+
* (`../typed/numeric.ts`, LU with partial pivoting) for the Newton step.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
import { type VectorField } from './numeric-jacobian.js';
|
|
11
|
+
type f64 = number;
|
|
12
|
+
type i32 = number;
|
|
13
|
+
/** Options for `fsolve` / `root`. */
|
|
14
|
+
export interface FsolveOptions {
|
|
15
|
+
/** Absolute tolerance on max|F_i(x)| for convergence (default 1e-10). */
|
|
16
|
+
tol?: f64;
|
|
17
|
+
/** Maximum Newton iterations (default 100). */
|
|
18
|
+
maxIter?: i32;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Solve `F(x) = 0` for `F: R^n -> R^n` via damped Newton's method.
|
|
22
|
+
*
|
|
23
|
+
* At each iterate: compute `J = numericJacobian(F, x)`, solve the Newton
|
|
24
|
+
* step `J * delta = -F(x)` via `linsolve`, then backtrack — try
|
|
25
|
+
* `lambda = 1, 1/2, 1/4, ...` (up to ~20 halvings) and take the largest
|
|
26
|
+
* `lambda` for which `||F(x + lambda*delta)||_2 < ||F(x)||_2`, falling back
|
|
27
|
+
* to `lambda = 1` (a plain Newton step) if no halving improves the residual.
|
|
28
|
+
* Update `x <- x + lambda*delta` and repeat until
|
|
29
|
+
* `max_i |F_i(x)| < tol` (converged) or `maxIter` is exhausted.
|
|
30
|
+
*
|
|
31
|
+
* @param F - Vector field whose root is sought (`F(x) = 0`)
|
|
32
|
+
* @param x0 - Initial guess (length n)
|
|
33
|
+
* @param opts - Options (tol, maxIter)
|
|
34
|
+
* @returns Approximate solution vector x with F(x) ~ 0
|
|
35
|
+
* @throws If the Jacobian is singular (`linsolve` fails) or Newton fails to
|
|
36
|
+
* converge within `maxIter` iterations.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* fsolve((v) => [v[0] ** 2 - v[1], v[0] + v[1] - 2], [0.5, 0.5]) // => ~[1, 1]
|
|
40
|
+
*/
|
|
41
|
+
export declare function fsolve(F: VectorField, x0: readonly number[], opts?: FsolveOptions): number[];
|
|
42
|
+
/** Alias for `fsolve` — `root(F, x0)` solves `F(x) = 0`. */
|
|
43
|
+
export declare const root: typeof fsolve;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=fsolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fsolve.d.ts","sourceRoot":"","sources":["../../src/numeric/fsolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAG1E,KAAK,GAAG,GAAG,MAAM,CAAC;AAClB,KAAK,GAAG,GAAG,MAAM,CAAC;AAElB,qCAAqC;AACrC,MAAM,WAAW,aAAa;IAC5B,yEAAyE;IACzE,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,+CAA+C;IAC/C,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AAgBD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,GAAE,aAAkB,GAAG,MAAM,EAAE,CAiDhG;AAED,4DAA4D;AAC5D,eAAO,MAAM,IAAI,eAAS,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scalar (1-D) function minimization via Brent's method.
|
|
3
|
+
*
|
|
4
|
+
* Distinct from root-finding (`findRoot`, `newton`, `secant`, `halley`, which
|
|
5
|
+
* solve f(x) = 0): this locates a local minimizer of f over a bounded
|
|
6
|
+
* interval. Combines golden-section search (guaranteed, slow) with parabolic
|
|
7
|
+
* interpolation (fast near a smooth minimum) — the classic algorithm of
|
|
8
|
+
* Brent (1973) / Numerical Recipes §10.2, and the same method behind
|
|
9
|
+
* `scipy.optimize.minimize_scalar(method='bounded')`.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
type f64 = number;
|
|
14
|
+
type i32 = number;
|
|
15
|
+
/**
|
|
16
|
+
* Options for {@link minimizeScalar}.
|
|
17
|
+
*/
|
|
18
|
+
export interface MinimizeScalarOptions {
|
|
19
|
+
/**
|
|
20
|
+
* Interval `[a, b]` to search over (bounded Brent). If omitted, defaults to
|
|
21
|
+
* `[-10, 10]` — a generic finite bracket; supply an explicit bracket for
|
|
22
|
+
* functions whose minimum may lie outside that range.
|
|
23
|
+
*/
|
|
24
|
+
bracket?: [f64, f64];
|
|
25
|
+
/** Convergence tolerance on the interval width (default 1e-8). */
|
|
26
|
+
tol?: f64;
|
|
27
|
+
/** Maximum iterations (default 100). */
|
|
28
|
+
maxIter?: i32;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Result of {@link minimizeScalar}.
|
|
32
|
+
*/
|
|
33
|
+
export interface MinimizeScalarResult {
|
|
34
|
+
/** The minimizer. */
|
|
35
|
+
x: f64;
|
|
36
|
+
/** f(x) at the minimizer. */
|
|
37
|
+
fval: f64;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Minimize a scalar function `f: R -> R` over a bounded interval using
|
|
41
|
+
* Brent's method (golden-section search + parabolic interpolation).
|
|
42
|
+
*
|
|
43
|
+
* If `opts.bracket` is not supplied, the default search interval is
|
|
44
|
+
* `[-10, 10]`.
|
|
45
|
+
*
|
|
46
|
+
* @param f - Function to minimize
|
|
47
|
+
* @param opts - Options (bracket, tol, maxIter)
|
|
48
|
+
* @returns `{ x, fval }` — the minimizer and its function value
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* minimizeScalar(x => (x - 2) ** 2) // => { x: ~2, fval: ~0 }
|
|
52
|
+
* minimizeScalar(Math.sin, { bracket: [0, 2 * Math.PI] }) // => { x: ~3pi/2, fval: ~-1 }
|
|
53
|
+
*/
|
|
54
|
+
export declare function minimizeScalar(f: (x: f64) => f64, opts?: MinimizeScalarOptions): MinimizeScalarResult;
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=minimize-scalar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minimize-scalar.d.ts","sourceRoot":"","sources":["../../src/numeric/minimize-scalar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,KAAK,GAAG,GAAG,MAAM,CAAC;AAClB,KAAK,GAAG,GAAG,MAAM,CAAC;AAQlB;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACrB,kEAAkE;IAClE,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,wCAAwC;IACxC,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,qBAAqB;IACrB,CAAC,EAAE,GAAG,CAAC;IACP,6BAA6B;IAC7B,IAAI,EAAE,GAAG,CAAC;CACX;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAC5B,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,GAAG,EAClB,IAAI,CAAC,EAAE,qBAAqB,GAC3B,oBAAoB,CAqFtB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Numeric Jacobian of a vector-valued function `f: R^n -> R^m` via central
|
|
3
|
+
* differences. Complements the symbolic `jacobian(exprs, vars, scope)` in
|
|
4
|
+
* `typed/cas.ts` — that path requires expression strings and throws on a
|
|
5
|
+
* plain numeric function (`exprs.map is not a function`). This is the
|
|
6
|
+
* foundation for numeric root-finding (`fsolve`, Phase 1 Task 3).
|
|
7
|
+
*/
|
|
8
|
+
/** A vector field ℝⁿ → ℝᵐ. */
|
|
9
|
+
export type VectorField = (x: number[]) => number[];
|
|
10
|
+
export interface NumericJacobianOptions {
|
|
11
|
+
/** Absolute step override. Default: per-coordinate relative step (see below). */
|
|
12
|
+
h?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Central-difference Jacobian: `J[i][j] = ∂f_i/∂x_j = (f_i(x0 + h·e_j) − f_i(x0 − h·e_j)) / (2h)`.
|
|
16
|
+
*
|
|
17
|
+
* `f` need not be square (`m = f(x0).length` rows, `n = x0.length` columns).
|
|
18
|
+
* The per-coordinate step defaults to `h = max(1, |x0[j]|) * cbrt(eps)`
|
|
19
|
+
* (eps = 2.22e-16, i.e. Number.EPSILON), the standard relative step for
|
|
20
|
+
* central differences (~6e-6 relative) that balances truncation error
|
|
21
|
+
* (O(h^2)) against floating-point round-off (O(eps/h)).
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* numericJacobian((v) => [v[0] ** 2 + v[1], v[0] * v[1]], [1, 2])
|
|
25
|
+
* // => [[2, 1], [2, 1]]
|
|
26
|
+
*/
|
|
27
|
+
export declare function numericJacobian(f: VectorField, x0: readonly number[], opts?: NumericJacobianOptions): number[][];
|
|
28
|
+
//# sourceMappingURL=numeric-jacobian.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numeric-jacobian.d.ts","sourceRoot":"","sources":["../../src/numeric/numeric-jacobian.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,8BAA8B;AAC9B,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,CAAC;AAEpD,MAAM,WAAW,sBAAsB;IACrC,iFAAiF;IACjF,CAAC,CAAC,EAAE,MAAM,CAAC;CACZ;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAC7B,CAAC,EAAE,WAAW,EACd,EAAE,EAAE,SAAS,MAAM,EAAE,EACrB,IAAI,GAAE,sBAA2B,GAChC,MAAM,EAAE,EAAE,CA0BZ"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Open (non-bracketing) scalar root-finders.
|
|
3
|
+
*
|
|
4
|
+
* Complements the bracketing `findRoot` (bisection/Brent, `../typed/numeric.ts`)
|
|
5
|
+
* with classic open methods that iterate from a starting point (or two)
|
|
6
|
+
* without requiring a sign-change bracket: Newton–Raphson, secant, and
|
|
7
|
+
* Halley's method (cubic convergence).
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
type f64 = number;
|
|
12
|
+
type i32 = number;
|
|
13
|
+
/**
|
|
14
|
+
* Options for Newton's method.
|
|
15
|
+
*/
|
|
16
|
+
export interface NewtonOptions {
|
|
17
|
+
/** Analytic derivative f'(x). If omitted, a central-difference estimate is used. */
|
|
18
|
+
fprime?: (x: f64) => f64;
|
|
19
|
+
/** Absolute tolerance for convergence (default 1e-12) */
|
|
20
|
+
tol?: f64;
|
|
21
|
+
/** Maximum iterations (default 100) */
|
|
22
|
+
maxIter?: i32;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Find a root of f(x) = 0 via Newton–Raphson iteration:
|
|
26
|
+
* `x_{k+1} = x_k - f(x_k) / f'(x_k)`.
|
|
27
|
+
*
|
|
28
|
+
* If `opts.fprime` is not supplied, the derivative is estimated by a
|
|
29
|
+
* central difference with step `h = max(1, |x|) * cbrt(eps)`.
|
|
30
|
+
*
|
|
31
|
+
* @param f - Function whose root is sought
|
|
32
|
+
* @param x0 - Initial guess
|
|
33
|
+
* @param opts - Options (fprime, tol, maxIter)
|
|
34
|
+
* @returns Approximate root
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* newton(x => x ** 2 - 2, 1) // => ~1.4142135623730951
|
|
38
|
+
*/
|
|
39
|
+
export declare function newton(f: (x: f64) => f64, x0: f64, opts?: NewtonOptions): f64;
|
|
40
|
+
/**
|
|
41
|
+
* Options for the secant method.
|
|
42
|
+
*/
|
|
43
|
+
export interface SecantOptions {
|
|
44
|
+
/** Absolute tolerance for convergence (default 1e-12) */
|
|
45
|
+
tol?: f64;
|
|
46
|
+
/** Maximum iterations (default 100) */
|
|
47
|
+
maxIter?: i32;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Find a root of f(x) = 0 via the secant method:
|
|
51
|
+
* `x_{k+1} = x_k - f(x_k) (x_k - x_{k-1}) / (f(x_k) - f(x_{k-1}))`.
|
|
52
|
+
*
|
|
53
|
+
* Requires no derivative, but two initial estimates.
|
|
54
|
+
*
|
|
55
|
+
* @param f - Function whose root is sought
|
|
56
|
+
* @param x0 - First initial estimate
|
|
57
|
+
* @param x1 - Second initial estimate
|
|
58
|
+
* @param opts - Options (tol, maxIter)
|
|
59
|
+
* @returns Approximate root
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* secant(x => x ** 2 - 2, 1, 2) // => ~1.4142135623730951
|
|
63
|
+
*/
|
|
64
|
+
export declare function secant(f: (x: f64) => f64, x0: f64, x1: f64, opts?: SecantOptions): f64;
|
|
65
|
+
/**
|
|
66
|
+
* Options for Halley's method.
|
|
67
|
+
*/
|
|
68
|
+
export interface HalleyOptions {
|
|
69
|
+
/** Analytic first derivative f'(x). If omitted, estimated via central difference. */
|
|
70
|
+
fprime?: (x: f64) => f64;
|
|
71
|
+
/** Analytic second derivative f''(x). If omitted, estimated via central difference. */
|
|
72
|
+
fprime2?: (x: f64) => f64;
|
|
73
|
+
/** Absolute tolerance for convergence (default 1e-12) */
|
|
74
|
+
tol?: f64;
|
|
75
|
+
/** Maximum iterations (default 100) */
|
|
76
|
+
maxIter?: i32;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Find a root of f(x) = 0 via Halley's method (cubic convergence):
|
|
80
|
+
* `x_{k+1} = x_k - 2 f f' / (2 f'^2 - f f'')`.
|
|
81
|
+
*
|
|
82
|
+
* If `opts.fprime` / `opts.fprime2` are not supplied, both derivatives are
|
|
83
|
+
* estimated by central differences with step `h = max(1, |x|) * cbrt(eps)`.
|
|
84
|
+
*
|
|
85
|
+
* @param f - Function whose root is sought
|
|
86
|
+
* @param x0 - Initial guess
|
|
87
|
+
* @param opts - Options (fprime, fprime2, tol, maxIter)
|
|
88
|
+
* @returns Approximate root
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* halley(x => x ** 3 - 2, 1) // => ~1.2599210498948732
|
|
92
|
+
*/
|
|
93
|
+
export declare function halley(f: (x: f64) => f64, x0: f64, opts?: HalleyOptions): f64;
|
|
94
|
+
export {};
|
|
95
|
+
//# sourceMappingURL=open-root-finders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-root-finders.d.ts","sourceRoot":"","sources":["../../src/numeric/open-root-finders.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,KAAK,GAAG,GAAG,MAAM,CAAC;AAClB,KAAK,GAAG,GAAG,MAAM,CAAC;AAelB;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,oFAAoF;IACpF,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,GAAG,CAAC;IACzB,yDAAyD;IACzD,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,uCAAuC;IACvC,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,GAAG,CAuB7E;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,yDAAyD;IACzD,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,uCAAuC;IACvC,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,GAAG,CA2BtF;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,qFAAqF;IACrF,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,GAAG,CAAC;IACzB,uFAAuF;IACvF,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,GAAG,CAAC;IAC1B,yDAAyD;IACzD,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,uCAAuC;IACvC,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,GAAG,CA2B7E"}
|
package/dist/typed/cas.d.ts
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import { parse } from '../factories/evaluate.js';
|
|
23
23
|
import { Complex } from '@danielsimonjr/mathts-core';
|
|
24
|
+
import { type VectorField } from '../numeric/numeric-jacobian.js';
|
|
24
25
|
type f64 = number;
|
|
25
26
|
type MathNode = ReturnType<typeof parse>;
|
|
26
27
|
/**
|
|
@@ -109,17 +110,25 @@ export declare function gradientSymbolic(expr: string, vars: string[], scope: Re
|
|
|
109
110
|
/**
|
|
110
111
|
* Compute the Jacobian matrix of a vector-valued function.
|
|
111
112
|
*
|
|
112
|
-
*
|
|
113
|
+
* Polymorphic: symbolic when `exprs` is an array of expression strings
|
|
114
|
+
* (J[i][j] = partial derivative of exprs[i] with respect to vars[j]);
|
|
115
|
+
* numeric (central differences) when `exprs` is a plain function
|
|
116
|
+
* `f: number[] => number[]` — dispatches to `numericJacobian(f, x0)`.
|
|
113
117
|
*
|
|
114
|
-
* @param exprs - Array of expression strings (vector field components)
|
|
115
|
-
*
|
|
116
|
-
* @param
|
|
118
|
+
* @param exprs - Array of expression strings (vector field components), OR a
|
|
119
|
+
* numeric vector field `f: (x: number[]) => number[]`
|
|
120
|
+
* @param vars - Variable names (symbolic), OR the numeric evaluation point `x0`
|
|
121
|
+
* @param scope - Variable values at which to evaluate (symbolic path only)
|
|
117
122
|
* @returns 2D array (matrix) of partial derivatives
|
|
118
123
|
*
|
|
119
124
|
* @example
|
|
120
125
|
* jacobian(['x*y', 'x^2'], ['x', 'y'], { x: 2, y: 3 })
|
|
121
126
|
* // => [[3, 2], [4, 0]]
|
|
127
|
+
* @example
|
|
128
|
+
* jacobian((v) => [v[0] * v[1], v[0] ** 2], [2, 3])
|
|
129
|
+
* // => [[3, 2], [4, 0]] (numeric, central differences)
|
|
122
130
|
*/
|
|
131
|
+
export declare function jacobian(exprs: VectorField, vars: number[]): f64[][];
|
|
123
132
|
export declare function jacobian(exprs: string[], vars: string[], scope: Record<string, f64>): f64[][];
|
|
124
133
|
/**
|
|
125
134
|
* Compute the Laplacian of a scalar field.
|
package/dist/typed/cas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cas.d.ts","sourceRoot":"","sources":["../../src/typed/cas.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QAAQ,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AAkKhF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;AACjF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AA8EpG;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;AAC3D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AA0C9E;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;AAC3D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC"}
|
package/dist/typed/numeric.d.ts
CHANGED
|
@@ -100,13 +100,17 @@ export declare function globalMinimize(f: (x: number[]) => f64, bounds: [number,
|
|
|
100
100
|
*/
|
|
101
101
|
export declare function leastSquares(A: number[][], b: number[]): number[];
|
|
102
102
|
/**
|
|
103
|
-
* Adaptive numerical integration
|
|
104
|
-
*
|
|
103
|
+
* Adaptive numerical integration via Gauss-Kronrod (G7-K15) quadrature (see
|
|
104
|
+
* {@link quad} in `../numeric/adaptive-quad.js`). Previously used a fixed
|
|
105
|
+
* 5-point Gauss-Legendre panel with Richardson-extrapolation adaptivity,
|
|
106
|
+
* which converged slowly on endpoint singularities (e.g. `x^-1/2` near 0,
|
|
107
|
+
* ~1.7e-6 error); G7-K15's embedded error estimate resolves those panels
|
|
108
|
+
* directly, down to ~1e-10.
|
|
105
109
|
*
|
|
106
110
|
* @param f - Function to integrate
|
|
107
111
|
* @param a - Lower bound
|
|
108
112
|
* @param b - Upper bound
|
|
109
|
-
* @param opts - Options (tol,
|
|
113
|
+
* @param opts - Options (tol, maxDepth for max subdivisions)
|
|
110
114
|
* @returns Approximate integral
|
|
111
115
|
*/
|
|
112
116
|
export declare function nintegrate(f: (x: f64) => f64, a: f64, b: f64, opts?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numeric.d.ts","sourceRoot":"","sources":["../../src/typed/numeric.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"numeric.d.ts","sourceRoot":"","sources":["../../src/typed/numeric.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH,KAAK,GAAG,GAAG,MAAM,CAAC;AAClB,KAAK,GAAG,GAAG,MAAM,CAAC;AASlB;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,yDAAyD;IACzD,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,uCAAuC;IACvC,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,eAAe,GAAG,GAAG,CAwExF;AAED;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAyC7D;AAMD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,wCAAwC;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