Thread: Arcsin?
View Single Post
  #3   Spotlight this post!  
Unread 05-03-2011, 16:04
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,089
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Arcsin?


Or you could roll your own. Accurate to less than 3 minutes of arc.

Code:
#include <math.h>

double asin (double x) {

const double pi2=1.57079632679;

const double hroot2=0.707106781186;

double f(double x);

if (x<-hroot2) return -pi2+f(sqrt(1-x*x));

else if (x<0) return -f(-x);

else if (x<hroot2) return f(x);

else return pi2-f(sqrt(1-x*x));

}

double f(double x) {
return -0.000786215+x*(1.021878945+x*(-0.118183378+x*(0.344819444)));
}


void main (void) {
int i;
for (i=-100;i<=100;i++) printf("%f,%f\n",0.01*i,asin(0.01*i));
}

Reply With Quote