Evaluates a mathematical expression and returns the result