A user is allowed to enter any mathematical equation they like (with one variable):
x + 5
1 - x/2
(x/3) * (56/13)
Depends...
What is the complexity it will accept? Because for common mathematical equations (like the ones you posted), I do not see too much problem in writing a parser. The main problematic question would be round the numbers and place correct parenthesis.
But if the equations are going to accept "advanced" inputs, like {[()]}, or X², X³, or getting further, diferential calculus and college maths, so things can go crazy.
If the complexity reach symbolic handling, try read and search something about CAS (Calculate Algebra Systems).
Of course, I extremely recommend you to make your own system for inputs, validate against it, and evangelize users to tie inputs to it. Nothing too complex, but enough to make you (and others) comfortable and safe to reach what you need.