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.Mon, 28 Aug 2023 23:51:26 +0200Define truncated power series as two variable function?https://ask.sagemath.org/question/72981/define-truncated-power-series-as-two-variable-function/I'd like to be able to define a function of two variables that involves a sum. My attempt is
x,n,k=var('x n k')
term(k,x) = (-1)^k*1/(2*k+1)*cos((2*k+1)*pi*x/2)
f(m,x) = 4/pi*sum(term(k,x),k,0,m)
show(f(2,x))
When I evaluate the function at any value of m, as above, sagemath doesn't expand the sum, or even evaluate to a number if I enter a value of x. Somehow the sum becomes atomic. Is there a way to make this sort of definition work?
My students naturally constructed truncated power series this way to experiment with in Desmos, and I'd like to bridge that gap into sagemath without Big-O notation or power series rings or anything like that.barremaMon, 28 Aug 2023 23:51:26 +0200https://ask.sagemath.org/question/72981/