Integrasi Numerik Metode Trapesium

Copyright STIS/2022/2KS5/Kelompok 11
mail@pastecode.io avatar
unknown
python
2 years ago
354 B
6
Indexable
#Integrasi Numerik Metode Trapesium

fx = lambda x : 6*x**2 - 2*x #ubah fungsi disini

def integrasiTrapesium(a, b, n) :
  h = (b - a) / n
  s = fx(a) + fx(b)
  i = 1
  while(i < n) :
    s += 2 * fx(a + i * h)
    i += 1
  return (h/2) * s

xa = 1 #ubah batas bawah
xb = 12 #ubah batas atas
n = 4 #ubah banyak pias


print(integrasiTrapesium(xa, xb, n))