packages/solver/lib/simplifyExpression/simplify.js
function simplify(node, debug=false) {
  if(checks.hasUnsupportedNodes(node)) {
    return node;
  }

  const steps = stepThrough(node, debug);
  let simplifiedNode;
  if (steps.length > 0) {
    simplifiedNode = steps.pop().newNode;
  }
  else {
    // removing parens isn't counted as a step, so try it here
    simplifiedNode = removeUnnecessaryParens(flattenOperands(node), true);
  }
  // unflatten the node.
  return unflatten(simplifiedNode);
}
function simplify(node, debug=false) {
  if(checks.hasUnsupportedNodes(node)) {
    return node;
  }

  const steps = stepThrough(node, debug);
  let simplifiedNode;
  if (steps.length > 0) {
    simplifiedNode = steps.pop().newNode;
  }
  else {
    // removing parens isn't counted as a step, so try it here
    simplifiedNode = removeUnnecessaryParens(flattenOperands(node), true);
  }
  // unflatten the node.
  return unflatten(simplifiedNode);
}
function simplify ( node , debug = false ) { if ( checks . hasUnsupportedNodes ( node ) ) { return node ; } const steps = stepThrough ( node , debug ) ; let simplifiedNode ; if ( steps . length > 0 ) { simplifiedNode = steps . pop ( ) . newNode ; } else { // removing parens isn't counted as a step, so try it here simplifiedNode = removeUnnecessaryParens ( flattenOperands ( node ) , true ) ; } // unflatten the node. return unflatten ( simplifiedNode ) ; }
Given a mathjs expression node, steps through simplifying the expression. Returns the simplified expression node.
Given a mathjs expression node steps through simplifying the expression . Returns the simplified expression node .