title: Own asin() function (with Taylor series) not accurate
body: <p>I need to write my own asin() function without math.h library with the use of Taylor series. It works fine for numbers between &lt;-0.98;0.98> but when I am close to limits it stops with 1604 iterations and therefore is inaccurate.</p>
  
  <p>I don't know how to make it more accurete. Any suggestions are very appreciated!</p>
  
  <p>The code is following:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  #define EPS 0.000000000001
  
  double my_arcsin(double x)
  {
      long double a, an, b, bn;
      a = an = 1.0;
      b = bn = 2.0;
      long double n = 3.0;
      double xn;
      double xs = x;
      double xp = x;
  
      int iterace = 0;
  
      xn = xs + (a/b) * (my_pow(xp,n) / n);
  
      while (my_abs(xn - xs) &gt;= EPS)
      {
          n += 2.0;
          an += 2.0;
          bn += 2.0;
          a = a * an;
          b = b * bn;
  
          xs = xn;
          xn = xs + (a/b) * (my_pow(xp,n) / n);
          iterace++;
      }
  
      //printf("%d\n", iterace);
  
      return xn;
  }
  
  int main(int argc, char* argv[])
  {
  
      double x = 0.0;
  
      if (argc &gt; 2)
          x = strtod(argv[2], NULL);
      if (strcmp(argv[1], "--asin") == 0)
      {
             if (x &lt; -1 || x &gt; 1)
                 printf("nan\n");
             else
             {
                 printf("%.10e\n", my_arcsin(x));
                 //printf("%.10e\n", asin(x));
             }
  
          return 0;
      }
  }
  </code></pre>
  
  <p>And also a short list of my values and expected ones:</p>
  
  <pre><code>My values              Expected values        my_asin(x)
  5.2359877560e-01       5.2359877560e-01       0.5
  1.5567132089e+00       1.5707963268e+00       1      //problem
  1.4292568534e+00       1.4292568535e+00       0.99   //problem
  1.1197695150e+00       1.1197695150e+00       0.9
  1.2532358975e+00       1.2532358975e+00       0.95
  </code></pre>