常见的泰勒展开:
void tylor_sin(int n)
{
double s=n;
double i=1;
double term=n;
do
{
term=-term*n*n/((i+2)*(i+1));
s+=term;
i+=2;
}while(fabs(term)>1e-6);
cout<<"the value of sin"<1e-6);
cout<<"the value of cos"<
结果如下:
思考:
用迭代法累加得到,要注意正负号和分母的阶乘就很简单了。



