Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. public static double partitionSumIterativ(double epsilon, double a, double b) {
  2. int n = 0;
  3. double c = b;
  4. while(c-a > epsilon) {
  5. n++;
  6. c = a + (c-a)/2;
  7. }
  8.  
  9. double area = 0;
  10. double h = (b-a)/n;
  11. for(int i = 0; i < n; i++) {
  12.  
  13. area += h * (-0.25 * a * a + 4);
  14. a = a + h;
  15. b = b - h;
  16. }
  17.  
  18. return area;
  19. }
  20.  
  21. public static double partitionSum(double epsilon, double a, double b) {
  22.  
  23. //Some code to calculate n
  24.  
  25. double h = (b-a)/n;
  26. double area = h * (-0.25 * a * a + 4) + partitionSum(epsilon, a', b'); //Where a' is a new a and b' is a new b (please see Questions below)
  27.  
  28. return area;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement