Samuel Albert Sitompul

From ccitonlinewiki
Revision as of 02:31, 21 October 2019 by Samuel.albert (talk | contribs) (QUIZ (14/10/2019))
Jump to: navigation, search

PROFILE

Nama saya adalah Samuel Albert Sitompul lahir di Medan, 1 Maret 1997. Saya mengawali pendidikan sekolah di Medan (TK-SMA) hingga sekarang saya sedang menempuh perkuliahan saya di Universitas Indonesia pada jurusan Teknik Mesin sejak tahun 2016. Hobi saya adalah berolahraga dan membaca.




QUIZ (14/10/2019)

Problem set 2.1 Number 6 page 55

Matrix given,

A = [[0, 0, 2, 1, 2], [0, 1, 0, 2, -1], [1, 2, 0, -2, 0], [0, 0, 0, -1, 1], [0, 1, -1, 1, -1]]

B = [1, 1, -4, -2, -1]

Before entering Gauss Elimination, matrix should be configured so we could eliminate it,

Matrix configuration,

A = [[1, 2, 0, -2, 0], [0, 1, 0, 2, -1],[0, 1, -1, 1, -1], [0, 0, 0, -1, 1], [0, 0, 2, 1, 2]]

B = [-4, 1, -1, -2, 1]

So the result is,

X1 = 2

X2 = -2

X3 = 1

X4 = 1

X5 = -1

PYTHON CODE

Import numpy as np

A=np.array([[1, 2, 0, -2, 0], [0, 1, 0, 2, -1],[0, 1, -1, 1, -1], [0, 0, 0, -1, 1], [0, 0, 2, 1, 2]],float)

B=np.array([-4, 1, -1, -2, 1],float)

n=len(A)

Gauss Elimination code

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) print ('matrix A:', '\n', A)

Back substitution

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] print ('nilai X', m+1, '=', x[m])

File:Code1.jpg


Problem set 7.1 Number 1 page 263

Python Script :

   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.arange (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)

Code2.jpg