Ask Your Question

barrema's profile - activity

2023-10-27 22:05:51 +0200 marked best answer 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.

2023-09-19 13:55:04 +0200 received badge  Self-Learner (source)
2023-09-19 13:55:04 +0200 received badge  Teacher (source)
2023-09-19 04:04:27 +0200 received badge  Editor (source)
2023-09-19 04:04:27 +0200 edited answer Define truncated power series as two variable function?

As it's been awhile I thought I'd submit Max Alekseyev's comment as an answer so that this question is seen as complete.

2023-09-19 04:04:02 +0200 answered a question Define truncated power series as two variable function?

As it's been awhile I thought I'd submit Max Alekseyev's comment as an answer so that this question is seen as answered.

2023-08-29 21:22:34 +0200 commented question Define truncated power series as two variable function?

These are both marvelously simple solutions. The lambda functions even remains differentiable. If you post this as an an

2023-08-29 01:22:53 +0200 received badge  Student (source)
2023-08-29 01:17:37 +0200 asked a question Define truncated power series as two variable function?

Define truncated power series as two variable function? I'd like to be able to define a function of two variables that i