Guest User

Untitled

a guest
Apr 30th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. double RowFunction(double x) {
  2. double sum = 0;
  3. int i = 1;
  4.  
  5. while (fabs(sum - log(x)) > 0.1) {
  6. sum += pow(x - 1, i) / (i*pow(x, i));
  7. i++;
  8. }
  9.  
  10. return sum;
  11. }
  12.  
  13. int RecursionFunction(int i, int n, double xs[], double array[]) {
  14. if (i < n)
  15. array[i] = log(xs[i]);
  16. if (i + 1 < n)
  17. RecursionFunction(i + 1, n, xs, array);
  18. return 0;
  19. }
  20.  
  21. double recurLog(double x, int n)
  22. {
  23. if (n == 1) return (x-1)/x;
  24. double n_term = 1;
  25. for(int i = 0; i < n; ++i)
  26. n_term *= (x-1)/x;
  27. n_term /= n;
  28. return recurLog(x,n-1) + n_term;
  29. }
  30.  
  31. double serialLog(double x, int n)
  32. {
  33. x = (x-1)/x;
  34. double term = x, sum = x;
  35. for(int i = 2; i <=n; ++i)
  36. sum += term *= x*(i-1)/i;
  37. return sum;
  38. }
Add Comment
Please, Sign In to add comment