fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3. #define N 10
  4.  
  5. double f(double x) { return (exp(x * sin(3.0 * x)) - 1.0) / ( x * sin(3.0 * x)); }
  6. double g(double t) { return (exp(t) - 1.0) / t; }
  7.  
  8. int main() {
  9. int i;
  10. double x;
  11. x = 1.0;
  12. for (i = 0; i < N; i++) {
  13. x /= 10.0;
  14. printf("x:%e f(x):%e g(x):%e\n", x, f(x), g(x));
  15. }
  16. return 0;
  17. }
  18. /* end */
  19.  
Success #stdin #stdout 0.01s 1720KB
stdin
Standard input is empty
stdout
x:1.000000e-01 f(x):1.014923e+00 g(x):1.051709e+00
x:1.000000e-02 f(x):1.000150e+00 g(x):1.005017e+00
x:1.000000e-03 f(x):1.000001e+00 g(x):1.000500e+00
x:1.000000e-04 f(x):1.000000e+00 g(x):1.000050e+00
x:1.000000e-05 f(x):1.000000e+00 g(x):1.000005e+00
x:1.000000e-06 f(x):1.000015e+00 g(x):1.000000e+00
x:1.000000e-07 f(x):9.992007e-01 g(x):1.000000e+00
x:1.000000e-08 f(x):7.401487e-01 g(x):1.000000e+00
x:1.000000e-09 f(x):0.000000e+00 g(x):1.000000e+00
x:1.000000e-10 f(x):0.000000e+00 g(x):1.000000e+00