|
1 | 1 | ### [Unreleased] |
2 | 2 |
|
3 | | -- **Fix: undeclared symbols with parenthesized numeric arguments now treated as |
4 | | - multiplication**. Previously `q(2q)` with undeclared `q` was auto-declared as |
5 | | - a function call, causing type inconsistencies. Now it is interpreted as |
6 | | - `q·(2q) = 2q²`. Only explicitly declared function symbols get function-call |
7 | | - treatment. Non-numeric arguments (e.g., tuples, triples) still trigger |
8 | | - function-call behavior. |
9 | | - |
10 | | -- **LatexSyntax is now an injectable dependency**. The `ComputeEngine` |
11 | | - constructor accepts an optional `latexSyntax` option to inject a `LatexSyntax` |
12 | | - instance. When importing the full package (`@cortex-js/compute-engine`), a |
13 | | - `LatexSyntax` is created automatically — existing code works unchanged. When |
14 | | - importing only `@cortex-js/compute-engine/core`, no `LatexSyntax` is bundled; |
15 | | - `ce.parse()`, `.latex`, and `.toLatex()` will throw unless a `LatexSyntax` is |
16 | | - explicitly provided. MathJSON serialization (`.json`, `.toMathJson()`) |
17 | | - gracefully omits the optional `latex` metadata field when no `LatexSyntax` is |
18 | | - available. |
19 | | - |
20 | | - ```ts |
21 | | - // Full package — works as before, LatexSyntax auto-created: |
22 | | - import { ComputeEngine } from '@cortex-js/compute-engine'; |
23 | | - const ce = new ComputeEngine(); |
24 | | - ce.parse('x^2'); // works |
25 | | - |
26 | | - // Core-only — explicit injection for LaTeX support: |
27 | | - import { ComputeEngine } from '@cortex-js/compute-engine/core'; |
28 | | - import { LatexSyntax } from '@cortex-js/compute-engine/latex-syntax'; |
29 | | - const ce = new ComputeEngine({ latexSyntax: new LatexSyntax() }); |
30 | | - ce.parse('x^2'); // works |
31 | | - |
32 | | - // Core-only — no LaTeX needed: |
33 | | - import { ComputeEngine } from '@cortex-js/compute-engine/core'; |
34 | | - const ce = new ComputeEngine(); |
35 | | - ce.expr(['Add', 'x', 1]).simplify(); // works |
36 | | - ce.parse('x + 1'); // throws: LatexSyntax not available |
37 | | - ``` |
38 | | - |
39 | | -- **New `ILatexSyntax` interface**: A structural interface for LaTeX |
40 | | - parser/serializers, exposed on `IComputeEngine.latexSyntax`. Allows custom |
41 | | - implementations without depending on the `LatexSyntax` class. |
42 | | - |
43 | | -**Package modularization**: The monolithic `@cortex-js/compute-engine` package |
44 | | -can now be imported as seven independently usable sub-paths, enabling smaller |
45 | | -bundles for consumers who only need a subset of functionality. |
46 | | - |
47 | | -- **New sub-path `@cortex-js/compute-engine/latex-syntax`**: Standalone LaTeX to |
48 | | - MathJSON parsing and serialization. No `ComputeEngine` instance needed. Use |
49 | | - the `LatexSyntax` class for custom configurations or the free functions |
50 | | - `parse()` and `serialize()` with a lazy default instance. |
51 | | - |
52 | | -- **New sub-path `@cortex-js/compute-engine/interval`**: Standalone interval |
53 | | - arithmetic library for reliable function evaluation with guaranteed |
54 | | - enclosures. |
55 | | - |
56 | | -- **New sub-path `@cortex-js/compute-engine/numerics`**: Standalone numeric |
57 | | - functions — rationals, big integers, arbitrary-precision decimals, complex |
58 | | - numbers, special functions (gamma, erf, Bessel, Fresnel, ...), statistics, |
59 | | - primes. |
60 | | - |
61 | | -- **New sub-path `@cortex-js/compute-engine/core`**: The `ComputeEngine` class, |
62 | | - `expr()`, type guards, and computation free functions (`simplify`, `evaluate`, |
63 | | - `N`, `expand`, `factor`, `solve`). No LaTeX or compilation dependencies. |
64 | | - |
65 | | -- **New sub-path `@cortex-js/compute-engine/compile`**: Compilation targets |
66 | | - (`JavaScriptTarget`, `GLSLTarget`, `WGSLTarget`, `PythonTarget`, |
67 | | - `IntervalJavaScriptTarget`) and the `compile()` function. The existing |
68 | | - `@cortex-js/compute-engine/math-json` sub-path is unchanged. |
69 | | - |
70 | | -- **New `LatexSyntax` class**: Standalone replacement for the engine's LaTeX |
71 | | - parsing/serialization. Accepts a `dictionary` option for custom LaTeX |
72 | | - dictionaries and options for number formatting, parse behavior, and |
73 | | - serialization style. |
74 | | - |
75 | | -- **LaTeX dictionary constants**: All 16 domain dictionaries are now |
76 | | - individually importable: `CORE_DICTIONARY`, `SYMBOLS_DICTIONARY`, |
77 | | - `ALGEBRA_DICTIONARY`, `ARITHMETIC_DICTIONARY`, `COMPLEX_DICTIONARY`, |
78 | | - `TRIGONOMETRY_DICTIONARY`, `CALCULUS_DICTIONARY`, `LINEAR_ALGEBRA_DICTIONARY`, |
79 | | - `STATISTICS_DICTIONARY`, `LOGIC_DICTIONARY`, `SETS_DICTIONARY`, |
80 | | - `INEQUALITIES_DICTIONARY`, `UNITS_DICTIONARY`, `OTHERS_DICTIONARY`, |
81 | | - `PHYSICS_DICTIONARY`, and the combined `LATEX_DICTIONARY`. |
82 | | - |
83 | | -- **Breaking: `ce.box()` renamed to `ce.expr()`**. The free function `box()` is |
84 | | - also renamed to `expr()`. The old `box()` method remains as a deprecated |
85 | | - wrapper. |
86 | | - |
87 | | -- **Breaking: `ce.latexDictionary` getter/setter removed**. Use |
88 | | - `new LatexSyntax({ dictionary: [...LATEX_DICTIONARY, ...customEntries] })` to |
89 | | - customize LaTeX dictionaries. |
90 | | - |
91 | | -- **Breaking: `static ComputeEngine.getLatexDictionary()` removed**. Import |
92 | | - dictionary constants directly from the `latex-syntax` sub-path or the main |
93 | | - package. |
94 | | - |
95 | | -- **Breaking: Deprecated type guard aliases removed**: `isBoxedExpression`, |
96 | | - `isBoxedNumber`, `isBoxedSymbol`, `isBoxedFunction`, `isBoxedString`, |
97 | | - `isBoxedTensor`. Use `isExpression`, `isNumber`, `isSymbol`, `isFunction`, |
98 | | - `isString`, `isTensor` instead. |
99 | | - |
100 | | -- **Breaking: LaTeX dictionaries decoupled from library definitions**. The |
101 | | - `latexDictionary` field on `LibraryDefinition` is removed. LaTeX dictionaries |
102 | | - are now owned entirely by the `latex-syntax` module. |
103 | | - |
104 | | -- **Compilation registry methods now `@internal`**: |
105 | | - `registerCompilationTarget()`, `getCompilationTarget()`, |
106 | | - `listCompilationTargets()`, `unregisterCompilationTarget()` are still |
107 | | - available but marked as internal API. Use the `compile()` free function with a |
108 | | - target instance or built-in name instead. |
109 | | - |
110 | | -- **New `Parser` type export**: The `Parser` type is now exported from the main |
111 | | - package, enabling typed custom `LatexDictionaryEntry` parse handlers. |
112 | | - |
113 | | -- **Dead code removal**: Removed unused files from `src/common/` (buffer, json5, |
114 | | - markdown, parser, result, sigil, styled-text, syntax-highlighter, terminal) |
115 | | - and `src/common/type/` (error-handler, resolve). |
116 | | - |
117 | | -- **Replaced `decimal.js` with custom `BigDecimal`**: Arbitrary-precision |
118 | | - arithmetic is now powered by a custom `BigDecimal` class (`src/big-decimal/`) |
119 | | - backed by native JavaScript `bigint`, replacing the `decimal.js` third-party |
120 | | - dependency. This brings smaller bundle size, no external dependencies for |
121 | | - numeric computation, and uses hardware-accelerated big-integer operations. The |
122 | | - `BigDecimal` representation is `significand × 10^exponent` where `significand` |
123 | | - is a `bigint` and `exponent` is a `number`. All transcendental functions (exp, |
124 | | - ln, sin, cos, atan2, gamma, etc.) are implemented using fixed-point `bigint` |
125 | | - arithmetic with configurable precision via `BigDecimal.precision`. |
126 | | - |
127 | | -- **Numeric serialization respects precision**: `.latex` and `.toString()` now |
128 | | - round arbitrary-precision numbers to `ce.precision` significant digits, |
129 | | - hiding noise digits from precision-bounded operations (division, |
130 | | - transcendentals). `.json` and `toJSON()` preserve the full unrounded value |
131 | | - for lossless round-tripping. Use `toMathJson({ fractionalDigits: 'auto' })` |
132 | | - for precision-rounded MathJSON output. |
133 | | - |
134 | | -- **Exact BigDecimal arithmetic**: `add()`, `sub()`, and `mul()` on `BigDecimal` |
135 | | - are now exact (no precision loss). Only `div()`, non-integer `pow()`, and |
136 | | - transcendental functions round to `BigDecimal.precision`. |
137 | | - |
138 | | -- **Precision-scaling Gamma and polygamma functions**: `bigGamma`, `bigGammaln`, |
139 | | - `bigDigamma`, `bigTrigamma`, `bigPolygamma`, and `bigZeta` (even-integer |
140 | | - special values) now scale with `BigDecimal.precision` instead of being capped |
141 | | - at ~16–50 correct digits. The fixed Lanczos/Spouge coefficient tables are |
142 | | - replaced with a Stirling asymptotic series using Bernoulli numbers computed at |
143 | | - runtime as exact bigint rationals. Integer Gamma values are now exact (returned |
144 | | - as factorials). At precision 500, Gamma(1/2) matches √π to all 500 digits. |
| 3 | +#### Breaking |
| 4 | + |
| 5 | +- `ce.box()`/`box()` renamed to `ce.expr()`/`expr()` (`ce.box()` remains as a |
| 6 | + deprecated wrapper). |
| 7 | +- Removed `ce.latexDictionary` getter/setter; configure dictionaries through |
| 8 | + `new LatexSyntax({ dictionary: [...] })`. |
| 9 | +- Removed `ComputeEngine.getLatexDictionary()`; import dictionary constants from |
| 10 | + package exports. |
| 11 | +- Removed deprecated type guard aliases: `isBoxedExpression`, `isBoxedNumber`, |
| 12 | + `isBoxedSymbol`, `isBoxedFunction`, `isBoxedString`, `isBoxedTensor` (use |
| 13 | + `isExpression`, `isNumber`, `isSymbol`, `isFunction`, `isString`, `isTensor`). |
| 14 | +- Removed `LibraryDefinition.latexDictionary`; LaTeX dictionaries now live in |
| 15 | + the `latex-syntax` module. |
| 16 | + |
| 17 | +#### Fixed |
| 18 | + |
| 19 | +- **#295** The `parse()` free function now accepts the form options object, so |
| 20 | + `parse("\\frac{10}{2}", { form: "raw" })` return `["Divide", "10", "2"]`. |
| 21 | +- Undeclared symbols followed by parenthesized numeric expressions are now |
| 22 | + interpreted as multiplication, not implicit function calls (for example, |
| 23 | + `q(2q)` -> `2q^2`). Function-call behavior remains for explicitly declared |
| 24 | + function symbols and non-numeric argument forms. |
| 25 | + |
| 26 | +#### Added |
| 27 | + |
| 28 | +- Modular package exports for smaller bundles: `@cortex-js/compute-engine/core`, |
| 29 | + `@cortex-js/compute-engine/compile`, `@cortex-js/compute-engine/latex-syntax`, |
| 30 | + `@cortex-js/compute-engine/numerics`, and `@cortex-js/compute-engine/interval` |
| 31 | + (with existing sub-paths still available, including `math-json`). |
| 32 | +- New standalone `LatexSyntax` API (class + `parse()`/`serialize()` helpers) for |
| 33 | + LaTeX <-> MathJSON without a `ComputeEngine` instance. |
| 34 | +- New `ILatexSyntax` interface exposed via `IComputeEngine.latexSyntax` to allow |
| 35 | + custom LaTeX parser/serializer implementations. |
| 36 | +- All 16 LaTeX domain dictionaries are now exported individually, plus the |
| 37 | + combined `LATEX_DICTIONARY`. |
| 38 | +- `Parser` type is now exported from the main package for typed custom |
| 39 | + `LatexDictionaryEntry` parse handlers. |
| 40 | + |
| 41 | +#### Changed |
| 42 | + |
| 43 | +- `ComputeEngine` now accepts an injectable `latexSyntax` dependency. |
| 44 | + - Full package imports still auto-create a LaTeX syntax instance. |
| 45 | + - Core-only imports do not bundle LaTeX support; `parse()`, `.latex`, and |
| 46 | + `toLatex()` require an injected `LatexSyntax`. |
| 47 | + - MathJSON serialization omits optional LaTeX metadata when no LaTeX syntax is |
| 48 | + present. |
| 49 | +- `decimal.js` has been replaced with a native `bigint`-backed `BigDecimal` |
| 50 | + implementation, reducing dependency surface and bundle size. |
| 51 | +- `BigDecimal` `add()`, `sub()`, and `mul()` are now exact; rounding is limited |
| 52 | + to operations that require it (`div()`, non-integer `pow()`, transcendentals). |
| 53 | +- Numeric string/LaTeX serialization now respects precision settings: |
| 54 | + `.latex`/`.toString()` round to `ce.precision`, while `.json`/`toJSON()` |
| 55 | + remain lossless. |
| 56 | +- High-precision special functions (`bigGamma`, `bigGammaln`, `bigDigamma`, |
| 57 | + `bigTrigamma`, `bigPolygamma`, `bigZeta`) now scale with |
| 58 | + `BigDecimal.precision`; integer Gamma values are exact. |
145 | 59 |
|
146 | 60 | ### 0.54.0 _2026-02-26_ |
147 | 61 |
|
|
0 commit comments