4 ms·
Not regularly but I used it recently at work to compute symbolically the sum of a non-trivial series. Turned out the sum has a closed form, which allowed me to
by reinhardt 15y ago
Not regularly but I used it recently at work to compute symbolically the sum of a non-trivial series. Turned out the sum has a closed form, which allowed me to replace an O(n) for loop with an O(1) bunch of additions, multiplications and divisions. Felt nice.
- steve19 15y agoCan you give an example?
- reinhardt 15y agoSure, here's one: given a list of n items, compute the sum of pairwise distances between every pair of items. The first item has distance 1 from the second, 2 from the third, ..., n-1 from the last. Similarly, the second item has distance 1 from the third, 2 from the fourth, ..., n-1 from the last. And so on until the (n-1)-th item. Expressed as a finite sum, this amounts to: sum (sum j, j=1 to n-i), i=1 to n-1 Paste this to Wolphram Alpha and you get the answer in a closed form: http://www.wolframalpha.com/input/?i=sum+%28sum+j%2C+j%3D1+to+n-i%29%2C+i%3D1+to+n-1 http://www.wolframalpha.com/input/?i=sum+%28sum+j%2C+j%3D1+t...