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
53 lines (34 loc) • 1.19 kB
Markdown
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
# Function simplifyConstant
simplifyConstant() takes a mathjs expression (either a Node representing
a parse tree or a string which it parses to produce a node), and replaces
any subexpression of it consisting entirely of constants with the computed
value of that subexpression.
## Syntax
```js
simplifyConstant(expr)
simplifyConstant(expr, options)
```
### Parameters
Parameter | Type | Description
--------- | ---- | -----------
`node` | Node | string | The expression to be simplified
`options` | Object | Simplification options, as per simplify()
### Returns
Type | Description
---- | -----------
Node | Returns expression with constant subexpressions evaluated
### Throws
Type | Description
---- | -----------
## Examples
```js
math.simplifyConstant('x + 4*3/6') // Node "x + 2"
math.simplifyConstant('z cos(0)') // Node "z 1"
math.simplifyConstant('(5.2 + 1.08)t', {exactFractions: false}) // Node "6.28 t"
```
## See also
[simplify](simplify.md),
[simplifyCore](simplifyCore.md),
[resolve](resolve.md),
[derivative](derivative.md)