Advertisement
Guest User

Untitled

a guest
May 30th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. function sum (xlow, xhigh, eps)
  2. %метод центральных прямоугольников
  3.  
  4. n = 2;
  5. h = (xhigh-xlow)/n;
  6. Itstop = 0;
  7. Inprev = 0;
  8. while (Itstop ~= 1);
  9. S = 0;
  10. for k=1:1:n
  11. x = xlow+k*h-h/2;
  12. S = S + funAr1(x);
  13. end
  14. Integral1 = S*h;
  15. if (abs(Integral1 - Inprev)<eps)
  16. Itstop = 1;
  17. else
  18. n = n*2;
  19. h = h/2;
  20. Inprev = Integral1;
  21. end
  22. end
  23. Integral1=2*pi*Integral1;
  24.  
  25. %метод центральных прямоугольников
  26. n = 2;
  27. h = (xhigh-xlow)/n;
  28. Itstop = 0;
  29. Inprev = 0;
  30. while (Itstop ~= 1);
  31. S = 0;
  32. for k=1:1:n
  33. x = xlow+k*h-h/2;
  34. S = S + funAr(x);
  35. end
  36. Integral2 = S*h;
  37. if (abs(Integral2 - Inprev)<eps)
  38. Itstop = 1;
  39. else
  40. n = n*2;
  41. h = h/2;
  42. Inprev = Integral2;
  43. end
  44. end
  45. Integral2=2*pi*Integral2;
  46.  
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement