title: Math equation to find number of iterations in asymptotic loop?
body: <p>I have a loop that decreases in growth as the iterations go up. I need to calculate the number of iterations it'll go through (I explain why I need this at the bottom of this question). The first 6 steps are </p>
  
  <p><code>0.50, 1.50, 1.83, 2.11, 2.34, 2.55, ...</code></p>
  
  <p><a href="https://i.stack.imgur.com/UTbZ1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UTbZ1.jpg" alt="X-axis: iterations, Y-axis: count"></a>
  <strong>X-axis: iterations, Y-axis: count</strong></p>
  
  <p>The count starts at 0.5 and grows at a decreasing rate until it reaches 20. The loop boils down to this:</p>
  
  <pre><code>var SCALE = 0.5; // Starting value, also affects increment
  var MAX = 20;    // Maximum value
  var i = 0;       // Just for counting
  
  for (var count = SCALE; count &lt; MAX; count += SCALE / count) {
      console.log(count, i);
      i++;
  }
  </code></pre>
  
  <p>You can see the graph grows more slowly as it progresses because of <code>count += SCALE / count</code>, so as count increases, the denominator increases too.</p>
  
  <p>I thought it followed an exponential <code>pow(MAX, 1 / SCALE)</code> line, but not quite:</p>
  
  <pre><code>MAX = 5 :  23 iterations      Math.pow(5, 2) = 25
  MAX = 10 : 97 iterations      Math.pow(10, 2) = 100
  MAX = 15 : 222 iterations     Math.pow(15, 2) = 225
  MAX = 20 : 397 iterations     Math.pow(20, 2) = 400
  </code></pre>
  
  <p>Plus this approach falls apart when <code>SCALE</code> isn't 0.5.</p>
  
  <h3>Question</h3>
  
  <p>What equation can I use that takes both <code>SCALE</code> and <code>MAX</code> into account to get the iteration count?</p>
  
  <h3>Why do I need this?</h3>
  
  <p>I'm trying to convert the sample code <a href="http://tuxedolabs.blogspot.com/2018/05/bokeh-depth-of-field-in-single-pass.html" rel="nofollow noreferrer">at the bottom of this article</a> into GLSL shader code. The problem is that graphics cards can only perform for-loops with integers counting up to a constant, so I need to know how many iterations the loop will take before starting the loop. </p>
  
  <p>I need something like this: <code>for(int i = 0; i &lt; MAX_COUNT; i++)</code> but first I need to know what <code>MAX_COUNT</code> will be.</p>