fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. const double EPS = 0.1;
  7. const int COUNT_ITERATIONS = 100;
  8. const double PI = 3.14159265;
  9.  
  10. double F ( double x ) {
  11. return ( !(int)x ? 1. : x*F( x - 1 ) );
  12. }
  13.  
  14. double S ( double x ) {
  15. double res = 0;
  16. for ( int i = 0; i < COUNT_ITERATIONS; i++ ) {
  17. res += pow ( -1., i )*pow ( x, 2*i ) / F ( 2*i + 1 );
  18. }
  19.  
  20. return res;
  21. }
  22.  
  23. double Y ( double x ) {
  24. return sin ( x ) / x;
  25. }
  26.  
  27. int main () {
  28. cout << F ( 10 ) << " " << F ( 13 ) << " " << F ( 15 ) << endl;
  29. cout << "x\t\tY(x)\t\tS(x)" << endl;
  30. for ( double x = 0.1; x < PI; x += 0.33 ) {
  31. cout << x << ":\t" << Y ( x ) << "\t" << S ( x ) << endl;
  32. }
  33. return 0;
  34. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
3.6288e+06 6.22702e+09 1.30767e+12
x		Y(x)		S(x)
0.1:	0.998334	0.998334
0.43:	0.969467	0.969467
0.76:	0.906476	0.906476
1.09:	0.813419	0.813419
1.42:	0.696234	0.696234
1.75:	0.562278	0.562278
2.08:	0.419775	0.419775
2.41:	0.277201	0.277201
2.74:	0.142659	0.142659
3.07:	0.0233002	0.0233002