ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 19 Feb 2019 01:31:11 +0100A function being an inputhttps://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 23:36:48 +0100https://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>
https://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)
Tue, 19 Feb 2019 01:31:11 +0100https://ask.sagemath.org/question/45504/a-function-being-an-input/?answer=45505#post-id-45505