0

I have a non-linear polynomial equation example: 2*x**2 - sin(x) + 1. how will I code to take this equation as a user input

i tried using eval() function but how will i describe the x

s= input("enter your equation here")

equation = eval(s)

  • *"how will I code to take this equation as a user input"* - that depends entirely on what you are going to do with it... i.e. what do you expect `eval(s)` to give? – Tomerikoo Mar 13 '23 at 13:29
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Mar 13 '23 at 13:30
  • Your expression is not a polynomial in the modern sense (the initial use in the 16th century was for just any grouped sum of multiple terms). Use sympy to convert the expression string into an expression instance and then lambdify to generate a python-numpy function. – Lutz Lehmann Mar 14 '23 at 08:36

0 Answers0