fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main(void){
  5. int kaijo3 = 1 * 2 * 3;
  6. int kaijo5 = 1 * 2 * 3 * 4 * 5;
  7. int kaijo7 = 1 * 2 * 3 * 4 * 5 * 6 * 7;
  8. double x, diff;
  9.  
  10. for(x = 0.0; x <= M_PI; x += 0.05 * M_PI){
  11. diff = sin(x) - (x - pow(x, 3) / kaijo3 + pow(x, 5) / kaijo5 - pow(x, 7) / kaijo7);
  12. printf("x=%1.10lf diff=%1.10lf\n", x, diff);
  13. }
  14.  
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0.02s 2724KB
stdin
Standard input is empty
stdout
x=0.0000000000 diff=0.0000000000
x=0.1570796327 diff=0.0000000000
x=0.3141592654 diff=0.0000000001
x=0.4712388980 diff=0.0000000032
x=0.6283185307 diff=0.0000000419
x=0.7853981634 diff=0.0000003116
x=0.9424777961 diff=0.0000016039
x=1.0995574288 diff=0.0000064038
x=1.2566370614 diff=0.0000212280
x=1.4137166941 diff=0.0000610432
x=1.5707963268 diff=0.0001568986
x=1.7278759595 diff=0.0003682377
x=1.8849555922 diff=0.0008017004
x=2.0420352248 diff=0.0016385917
x=2.1991148575 diff=0.0031735611
x=2.3561944902 diff=0.0058673981
x=2.5132741229 diff=0.0104172008
x=2.6703537556 diff=0.0178475009
x=2.8274333882 diff=0.0296262255
x=2.9845130209 diff=0.0478096384
x=3.1415926536 diff=0.0752206159