title: finding pi - using Machin's formula. Different iterations are giving same result
body: <p>I've written a few programs to find pi, this one being the most advanced. I used Machin's formula, <code>pi/4 = 4(arc-tan(1/5)) - (arc-tan(1/239))</code>.</p>
  
  <p>The problem is that however many iterations I do, I get the same result, and I can't seem to understand why. </p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;math.h&gt;
  using namespace std;
  
  double arctan_series(int x, double y) // x is the # of iterations while y     is the number
  {
      double pi = y;
      double temp_Pi;
      for (int i = 1, j = 3; i &lt; x; i++, j += 2) 
      {
          temp_Pi = pow(y, j) / j; //the actual value of the iteration
          if (i % 2 != 0)     // for every odd iteration that subtracts
          {
              pi -= temp_Pi;
          }
          else    // for every even iteration that adds
          {
              pi += temp_Pi;
          }
      }
      pi = pi * 4;
      return pi;
  }
  
  double calculations(int x) // x is the # of iterations
  {
      double value_1, value_2, answer;
      value_1 = arctan_series(x, 0.2);
      value_2 = arctan_series(x, 1.0 / 239.0);
      answer = (4 * value_1) - (value_2);
      return answer;
  }
  
  int main() 
  {
      double pi;
      int iteration_num;
      cout &lt;&lt; "Enter the number of iterations: ";
      cin &gt;&gt; iteration_num;
      pi = calculations(iteration_num);
      cout &lt;&lt; "Pi has the value of: " &lt;&lt; setprecision(100) &lt;&lt; fixed &lt;&lt; pi     &lt;&lt; endl;
      return 0;
  
  }
  </code></pre>