Re: Differentiating sums
- To: mathgroup at smc.vnet.net
- Subject: [mg63815] Re: [mg63770] Differentiating sums
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Sun, 15 Jan 2006 05:43:28 -0500 (EST)
- Reply-to: hanlonr at cox.net
- Sender: owner-wri-mathgroup at wolfram.com
Clear[x]; x/:D[Sum[expr_,{i_Symbol,imin_:1,imax_}],x[k_]]:= D[expr/.{i:>k},x[k]]; prod=Sum[x[i] y[i],{i,n}]; D[prod,x[j]] y[j] Bob Hanlon > > From: "Zvi Tarem" <zvi.tarem at cern.ch> To: mathgroup at smc.vnet.net > Subject: [mg63815] [mg63770] Differentiating sums > > How can I use Mathematica to represent sums in a way that can be > differentiated correctly? Here is a trivial example: > > If x and y are both vectors of length N then the derivative of the product > of the vectors with respect to any element x[i] is simply y[i]. I cannot > make Mathematica 'understand' the concept of indexing. Here is what I tried: > > prod = Sum[x[i] y[i], {i, N}] > D[prod, x[j]] > I get 0 > > D[prod, x[i]] > I get Sum[y[i],{i,N}] which is wrong. > > The same for subscript notation. > > Then I tried Array[] and Part[], but they require constants as the limit and > selectors. > > Can anyone help? > > >