OpenersNotesSection(Spacer1)Details

OpenersPrimaryExamplesSection(Spacer1)Examples  (7)

OpenersExampleSection0(Spacer1)Basic Examples  (7)

Interpret mathematical formulas:

Interpreter["MathFormula"]["x + 3y >= -2"]

Interpreter["MathFormula"]["sin(a)+1 = 1.5"]

The resulting formula evaluates, which may lead to a Boolean result:

Interpreter["MathFormula"]["e^2 > 4"]

Interpreter["MathFormula"]["x^2 > 4"]

Restrict to a list of choices:

Interpreter[Restricted["MathFormula",{{True, False}}]]["log e == 1"]

Interpreter[Restricted["MathFormula",{{True, False}}]]["log x == 1"]

By default, all symbols are allowed. Restrict to a list of allowed symbols:

Interpreter[Restricted["MathFormula",{Greater}]]["x>2"]

Interpreter[Restricted["MathFormula",{Greater}]]["log e>2"]

By default, new symbols are created in (RefLink[$Context, paclet:ref/$Context]), but a custom context can be specified:

Interpreter[Restricted["MathFormula",All,Automatic,Automatic]]["x = y + 2"]
Context[y]

Interpreter[Restricted["MathFormula",All,Automatic,"mycontext`"]]["h = k^3"]
Context[k]

Specify contexts for the allowed and output symbols:

mycontext`b = 10;
Interpreter[Restricted["MathFormula",Automatic,{"mycontext`","System`"},"mycontext`"]]["a < b+c"]
Context[c]

Prevent the creation of any new symbol:

Interpreter[Restricted["MathFormula",Automatic,Automatic,None]]["cos(pi) = -1"]

Interpreter[Restricted["MathFormula",Automatic,Automatic,None]]["cos(z) = -1"]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Interpreter, paclet:ref/Interpreter])  ▪  (RefLink[SemanticImport, paclet:ref/SemanticImport])  ▪  (RefLink[Restricted, paclet:ref/Restricted])  ▪  (RefLink[Failure, paclet:ref/Failure])  ▪  (RefLink[Equal, paclet:ref/Equal])  ▪  (RefLink[Greater, paclet:ref/Greater])  ▪  (RefLink[GreaterEqual, paclet:ref/GreaterEqual])  ▪  (RefLink[Less, paclet:ref/Less])  ▪  (RefLink[LessEqual, paclet:ref/LessEqual])}, {Related Interpreter Types:  (RefLink[HeldMathFormula, paclet:ref/interpreter/HeldMathFormula])  ▪  (RefLink[InactiveMathFormula, paclet:ref/interpreter/InactiveMathFormula])  ▪  (RefLink[MathExpression, paclet:ref/interpreter/MathExpression])  ▪  (RefLink[Expression, paclet:ref/interpreter/Expression])  ▪  (RefLink[WolframLanguageSymbol, paclet:ref/interpreter/WolframLanguageSymbol])  ▪  (RefLink[HeldMathExpression, paclet:ref/interpreter/HeldMathExpression])  ▪  (RefLink[InactiveMathExpression, paclet:ref/interpreter/InactiveMathExpression])  ▪  (RefLink[HeldExpression, paclet:ref/interpreter/HeldExpression])  ▪  (RefLink[InactiveExpression, paclet:ref/interpreter/InactiveExpression])  ▪  (RefLink[SemanticExpression, paclet:ref/interpreter/SemanticExpression])  ▪  (RefLink[HeldSemanticExpression, paclet:ref/interpreter/HeldSemanticExpression])  ▪  (RefLink[InactiveSemanticExpression, paclet:ref/interpreter/InactiveSemanticExpression])  ▪  (RefLink[ComputedWolframLanguageSymbol, paclet:ref/interpreter/ComputedWolframLanguageSymbol])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Setting Up Input Interpreters, paclet:guide/InterpretingStrings])}})}})