Difference between revisions of "Irfan Rahadi Kurninato"
Line 84: | Line 84: | ||
print("Sin theta = ", sinusa,"") | print("Sin theta = ", sinusa,"") | ||
[[File:uts_cara1_irfan.jpg]] | [[File:uts_cara1_irfan.jpg]] | ||
+ | |||
+ | #Cara 2 | ||
+ | Matrex=[[1,2,3,10,12],[2,2,5,2,20],[1,8,9,10,12],[10,2,0,5,2]] #Matrix yg mau di gauss | ||
+ | def PrintMatrix(Matrix): #untuk print | ||
+ | for i in range(len(Matrix)): | ||
+ | for j in range(len(Matrix[i])): | ||
+ | print(Matrix[i][j],end="\t") | ||
+ | print() | ||
+ | def MultiplyRow(Row,Scalar): #untuk kali | ||
+ | for i in range(len(Row)): | ||
+ | Row[i]=Row[i]*Scalar | ||
+ | def AddRow(Matrix,RowNR1,RowNR2,multi=1): #untuk tambah | ||
+ | for i in range(len(Matrix[RowNR2])): | ||
+ | Matrix[RowNR2][i]+=Matrix[RowNR1][i]*multi | ||
+ | def SwitchRow(Matrix,RowNR1,RowNR2): #untuk tukar | ||
+ | bufrow=Matrix[RowNR1] | ||
+ | Matrix[RowNR1]=Matrix[RowNR2] | ||
+ | Matrix[RowNR2]=bufrow | ||
+ | return 0 | ||
+ | def ZeroRowsBelow(Matrix,RowNR,CollumnNR): #untuk menghindari eror 0 | ||
+ | for i in range(len(Matrix)-RowNR-1): | ||
+ | if not(Matrix[RowNR][CollumnNR]==0): | ||
+ | AddRow(Matrix,RowNR,i+1+RowNR,-float(Matrix[i+1+RowNR][CollumnNR])/Matrix[RowNR][CollumnNR]) | ||
+ | #print(i) | ||
+ | def SolveMatrix(Matrix): #untuk mensolve | ||
+ | #Bring To Row-Echelon Form | ||
+ | for i in range(len(Matrex)): | ||
+ | ZeroRowsBelow(Matrex,i,i) | ||
+ | #Make Row-Echelon 1 | ||
+ | for i in range(len(Matrex)): | ||
+ | if not(Matrex[i][i]==0): | ||
+ | MultiplyRow(Matrex[i],1./Matrex[i][i]) | ||
+ | #diulang lagi | ||
+ | for i in range(len(Matrex)): | ||
+ | for j in range(i): | ||
+ | if not(Matrex[i][i]==0): | ||
+ | AddRow(Matrex,i,j,-float(Matrex[j][i])/Matrex[i][i]) | ||
+ | def IsRRowEchelon(Matrix): #cek selsai | ||
+ | for i in range(len(Matrix)): | ||
+ | pos=[1,0] | ||
+ | if not(Matrix[i][i] in pos): | ||
+ | return 0 | ||
+ | return 1 | ||
+ | def CheckForEqualRows(Matrix):#cek nilai | ||
+ | newlist=[] | ||
+ | for i in Matrix: | ||
+ | if i not in newlist: | ||
+ | newlist.append(i) | ||
+ | return newlist | ||
+ | MatrixNew=[] | ||
+ | for j in range(len(Matrex)): | ||
+ | RowNew=[] | ||
+ | for i in range(len(Matrex[j])): | ||
+ | RowNew.append(Matrex[j][i]) | ||
+ | MatrixNew.append(RowNew) | ||
+ | Matrex=MatrixNew | ||
+ | PrintMatrix(Matrex) | ||
+ | print() | ||
+ | while True: | ||
+ | SolveMatrix(Matrex) | ||
+ | Matrex=CheckForEqualRows(Matrex) | ||
+ | if IsRRowEchelon(Matrex): | ||
+ | break | ||
+ | PrintMatrix(Matrex)#print matrix | ||
'''3 B''' | '''3 B''' |
Revision as of 23:06, 28 October 2019
السلام عليكم Irfan Rahadi Kurnianto - 1706036255
[4 September 2019] Mengapa kita harus belajar kalkulus? kalkulus adalah mata kuliah dasar teknik. Mata kuliah kalkulus sangat berguna untuk membentuk logika agar mudah dalam belajar suatu hal lain
Tugas 1
[11 September 2019] Bit Komputer Program Catur
coding bukan pelajaran anak fasilkom/elektro belajar python praktek programing dasar2 programing + pyhton programnya irfan t2 dikelas
[18 September 2019]
Tugas irfan 18 sep 19
[25 September 2019]
Tugas irfan 25 sep 19 catatan irfan 25 sep 19
[Kuis 16 Oktober 2019] program runge kutta
https://pastebin.com/GxfenTa3 # dibuat oleh irfan rahadi 1706036255 def TurunanY(x, y): #Fungsi Turunan Y return ((x**2 - 4*y)) xawal = 0 #boundary condition x awal soal yinit = 1 #boundary condition y awal soal x = 0.03 #nilai x yang ditanya h = 0.01 #delta yang digunakan angka = (int)((x - xawal)/h) #menghitung jumlah increment yg diperlukan for i in range(1, angka + 1): k1 = h * TurunanY(xawal, yinit) #rumus runge kutta k2 = h * TurunanY(xawal + 0.5 * h, yinit + 0.5 * k1) k3 = h * TurunanY(xawal + 0.5 * h, yinit + 0.5 * k2) k4 = h * TurunanY(xawal + h, yinit + k3) yinit = yinit + (1.0 / 6.0)*(k1 + 2 * k2 + 2 * k3 + k4) #menjumlahkan nilai k1,k2,k3,k4 ke y' yang baru dan membaginya xawal = xawal + h #menambahkan xawal besarkan delta h print(yinit)
PROGRAM GAUSS from numpy import linalg import numpy as np a= np.array ([[0,0,2,1,2] ,[0,1,0,2,-1], [1,2,0,-2,1], [0,0,0,-1,1], [0,1,-1,1,-1]]) b= np.array ([[1], [1], [-4], [-2], [-1]]) c= np.array ([[0,0,2,1,2,1] ,[0,1,0,2,-1,1], [1,2,0,-2,1,-4], [0,0,0,-1,1,-2], [0,1,-1,1,-1,-1]]) print ("Matrix a " , a) print ("Matrix b ", b) print ("Matrixnya adalah:" , c) matsolve = linalg.solve (a,c) x1 = int(matsolve[0]) x2 = int(matsolve[1]) x3 = int(matsolve[2]) x4 = int(matsolve[3]) x5 = int(matsolve[4]) hasil= (x1, x2, x3, x4, x5) print ("Hasil nilai x1,x2,x3,x4,x5 :") print (hasil)
UTS 23 oktober 3 A # Cara 1 m1 = eval(input("Massa Benda 1 ? ")) m2 = eval(input("Massa Benda 2 ? ")) m3 = eval(input("Massa Benda 3 ? ")) m4 = eval(input("Massa Benda 4 ? ")) g = eval(input("Gravitasi ? ")) sinusa = ((m1+m2+m3)/m4) T1 = m1*sinusa*g T2 = m2*sinusa*g + T1 T3 = m3*sinusa*g + T2 print("T1", T1) print("T2",T2) print("T3", T3) print("Sin theta = ", sinusa,"") #Cara 2 Matrex=[[1,2,3,10,12],[2,2,5,2,20],[1,8,9,10,12],[10,2,0,5,2]] #Matrix yg mau di gauss def PrintMatrix(Matrix): #untuk print for i in range(len(Matrix)): for j in range(len(Matrix[i])): print(Matrix[i][j],end="\t") print() def MultiplyRow(Row,Scalar): #untuk kali for i in range(len(Row)): Row[i]=Row[i]*Scalar def AddRow(Matrix,RowNR1,RowNR2,multi=1): #untuk tambah for i in range(len(Matrix[RowNR2])): Matrix[RowNR2][i]+=Matrix[RowNR1][i]*multi def SwitchRow(Matrix,RowNR1,RowNR2): #untuk tukar bufrow=Matrix[RowNR1] Matrix[RowNR1]=Matrix[RowNR2] Matrix[RowNR2]=bufrow return 0 def ZeroRowsBelow(Matrix,RowNR,CollumnNR): #untuk menghindari eror 0 for i in range(len(Matrix)-RowNR-1): if not(Matrix[RowNR][CollumnNR]==0): AddRow(Matrix,RowNR,i+1+RowNR,-float(Matrix[i+1+RowNR][CollumnNR])/Matrix[RowNR][CollumnNR]) #print(i) def SolveMatrix(Matrix): #untuk mensolve #Bring To Row-Echelon Form for i in range(len(Matrex)): ZeroRowsBelow(Matrex,i,i) #Make Row-Echelon 1 for i in range(len(Matrex)): if not(Matrex[i][i]==0): MultiplyRow(Matrex[i],1./Matrex[i][i]) #diulang lagi for i in range(len(Matrex)): for j in range(i): if not(Matrex[i][i]==0): AddRow(Matrex,i,j,-float(Matrex[j][i])/Matrex[i][i]) def IsRRowEchelon(Matrix): #cek selsai for i in range(len(Matrix)): pos=[1,0] if not(Matrix[i][i] in pos): return 0 return 1 def CheckForEqualRows(Matrix):#cek nilai newlist=[] for i in Matrix: if i not in newlist: newlist.append(i) return newlist MatrixNew=[] for j in range(len(Matrex)): RowNew=[] for i in range(len(Matrex[j])): RowNew.append(Matrex[j][i]) MatrixNew.append(RowNew) Matrex=MatrixNew PrintMatrix(Matrex) print() while True: SolveMatrix(Matrex) Matrex=CheckForEqualRows(Matrex) if IsRRowEchelon(Matrex): break PrintMatrix(Matrex)#print matrix
3 B vtop = eval(input("vtop ? ")) percepatan = eval(input("a ? ")) t = (2*vtop/percepatan)**(1/2) print(t)