@danielsimonjr/mathts-functions 0.60.0 → 0.61.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.
@@ -29,6 +29,49 @@ export declare function ratSub(a: Rat, b: Rat): Rat;
29
29
  export declare function ratMul(a: Rat, b: Rat): Rat;
30
30
  export declare function ratDiv(a: Rat, b: Rat): Rat;
31
31
  export declare function ratFromBigint(n: bigint): Rat;
32
+ /**
33
+ * A quadratic surd `a + b·√Δ` for a fixed positive non-square radicand `Δ`
34
+ * (Δ > 0, non-square — a perfect-square Δ never occurs here since it would
35
+ * already have split into rational linear factors). `Δ` is NOT stored on the
36
+ * `Surd` itself: surds produced within one computation share a single `Δ`,
37
+ * and every op that needs it (`surdMul`, `surdDiv`, `surdRender`) takes it as
38
+ * an explicit parameter. `surdAdd`/`surdSub`/`surdNeg`/`surdFromRat` are
39
+ * Δ-independent (componentwise on `a`/`b`), so they don't take it.
40
+ *
41
+ * See docs/superpowers/specs/2026-07-21-risch-layer2-quadratic-surd-design.md
42
+ * (Architecture §1).
43
+ */
44
+ export interface Surd {
45
+ a: Rat;
46
+ b: Rat;
47
+ }
48
+ /** Lifts a rational number to a surd with zero `√Δ` component. */
49
+ export declare function surdFromRat(r: Rat): Surd;
50
+ /** Negates a surd componentwise. */
51
+ export declare function surdNeg(s: Surd): Surd;
52
+ /** Componentwise surd addition (Δ-independent). */
53
+ export declare function surdAdd(x: Surd, y: Surd): Surd;
54
+ /** Componentwise surd subtraction (Δ-independent). */
55
+ export declare function surdSub(x: Surd, y: Surd): Surd;
56
+ /**
57
+ * Surd multiplication: `(a+b√Δ)(c+d√Δ) = (ac+bdΔ) + (ad+bc)√Δ`, using exact
58
+ * `Rat` arithmetic throughout (`Δ` lifted to a `Rat` via `ratFromBigint`).
59
+ */
60
+ export declare function surdMul(x: Surd, y: Surd, delta: bigint): Surd;
61
+ /**
62
+ * Surd division, rationalized by the conjugate: `(a+b√Δ)/(c+d√Δ) =
63
+ * (a+b√Δ)(c−d√Δ) / (c²−d²Δ)`, where `c²−d²Δ` is a plain rational scalar.
64
+ * Throws when `y` is zero (both components zero).
65
+ */
66
+ export declare function surdDiv(x: Surd, y: Surd, delta: bigint): Surd;
67
+ /**
68
+ * Renders a surd as a readable, evaluable string `a + b*sqrt(Δ)`: a zero `a`
69
+ * or zero `b` component is omitted, `b = 1`/`b = -1` render as bare
70
+ * `sqrt(Δ)`/`- sqrt(Δ)`, and integer `Rat`s print without a `/1`. Exact
71
+ * format is non-contractual (correctness is verified by differentiation
72
+ * elsewhere); this only needs to stay evaluable and readable.
73
+ */
74
+ export declare function surdRender(s: Surd, delta: bigint): string;
32
75
  /**
33
76
  * Parses a single-variable expression `numerExpr/denomExpr` (or a bare
34
77
  * polynomial, denominator `[1n]`) into integer numerator/denominator dense
@@ -64,29 +107,37 @@ export declare function polynomialPart(rf: RatFunc): {
64
107
  */
65
108
  export declare function integratePolynomial(p: IntPoly, v: string): string;
66
109
  /**
67
- * An irreducible factor of a rational function's denominator, classified by
68
- * degree for Layer 1 closed-form integration: degree 1 ("linear") integrates
69
- * to a `log`, degree 2 ("quadratic") to a `log` + `atan` pair. Degree ≥ 3
70
- * irreducible factors are outside Layer 1's scope (see `factorDenominator`).
110
+ * An irreducible factor of a rational function's denominator, classified for
111
+ * closed-form integration:
112
+ * - `'linear'` (degree 1) a `log`;
113
+ * - `'quadratic-neg'` (degree 2, discriminant `b²−4ac < 0`, complex roots)
114
+ * a `log` + `atan` pair (Layer 1);
115
+ * - `'quadratic-pos'` (degree 2, discriminant `> 0`, real irrational roots,
116
+ * multiplicity 1) → a pair of real `log`s with quadratic-surd coefficients
117
+ * (Layer 2, see the quadratic-surd design doc).
118
+ * Degree-≥3 irreducible factors, and repeated positive-discriminant quadratics,
119
+ * are out of scope (see `factorDenominator`, which returns `null` for them).
71
120
  */
72
121
  export interface DenFactor {
73
122
  poly: IntPoly;
74
123
  mult: number;
75
- kind: 'linear' | 'quadratic';
124
+ kind: 'linear' | 'quadratic-neg' | 'quadratic-pos';
76
125
  }
77
126
  /**
78
127
  * Factors `denom` completely over ℤ/ℚ via the #7 factorization engine
79
128
  * (`factorUnivariateZ`) and classifies each irreducible factor by degree.
80
129
  *
81
- * A degree-1 factor is `'linear'`; a degree-2 factor is `'quadratic'` — and,
82
- * having survived complete factorization over ℚ, necessarily irreducible
83
- * (any rational root would already have split it into two linear factors,
84
- * i.e. it has negative discriminant).
130
+ * A degree-1 factor is `'linear'`. A degree-2 factor, having survived complete
131
+ * factorization over ℚ, is irreducible over but that does NOT fix its
132
+ * discriminant sign: `disc = b²−4ac < 0` (complex roots, e.g. x²+1) is
133
+ * `'quadratic-neg'` (Layer 1 arctan path); `disc > 0` (real irrational roots,
134
+ * a non-square disc, e.g. x²−2) with **multiplicity 1** is `'quadratic-pos'`
135
+ * (Layer 2 quadratic-surd path).
85
136
  *
86
- * Returns `null` when any irreducible factor has degree 3: Layer 1 only
87
- * handles linear + irreducible-quadratic denominators, so a higher-degree
88
- * irreducible factor is out of scope and the caller falls back to the
89
- * `integral(...)` marker (Layer 2/Rothstein–Trager territory).
137
+ * Returns `null` when a factor is out of scope: any irreducible factor of
138
+ * degree 3, or a **repeated** positive-discriminant quadratic (`disc > 0`,
139
+ * `mult > 1`) the reduction formula for repeated real-root quadratics is
140
+ * Layer 3. The caller then falls back to the `integral(...)` marker.
90
141
  */
91
142
  export declare function factorDenominator(denom: IntPoly): DenFactor[] | null;
92
143
  /**
@@ -117,12 +168,16 @@ export interface PFTerm {
117
168
  export declare function partialFractions(remainder: IntPoly, factors: DenFactor[]): PFTerm[];
118
169
  /**
119
170
  * Integrates a single partial-fraction term in closed form. Dispatches on the
120
- * degree of `term.factor`: degree 1 `log` (+ rational part for a repeated
121
- * factor); degree 2 (irreducible, disc < 0) → `log`/rational part + `atan`.
171
+ * degree of `term.factor` and, for a quadratic, on its discriminant sign:
172
+ * - degree 1 → `log` (+ rational part for a repeated factor);
173
+ * - degree 2, `disc < 0` (complex roots) → `log`/rational part + `atan`;
174
+ * - degree 2, `disc > 0` (real irrational roots, power 1) → a pair of real
175
+ * `log`s with quadratic-surd coefficients (Layer 2).
122
176
  * The produced string is evaluable by the expression engine (`log`, `atan`,
123
177
  * `sqrt`, `abs`, `^`, `*`); its exact form is not contractual — correctness is
124
- * verified by differentiation. Throws on any other factor degree (unreachable
125
- * for a `factorDenominator`-classified factor).
178
+ * verified by differentiation. Throws on any other factor degree, or on a
179
+ * positive-discriminant quadratic with power > 1 (both unreachable for a
180
+ * `factorDenominator`-classified factor).
126
181
  */
127
182
  export declare function integratePFTerm(term: PFTerm, v: string): string;
128
183
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"rational-integrate.d.ts","sourceRoot":"","sources":["../../src/cas/rational-integrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAKL,KAAK,OAAO,EACb,MAAM,wCAAwC,CAAC;AAGhD,4FAA4F;AAC5F,MAAM,WAAW,GAAG;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAED,2FAA2F;AAC3F,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;CAChB;AAoBD,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,GAAG,CAE1C;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,GAAG,CAE1C;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,GAAG,CAE1C;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,GAAG,CAK1C;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAE5C;AAsDD;;;;;;;;;;;;GAYG;AACH,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EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAiB/D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA+ChF"}
package/dist/index.js CHANGED
@@ -10019,11 +10019,15 @@ function landauMignotte(p) {
10019
10019
  return 1n;
10020
10020
  }
10021
10021
  const n = BigInt(d + 1);
10022
- const lcAbs = t[d] < 0n ? -t[d] : t[d];
10023
10022
  const powerOfTwo = 1n << BigInt(d);
10023
+ let normSq = 0n;
10024
+ for (const c of t) {
10025
+ normSq += c * c;
10026
+ }
10027
+ const norm2Ceil = isqrt(normSq) + 1n;
10024
10028
  const sq = isqrt(n);
10025
10029
  const sqrtCeil = sq * sq === n ? sq : sq + 1n;
10026
- const bound = sqrtCeil * powerOfTwo * (lcAbs === 0n ? 1n : lcAbs);
10030
+ const bound = sqrtCeil * powerOfTwo * norm2Ceil;
10027
10031
  return bound > 0n ? bound : 1n;
10028
10032
  }
10029
10033
  function modSymmetric(p, m) {
@@ -50626,6 +50630,9 @@ function ratNormalize(num2, den) {
50626
50630
  const g = bigintGcd(n, d);
50627
50631
  return { num: n / g, den: d / g };
50628
50632
  }
50633
+ function ratAdd(a, b) {
50634
+ return ratNormalize(a.num * b.den + b.num * a.den, a.den * b.den);
50635
+ }
50629
50636
  function ratSub(a, b) {
50630
50637
  return ratNormalize(a.num * b.den - b.num * a.den, a.den * b.den);
50631
50638
  }
@@ -50642,6 +50649,53 @@ function ratFromBigint(n) {
50642
50649
  return { num: n, den: 1n };
50643
50650
  }
50644
50651
  var RAT_ZERO = { num: 0n, den: 1n };
50652
+ function surdFromRat(r) {
50653
+ return { a: r, b: RAT_ZERO };
50654
+ }
50655
+ function surdNeg(s) {
50656
+ return { a: ratNeg(s.a), b: ratNeg(s.b) };
50657
+ }
50658
+ function surdAdd(x, y) {
50659
+ return { a: ratAdd(x.a, y.a), b: ratAdd(x.b, y.b) };
50660
+ }
50661
+ function surdMul(x, y, delta) {
50662
+ const d = ratFromBigint(delta);
50663
+ return {
50664
+ a: ratAdd(ratMul(x.a, y.a), ratMul(ratMul(x.b, y.b), d)),
50665
+ b: ratAdd(ratMul(x.a, y.b), ratMul(x.b, y.a))
50666
+ };
50667
+ }
50668
+ function surdDiv(x, y, delta) {
50669
+ if (y.a.num === 0n && y.b.num === 0n) {
50670
+ throw new Error("surdDiv: division by zero surd");
50671
+ }
50672
+ const d = ratFromBigint(delta);
50673
+ const scale4 = ratSub(ratMul(y.a, y.a), ratMul(ratMul(y.b, y.b), d));
50674
+ const conj3 = { a: y.a, b: ratNeg(y.b) };
50675
+ const numer = surdMul(x, conj3, delta);
50676
+ return { a: ratDiv(numer.a, scale4), b: ratDiv(numer.b, scale4) };
50677
+ }
50678
+ function surdRender(s, delta) {
50679
+ const parts = [];
50680
+ if (s.a.num !== 0n) {
50681
+ parts.push(ratToStr(s.a));
50682
+ }
50683
+ if (s.b.num !== 0n) {
50684
+ const neg2 = s.b.num < 0n;
50685
+ const absB = neg2 ? ratNeg(s.b) : s.b;
50686
+ const sqrtPart = `sqrt(${delta})`;
50687
+ const term = absB.num === absB.den ? sqrtPart : `${ratToStr(absB)}*${sqrtPart}`;
50688
+ if (parts.length === 0) {
50689
+ parts.push(neg2 ? `- ${term}` : term);
50690
+ } else {
50691
+ parts.push(neg2 ? `- ${term}` : `+ ${term}`);
50692
+ }
50693
+ }
50694
+ if (parts.length === 0) {
50695
+ return "0";
50696
+ }
50697
+ return parts.join(" ");
50698
+ }
50645
50699
  function splitTopLevelDivision(expr) {
50646
50700
  let depth = 0;
50647
50701
  for (let i = 0; i < expr.length; i += 1) {
@@ -50793,10 +50847,13 @@ function factorDenominator(denom) {
50793
50847
  } else if (deg === 2) {
50794
50848
  const q = trim(poly);
50795
50849
  const disc = q[1] * q[1] - 4n * q[2] * q[0];
50796
- if (disc >= 0n) {
50850
+ if (disc < 0n) {
50851
+ out.push({ poly, mult, kind: "quadratic-neg" });
50852
+ } else if (mult === 1) {
50853
+ out.push({ poly, mult, kind: "quadratic-pos" });
50854
+ } else {
50797
50855
  return null;
50798
50856
  }
50799
- out.push({ poly, mult, kind: "quadratic" });
50800
50857
  } else {
50801
50858
  return null;
50802
50859
  }
@@ -51020,6 +51077,36 @@ function integrateQuadraticTerm(factor2, k, numer, v) {
51020
51077
  }
51021
51078
  return joinTerms(parts);
51022
51079
  }
51080
+ function integrateQuadraticPosTerm(factor2, numer, v) {
51081
+ const c = factor2[0];
51082
+ const b = factor2[1];
51083
+ const a = factor2[2];
51084
+ const R = b * b - 4n * a * c;
51085
+ const D = numer[1] ?? RAT_ZERO;
51086
+ const E = numer[0] ?? RAT_ZERO;
51087
+ const twoA = ratFromBigint(2n * a);
51088
+ const negBOver2A = ratDiv(ratFromBigint(-b), twoA);
51089
+ const inv2A = ratDiv(ratFromBigint(1n), twoA);
51090
+ const r1 = { a: negBOver2A, b: inv2A };
51091
+ const r2 = { a: negBOver2A, b: ratNeg(inv2A) };
51092
+ const sqrtR = { a: RAT_ZERO, b: ratFromBigint(1n) };
51093
+ const Dsurd = surdFromRat(D);
51094
+ const Esurd = surdFromRat(E);
51095
+ const numA = surdAdd(surdMul(Dsurd, r1, R), Esurd);
51096
+ const numB = surdAdd(surdMul(Dsurd, r2, R), Esurd);
51097
+ const A = surdDiv(numA, sqrtR, R);
51098
+ const B = surdDiv(numB, surdNeg(sqrtR), R);
51099
+ const parts = [];
51100
+ const emit = (coeff, root2) => {
51101
+ if (coeff.a.num === 0n && coeff.b.num === 0n) {
51102
+ return;
51103
+ }
51104
+ parts.push(`(${surdRender(coeff, R)})*log(abs(${v} - (${surdRender(root2, R)})))`);
51105
+ };
51106
+ emit(A, r1);
51107
+ emit(B, r2);
51108
+ return joinTerms(parts);
51109
+ }
51023
51110
  function integratePFTerm(term, v) {
51024
51111
  const factor2 = trim(term.factor);
51025
51112
  const deg = factor2.length - 1;
@@ -51027,7 +51114,14 @@ function integratePFTerm(term, v) {
51027
51114
  return integrateLinearTerm(factor2, term.power, term.numer, v);
51028
51115
  }
51029
51116
  if (deg === 2) {
51030
- return integrateQuadraticTerm(factor2, term.power, term.numer, v);
51117
+ const disc = factor2[1] * factor2[1] - 4n * factor2[2] * factor2[0];
51118
+ if (disc < 0n) {
51119
+ return integrateQuadraticTerm(factor2, term.power, term.numer, v);
51120
+ }
51121
+ if (term.power !== 1) {
51122
+ throw new Error("integratePFTerm: repeated positive-discriminant quadratic is out of scope");
51123
+ }
51124
+ return integrateQuadraticPosTerm(factor2, term.numer, v);
51031
51125
  }
51032
51126
  throw new Error(`integratePFTerm: unsupported factor degree ${deg}`);
51033
51127
  }
@@ -1 +1 @@
1
- {"version":3,"file":"integer-poly.d.ts","sourceRoot":"","sources":["../../../src/typed/factorization/integer-poly.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,qEAAqE;AACrE,MAAM,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC;AAE/B;;;GAGG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAMxC;AAED,sEAAsE;AACtE,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAGzC;AAED,+DAA+D;AAC/D,wBAAgB,EAAE,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAGrC;AAED,4EAA4E;AAC5E,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAE1C;AAED,wBAAwB;AACxB,wBAAgB,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CASnD;AAED,wBAAwB;AACxB,wBAAgB,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CASnD;AAED,qBAAqB;AACrB,wBAAgB,GAAG,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAEvC;AAED,uDAAuD;AACvD,wBAA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AED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAYjD;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAmClE;AAED,sEAAsE;AACtE,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAU9C;AAyBD;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAkBxD;AAmBD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAyBjD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAa3D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielsimonjr/mathts-functions",
3
- "version": "0.60.0",
3
+ "version": "0.61.0",
4
4
  "description": "Mathematical functions for MathTS - arithmetic, algebra, trigonometry, statistics, and more",
5
5
  "author": "Daniel Simon Jr.",
6
6
  "license": "MIT",