Expressions that stay readable.
Write the calculation your users already understand. Variables, familiar operators, and a focused set of math functions.
See the grammar →Evaluate readable expressions with explicit grammar, stable errors, and configurable limits. Add private explanation, visual, or unit layers only when your product needs them.
Write the calculation your users already understand. Variables, familiar operators, and a focused set of math functions.
See the grammar →Every failure has a stable code and source span, so validation messages can be useful instead of mysterious.
Explore error codes →Overflow, non-finite values, malformed input, and resource limits are handled explicitly and consistently.
View the limits →MathPHP stays a small, open core. Private add-ons plug into the same contracts when your product needs to teach a calculation, present it beautifully, or keep measurements honest.
Turn an expression into a clear, ordered lesson: substitutions, operation rules, partial results, source spans, and translated messages.
Turn formulas and analysis into renderer-neutral data with accessible SVG fallbacks for charts, graphs, matrices, and calculus.
Evaluate quantities such as 2m * 6 + 200cm with compatible conversions, dimensions, and stable errors.
to conversionsKeep the evaluator behind your own form, API, or rule editor. MathPHP does the careful part.
$result = Math::evaluate('2 * (3 + 4)');Input becomes a small, immutable syntax tree. Operators and grouping are resolved before any value is calculated.
Names, function arity, domains, spans, and resource limits are checked before work can escape your boundary.
The result is a native integer or float. Optional packages can observe the same events and add explanations or visual models.