Advertisement
STANAANDREY

simpson comp

Apr 3rd, 2023
1,130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.18 KB | None | 0 0
  1. function int = simpsoncomp(f, m, a, b)
  2.     h=(b-a)/(2*m);  
  3.     for i=1:(2*m)
  4.         y(i)=f(a+h*i);
  5.     end
  6.     int = (h/3)*(f(a)+f(b)+4*sum(y(1:2:m))+2*sum(y(2:2:m-1)));
  7. end
  8.  
  9.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement