@danielsimonjr/mathts-functions 0.58.0 → 0.60.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.
@@ -227,12 +227,20 @@ export declare function expand(expr: string): string;
227
227
  * `factor('x^4+3*x^2+2')` → `'(x^2 + 1)*(x^2 + 2)'`. Polynomials irreducible
228
228
  * over ℚ (`x^4 + 1`, `x^2 + x + 1`) are returned unchanged.
229
229
  *
230
- * **Multivariate polynomials** get the tractable subset (see
231
- * {@link factorMultivariate}): integer-content + common-monomial extraction
232
- * and monomial difference-of-squares `x^2*y + x*y^2 'x*y*(x + y)'`,
233
- * `4*x^2 - 9*y^2 '(2*x - 3*y)*(2*x + 3*y)'`. Full multivariate factorization
234
- * into irreducible factors (Wang/Zassenhaus/EEZ) is OUT OF SCOPE and returns
235
- * the partially-factored or unchanged expression rather than a wrong answer.
230
+ * **Multivariate polynomials** (`n 2` variables, integer coefficients) are
231
+ * factored **completely over ℤ/ℚ** into irreducible factors. A fast path (see
232
+ * {@link factorMultivariate}) handles the common cases byte-for-byte integer
233
+ * content, common-monomial extraction, monomial difference-of-squares
234
+ * (`x^2*y + x*y^2 → 'x*y*(1*y + 1*x)'`, `4*x^2 - 9*y^2 '(2*x - 3*y)*(2*x + 3*y)'`).
235
+ * Anything the fast path leaves whole or only partially factored is routed
236
+ * through the Kronecker-substitution engine ({@link factorMultivariateString}),
237
+ * which reduces to the univariate ℤ engine and recombines by exact division
238
+ * (`x^2 + 3*x*y + 4*x + 2*y^2 + 5*y + 3 → (1*x + 1*y + 1)*(1*x + 2*y + 3)`). The
239
+ * engine declines (and the caller keeps the fast-path/legacy output) beyond a
240
+ * substituted-degree cap; irreducible multivariate polynomials (`x^2 + y^2`) are
241
+ * returned unchanged. Wang/EEZ is a future performance upgrade, not a
242
+ * capability gap. Because the engine confirms every factor by division, it never
243
+ * emits a wrong factorization.
236
244
  *
237
245
  * Everything else (no rational root, no common factor) falls back to the
238
246
  * original common-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wBjD;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,CAKrD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,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"}
@@ -44,4 +44,29 @@ export declare function renderFactor(poly: IntPoly, v: string): string;
44
44
  * order.
45
45
  */
46
46
  export declare function factorPolynomialUnivariate(expr: string, v: string): string | null;
47
+ /**
48
+ * Factor a MULTIVARIATE (`n ≥ 2` variable) integer polynomial given as an
49
+ * expression string, completely over ℤ/ℚ via the Kronecker-substitution engine
50
+ * ({@link factorMultivariateKronecker}), rendered to a string matching
51
+ * `factor()`'s multivariate conventions.
52
+ *
53
+ * Returns `null` when the input is not an integer multivariate polynomial in
54
+ * `vars` (parse failure, non-integer coefficients, single variable, constant,
55
+ * or the degree cap is exceeded — the engine declines) OR when the
56
+ * factorization is not worth substituting for the caller's current output.
57
+ *
58
+ * The "worth it" threshold is `minFactors` (default 2): a result is returned
59
+ * only when it has at least `minFactors` irreducible POLYNOMIAL factors.
60
+ * - Default (the caller's fast path already declined): require ≥ 2 factors —
61
+ * a genuine multi-factor factorization. A single polynomial factor (an
62
+ * irreducible, or a bare integer-content extraction like `2·(3x + 2y)`) is
63
+ * declined so the caller's legacy content-extraction path keeps its exact
64
+ * byte output; the Kronecker rendering's monomial order differs and must not
65
+ * override that contract.
66
+ * - Provided (the caller's fast path produced a partial factorization with
67
+ * `minFactors − 1` irreducible factors): return a result ONLY if it has at
68
+ * least `minFactors` factors, i.e. the engine strictly refined a reducible
69
+ * cofactor the fast path left whole.
70
+ */
71
+ export declare function factorMultivariateString(expr: string, vars: string[], minFactors?: number): string | null;
47
72
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/typed/factorization/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAU,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAsBzD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAoBvE;AA8CD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAG7D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA0BjF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/typed/factorization/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAU,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAwBzD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAoBvE;AA8CD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAG7D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA0BjF;AAmBD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EAAE,EACd,UAAU,SAAI,GACb,MAAM,GAAG,IAAI,CAQf"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Multivariate factorization over ℤ via Kronecker substitution (Layer 2 v1).
3
+ *
4
+ * The orchestration ties three shipped pieces together:
5
+ * 1. Kronecker substitution (`kronecker.ts`) collapses an `n ≥ 2` variable
6
+ * integer polynomial to a single univariate image whose monomials are in
7
+ * bijection with the original's (mixed-radix place values).
8
+ * 2. The univariate Zassenhaus engine (`zassenhaus.ts`) factors that image
9
+ * into irreducibles over ℤ.
10
+ * 3. Subset recombination lifts each univariate irreducible (or product of
11
+ * several) back to a multivariate candidate and confirms it by EXACT
12
+ * multivariate division (`multiExactDivide`) — division is the sole
13
+ * arbiter, so no unverified factor is ever emitted.
14
+ *
15
+ * Correctness follows because (a) every true multivariate factor's image is a
16
+ * subset of the univariate factors, so recombination is complete up to the
17
+ * caps, and (b) division confirms each candidate, so recombination is sound.
18
+ *
19
+ * Two caps bound the work (each logs, never returns a silently wrong answer):
20
+ * - `KRONECKER_MAX_DEGREE` on the substituted univariate degree
21
+ * (`∏(degᵢ+1) − 1`), the Kronecker analogue of Layer 1's factor-count cap.
22
+ * - `MAX_MODULAR_FACTORS` on the univariate factor-pool size, matching
23
+ * Layer 1's recombination cap.
24
+ *
25
+ * `bigint`-only, matching the rest of the factorization engine.
26
+ */
27
+ import { type MultiPoly } from './multi-poly.js';
28
+ /** Complete multivariate factorization: `p = constant · ∏ factorsᵢ^multᵢ`. */
29
+ export type MultiFactorization = {
30
+ constant: bigint;
31
+ factors: Array<{
32
+ poly: MultiPoly;
33
+ mult: number;
34
+ }>;
35
+ };
36
+ /**
37
+ * Factors a multivariate (`n ≥ 2` variables) integer polynomial completely
38
+ * over ℤ into irreducible factors with multiplicity, via Kronecker
39
+ * substitution onto the Layer 1 univariate engine.
40
+ *
41
+ * Returns `null` (declines) when it cannot help — a single variable, the zero
42
+ * or a constant polynomial, or the substituted degree exceeding the cap — so
43
+ * the caller keeps its existing behavior. On success the constant carries the
44
+ * signed integer content and every factor has a positive leading term under
45
+ * the canonical (degree-lex) monomial order.
46
+ */
47
+ export declare function factorMultivariateKronecker(p: MultiPoly): MultiFactorization | null;
48
+ //# sourceMappingURL=kronecker-factor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kronecker-factor.d.ts","sourceRoot":"","sources":["../../../src/typed/factorization/kronecker-factor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAUL,KAAK,SAAS,EACf,MAAM,iBAAiB,CAAC;AAKzB,8EAA8E;AAC9E,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,SAAS,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACnD,CAAC;AA4GF;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,SAAS,GAAG,kBAAkB,GAAG,IAAI,CA0HnF"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Kronecker substitution: reduces a multivariate integer polynomial to a
3
+ * univariate one so it can be factored by the Layer 1 univariate engine
4
+ * (`zassenhaus.ts`), then inverts the map to recover multivariate
5
+ * candidates.
6
+ *
7
+ * The substitution maps `x_k ↦ x^{bases[k]}`, where `bases[0] = 1` and
8
+ * `bases[k] = ∏_{i<k} (degreeIn(p, i) + 1)`. Every monomial
9
+ * `∏_i x_i^{e_i}` then lands at the distinct univariate degree
10
+ * `Σ_i e_i · bases[i]` — distinct because the bases form the place values of
11
+ * a mixed-radix numeral system with radix `degreeIn(p, i) + 1` at position
12
+ * `i`, so no two exponent vectors bounded by the original per-variable
13
+ * degrees can collide. This is what makes the map invertible via
14
+ * {@link backSubstitute}.
15
+ *
16
+ * `bigint`-only per the Layer 2 factorization engine's constraints; the
17
+ * univariate degree used as an array index is a `Number`, guarded against
18
+ * exceeding `Number.MAX_SAFE_INTEGER` before conversion.
19
+ */
20
+ import { type MultiPoly } from './multi-poly.js';
21
+ import { type IntPoly } from './integer-poly.js';
22
+ /**
23
+ * One substitution base per variable of `p`: `bases[0] = 1`,
24
+ * `bases[k] = ∏_{i<k} (degreeIn(p, i) + 1)`.
25
+ */
26
+ export declare function substitutionBases(p: MultiPoly): bigint[];
27
+ /**
28
+ * The univariate degree that the substitution `x_k ↦ x^{bases[k]}` sends
29
+ * `p`'s highest-degree corner monomial to: `Σ_i degreeIn(p, i) · bases[i]`.
30
+ * Callers use this (as a `bigint`) to enforce a degree cap BEFORE calling
31
+ * {@link substitute}, which throws if this bound exceeds
32
+ * `Number.MAX_SAFE_INTEGER`.
33
+ */
34
+ export declare function substitutedDegree(p: MultiPoly, bases: bigint[]): bigint;
35
+ /**
36
+ * Applies the Kronecker substitution `x_k ↦ x^{bases[k]}` to `p`, producing
37
+ * the univariate image as a dense `IntPoly`. Each term's coefficient is
38
+ * placed at univariate degree `Σ_i e_i · bases[i]` (summed with any other
39
+ * term landing at the same degree, though the mixed-radix construction of
40
+ * `bases` guarantees that never happens for exponents within `p`'s own
41
+ * degrees).
42
+ *
43
+ * Throws `RangeError` if the maximum possible substituted degree exceeds
44
+ * `Number.MAX_SAFE_INTEGER` (the array index cannot represent it exactly).
45
+ * Callers should apply the `KRONECKER_MAX_DEGREE` cap via
46
+ * {@link substitutedDegree} before calling this, so this throw is a defensive
47
+ * backstop, not the primary cap enforcement.
48
+ */
49
+ export declare function substitute(p: MultiPoly, bases: bigint[]): IntPoly;
50
+ /**
51
+ * Inverts {@link substitute}: recovers the `MultiPoly` whose Kronecker image
52
+ * is `u`, given the same `bases` and the ORIGINAL polynomial's per-variable
53
+ * degree bounds `degBounds`.
54
+ *
55
+ * Each nonzero univariate coefficient at degree `e` is decomposed by
56
+ * mixed-radix division — radix `degBounds[i] + 1` at position `i` — into an
57
+ * exponent vector. If `e` doesn't fit within the mixed-radix system sized by
58
+ * `degBounds` (a nonzero remainder after the top digit), the decomposition is
59
+ * an out-of-range carry: `e` cannot correspond to a genuine exponent vector
60
+ * bounded by `degBounds`, so this returns `null` rather than a bogus
61
+ * `MultiPoly`. This is the guard that rejects spurious univariate factors
62
+ * during Kronecker recombination.
63
+ */
64
+ export declare function backSubstitute(u: IntPoly, bases: bigint[], degBounds: number[], vars: string[]): MultiPoly | null;
65
+ //# sourceMappingURL=kronecker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kronecker.d.ts","sourceRoot":"","sources":["../../../src/typed/factorization/kronecker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAA8B,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAQ,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,EAAE,CAWxD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAQvE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAmBjE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,CAAC,EAAE,OAAO,EACV,KAAK,EAAE,MAAM,EAAE,EACf,SAAS,EAAE,MAAM,EAAE,EACnB,IAAI,EAAE,MAAM,EAAE,GACb,SAAS,GAAG,IAAI,CAsBlB"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Sparse multivariate polynomial arithmetic over ℤ, backed by a
3
+ * `Map<string, bigint>` keyed by an encoded exponent vector.
4
+ *
5
+ * Convention: a `MultiPoly` fixes an ordered variable list `vars`; every
6
+ * exponent vector has `vars.length` entries, one per variable in that order.
7
+ * `terms` maps `key(exponents)` to the (always nonzero) coefficient — zero
8
+ * coefficients are pruned on every construction/operation, so the zero
9
+ * polynomial is represented by an empty map.
10
+ *
11
+ * This module is part of the multivariate factorization engine
12
+ * (`functions/src/typed/factorization/`, Layer 2) and is `bigint`-only by
13
+ * design, matching the univariate engine in `integer-poly.ts`.
14
+ */
15
+ /** Sparse multivariate polynomial over ℤ. */
16
+ export interface MultiPoly {
17
+ /** Ordered variable names; every exponent vector has this length. */
18
+ vars: string[];
19
+ /** Exponent-vector key -> nonzero coefficient. */
20
+ terms: Map<string, bigint>;
21
+ }
22
+ /** Encodes an exponent vector as a stable map key (comma-joined). */
23
+ export declare function key(exps: number[]): string;
24
+ /** Decodes a `key()`-encoded exponent vector back into numbers. */
25
+ export declare function unkey(k: string): number[];
26
+ /** The zero polynomial over `vars`. */
27
+ export declare function zeroPoly(vars: string[]): MultiPoly;
28
+ /** The constant polynomial `c` over `vars` (zero exponents throughout). */
29
+ export declare function constPoly(vars: string[], c: bigint): MultiPoly;
30
+ /**
31
+ * Builds a `MultiPoly` over `vars` from `(exponents, coefficient)` entries.
32
+ * Entries sharing an exponent vector are summed; zero coefficients (after
33
+ * summing) are pruned.
34
+ */
35
+ export declare function fromTerms(vars: string[], entries: Array<[number[], bigint]>): MultiPoly;
36
+ /** The degree of `p` in the variable at `varIndex` (max exponent across terms; -1 if zero). */
37
+ export declare function degreeIn(p: MultiPoly, varIndex: number): number;
38
+ /** The total degree of `p` (max sum of exponents across terms; -1 if zero). */
39
+ export declare function totalDegree(p: MultiPoly): number;
40
+ /** True iff `p` has no nonzero terms. */
41
+ export declare function isZero(p: MultiPoly): boolean;
42
+ /** Structural equality: same `vars` (in order) and the same term map. */
43
+ export declare function equals(a: MultiPoly, b: MultiPoly): boolean;
44
+ /** `a + b` (both over the same `vars`). */
45
+ export declare function addMP(a: MultiPoly, b: MultiPoly): MultiPoly;
46
+ /** `a - b` (both over the same `vars`). */
47
+ export declare function subMP(a: MultiPoly, b: MultiPoly): MultiPoly;
48
+ /** `a * b` (both over the same `vars`), via distributed convolution. */
49
+ export declare function mulMP(a: MultiPoly, b: MultiPoly): MultiPoly;
50
+ /** `p * k` for a scalar `k: bigint`. */
51
+ export declare function scalarMulMP(p: MultiPoly, k: bigint): MultiPoly;
52
+ /** `-p`. */
53
+ export declare function negMP(p: MultiPoly): MultiPoly;
54
+ /**
55
+ * Total monomial order used for canonicalizing multivariate polynomials:
56
+ * degree-lex — higher total degree first, then lexicographic comparison of
57
+ * the exponent vector (earlier variables weighted higher). Returns a
58
+ * negative number if `expsA` sorts before `expsB` (i.e. `expsA` is the
59
+ * "larger"/leading monomial), positive if after, 0 if equal.
60
+ */
61
+ export declare function canonicalCompare(expsA: number[], expsB: number[]): number;
62
+ /**
63
+ * The leading term of `p` under `canonicalCompare`: the term whose exponent
64
+ * vector sorts first. Returns `null` for the zero polynomial.
65
+ */
66
+ export declare function leadingTerm(p: MultiPoly): {
67
+ exps: number[];
68
+ coeff: bigint;
69
+ } | null;
70
+ /** Non-negative gcd of all coefficients of `p` (0 for the zero polynomial). */
71
+ export declare function integerContentMP(p: MultiPoly): bigint;
72
+ /**
73
+ * Primitive part of `p`: divide out `integerContentMP(p)`, then flip sign
74
+ * so the leading term (under `canonicalCompare`) has a positive
75
+ * coefficient. The zero polynomial maps to itself.
76
+ */
77
+ export declare function primitivePartMP(p: MultiPoly): MultiPoly;
78
+ /**
79
+ * Multivariate polynomial long division: returns the quotient `a / b` iff
80
+ * `b` divides `a` **exactly** over ℤ, else `null`.
81
+ *
82
+ * Repeatedly takes the `canonicalCompare`-leading term of the current
83
+ * remainder and attempts to cancel it against `b`'s leading term: the
84
+ * exponent vector must dominate `b`'s leading exponents component-wise, and
85
+ * the coefficient must divide `b`'s leading coefficient exactly in ℤ (bigint
86
+ * `%` gives an exact `0` remainder regardless of operand signs). Any failure
87
+ * of either condition means the division is not exact — this function is the
88
+ * recombination correctness arbiter and must never round or approximate.
89
+ */
90
+ export declare function multiExactDivide(a: MultiPoly, b: MultiPoly): MultiPoly | null;
91
+ /**
92
+ * Parses `expr` over `vars` via algebra's exact `polyFromExpression`, then
93
+ * lifts it to a bigint-backed {@link MultiPoly} — but only if EVERY
94
+ * coefficient is an exact integer. Returns `null` on any non-integer
95
+ * coefficient or if parsing throws (unknown symbol, non-integer exponent,
96
+ * non-constant divisor, etc.).
97
+ */
98
+ export declare function fromAlgebraExpr(expr: string, vars: string[]): MultiPoly | null;
99
+ /**
100
+ * Renders `p` back to an expression string in the SAME format as
101
+ * `polynomial-ideal.polyToString` (term order, `*`/`^` spacing, `+ -`
102
+ * collapsing, `1*x` unit-coefficient style) — but rendered directly from
103
+ * `bigint` coefficients so values above 2^53 stay exact. Routing through
104
+ * `polyToString` would require `Number(v)`, which silently rounds.
105
+ */
106
+ export declare function toAlgebraString(p: MultiPoly): string;
107
+ //# sourceMappingURL=multi-poly.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi-poly.d.ts","sourceRoot":"","sources":["../../../src/typed/factorization/multi-poly.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,6CAA6C;AAC7C,MAAM,WAAW,SAAS;IACxB,qEAAqE;IACrE,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,kDAAkD;IAClD,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5B;AAED,qEAAqE;AACrE,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAE1C;AAED,mEAAmE;AACnE,wBAAgB,KAAK,CAAC,C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C;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAYzE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CASlF;AAED,+EAA+E;AAC/E,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAMrD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,SAAS,GAAG,SAAS,CAevD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI,CA+B7E;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI,CAmB9E;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAcpD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielsimonjr/mathts-functions",
3
- "version": "0.58.0",
3
+ "version": "0.60.0",
4
4
  "description": "Mathematical functions for MathTS - arithmetic, algebra, trigonometry, statistics, and more",
5
5
  "author": "Daniel Simon Jr.",
6
6
  "license": "MIT",