Skip to content

Commit 5326afe

Browse files
committed
doc
1 parent 7024d9f commit 5326afe

3 files changed

Lines changed: 4210 additions & 1649 deletions

File tree

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ $ npm install --save @cortex-js/compute-engine
2929
No setup required:
3030

3131
```js
32-
import { parse, simplify, evaluate, N, assign } from "@cortex-js/compute-engine";
32+
import { simplify, evaluate, N, assign } from "@cortex-js/compute-engine";
3333

3434
simplify("x + x + 1").print();
3535
// ➔ 2x + 1
@@ -107,27 +107,30 @@ if (isBoxedFunction(expr)) {
107107
```js
108108
import { parse, simplify, expand } from "@cortex-js/compute-engine";
109109

110-
111110
// Simplify expressions
112111
simplify("x + x").print();
113112
// ➔ 2x
114113

115-
// Expand expressions (free function)
116-
const expr = parse("(x + 1)^2");
117-
expand(expr).print();
114+
// Expand from LaTeX or BoxedExpression
115+
expand("(x + 1)^2").print();
118116
// ➔ x^2 + 2x + 1
119117

120118
// Substitute values
121-
const expr2 = parse("x^2 + 2x + 1");
122-
expr2.subs({ x: 3 }).evaluate().print();
119+
const expr = parse("x^2 + 2x + 1");
120+
expr.subs({ x: 3 }).evaluate().print();
123121
// ➔ 16
124122
```
125123

126124
### Solving Equations
127125

128126
```js
127+
import { solve, parse } from "@cortex-js/compute-engine";
128+
129+
// Solve from LaTeX
130+
solve("x^2 - 5x + 6 = 0", "x");
131+
// ➔ [2, 3]
129132

130-
// Solve linear system
133+
// Solve a linear system
131134
const system = parse("\\begin{cases}x+y=5\\\\x-y=1\\end{cases}");
132135
const solution = system.solve(["x", "y"]);
133136

docs/README.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,28 @@ read the repository [`README.md`](../README.md).
1313
| Goal | Recommended doc |
1414
| --- | --- |
1515
| Learn package usage quickly | [`../README.md`](../README.md) |
16-
| Use parse-and-transform helper methods | This file (Workflow Helpers section) |
16+
| Use free functions for common operations | This file (Free Functions section) |
1717
| Understand simplification behavior snapshots | [`SIMPLIFY.md`](./SIMPLIFY.md), [`SIMPLIFICATIONS.md`](./SIMPLIFICATIONS.md) |
1818
| Review playground sample outcomes | [`PLAYGROUND.md`](./PLAYGROUND.md) |
1919
| Review internal architecture boundaries | [`architecture/README.md`](./architecture/README.md) |
2020

21-
## Workflow Helpers
21+
## Free Functions
2222

23-
High-level workflow entrypoints:
23+
Top-level free functions for common operations — no `ComputeEngine` setup required:
2424

25-
- `ce.parseSimplify(latex, options?)`
26-
- `ce.parseEvaluate(latex, options?)`
27-
- `ce.parseNumeric(latex, options?)`
25+
- `parse(latex)` — parse a LaTeX string into a `BoxedExpression`
26+
- `simplify(latex | expr)` — simplify a LaTeX string or expression
27+
- `evaluate(latex | expr)` — evaluate a LaTeX string or expression
28+
- `N(latex | expr)` — compute a numeric approximation
29+
- `expand(latex | expr)` — expand products and powers (distributive law)
30+
- `expandAll(latex | expr)` — recursively expand all sub-expressions
31+
- `factor(latex | expr)` — factor an expression as a product
32+
- `solve(latex | expr, vars)` — solve an equation or system for the given variables
33+
- `compile(latex | expr, options?)` — compile an expression to JavaScript (or another target)
34+
- `assign(id, value)` / `assign({...})` — assign values in the shared engine
2835

29-
Policy presets:
30-
31-
- Parse policy: `parseMode: 'strict' | 'permissive'`
32-
- Evaluation policy: `evaluateMode: 'exact' | 'numeric'` (`parseEvaluate`)
33-
- Simplification policy: `simplifyMode: 'default' | 'trigonometric'` (`parseSimplify`)
34-
35-
Option precedence (explicit low-level options win):
36-
37-
- `parse.strict` overrides `parseMode`
38-
- `evaluate.numericApproximation` overrides `evaluateMode`
39-
- `simplify.strategy` overrides `simplifyMode`
36+
These use a shared `ComputeEngine` instance created on first call.
37+
Use `getDefaultEngine()` to configure it (precision, angular unit, etc.).
4038

4139
## Extension Contracts
4240

0 commit comments

Comments
 (0)