Skip to content

Instantly share code, notes, and snippets.

@lol97
Created June 20, 2018 14:18
Show Gist options
  • Select an option

  • Save lol97/5b6a1e45db49dd60cb7a8a446ca28e06 to your computer and use it in GitHub Desktop.

Select an option

Save lol97/5b6a1e45db49dd60cb7a8a446ca28e06 to your computer and use it in GitHub Desktop.
Get Area of Graph with riemann methode
'''
Trapezioda Integral
Sufyan Saori
xsufyan@gmail.com
'''
x = [0, 0.2, 0.4, 0.6, 0.8, 1.0]
y = [2, 3, 6, 5, 4, 1]
def trapezioda(x,y):
#mengecheck setiap nilai h sama
def cekSelisih(x):
i= 0
temp = x[1]-x[0]
while(i<len(x)-1):
h=round(x[i+1]-x[i],2)
if(temp!=h):
return(False)
break
i+=1
return True
if(cekSelisih(x)):
h = x[1]-x[0]
hasil=h*(sum(y))
print("dengan nilai x : ",x)
print("dengan nilai y : ",y)
print("maka didapatkan luas area dari "+str(x[0])+" sampai "+str(x[len(x)-1])+" hasilnya : "+str(hasil))
trapezioda(x,y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment