Decelerated summation of X

36 Views Asked by At

Disclaimer: I'm a 19 year old who didn't pay enough attention in math class, so there is likely a very simple solution to this that I just can't think of.

I'm writing an algorithm that will run forever. For unrelated reasons, I want to sum up to 1 billions during steps 1 through 2,628,000. The catch is, I would like to decrease the value that is getting summed as n, the number of iterations, increases. I will always be starting at 0 and want to sum up to exactly 1 billion after 2,628,000 iterations.

In other words, lets say I wanted to do this in 10 iterations with the number 100, starting at 0:

  1. 0 + 27
  2. 27 + 18
  3. 45 + 15
  4. 60 + 11
  5. 71 + 10
  6. 81 + 8
  7. 89 + 6
  8. 95 + 3
  9. 98 + 1.5
  10. 99.5 + 0.5

I've looked at quadratic bezier curves as they seem to do what I want but I've read that it's very difficult (or impossible) to calculate y based on x (x in my case would be the iteration number).

Any help with a formula would be very much appreciated.

1

There are 1 best solutions below

0
On BEST ANSWER

So, you want numbers $a_1>a_2>\cdots>a_m>0$ with $m=2628000$ and $a_1+a_2+\cdots+a_m=1000000000$. There are infinitely many ways to achieve this goal. Here's one of them:

Calculate $1+2+\cdots+2628000$. Call the answer $Q$. Then let $a_i=1000000000i/Q$ for $i=1,2,\dots,2628000$.