symbolicjs 0.0.1
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/LICENSE +21 -0
- package/README.md +116 -0
- package/package.json +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 John Lott
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# symbolicjs
|
|
2
|
+
|
|
3
|
+
Computer algebra extensions for [MathJS](https://mathjs.org/), beginning with
|
|
4
|
+
first-class equations.
|
|
5
|
+
|
|
6
|
+
> Early development release. The initial package provides the equation node and
|
|
7
|
+
> parser boundary; solving is the next milestone.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
npm install symbolicjs mathjs
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
import {all, create} from 'mathjs';
|
|
16
|
+
import {importsymbolicjs} from 'symbolicjs';
|
|
17
|
+
|
|
18
|
+
const math = importsymbolicjs(create(all));
|
|
19
|
+
const equation = math.parseEquation('x + 1 =:= y / 2');
|
|
20
|
+
|
|
21
|
+
equation.type; // 'EqualityNode'
|
|
22
|
+
equation.lhs.toString(); // 'x + 1'
|
|
23
|
+
equation.rhs.toString(); // 'y / 2'
|
|
24
|
+
equation.toString(); // 'x + 1 =:= y / 2'
|
|
25
|
+
equation.toTex(); // MathJS LaTeX joined by '='
|
|
26
|
+
|
|
27
|
+
The lower-level factory array can be imported directly when an application
|
|
28
|
+
manages its own MathJS instance typing:
|
|
29
|
+
|
|
30
|
+
import {all, create} from 'mathjs';
|
|
31
|
+
import {symbolicjsFactories} from 'symbolicjs';
|
|
32
|
+
|
|
33
|
+
const math = create(all);
|
|
34
|
+
math.import([...symbolicjsFactories]);
|
|
35
|
+
|
|
36
|
+
## Equality syntax
|
|
37
|
+
|
|
38
|
+
symbolicjs uses **=:=** as its canonical equation operator. This keeps mathematical
|
|
39
|
+
equality distinct from MathJS assignment (**=**) and boolean comparison
|
|
40
|
+
(**==**).
|
|
41
|
+
|
|
42
|
+
MathJS documents extension through **math.import** and factory functions, but
|
|
43
|
+
it does not expose a supported API for adding an infix grammar token. For that
|
|
44
|
+
reason, symbolicjs imports **EqualityNode** and **parseEquation** into a MathJS
|
|
45
|
+
instance. **parseEquation** recognizes one top-level **=:=**, delegates each
|
|
46
|
+
side to that instance's original MathJS parser, and returns:
|
|
47
|
+
|
|
48
|
+
EqualityNode {
|
|
49
|
+
lhs: MathNode;
|
|
50
|
+
rhs: MathNode;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
The package does not monkey-patch or silently replace **math.parse**. Ordinary
|
|
54
|
+
MathJS parsing, including assignment parsing, remains unchanged.
|
|
55
|
+
Assignments and function assignments are rejected inside equation sides.
|
|
56
|
+
|
|
57
|
+
## Initial API
|
|
58
|
+
|
|
59
|
+
- **importsymbolicjs(math)** imports the symbolicjs factories and returns the same
|
|
60
|
+
instance with typed **EqualityNode** and **parseEquation** members.
|
|
61
|
+
- **symbolicjsFactories** is the factory array for direct **math.import**.
|
|
62
|
+
- **EqualityNode** is a MathJS node with **lhs** and **rhs** children.
|
|
63
|
+
- **splitEquation(expression)** validates and splits one top-level **=:=**.
|
|
64
|
+
- **isEqualityNode(value)** is the runtime type guard.
|
|
65
|
+
- **EQUALITY_OPERATOR** is the canonical **=:=** token.
|
|
66
|
+
|
|
67
|
+
**EqualityNode** supports MathJS traversal, transformation, cloning,
|
|
68
|
+
compilation, equality evaluation, string output, LaTeX output, HTML output, and
|
|
69
|
+
its own JSON codec.
|
|
70
|
+
|
|
71
|
+
## Roadmap
|
|
72
|
+
|
|
73
|
+
1. First-class equality node, parser boundary, formatting, and serialization.
|
|
74
|
+
2. Symbol discovery, immutable substitution, conservative simplification,
|
|
75
|
+
domain conditions, and candidate verification.
|
|
76
|
+
3. Single-occurrence isolation for arithmetic, powers, roots, exponential,
|
|
77
|
+
logarithm, and absolute value.
|
|
78
|
+
4. Target-relative rational and polynomial normalization, with symbolic linear
|
|
79
|
+
and quadratic solving.
|
|
80
|
+
5. Typed solve cases for finite roots, identities, contradictions, conditions,
|
|
81
|
+
partial results, unsupported families, and complexity limits.
|
|
82
|
+
6. Numeric cubic fallback when all coefficients are numeric.
|
|
83
|
+
|
|
84
|
+
The initial solver domain will be real scalar equations. Periodic
|
|
85
|
+
trigonometric families, simultaneous systems, matrices, units, and a general
|
|
86
|
+
equivalence prover are not part of the first solver release.
|
|
87
|
+
|
|
88
|
+
## Development
|
|
89
|
+
|
|
90
|
+
Requires Node 22 or newer.
|
|
91
|
+
|
|
92
|
+
npm install
|
|
93
|
+
npm run check
|
|
94
|
+
npm run pack:dry
|
|
95
|
+
|
|
96
|
+
The package is tested independently of any consuming application. MathJS is a
|
|
97
|
+
peer dependency and is pinned to 15.2.0 in development so the node contract is
|
|
98
|
+
tested against a known implementation.
|
|
99
|
+
|
|
100
|
+
## Publishing
|
|
101
|
+
|
|
102
|
+
The repository includes a tag-triggered GitHub Actions publishing workflow.
|
|
103
|
+
After the package has been created on npm, configure npm trusted publishing for:
|
|
104
|
+
|
|
105
|
+
- GitHub owner: **Wu-Li**
|
|
106
|
+
- Repository: **symbolicjs**
|
|
107
|
+
- Workflow: **publish.yml**
|
|
108
|
+
- Allowed action: **npm publish**
|
|
109
|
+
|
|
110
|
+
Then create a version tag such as **v0.0.2**. npm trusted publishing requires no
|
|
111
|
+
long-lived publish token and automatically records provenance for a public
|
|
112
|
+
repository and package.
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
[MIT](LICENSE)
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "symbolicjs",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Computer algebra extensions for MathJS, beginning with first-class equations.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "John Lott",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/Wu-Li/symbolicjs.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/Wu-Li/symbolicjs/issues"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/Wu-Li/symbolicjs#readme",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"algebra",
|
|
18
|
+
"cas",
|
|
19
|
+
"equation",
|
|
20
|
+
"mathjs",
|
|
21
|
+
"symbolic-math"
|
|
22
|
+
],
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=22"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"main": "./dist/index.js",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"import": "./dist/index.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsc -p tsconfig.build.json",
|
|
39
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
40
|
+
"test": "vitest run",
|
|
41
|
+
"test:watch": "vitest",
|
|
42
|
+
"check": "npm run typecheck && npm test && npm run build",
|
|
43
|
+
"pack:dry": "npm pack --dry-run"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"mathjs": ">=15.2.0 <16"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"mathjs": "15.2.0",
|
|
50
|
+
"typescript": "7.0.2",
|
|
51
|
+
"vitest": "4.1.11"
|
|
52
|
+
},
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public"
|
|
55
|
+
}
|
|
56
|
+
}
|