I'm writing a program that involves calculating the maximum of a user defined function, however if the user enters a function in terms of a variable such as x, i.e.
input = x**2 + 2*x + 1
I (fairly expectedly) get an error as x is not defined.
Does anyone know of an effective way to allow a user to input a function in terms of a single variable such as x?