MathGroup Archive 2004

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

Search the Archive

Re: Sum question and general comment

  • To: mathgroup at smc.vnet.net
  • Subject: [mg50673] Re: [mg50638] Sum question and general comment
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Wed, 15 Sep 2004 07:55:02 -0400 (EDT)
  • Reply-to: hanlonr at cox.net
  • Sender: owner-wri-mathgroup at wolfram.com

excludedSum[f_, 
      {i_Symbol, imin_Integer:1,imax_Integer}, 
      exclude:{_Integer..}] := 
    Tr[f /. ({i->#}& /@ 
            DeleteCases[Range[imin,imax], 
              _?(Or@@Thread[#==exclude]&) ])];

excludedDiagonalSum[f_, 
      {i_Symbol,imin_Integer:1,imax_Integer},
      {j_Symbol,jmin_Integer:1,jmax_Integer}] :=
    Sum[excludedSum[f, {j,jmin,jmax},{i}],{i,imin,imax}];

excludedSum[f[i],{i,5},{2,4}]

f[1] + f[3] + f[5]

excludedDiagonalSum[f[i,j],{i,3},{j,3}]

f[1, 2] + f[1, 3] + f[2, 1] + f[2, 3] + f[3, 1] + f[3, 2]

Tr[f /@ {1,2,3,5,7,8,21}]

f[1] + f[2] + f[3] + f[5] + f[7] + f[8] + f[21]


Bob Hanlon

> 
> From: Steve Gray <stevebg at adelphia.net>
To: mathgroup at smc.vnet.net
> Date: 2004/09/15 Wed AM 01:49:43 EDT
> To: mathgroup at smc.vnet.net
> Subject: [mg50673] [mg50638] Sum question and general comment
> 
> I don't want to overload the group with my questions, so I only post after
> not being able to find the answer in the Help or at the site. Part of the
> problem of course is that it isn't clear how to state the question so that
> I can look it up*. Anyway, the current question has to do with Sum and
> similar "indexed" operations:
> 
> I find no way to do, for example, 
> "Sum over i=1 to 100 except i!= 23 and 36", etc., or Sum over values 
belonging to a list, such as 
> "Sum over i (belonging to) {1,2,3,5,7,8,21}", etc., or
> "Sum ( i=1 to 10) Sum (0ver j=1 to 10 but j !=i)", etc. (this can be 
awkwardly done with j=1 to i-1
> and j=i+1 to 10)
> In some cases there can be workarounds using things like
> (1- KroneckerDelta[i,j]), etc., but these can get complicated and obscure. 
> I would have thought that Mathematica could do operations like these 
directly,
> but ??. Thank you for any information.
> 
> Steve Gray
> 
> * Someone who makes major progress on the problem of letting users 
communicate with a computer in
> ordinary, appropriate technical "people" language will have big success. 
Currently in almost all
> software one must ask using exactly the right terms. (I realize that 
Microsoft and others are trying
> to make progress here, but it's negligible so far in my opinion.) Part of the 
answer would be a
> greatly expanded index, compiled knowing what terms people are likely to 
use for their questions.
> 
> 


  • Prev by Date: Re: Sum question and general comment
  • Next by Date: Re: Sum question and general comment
  • Previous by thread: Re: Sum question and general comment
  • Next by thread: Re: Sum question and general comment