Understanding symbolic summation



On Fri, 22 Nov 2013, Avdeev V. M. wrote:
> #1
> a(x):=sum(w[i]*x[i],i,0,inf);
> diff(a(xx), xx[1]);
> kill(w,xx,layer_size);
> 
> #2
> declare(layer_size, constant);
> a(x):=sum(w[i]*x[i],i,0,layer_size);
> diff(a(xx), xx[1]);
> kill(w,xx,layer_size);
> 
> #3
> a(x):=sum(w[i]*x[i],i,0,2);
> diff(a(xx), xx[1]);
> kill(w,xx,layer_size);
> 
> Scripts #1 and #2 gives me 0 as a result of differentiating. But script #3 works fine and returns w[1];

(%i1) display2d:false$
(%i2) a(x):=sum(w[i]*x[i],i,0,2)$
(%i3) a(xx);
(%o3) w[2]*xx[2]+w[1]*xx[1]+w[0]*xx[0]

This expression contains xx[1]. You can differentiate it in xx[1] and get

(%i4) diff(a(xx), xx[1]);
(%o4) w[1]

(%i5) a(x):=sum(w[i]*x[i],i,0,layer_size)$
(%i6) a(xx);
(%o6) 'sum(w[i]*xx[i],i,0,layer_size)

This expression does not contain xx[1], only xx[i]. Therefore,

(%i7) diff(a(xx), xx[1]);
(%o7) 0

Andrey