Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. function calka( a, b, n )
  2.  
  3. local function f( x )
  4. return x^2 + 2*x;
  5. end
  6.  
  7. local h = ( b-a ) /n
  8. local calka = 0
  9.  
  10. for i = 1, n-1 do
  11. calka = calka + f( a + i/n * (b-a) );
  12. end
  13. calka = calka + ( f( a ) + f( b )) / 2;
  14. calka = calka * h;
  15.  
  16. print( "calka: "..calka );
  17.  
  18. end
  19. calka( 1, 5, 444 )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement