这里给出了无限级数展开的公式:
sin x = x - x3/3! + x5/5! - x7/7! + ...
这里,x
是弧度,它取值范围-1 <= x <= 1
。
#include <stdio.h>
int main()
{
double sine, term, x = 0.7, z;
int k = 1;
char ch;
term = x;
sine = x;
z = x * x;
for (int i = 1; i <= 10; i++) {
k = k + 2;
term = -term * z /(k * (k - 1));
sine = sine + term;
}
printf("Sine of %lf is %lf/n", x, sine);
return(0);
}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/266693.html