Difference between revisions of "Nadhif Rizki Priambodo"
Line 11: | Line 11: | ||
coding | coding | ||
+ | |||
+ | No.1 | ||
+ | |||
print ("QUIZ nadhif rizki p - 1706026140") | print ("QUIZ nadhif rizki p - 1706026140") | ||
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) | 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) | ||
Line 35: | Line 38: | ||
SCREENSHOT HASIL | SCREENSHOT HASIL | ||
[[File:Bob.PNG]] | [[File:Bob.PNG]] | ||
+ | |||
+ | NO.2 | ||
+ | |||
+ | import numpy as np from run_kut4 import * from printSoln import * from math import exp | ||
+ | |||
+ | x = 0.03 def F(x,y): | ||
+ | |||
+ | F = np.zeros(1) | ||
+ | F[0] = ((31/32)*exp(-4))+((1/4)*x**2)-(1/8)*x+(1/32) | ||
+ | return F | ||
+ | x = 0.0 xStop = 0.03 y = np.array([160]) h = 0.01 freq = 1 | ||
+ | |||
+ | print(y) | ||
+ | |||
+ | X,Y = integrate(F,x,y,xStop,h) printSoln(X,Y,freq) input("\nPress return to exit") |
Revision as of 15:17, 14 October 2019
[Nama : Nadhif rizki priambodo]
[Semester : 5]
[Npm : 1706026140]
Mengikuti lomba kompetisi mobil hemat energi dan shell eco marathon tahun 2018-2020
HASIL QUIZ
coding
No.1
print ("QUIZ nadhif rizki p - 1706026140") 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)
- menggunakan gauss elimination
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)
x=np.zeros( n,float) for m in range ( n-1, -1, -1)P:
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])
NO.2
import numpy as np from run_kut4 import * from printSoln import * from math import exp
x = 0.03 def F(x,y):
F = np.zeros(1) F[0] = ((31/32)*exp(-4))+((1/4)*x**2)-(1/8)*x+(1/32) return F
x = 0.0 xStop = 0.03 y = np.array([160]) h = 0.01 freq = 1
print(y)
X,Y = integrate(F,x,y,xStop,h) printSoln(X,Y,freq) input("\nPress return to exit")