C语言编程,根据泰勒多项式编程计算sinx的近似值 sinx≈x/1-x3/3!+x5/5!-x7/7!+……(-1)n-1x2n-1/(2n-1)!设x的值为0.3,直到最后一项数据的绝对值 答案 //用sinx=x-x^3/3!+x^5/5!……+(-1)^(n-1)*(x^(2*n-1)/(2*n-1)!#include#includedouble power(double x,int n){if(n=...
C语言编程,根据泰勒多项式编程计算sinx的近似值 sinx≈x/1-x3/3!+x5/5!-x7/7!+……(-1)n-1x2n-1/(2n-1)!设x的值为0.3,直到最后一项数据的绝对值
int main(int argc,char *argv[]){ double x,s,t,eps;int i;printf("Please enter x & eps(R...
/*sinx=x-x^3/3!+x^5/5-x^7/7!...*/ include<stdio.h> include<math.h> define ACCURARY 0.00000001 main(){ int i=1,j=1,k,n=1,x;printf("sinx=x-x^3/3!+x^5/5-x^7/7!...\n请输入一个x\n");scanf("%d",&x);double sinx=0;for(i=1;fabs(t)>=ACCURARY;i...
int i;printf("Please enter x & eps(R:0<eps<1)...\n");if(scanf("%lf%lf",&x,&eps)!=2 || eps<=0 || eps>=1){printf("Input error, exit...\n");return 0;}printf("sin(%g)≈",x);for(s=t=x,x*=x,i=1;t>=eps;i++){(t*=x)/=((i*i<<2)+i+i)...
{ int t=0,n,m,i; float eps,sinx=0.0,x,f=1,s=1; scanf("%f%f",&x,&eps); for(m=1; fabs(f)>eps; m+=2) { f=(pow(-1.0,t))*(pow(x,2*t+1))/s; sinx=sinx+f; s=s*(m+1)*(m+2); t++; } printf("%.2f",sinx); } ...
include<stdio.h> include<math.h> main(){ float a,b=1;float i,sinx,x;scanf("%f",&x);a=x;sinx=0;for(i=1;fabs(a/b)>=1e-6;i++){ sinx+=a/b;a=-a*x*x;b=b*2*i*(2*i+1); } printf("%f",sinx);} ...
for(i=1;a>=pow(10,-8);i++)里面的条件有问题,a可能为负数,所以,应该改为 fabs(a)>=pow(10,-8)这样就好了
C语言编程,根据泰勒多项式编程计算sinx的近似值 sinx≈x/1-x3/3!+x5/5!-x7/7!+……(-1)n-1x2n-1/(2n-1)! 设x的值为0.3,直到最后一项数据的绝对值 答案 //用sinx=x-x^3/3!+x^5/5!……+(-1)^(n-1)*(x^(2*n-1)/(2*n-1)!#include#includedouble power(double x,int n){if(...