UNPKG

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
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. --> # Function resolve resolve(expr, scope) replaces variable nodes with their scoped values ## Syntax ```js resolve(expr, scope) ``` ### Parameters Parameter | Type | Description --------- | ---- | ----------- `node` | Node &#124; Node[] | The expression tree (or trees) to be simplified `scope` | Object | Scope specifying variables to be resolved ### Returns Type | Description ---- | ----------- Node &#124; Node[] | Returns `node` with variables recursively substituted. ### Throws Type | Description ---- | ----------- ReferenceError | If there is a cyclic dependency among the variables in `scope`, resolution is impossible and a ReferenceError is thrown. ## Examples ```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" ``` ## See also [simplify](simplify.md), [evaluate](evaluate.md)