Difference between revisions of "Almacho Rachmanudiputra"
Line 1: | Line 1: | ||
− | Nama : Almacho Rachmanudiputra | + | [[File:http://air.eng.ui.ac.id/index.php?title=File:IMG-20190901-WA0001.jpg]]Nama : Almacho Rachmanudiputra |
Jurusan : Teknik Mesin Paralel Universitas Indonesia | Jurusan : Teknik Mesin Paralel Universitas Indonesia |
Revision as of 20:30, 27 October 2019
File:Http://air.eng.ui.ac.id/index.php?title=File:IMG-20190901-WA0001.jpgNama : Almacho Rachmanudiputra
Jurusan : Teknik Mesin Paralel Universitas Indonesia
NPM : 1706026701
Contents
Biografi dan Riwayat Pendidikan
Lahir : Jakarta, 23 Oktober 1998
2002-2003 : Sakinah Al Azhar Rawamangun
2003-2005 : TK Islam Al Azhar Rawamangun
2005-2011 : SDI Al Azhar 13 Rawamangun
2011-2014 : SMP Negeri 115 Jakarta
2014-2017 : SMA Negeri 8 Jakarta
2017- : S1 Teknik Mesin Paralel Universitas Indonesia
Hasil Belajar Pemrograman Python/C++
Di minggu pertama saya mencoba untuk mengunduh aplikasi python namun saya belum menemukan crack file tersebut. Lalu saya membaca e-book panduan python, disitu saya membaca peraturan penulisan sintaks pada python yang harus dipenuhi, antara lain penulisan statement, penulisan string, penulisan case, penulisan blok, serta cara menulis komentar di python. Untuk penulisan komentar biasanya menggunakan tanda baca pagar (#), serta menggunakan tanda petik ('). Terakhir saya membaca berbagai macam penulisan blok seperti blok percabangan, blok fungsi, blok perulangan, blok class, blok exception, dan block with.
Statement = instruksi yang akan dieksekusi oleh komputer.
String = teks atau kumpulan karakter.
Blok program = kumpulan dari beberapa statement yang dikumpulkan menjadi satu blok.
Contoh Pengerjaan Phython :
x1 = 0
dx1 = ('0.1')
dx = float (dx1)
x2 = x1+dx
Fx_1 = ((x2**2)-1) / (x1-1)
n = 1 error = 0
print ("n x F(x) error")
print (n," ",x1," ",Fx_1," ",error)
while x2<1 :
Fx_2 = ((x2**2)-1) / (x2-1)
error = ((Fx_2-Fx_1) / Fx_1)
Fx_1 = Fx_2
n = n+1
print (n," ",x1," ",Fx_1," ",error)
x2=x2+dx
Hiburan 1
x1 = 0
dx1 = ('0.1')
dx = float (dx1)
x2 = x1+dx
Fx_1 = ((x2**2)-1) / (x1-1)
n = 1 error = 0
print ("n x F(x) error")
print (n," ",x1," ",Fx_1," ",error)
while x2<1 :
Fx_2 = ((x2**2)-1) / (x2-1)
error = ((Fx_2-Fx_1) / Fx_1)
Fx_1 = Fx_2
n = n+1
print (n," ",x1," ",Fx_1," ",error)
x2=x2+dx
Hiburan 2
Konversi dar Eliminasi dengan metode Gaussian
6x1 + 4x2 = 50
2x1 + x3 + 4x4 = 50
7x2 + 3x3 + 4x4 = 50
4x1 + 4x3 = 50
Masukkan kedalam persamaan matriks
[[6, 4, 0, 0,][2, 0, 1, 4][0, 7, 3, 4][4, 0, 4, 0]]
Lalu masukkan matriks kedalam program Phyton
import numpy as np
A = np. array ([[6, 4, 0, 0], [2, 0, 1, 4], [0, 7, 3, 4], [4, 0, 4, 0]], float)
B = np.array ([50, 50, 0, 0], float)
n = len (A)
Gunakan eliminasi Gauss
for k in range(0,n-1) :
for i in range (k+1,n) :
if A[i,k]! = 0 :
lam = A[i,k]/A[k,k]
A[i,k:n] = A[i,k:n] - (A[k,k:n]*lam)
B[i] = B[i] - B[k]*lam
x = np.zeros(n,float)
for m in range(n-1,-1,-1) :
X[m] = (B[m] - np.dot(A[m,m+1:n],x[m+1:n])/A[m,m]
Hiburan 4 dan 5
Pada hiburan minggu ke-4 & ke-5, saya menggunakan matriks dalam menyelesaikan suatu persoalan yang menggunakan persamaan. Dikerjakan dalam Python dengan memasukkan modul pengerjaan.
Secara teori, digunakan hukum kontinuitas massa sehingga didapati rumus Q*p=Q*p dan didapatakan 4 persamaan dengan 4 variabel
6C1 - 4C2 = 50
-2C1 - 1C3 + 4C4 = 50
7C2 - 3C3 - 4C4 = 0
-4C1 + 4C3 = 0
6C1 - 4C2 + 0C3 + 0C4 = 50
-2C1 + 0C2 - 1C3 + 4C4 = 50
0C1 + 7C2 - 3C3 - 4C4 = 0
-4C1 + 0C2 + 4C3 + 0C4 = 0
Kemudian, persamaan - persamaan ini dimasukkan kedalam python untuk di hitung hasil persamaannya.
Kuis
Nomor 1 :
import numpy as np
class GEPP():
def __init__(self, A, b, doPricing=True): #super(GEPP, self).__init__()
self.A = A # input: A is an n x n numpy matrix self.b = b # b is an n x 1 numpy array self.doPricing = doPricing
self.n = None # n is the length of A self.x = None # x is the solution of Ax=b
self._validate_input() # method that validates input self._elimination() # method that conducts elimination self._backsub() # method that conducts back-substitution
def _validate_input(self): self.n = len(self.A) if self.b.size != self.n: raise ValueError("Invalid argument: incompatible sizes between" + "A & b.", self.b.size, self.n)
def _elimination(self):
# Elimination for k in range(self.n - 1): if self.doPricing: # Pivot maxindex = abs(self.A[k:, k]).argmax() + k if self.A[maxindex, k] == 0: raise ValueError("Matrix is singular.") # Swap if maxindex != k: self.Ak, maxindex = self.Amaxindex, k self.bk, maxindex = self.bmaxindex, k else: if self.A[k, k] == 0: raise ValueError("Pivot element is zero. Try setting doPricing to True.") # Eliminate for row in range(k + 1, self.n): multiplier = self.A[row, k] / self.A[k, k] self.A[row, k:] = self.A[row, k:] - multiplier * self.A[k, k:] self.b[row] = self.b[row] - multiplier * self.b[k]
def _backsub(self): # Back Substitution
self.x = np.zeros(self.n) for k in range(self.n - 1, -1, -1): self.x[k] = (self.b[k] - np.dot(self.A[k, k + 1:], self.x[k + 1:])) / self.A[k, k]
def main():
A = np.array([[1., 2., 0., -2., 0.], [0., 1., 0., 2., -1.], [0., 0., 2., 1., 2.], [0., 0., 0., -1., 1.], [0., 1., -1., 1., -1.]]) b = np.array([[-4.], [1.], [1.], [-2.], [-1.]]) GaussElimPiv = GEPP(np.copy(A), np.copy(b), doPricing=False) print(GaussElimPiv.x) print(GaussElimPiv.A) print(GaussElimPiv.b) GaussElimPiv = GEPP(A, b) print(GaussElimPiv.x)
if __name__ == "__main__":
main()
Nomor 2 :
import numpy as np
def diff_y (x,y) :
fungsi = x**2 - 4*y return (fungsi)
x = 0 y = 1 h = 0.01 step_size = np.arrange (0,0.03,h)
for t in step_size :
k1 = diff_y (x,y) k2 = diff_y ((x+0,5*h), (y+0.5*k1*h))
y = y + k1*h
print ('maka y(0.03) adalah', y)
UTS Metode Numerik
import numpy as np def diff_y (x,y):
fungsi = x**2 - 4*y return (fungsi) x=0 y=10 h=10 a = 1 j = 1 step_size = -np.arange (0,0.5,h)
for t in step_size:
k1 = diff_y (x,y) - (a + j) k2 = diff_y ((x+0.5*h),(y+0.05*k1*h)) - (a + j)
w1 = y + 1/3*(k1+2*k2)
print ('maka x(0.5) adalah', w1)