Problem with a derivative of order k in a summation in k

28 views
Skip to first unread message

Bruno

unread,
May 15, 2014, 9:03:04 AM5/15/14
to sage-s...@googlegroups.com
Hi,
I'm trying to put a derivative of order k in a summation in k, like the code below

var('t k')

a=0 
u=6/10
n=1 + floor(u)

s=cos(3*t)

somat=sum( (((t-a)**k)/factorial(k))*((derivative(s,t,k)).limit(t=1)) ,k,0,3) 

show(somat)

Sage gives me a zero and I know that's not the right answer.
I don't know what I did wrong, can anyone give me a clue?

Thanks.

Nils Bruin

unread,
May 15, 2014, 12:09:50 PM5/15/14
to sage-s...@googlegroups.com
On Thursday, May 15, 2014 6:03:04 AM UTC-7, Bruno wrote:

somat=sum( (((t-a)**k)/factorial(k))*((derivative(s,t,k)).limit(t=1)) ,k,0,3) 

This is unfortunately rather subtle. The problem is that your notation derivative(s,t,k) clashes with the also accepted notation for the double derivative of s with respect to t and then to k, so it's not possible in sage presently to specify the k-th derivative for a symbolic k. So you need to not write that. Instead, you can use a python iterator to write out the sum completely, instead of trying to construct a symbolic sum. The notation is very close, but the meaning is completely different:

somat=sum( (((t-a)**k)/factorial(k))*((derivative(s,t,k)).limit(t=1)) for k in [0..3])

In this expression, k is never a symbolic variable (so you wouldn't need the var('k') declaration). It's a python variable, taking the values 0,1,2,3 sequentially.

Bruno

unread,
May 16, 2014, 8:34:18 PM5/16/14
to sage-s...@googlegroups.com
Thanks for your help.


--
You received this message because you are subscribed to a topic in the Google Groups "sage-support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sage-support/DOQGWS1tgTg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sage-support...@googlegroups.com.
To post to this group, send email to sage-s...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages