title: Mathematics behind Babylonian Square Root method
body: <p>I read the method to calculate the square root of any number and the algorithm is as follows:</p>
  
  <pre><code>double findSquareRoot(int n) {
      double x = n;
      double y = 1;
      double e = 0.00001;
      while(x-y &gt;= e) {
          x = (x+y)/2;
          y = n/x;
      }
      return x;
  }
  </code></pre>
  
  <p><strong>My question regarding this method are</strong></p>
  
  <ol>
  <li><p>How it calculates the square root? I didn't understand the mathematics behind this. How <code>x=(x+y)/2 and y=n/x</code> converges to square root of n. Explain this mathematics.</p></li>
  <li><p>What is the complexity of this algorithm?</p></li>
  </ol>