Function simplifyCore #
simplifyCore() performs single pass simplification suitable for applications requiring ultimate performance. To roughly summarize, it handles cases along the lines of simplifyConstant() but where knowledge of a single argument is sufficient to determine the value. In contrast, simplify() extends simplifyCore() with additional passes to provide deeper simplification (such as gathering like terms).
- Converts all function calls with operator equivalents to their operator forms.
- Removes operators or function calls that are guaranteed to have no effect (such as unary ‘+’).
- Removes double unary ‘-‘, ‘~’, and ‘not’
- Eliminates addition/subtraction of 0 and multiplication/division/powers by 1 or 0.
- Converts addition of a negation into subtraction.
- Eliminates logical operations with constant true or false leading arguments.
- Puts constants on the left of a product, if multiplication is considered commutative by the options (which is the default)
simplifyCore(expr) simplifyCore(expr, options)
||Node | string||The expression to be simplified|
||Object||Simplification options, as per simplify()|
|Node||Returns expression with basic simplifications applied|
Type | Description —- | ———–
const f = math.parse('2 * 1 * x ^ (1 - 0)') math.simplifyCore(f) // Node "2 * x" math.simplify('2 * 1 * x ^ (1 - 0)', [math.simplifyCore]) // Node "2 * x"