Take Home Video

From ccitonlinewiki
Revision as of 02:16, 29 October 2019 by Alesdaniel (talk | contribs) (Created page with "==CODING SOAL A== import numpy as np from math import * g = 9.81 m1 = eval(input("Massa benda 1= ")) m2 = eval(input("Massa benda 2= ")) m3 = eval(input("Massa benda 3= "))...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

CODING SOAL A

import numpy as np from math import *

g = 9.81 m1 = eval(input("Massa benda 1= ")) m2 = eval(input("Massa benda 2= ")) m3 = eval(input("Massa benda 3= ")) u = eval(input("Koefisien gesekan = ")) alpha = eval(input("Sudut yang diketahui = ")) #ubah derajat menjadi radian v = sin(alpha) w = cos(alpha)

A = np.array([[1, 0, 0], [-1, 1, 0], [0, -1, 1]], dtype='float') b = np.array([(m1*g*(v-(u*w)), m2*g*(v-(u*w)), m3*g*(v-(u*w)))])

n = len(b) for k in range(0,n-1):

 for i in range (k+1,n):
   if a[i,k] != 0.0:
     lam = a[i,k]/a[k,k]
     a[i,k+1:n] = a[i,k+1:n]-lam*a[k,k+1:n]
     b[i] = b[i] - lam*b[k]

for k in range(n-1,-1,-1):

 b[k] = (b[k] - np.dot(A[k,k+1:n],b[k+1:n]))/A[k,k]

print(list(b[k]))