y = var('y')
f(y) = eval(input("What is the function:"))
integral(f(y),y,0,16)

I have been trying to develop a user based code in which they input a function using x, and y which is then read into an integral. I tried using eval, and sage_eval but they haven't worked.

1 Answers

1
Samuel Lelièvre On Best Solutions

Works for me:

sage: y = var('y')
sage: f(y) = eval(input("What is the function: "))
What is the function: sin(y)
sage: integral(f(y), y, 0, 16)
-cos(16) + 1

Suggestion: read about SageCell, interacts, widgets.