+ 1
How to input a function ?
I want input a function. Example: >> Enter f (x): (x**2) + 1 >> enter interval separeted by comma: 0,1 >> Insert the number of n: 10 #This code will calculate an integral from 0 to 1 of x^2 + 1, separating this interval in 10 equal parts, using the Simpsons method. But I don't know how to input a function an use it inside my code. Could someone help me ? Thanks for your attention.
1 Answer
0
use built-in eval() and exec() function refer py doc for more info