Created
June 27, 2018 12:45
-
-
Save lol97/c1f77f15934993d179dbf17b80491bfe to your computer and use it in GitHub Desktop.
Integrasi Numerik menggunakan metode Trapezioda
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| integral trapezioda | |
| Warteg Dust | |
| 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): | |
| 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/2)*(y[0]+2*(sum(y)-y[0]-y[-1])+y[-1]) | |
| 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