MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Symbolic Integration of Sums

  • To: mathgroup at smc.vnet.net
  • Subject: [mg79190] Re: Symbolic Integration of Sums
  • From: Peter Pein <petsie at dordos.net>
  • Date: Fri, 20 Jul 2007 03:35:45 -0400 (EDT)
  • References: <f7n4pv$286$1@smc.vnet.net>

Peter schrieb:
> I am having trouble figuring out how to Mathematica to recognize sums when I
> take derivates.
> 
> Here is a very simple example, define
> 
> portM = Sum[w[i] m[i], {i, 1, n}]
> 
> Then, if I try to take the derivative of portM wrt say w[1] I get 0
> instead of m[1].
> 
> D[portM, w[1]] --> returns 0
> 
> If I spell the sum out explicitly using say for n=10:
> 
> portM = Sum[w[i] m[i], {i, 1, 10}]
> 
> I get the correct answer but this is often messy with the real
> problems I am working with and it also removes the ability to work
> with the length of sum in the other parts of the analysis I am doing.
> 
> Is using Sum in this way simply a level of abstraction more than Mathematica
> can do or am I asking it the wrong question?
> 
> Many thanks.
> 
> 

Hi Peter,

it is usually not a good idea to change system-functions.
Therefore I can not guarantee, that the following is 1.) correct and 2.)
free of side-effects:

In[1]:=
Unprotect[D];
D[HoldPattern[Sum[expr_, {i_, i0_, i1_}]], (m_)[j_]] :=
   If[FreeQ[expr, _m], 0,
    Simplify[Piecewise[
      {{D[expr, m[i]]/. i->j, IntegerQ[j - i0] &&  i0<=jy= i1}}]]];
Protect[D];
In[4]:=
portM = Sum[w[i]*m[i], {i, 1, n}];
In[5]:=
Assuming[n >= 1, D[portM, m[1]]]
Out[5]=
w[1]
In[6]:=
Assuming[n >= 100, D[portM, m[5]]]
Out[6]=
w[5]
In[7]:=
Assuming[n >= 100, D[portM, m[Pi]]]
Out[7]=
0
In[8]:=
Assuming[n >= 100, D[portM /. w -> (Sin[Pi*m[#1]] & ), m[2]]]
Out[8]=
Pi*Cos[Pi*m[2]]*m[2] + Sin[Pi*m[2]]

again: be catious with such stuff!

Peter


  • Prev by Date: Re: strange bug?
  • Next by Date: Re: Re: Coding an inverse permutation
  • Previous by thread: Re: Symbolic Integration of Sums
  • Next by thread: Property of TransformationFunction