MathGroup Archive 2007

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

Search the Archive

Re: Symbolic Integration of Sums

  • To: mathgroup at smc.vnet.net
  • Subject: [mg79192] Re: Symbolic Integration of Sums
  • From: dimitris <dimmechan at yahoo.com>
  • Date: Fri, 20 Jul 2007 03:36:49 -0400 (EDT)
  • References: <f7n4pv$286$1@smc.vnet.net>

On 19     , 10:45, Peter <pjcros... at gmail.com> wrote:
> 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.

How about?

In[552]:=
f[n_, (w_)[i_], (m_)[i_]] := Sum[w[i]*m[i], {i, 1, n}]

Then for example

In[558]:=
f[10, w[e], m[e]]

Out[558]=
m[1]*w[1] + m[2]*w[2] + m[3]*w[3] + m[4]*w[4] + m[5]*w[5] + m[6]*w[6]
+ m[7]*w[7] + m[8]*w[8] + m[9]*w[9] + m[10]*w[10]

In[559]:=
(D[f[10, w[e], m[e]], w[#1]] & ) /@ Range[10]

Out[559]=
{m[1], m[2], m[3], m[4], m[5], m[6], m[7], m[8], m[9], m[10]}

Dimitris S. Anagnostou



  • Prev by Date: Re: strange bug?
  • Next by Date: Creating and Exporting layered PDFs? (in 5.2)
  • Previous by thread: Re: Symbolic Integration of Sums
  • Next by thread: Re: Symbolic Integration of Sums