Difference between revisions of "Oimolala Putrawan"
Line 193: | Line 193: | ||
Tugas 30 Oktober 2019 | Tugas 30 Oktober 2019 | ||
− | + | def derivative_velocity(acc, vfinal): #Function | |
− | + | return (9.8*sina-(1/2)*(1/m)*(cd)**(3/2)-miu*9.8) | |
− | cd=eval(input("drag coefficient: ")) #input coef drag | + | cd=eval(input("drag coefficient: ")) #input coef drag |
− | miu = eval(input("friction coef: ")) | + | miu = eval(input("friction coef: ")) |
− | Vinitial=0 #stationary condition | + | Vinitial=0 #stationary condition |
− | sina = 0.5 | + | sina = 0.5 |
− | m=eval(input("mass (kg): ")) #mass | + | m=eval(input("mass (kg): ")) #mass |
− | accceleration=eval(input("acceleration (m/s^2): ")) | + | accceleration=eval(input("acceleration (m/s^2): ")) |
− | + | #perc | |
− | Vakhir=eval(input("top speed (m/s): ")) | + | Vakhir=eval(input("top speed (m/s): ")) |
− | #vtop | + | #vtop |
− | xawal = 0 #boundary condition x awal soal | + | xawal = 0 #boundary condition x awal soal |
− | yinit = 0 #boundary condition y awal soal | + | yinit = 0 #boundary condition y awal soal |
− | x = Vfinal #the asked x | + | x = Vfinal #the asked x |
− | h = 1 #delta used | + | h = 1 #delta used |
− | number = (int)((x - xawal)/h) calculate the increment | + | number = (int)((x - xawal)/h) calculate the increment |
− | for i in range(1, angka + 1): | + | for i in range(1, angka + 1): |
− | + | k1 = h * Derivative_velocity(xawal, yinit) #runge kutta formula | |
− | + | k2 = h * Derivative_velocity(xawal + 0.5 * h, yinit + 0.5 * k1) | |
− | + | k3 = h * Derivative_velocity(xawal + 0.5 * h, yinit + 0.5 * k2) | |
− | + | k4 = h * Derivative_velocity(xawal + h, yinit + k3) | |
− | + | yinit = yinit + (1 / 6.0)*(k1 + 2 * k2 + 2 * k3 + k4) sum value of k1,k2,k3,k4 to the nwe y' and divide it | |
− | + | xawal = xawal + h | |
− | + | #sum xawal increase delta h | |
− | print("time needed", yinit,"second") | + | print("time needed", yinit,"second") |
Revision as of 16:03, 6 November 2019
Assalamualaikum
Contents
Oimolala Putrawan
Nama : Oimolala Putrawan (Oi)
NPM : 1706036412
== Pertemuan Pertama ==
Hari/Tanggal : Rabu, 4 September 2019
Kenapa saya harus belajar kalkulus?
Saya belajar kalkulus untuk meningkatkan kemampuan bermatematika saya yang kelak berguna untuk memahami fenomena fisik yang terjadi. selain itu belajar kalkulus meningkatkan kemampuan berpikir dan pola pikir saya.
emas.ui.ac.id
Apa itu Python?
Python merupakan salah satu general purpose high-programing language, yang berarti memiliki sintaks yang mudah dimengerti oleh manusia. Diciptakan pertama kali oleh Guido von Rossum pada 1991. Python dengan bantuan beberapa libraries memiliki banyak kegunaan seperti web developing, scientific computing, sebagai scripting language pada software finite element method, dan yang paling menarik penggunaan python sebagai bahasa yang paling digunakan untuk artificial intelligence terutama pada machine learning.
Minggu 3
While Loop Fibonacci
a, b = 0, 1 while a< 100: print (a) a, b = b, a+b
For Loop Fibonacci
a, b = 0, 1 for i in range(0,100): print(a) a, b= b, a+b
Function Fibonacci
def fib(n): a = 0 b = 1 if n < 0: print("Incorrect input") elif n == 0: return a elif n == 1: return b else: for i in range(2,n): c = a + b a = b b = c return b
Submission Tugas
TUGAS 1
File:Tugas 1
TUGAS 2
Fibonacci with Python
File:Tugas 2 Function Approach
File:Tugas 2 Loop (while) Approach
File:Tugas 2 Loop (for) Approach
UTS [23 Oktober]
UTS
#cara 1 3A
mass1 = eval(input("Massa Benda 1 ? ")) #menginput m1 mass2 = eval(input("Massa Benda 2 ? "))#menginput m2 mass3 = eval(input("Massa Benda 3 ? ")) #meninput m3 mass4 = eval(input("Massa Benda 4 ? ")) g = eval(input("Gravitasi ? ")) #input g sinus@ = ((mass1+mass2+mass3)/mass4)#hitung sin theta T1 = mass1*sinus@*g #hitung T1 T2 = mass2*sinus@*g + T1 #hitung T2 T3 = mass3*sinus@*g + T2 #hitung T3 print("T1", T1) print("T2",T2) print("T3", T3) print("Sin theta = ", sinus@,"")
#cara 2
#Cara 2 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) Matrx=[[1,0,0,m1*sinusa*g],[1,1,0,(2*m1+m2)*sinusa*g],[2,1,1,((2*(2*m1+m2))+m3)*sinusa*g]] #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 print("") print("Solusinya") print("T1 = ",Matrex[0][3]) print("T2 = ",Matrex[1][3]) print("T3 = ",Matrex[2][3]) print("Sin Theta = ",Matrex[0][3]/(m1*g))
3B
cd=eval(input("drag coefficient: ")) #input coef drag Vawal=0 #kondisi diam m=eval(input("mass (kg): ")) #massa a=eval(input("acceleration (m/s^2): ")) #perc Vakhir=eval(input("top speed (m/s): ")) #vtop fdrag=(cd*Vakhir**(3/2))/m #gayagesek Ftotal=a-fdrag Atotal = Ftotal #dibagi m t=(Vakhir-Vawal)/Atotal #hitung waktu print("Waktu untuk mencapai Vakhir: ",t, "detik")
Video Muhasabah
Tugas 30 Oktober 2019 def derivative_velocity(acc, vfinal): #Function return (9.8*sina-(1/2)*(1/m)*(cd)**(3/2)-miu*9.8) cd=eval(input("drag coefficient: ")) #input coef drag miu = eval(input("friction coef: ")) Vinitial=0 #stationary condition sina = 0.5 m=eval(input("mass (kg): ")) #mass accceleration=eval(input("acceleration (m/s^2): ")) #perc Vakhir=eval(input("top speed (m/s): ")) #vtop xawal = 0 #boundary condition x awal soal yinit = 0 #boundary condition y awal soal x = Vfinal #the asked x h = 1 #delta used number = (int)((x - xawal)/h) calculate the increment for i in range(1, angka + 1): k1 = h * Derivative_velocity(xawal, yinit) #runge kutta formula k2 = h * Derivative_velocity(xawal + 0.5 * h, yinit + 0.5 * k1) k3 = h * Derivative_velocity(xawal + 0.5 * h, yinit + 0.5 * k2) k4 = h * Derivative_velocity(xawal + h, yinit + k3) yinit = yinit + (1 / 6.0)*(k1 + 2 * k2 + 2 * k3 + k4) sum value of k1,k2,k3,k4 to the nwe y' and divide it xawal = xawal + h #sum xawal increase delta h print("time needed", yinit,"second")