Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. %calka = 0.03562*x^4 + 0.8672*x^3 + 0.572*x^2 + 7.24*x + 3.21
  2.  
  3. k = 1;
  4. for i=-24:0.5:7
  5. x(k) = i;
  6. y(k) = f(i);
  7. k = k+1;
  8. end
  9. hold off;
  10. plot(x, y);
  11. hold on;
  12.  
  13. x0 = -24;
  14. xn = 7;
  15.  
  16. wynik_ana = cal_nieozn(xn) - cal_nieozn(x0)
  17.  
  18. % Romberg
  19. h = (xn-x0) * 2;
  20. for i=1:1:4
  21. h = h / 2
  22. I1 = trapez(x0,xn,h);
  23. I2 = trapez(x0,xn,h/2);
  24. I = 4/3 * I2 - 1/3 * I1;
  25. eWzgl = (wynik_ana - I)/wynik_ana * 100;
  26. end
  27. eWzgl
  28. I
  29. % Gauss
  30.  
  31. h1 = (xn + x0)/2;
  32. h2 = (xn - x0)/2;
  33.  
  34. GI1 = f(h1 + h2 * (-sqrt(3/5))) * h2;
  35.  
  36. GI0 = f(h1) * h2;
  37.  
  38. GI2 = f(h1 + h2 * sqrt(3/5)) * h2;
  39. GI = 5/9 * GI1 + 8/9 * GI0 + 5/9 * GI2
  40. eWzgl = (wynik_ana - GI)/wynik_ana * 100
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement