MathGroup Archive 1999

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

Search the Archive

Re: "At long last, Sir, have you no shame?"

  • To: mathgroup at smc.vnet.net
  • To: mathgroup at smc.vnet.net
  • Subject: [mg18629] Re: "At long last, Sir, have you no shame?"
  • From: Colin Rose <colin at tri.org.au>
  • Date: Tue, 13 Jul 1999 01:01:43 -0400
  • References: <E1168E31432DD211AF990000F806EFD801FB512A@nems04.nawcad.navy.mil>
  • Sender: owner-wri-mathgroup at wolfram.com

Ted Ersek wrote:

    Sum[g, {} ] ...


>I am pretty sure WRI made it work that way on purpose, so if I am right it
>isn't a bug!


This is obsequious semantic twaddle.

If it gives the mathematically wrong answer, it is a bug.
The "it's not a bug, it's a feature" argument may work elsewhere,
but it is difficult to argue that 2+2==5, whether it's programmed
that way or not.




>You can make Sum work the way you prefer by changing the attributes of Sum
>with the line below.  If you like you can put this in your (init.m) file and
>Sum will always work the way you prefer.



1. You completely miss the point, which is that 99.5% of people
    are not aware that Mathematica v4 gives the wrong answer
    to an entire class of problems. This is compounded by the
    fact that:

     (i)  the same syntax is perfectly acceptable in other iterator
          functions including Product, Plot, Table, etc

     (ii) the same syntax was acceptable in earlier versions.



2. If you bothered to check the behaviour of Sum under v3 before posting,
    you would see that it **used to work** perfectly well for both
    the examples you proffer.


Cheers

Colin


_________


>In[1]:=
>ClearAttributes[Sum,HoldAll];
>SetAttributes[Sum,HoldRest];
>
>In[3]:=
>g=Exp[-i];
>
>In[4]:=
>Sum[g,{i,1,n}] //InputForm
>
>Out[4]//InputForm=
>(-1 + E^n)/((-1 + E)*E^n)
>
>
>In the example above Sum does what you expect, but now Sum gives the wrong
>answer in the next example.  If Sum has the HoldRest attribute instead of
>HoldAll you have to use Unevaluated[f[i]] in this example. This is sort of
>the flip side of the problem you noted. Notice when Sum has the default
>attributes you don't need to use Unevaluated in this example.
>
>
>In[5]:=
>f[n_Integer]:=n^2
>f[_]=0;
>
>In[7]:=
>Sum[f[i],{i,1,5}]
>
>Out[7]=
>0
>
>In[8]:=
>Sum[Unevaluated[f[i]],{i,1,5}]
>
>Out[8]=
>55
>
>-------------------

Colin Rose
tr(I)    -  Theoretical Research Institute
__________________________________________
colin at tri.org.au    http://www.tri.org.au/


 






  • Prev by Date: Re: Try this on your shiny new v4 Front end (Mac)
  • Next by Date: Re: Livegraphics3D
  • Previous by thread: Re: Re: Re: "At long last, Sir, have you no shame?"
  • Next by thread: Re: "At long last, Sir, have you no shame?"