mathjs
Version:
Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with dif
47 lines (29 loc) • 1.07 kB
Markdown
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
resolve(expr, scope) replaces variable nodes with their scoped values
```js
resolve(expr, scope)
```
### Parameters
Parameter | Type | Description
--------- | ---- | -----------
`node` | Node | Node[] | The expression tree (or trees) to be simplified
`scope` | Object | Scope specifying variables to be resolved
### Returns
Type | Description
---- | -----------
Node | Node[] | Returns `node` with variables recursively substituted.
Type | Description
---- | -----------
ReferenceError | If there is a cyclic dependency among the variables in `scope`, resolution is impossible and a ReferenceError is thrown.
```js
math.resolve('x + y', {x:1, y:2}) // Node {1 + 2}
math.resolve(math.parse('x+y'), {x:1, y:2}) // Node {1 + 2}
math.simplify('x+y', {x:2, y:'x+x'}).toString() // "6"
```
[](simplify.md),
[](evaluate.md)