Quiz 1

From ccitonlinewiki
Revision as of 15:18, 14 October 2019 by Rais dida (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Nomor 1

Coding.jpg

Hasil.jpg

coding nomor 1

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([1, 1, -4, -2, -1], float) print ('Matriks A', A) print ('Matriks B', B) n = len(A) 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 ('Matriks A sesudah di eliminasi Gauss : ', '\n',A) 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 sama dengan', m+1, '=', x[m])


nomor 2

Coding2.jpg

Error creating thumbnail: File with dimensions greater than 12.5 MP

coding 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.arange (0,0.03,h)

for t in step_size:

   kl-diff_y (x,y)
   k2- diff_y ((x+0.5*h), (y+0.5*kl*h))
   y-y+kl*h

print ('maka y(0.03) sama dengan', y)