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 #

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 #

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, simplifyCore, resolve, derivative

Fork me on GitHub