C语言编程求arcsin x
发布网友
发布时间:2023-10-22 21:47
我来回答
共1个回答
热心网友
时间:2024-11-25 05:33
#include "math.h"
double fn[1000] = {1};
double f(int n) {
int i;
if (fn[n]) return fn[n];
for (i = 1; i <= n; i++) {
if (fn[n-i]) {
int t = n-i+1;
while (t <= n) {
fn[t] = fn[t-1]* t;
t++;
}
break;
}
}
return fn[n];
}
double C(double x, int n) {
int t = 2*n;
return f(t)*pow(x,t+1)/(pow(2, t) * f(n) * f(n) *(t+1));
}
double asin0(double x)
{
double res = 0, t;
int i = 0;
do {
t = C(x, i++);
res += t;
}while (t > 1e-7);
return res;
}
int main() {
printf("%f", asin0(0.5));
return 0;
}