Maximilian Hasler on Sat, 29 Dec 2012 22:16:47 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Square of an unsigned integer without products. |
It would be nice if you could be a little less cryptic to save time (needed to understand), to all those which receive this message. I hope no computer uses " sum(i=1,2 (some other sum independent of i) ) " to compute twice that other sum, by doing all the calculation two times ; while multiplication by 2 is achieved with nearly zero computational complexity by binary left shift. Why do you want to avoid "multiplication", do you think it is more expensive than a triple nested sum ? This is certainly not the case. (cf. e.g. http://en.wikipedia.org/wiki/Sch%C3%B6nhage%E2%80%93Strassen_algorithm) As a side note (since you post this on a PARI list, which is maybe not really the best place for such a question), the " my(i,j,k); " statement leads to a useless duplicate of the summation variables. (They are automatically declared as local variable by the for(..) statement.) Best regards, Maximilian On Sat, Dec 29, 2012 at 3:05 PM, Remy José Cano Ramírez <aallggoorriitthhmmuuss@gmail.com> wrote: > Greetings, > > About the following: > > ---------------------------------------------------------------------------------------- > > /* > Please review and comment if at certain low level the computers today > already > make such calculations with the method shown below. > */ > > uisqr(x)={my(i,j,k); x+sum(i=1,2,sum(j=1,(x-1),sum(k=(j+1),x,1)))}; > > ---------------------------------------------------------------------------------------- > > (Also available at: http://pastebin.com/qb7FHEzA) > > Regards, > > Remy