0

Research

I know that I can use Gauss' Trick for finding the sum of consecutive numbers. n/2 * (start + end)

This is illustrated here: Sum of n consecutive numbers

Question

I am trying to find a shorter solution, (one without loops) to the algorithm below: (sorry for lack of LaTeX knowledge)

For each number from 1 to N, find the sum of (the sum the numbers from 1 to Nx)

Expanded Version:

Given N = 4

N1: [(1)] + 
N2: [(1 + 2) + (1)] + 
N3: [(1 + 2 + 3) + (1 + 2) + (1)] +
N4: [(1 + 2 + 3 + 4) + (1 + 2 + 3) + (1 + 2) + (1)]

Using Gauss' Trick

Given N = 4

N1: [1/2 * (1 + 1)] +
N2: [2/2 * (1 + 2)] +
N3: [3/2 * (1 + 3)] +
N4: [4/2 * (1 + 4)]

Looking for a "Double Guass' Trick"

So, is there a mathematical way to calculate this "second level" approximation without needing to loop through 1-N?

Tim
  • 123
  • 1
    What's $x$? Do you just mean $\sum_{i=1}^N \frac {i(i+1)}2$? But that is just $\frac 12\times \sum_{i=1}^N i^2 +\frac 12\times \sum_{i=1}^N i$. And both of those sums are well known polynomials in $N$. – lulu Feb 13 '21 at 23:12
  • See Faulhaber's formula for a general discussion of sums of the form $\sum_{i=1}^N i^k$ though here you only need the cases $k=1,2$. – lulu Feb 13 '21 at 23:13
  • I will modify the title of the question. X should be N. – Tim Feb 13 '21 at 23:14
  • But it's not just the title, your phrase "find the sum of (the sum the numbers from 1 to Nx)" doesn't really make sense. Again, what is $x$? In my first comment I made a guess as to what you meant to ask, but I do not know if I guessed correctly. – lulu Feb 13 '21 at 23:15
  • @lulu In Nx, x is the iteration number of N. I am trying to find a summation inside of a summation. I am not sure how to word or write the formula for this, but I feel like the Expanded Version of my question illustrates the steps which should help you extract the meaning. – Tim Feb 13 '21 at 23:18
  • Well, do you think that the formula in my first comment matches your intent? If so, then I think the issue is resolved. If not, please edit your post to clarify. – lulu Feb 13 '21 at 23:19
  • @lulu I just took a closer look at your comment and it 100% represents what I am trying to do. I am taking a look at the "but that is just... " part now. Is there an algebraic representation to that? My math skills are somewhat lacking. – Tim Feb 13 '21 at 23:21
  • To clarify, I am looking for the kind of simplification Gauss made instead of having to calculate out sum(i=1, N) i – Tim Feb 13 '21 at 23:23
  • 1
    So that would be $\Psi(N)=\frac {N(N+1)(2N+1)}{12}+\frac {N(N+1)}4$. The sequence of values is ${1,4,10,20,35,\cdots}$ These are the so called tetrahedral numbers. Note: I believe the polynomial I wrote out can be simplified somewhat, I did not try. – lulu Feb 13 '21 at 23:24
  • Checking this out now. If you want to put it in an answer, I will accept and up vote. What do you mean by "both of those sums are well known polynomials in N?" – Tim Feb 13 '21 at 23:30
  • Look up the article I linked to on Faulhaber, $\sum_{i=1}^Ni^2=\frac {N(N+1)(2N+1)}6$ is well known and you certainly know $\sum_{i=1}^N i=\frac {N(N+1)}2$ – lulu Feb 13 '21 at 23:31
  • Note my polynomial simplifies to $\Psi(N)=\frac {N(N+1)(N+2)}6$. – lulu Feb 13 '21 at 23:32
  • @lulu Thanks! This just cut so many iterations off of my algorithm!!! I appreciate the time and references! – Tim Feb 13 '21 at 23:41

0 Answers0