ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 24 Apr 2012 09:16:55 -0500I want to plot power series with symbolic functionshttp://ask.sagemath.org/question/8922/i-want-to-plot-power-series-with-symbolic-functions/See [this worksheet on sagenb.org](http://www.sagenb.org/home/pub/4482/).
var('x')
f = sin
def P(n,x):
return sum([(-1)^k*x^(2*k+1)/factorial(2*k+1) for k in range(n)])
sinplot = plot(f(x),(x,-2*pi,2*pi),color='red')
@interact
def _(n=(1..10)):
seriesplot = plot(P(n,x),(x,-2*pi,2*pi),color='blue')
html('$P(%s,x) = %s$'%(latex(n),latex(P(n,x))))
show(sinplot+seriesplot,ymin=-4,ymax=4)
Notice that they have to define a *Python* function in order for this to work. I could not get this to work with a Sage callable function like `P(n,x) = sum([...])` for the life of me. I tried lambdas, everything.
Now, likely either
- I've already answered this question somewhere else on the Internet, or
- It's not possible.
But I'd like confirmation of this. It's really annoying that one has to use a Python function to do this.kcrismanTue, 24 Apr 2012 09:16:55 -0500http://ask.sagemath.org/question/8922/