ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 18 Feb 2019 18:31:11 -0600A function being an inputhttp://ask.sagemath.org/question/45504/a-function-being-an-input/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)Mon, 18 Feb 2019 16:36:48 -0600http://ask.sagemath.org/question/45504/a-function-being-an-input/Answer by tmonteil for <p>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?</p>
<pre><code> var('y')
f = sage_eval(str(input("What is the function:" )), locals = {'y' == y})
integral(f,y,0,16)
</code></pre>
http://ask.sagemath.org/question/45504/a-function-being-an-input/?answer=45505#post-id-45505The 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)
Mon, 18 Feb 2019 18:31:11 -0600http://ask.sagemath.org/question/45504/a-function-being-an-input/?answer=45505#post-id-45505