Ask Your Question
2

A function being an input

asked 2019-02-18 23:36:48 +0100

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)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2019-02-19 01:31:11 +0100

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)
edit flag offensive delete link more

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: 2019-02-18 23:36:48 +0100

Seen: 328 times

Last updated: Feb 19 '19