title: C++ Newton Raphson method is slower than bisection?
body: <p><br>
  My task is to find the root of a function with both the Newton Raphson and the bisection method within an error margin of 10E-7.
  The point of all that is, that we learn that the Newton Raphson method is faster and more effective.
  Now for some reason I come to the opposite result. Although I am aware that the initial guess of the root in both methods strongly affects the number of necessary iterations. But I entered a similar guess in both algorithms and my fellow students dont get the result I do.</p>
  
  <p>Bisection method:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  
  using namespace std;
  
  
  //Declaring the given function
  double func1(double x) {
  
      return 0.00000000027 * (x - 10000000) - 0.16460351745 * (-1 + ((1000000000) / (x))) * 1 / (sqrt(x));
  
  }
  
  int main() {
      std::fixed;
  
  
      //Initial guess: root ist at 10 to the 7.
      double x1 = 10000000;
      double x2 = 1000000000;
      double eps = 0.0000001;
      int i = 0;
      double x0[100000];
      x0[0] =0;
  
  
      //Exception handler
      if (func1(x1) * func1(x2) &gt; 0) {
          cout &lt;&lt; "Root is not inside the bracket.";
          goto end;
      }
      goto start;
  
  
      //Bisection Algorithm 
      while (abs(x0[i] - x0[i-1]) &gt;= eps) {
  
      start:
  
          i = i + 1;
          x0[i] = 0.5 * (x1 + x2);
  
  
          if (func1(x1) * func1(x0[i]) &lt; 0) {
  
              x2 = x0[i];
          }
          else {
              x1 = x0[i];
          }
  
  
  
  
  
      }
  
      cout &lt;&lt; endl &lt;&lt; "Bisection Method: " &lt;&lt; fixed &lt;&lt; setprecision(10) &lt;&lt; x0[i] &lt;&lt; endl &lt;&lt; "Iterations: " &lt;&lt; i &lt;&lt; endl &lt;&lt; endl &lt;&lt; endl &lt;&lt; endl &lt;&lt; endl;
  
      end:
      return 0;
  }
  }
  </code></pre>
  
  <p>Newton Raphson:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  
  using namespace std;
  
  // Declaring the function and its derivative
   double func1(double x) {
  
    return 0.00000000027 * (x - 10000000) - 0.16460351745 * (-1 + ((1000000000) / (x))) * 1 / (sqrt(x));
  
  }
  
  double funcderiv1(double x) {
  
       return 0.00000000027+((0.1646035174)/(2*x*x*sqrt(x)))*(30000000-x);
  
  }
  
  
  int main()
  {
      std::fixed;
      double eps = 1;
      double x_start = 10000000;
      double c;
  
      int i = 0;
  
      while (eps &gt;= 0.0000001) {
  
  
          c = x_start - ((func1(x_start)) / (funcderiv1(x_start)));
          eps = abs(func1(x_start) / funcderiv1(x_start));
          x_start = c;
  
          i = i + 1;
  
  
  
      }
  
      cout &lt;&lt; fixed &lt;&lt; setprecision(5) &lt;&lt; "RESULT " &lt;&lt; c &lt;&lt; endl &lt;&lt; " Iterations: " &lt;&lt; i &lt;&lt; endl;
  
  }
  
  
  </code></pre>
  
  <p>The root is at 17903534.23630</p>
  
  <p>Does anyone know why my bisection method needs 55 iterations while Newton Raphson takes like 82?</p>