Math Expression Evaluator
Evaluate math expressions safely — supports arithmetic, trig, logarithms, parentheses, and constants.
Frequently Asked Questions
What operations does this evaluator support?
It supports addition (+), subtraction (-), multiplication (*), division (/), exponentiation (^), modulo (%), parentheses, and functions like sqrt, sin, cos, tan, log (base 10), ln (natural log), abs, ceil, floor, round, min, and max. Constants pi and e are also available.
Is eval() used internally?
No. This evaluator uses a safe, custom-built recursive descent parser. JavaScript's eval() is never called, making it safe to use with arbitrary input — there is no risk of code injection.
What is the order of operations?
The evaluator follows standard mathematical order: parentheses first, then functions, then exponentiation (right-associative), then multiplication/division/modulo, and finally addition/subtraction.
How do I use functions with multiple arguments?
Use comma-separated arguments inside parentheses: min(3, 7) returns 3, max(10, 20) returns 20. Single-argument functions like sqrt(16) or sin(pi/2) work with one value.
Are angles in degrees or radians?
Trigonometric functions (sin, cos, tan) use radians. To convert degrees to radians, multiply by pi/180. For example, sin(30 * pi / 180) calculates the sine of 30 degrees.