daily pastebin goal
69%
SHARE
TWEET

Untitled

a guest Aug 12th, 2017 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function I= Simpson( a, b, n, f )
  2. % Calcul integrala prin metoda Simpson
  3. % f functie, a, b capetele intervalului, n precizia
  4.  
  5.     m =(b-a) / (2*n);
  6.     s1 = 0;
  7.     s2 = 0;
  8.     for i = 1 : n
  9.         s1 = s1 + f(a+(2*i-1)*m); %calculul f1
  10.     end
  11.     for i = 1 : n-1
  12.         s2 = s2 + f(a+2*i*m); %calculul f2
  13.     end
  14.     I = m*(f(a) + f(b) + 4*s1 + 2*s2)/3;
  15.  
  16. end
  17.  
  18. % P.S. Desi m-am inspirat, am inteles ce e cu formula :D
RAW Paste Data
Top