parse

parse(expr)

parse(expr, options)

parse([expr1, expr2, expr3, ...])

parse([expr1, expr2, expr3, ...], options)

Try it yourself:

See also:

parse(): turn expression text into a calculation

parse(text) reads mathematical text and produces an expression that can be evaluated or transformed. It is the bridge between calculator input and structured mathematics.

Example

Parsing 2 * (x + 1) preserves its operators and grouping. It is safer than trying to manipulate a formula with ordinary text replacement.

Workflow

Use evaluate() to calculate a parsed expression, simplify() to transform it, and numeric() for an approximation. parser() supports a reusable evaluation context.

Caveat

Treat untrusted expression text carefully. Validate expected variables and syntax before evaluating it in a wider application.

Try Parse in Calcul.io

Start with one of the editable examples above, then replace its arguments with your own values. Keeping the function on a separate calculator line makes the input and result easy to compare. For a longer workflow, assign the result to a variable or reference that line in the next expression.

Check the shown signature before adding optional arguments, and use the related-function links to compare operations with similar purposes.

All functions