id summary reporter owner description type status priority milestone component resolution keywords cc merged author reviewer upstream work_issues branch commit dependencies stopgaps
10246 Can't get symbol from callable function x |--> x kcrisman burcin "From [http://ask.sagemath.org/question/198/plotting-x-free-variable-error this] ask.sagemath question:
{{{
I was plotting sin(x)/x and also wanted a seperate plot of sin(x) and x so I could visualize those components as well. However I get an error when plotting x saying ""free variable x -> x"". If I add a coefficient to h(x) such as h(x) = 1.0001*x then it works fine.
This is the code I am using:
f(x) = sin(x)/x
g(x) = sin(x)
h(x) = x
fig1 = plot(f,-10,10,rgbcolor='green')
fig2 = plot(g,-10,10,rgbcolor='purple')
fig3 = plot(h,-10,10,rgbcolor='red')
figure = fig1 + fig2 + fig3
show(figure,xmin=-10,xmax=10,ymin=-10,ymax=10,figsize=[8,8],fontsize=20)
}}}
The underlying problem is
{{{
The exception arises in `sage.symbolic.expression_conversions.FastFloatConverter.symbol`:
try:
return self.ff.fast_float_constant(float(ex))
except TypeError:
raise ValueError, ""free variable: %s"" % repr(ex)
so that it assumes if a callable expression doesn't have the variable, it must be a constant. However, it before this asks for `if name in vars` and `if name in svars`, but here the `name` is `'x |--> x'`.
So what we need to do is fix it so that if the operator is `None` in the previous traceback in your error message, we check for this case explicitly, where the name isn't just one of the variables.
}}}
----
Apply attachment:trac_10246-callable-x.patch" defect closed critical sage-4.7 symbolics fixed plot, beginner jason sage-4.7.alpha4 Karl-Dieter Crisman Mike Hansen N/A