Ask Your Question
2

A function being an input

asked 6 years ago

EnlightenedFunk gravatar image

I have the following code and I am trying to get an output, and I keep getting an error y is not defined. Could you please help?

 var('y')
 f = sage_eval(str(input("What is the function:" )), locals = {'y' == y})
 integral(f,y,0,16)
Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 6 years ago

tmonteil gravatar image

The parameter locals should be a dictionary not the set {False}:

sage: var('y')
y
sage: f = sage_eval(str(input("What is the function:" )), locals = {'y': y})
What is the function:cos(y)
sage: integral(f,y,0,16)
sin(16)
Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 6 years ago

Seen: 354 times

Last updated: Feb 19 '19