JavaScript and Lua both have eval as well.
scrdest is right, however a raw eval will have access to all "basic" math operations, but not necessarily sin, cos, exp etc. So you'd need to test what range of expressions you're allowing and add to that as needed. It might require sticking some preset string of includes at the start of the string you send to eval.
Also, for variables, you'd need to let the eval know what the values of those variables actually are. Here's a rough guide (I only use eval in Javascript so YMMV):
if you eval "1+2" it will return "3", the value of that statement. However if you try and eval "x1+x2" you'll get an error, since eval doesn't know what x1 and x2 mean. Eval is running in it's own scope, so it only knows local variables.
So you'd need to either search and replace the variables (using a builtin string replace function for simplicity) with the real values, or declare them as variables inside the eval right before the statement. e.g. javascript would look like this then:
"var x1 = 1; var x2 = 2; return x1 + x2;" where "x1 + x2" was your original external equation. I'm assuming it's safer to put the "return" keyword here to unambiguously tell the system that you want the whole thing to return the value of "x1 + x2" since there are multiple statements now, and I don't know if it always returns the value of the final one.