Can Mathematica Count?

Discussion in 'Physics & Math' started by prometheus, Jan 22, 2009.

  1. prometheus viva voce! Registered Senior Member

    Messages:
    2,045
    I use mathematica a lot for my work and I recently came across a curious property of the sum command.

    Suppose you want to calculate \(\sum_{x=1}^{36} x\) which you may or may not know is the beast number. In mathematica you would type
    Code:
    Sum[x, {x, 1, 36}]
    and you get the answer 666. Lovely.

    If you add a redundant sum, ie, a sum over an index that is not summed \(\sum_{y=1}^{36}\sum_{x=1}^{36} x\) then you the answer should not change - the redundant sum is not doing anything right? However, if you type the following into mathematica;
    Code:
    Sum[x, {x, 1, 36}, {y, 1, 36}]
    then the answer you get is 23976! A way to see why this is is to type
    Code:
    Sum[x, {y, 1, 36}]
    and you get the answer 36x. What the "redundant" sum is doing is taking the 1 and summing it 36 times and the treating it as a multiplicative factor.

    I wonder if there is any good reason why mathematica should do this? I can't see what it is if there is one.
     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. John Connellan Valued Senior Member

    Messages:
    3,636
    Probably does not like redundant variables. Maybe it presumes you have made a mistake typing the variable name and sums whatever you have defined anyway!

    Doesn't seem like a very reliable program either way
     
  4. Google AdSense Guest Advertisement



    to hide all adverts.
  5. przyk squishy Valued Senior Member

    Messages:
    3,203
    Yes it is. Stated differently, what's

    \(\sum_{k=1}^{36} a_{k}\)​

    with \(a_{k} = 1 \; \forall k\) ?
     
  6. Google AdSense Guest Advertisement



    to hide all adverts.
  7. AlphaNumeric Fully ionized Registered Senior Member

    Messages:
    6,702
    Is not the \(\sum_{y=1}^{36}x\) equivalent to doing x+....+x? I'd expect it to end up with 36 times the answer. Am I missing something?
     
  8. Tom2 Registered Senior Member

    Messages:
    726
    No, you're not missing anything. The correct answer is indeed 23,976.

    promethus, the sum is found as follows.

    \(\sum_{y=1}^{36}\sum_{x=1}^{36} x=\sum_{y=1}^{36} 666\)

    Now look at what happens on the right side. When y=1, what is the value of the summand? Answer: 666. When y=2, what is the value of the summand? Answer: Again, 666. Keep doing this and you end up adding 36 copies of the number 666. So,

    \(\sum_{y=1}^{36}\sum_{x=1}^{36} x=(36)(666)=23,976\)
     
  9. prometheus viva voce! Registered Senior Member

    Messages:
    2,045
    Fair enough, and thanks for the help all. I'm used to writing things using the Einstein summation convention so the dot product of two vectors in Euclidean space is written \(\vec{a}.\vec{b} = \sum_{i,j} \delta^{ij} a_i b_j = \delta^{ij} a_i b_j\). That's nice neat notation because you don't have a ton off summation signs everywhere.

    The story behind this is that I had this expression: \(n_a \left(\frac{\partial^2 x^a}{\partial \xi^i \partial \xi^j} + \Gamma^a_{b c} \frac{\partial x^b}{\partial \xi^i } \frac{\partial x^c}{\partial \xi^j} \right)\) that I wanted to use mathematica to work out. Clearly in the first term the sum is over a only whereas the second term has sums over a,b and c. I'm fairly sloppy about programming so I just put a sum over all three terms around the lot and then wondered why it didn't work.
     

Share This Page