Consider the following:

var("p, Np, w")
Vsp = function("Vsp",p)
VSm(m) = sum(Vsp(p=p)*exp(I*w*p*m),p,1,Np-1)
def KS(Sm): return sum(Sm*exp(-I*w*p*m),m,0,Np-1)
KS(VSm(m))

--> sum(sum(Vsp(I)*e^(-I*m*p*w - m*w), I, 1, Np - 1), m, 0, Np - 1)

This is incorrect.  Sage has replaced the dummy sum variable "p" with "I", 
which conflicts with the imaginary number "I".  This can be verified by 
using "j" instead of "I":

var("p, Np, w, j")
Vsp = function("Vsp",p)
VSm(m) = sum(Vsp(p=p)*exp(j*w*p*m),p,1,Np-1)
def KS(Sm): return sum(Sm*exp(-j*w*p*m),m,0,Np-1)
KS(VSm(m))

--> sum(sum(Vsp(I)*e^(-j*m*p*w + I*j*m*w), I, 1, Np - 1), m, 0, Np - 1)

Note incorrect term "-m*w" in previous expression has become "I*j*m*w".

A workaround is to use an unused variable in the original sum, so that Sage 
doesn't replace it:

var("p, Np, w, q")
Vsp = function("Vsp",p)
VSm(m) = sum(Vsp(p=q)*exp(I*w*q*m),q,1,Np-1)
def KS(Sm): return sum(Sm*exp(-I*w*p*m),m,0,Np-1)
KS(VSm(m))

--> sum(sum(Vsp(q)*e^(-I*m*p*w + I*m*q*w), q, 1, Np - 1), m, 0, Np - 1)

which is the desired result.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to