Outline:
- Referensi/Materi
- Referensi Video
- Code/Module
- Forum Diskusi
Referensi/Materi
- https://www.math.tamu.edu/~dallen/linear_algebra/chpt6.pdf
- https://www.math.upenn.edu/~deturck/m320/text/part8.pdf
- Materi Bahasa Indonesia
Referensi Video
Open Code in Google Colaboratory
Metode Numerik
EigenValue dan EigenVektor Numerik
(C) Taufik Sutanto - 2020
tau-data Indonesia ~ https://tau-data.id/mfds-nm-05/
Eigenvalue (Eigenvector) Numerik:¶
- Pendahuluan Eigenvalue dan eigen vektor
- Aplikasi & Intuisi
- Karakteristik Polinomial
- Power Method
- Rayleigh Quotient
- Deflated Matrix Method
- Jacobi Method
Karektiristik Polynomial ~ Permasalahan Mencari Akar¶
Keterbatasan - Companion Matrix
Contoh lain permasalahan numerik menggunakan AKP¶
In [1]:
# Python implementation
import numpy as np
A = np.array([[ 1, 1 ],
[ 0, 2 ]])
A
Out[1]:
array([[1, 1], [0, 2]])
In [2]:
# Operasi Matrix
print('A \n',A)
print('A*A \n',A.dot(A))
print('A+A \n',A+A)
print("A' \n",A.transpose())
A [[1 1] [0 2]] A*A [[1 3] [0 4]] A+A [[2 2] [0 4]] A' [[1 0] [1 2]]
In [3]:
# Eigenvalue dan eigenvector
A = np.array([[ 3, -1 ],[ -1, 3 ]])
print(A)
eVa, eVe = np.linalg.eig(A)
print('Eigenvalues \n',eVa)
print('Eigenvectors \n',eVe)
[[ 3 -1] [-1 3]] Eigenvalues [4. 2.] Eigenvectors [[ 0.70710678 0.70710678] [-0.70710678 0.70710678]]
In [4]:
A = [[1,2,3],[0,4,5],[0,0,6]]
A = np.array(A)
eVa, eVe = np.linalg.eig(A)
print('Eigenvalues \n',eVa)
print('Eigenvectors \n',eVe)
Eigenvalues [1. 4. 6.] Eigenvectors [[1. 0.5547002 0.51084069] [0. 0.83205029 0.79818857] [0. 0. 0.31927543]]
In [5]:
eVe[1]/eVe[1].max()
Out[5]:
array([0. , 1. , 0.95930327])
Latihan 1:¶
- Diberikan matrix sbb: $$ \begin{bmatrix} -2 & -3 \\ 6 & 7 \end{bmatrix} $$
- Tentukan Error Relatif aproksimasi eigenvalue terkait matrix tersebut
- jika persamaan karakteristik polinomial-nya diselesaikan dengan metode Newton
- tiga iterasi ($\lambda_3$) dengan $\lambda_0 = 1$
In [6]:
def F(x):
return x**2-5*x+4
def f(x):
return 2*x-5
# Newton (L3, Lo=1)
Lo =1
L1 = Lo - F(Lo)/f(Lo)
L2 = L1 - F(L1)/f(L1)
L3 = L2 - F(L2)/f(L2)
L3
eksak = 1
abs(L3-eksak)/abs(eksak) # Error_Relatif
Out[6]:
0.0
Power Method - Contoh
In [7]:
# Contoh
A = np.array([[ 2, 9 ],[ 9, 1 ]])
x = np.array([1,1]).transpose()
N = 5
for i in range(N):
xo = x
x = A.dot(x)
x1 = x
eigen = max(abs(x1))/max(abs(xo))
print('Eigenvalue = ', eigen)
print('Eigenvector = ', x)
Eigenvalue = 10.63820909893284 Eigenvector = [132584 124129]
In [8]:
eVa, eVe = np.linalg.eig(A)
print('Eigenvalues \n',eVa)
print('Eigenvectors \n',eVe)
Eigenvalues [10.51387819 -7.51387819] Eigenvectors [[ 0.72645372 -0.68721539] [ 0.68721539 0.72645372]]
In [9]:
# Seringnya Power method menggunakan normalisasi vector di setiap langkahnya
x = np.array([1,1]).transpose()
N = 6
for i in range(N):
x = x/x.max()
xo = x
x = A.dot(x)
x1 = x
eigen = max(abs(x1))/max(abs(xo))
print('Eigenvalue = ', eigen)
print('Eigenvector = ', x/x.max())
Eigenvalue = 10.426061968261632 Eigenvector = [1. 0.95301842]
Latihan 2:¶
- Diberikan matrix sbb: $$ \begin{bmatrix} 1 & 1 \\ 4 & 1 \end{bmatrix} $$
- Tentukan Error Relatif aproksimasi eigenvalue
- terkait matrix tersebut jika eigenvalue-nya didekati
- dengan metode Rayleigh power Method dua iterasi ($\lambda_2$) dengan $x_0 = [1,1]'$
In [10]:
# Contoh
A = np.array([[ 1, 1 ],[ 4, 1 ]])
x = np.array([1,1]).transpose()
N = 4
for i in range(N):
xo = x
x = A.dot(x)
x1 = x
eigen = max(abs(x1))/max(abs(xo))
print('Eigenvalue = ', eigen)
print('Error Relatif = ', abs(3-eigen)/3)
Eigenvalue = 2.951219512195122 Error Relatif = 0.016260162601626032
Rayleigh Quotient
- Secara umum Power method Lambat, methode Rayleigh mempercepat iterasi Power Method
In [11]:
# Contoh (Sebelumnya)
import numpy as np
A = np.array([[ 1, 0, 2 ],[ 0, 1, 1 ], [2, 1, 2]])
A = np.linalg.inv(A)
x = np.array([1,1, 1]).transpose()
N = 2
eksak = -1
for i in range(N):
xo = x
x = A.dot(x)
x1 = x
eigen = max(abs(x1))/max(abs(xo))
eigenRayleigh = x.transpose().dot(A).dot(x)/x.transpose().dot(x)
print('EigenValue Menurut metode Rayleigh 2 iterasi =', eigenRayleigh)
print('EA Eigenvalue (Power Method)= ', abs(eigen-eksak))
print('EA Eigenvalue (Rayleigh)= ', abs(eigenRayleigh-eksak))
print('Eigenvector = ', x)
EigenValue Menurut metode Rayleigh 2 iterasi = -0.5555555555555552 EA Eigenvalue (Power Method)= 2.0 EA Eigenvalue (Rayleigh)= 0.44444444444444475 Eigenvector = [ 0.33333333 0.66666667 -0.33333333]
End of Module
...
Jangan lupa kolom komentar bukan untuk berdiskusi/bertanya, untuk keperluan tersebut silahkan klik tautan untuk menuju Forum terkait modul ini.
What's Next?
Referensi:
- Johansson, R. (2018). Numerical Python: Scientific Computing and Data Science Applications with Numpy, SciPy and Matplotlib. Apress.
- John H. Mathews, Numerical Methods for Mathematics, Prentice Hall, 1992 [Refernsi Utama]
- Heath, M. T. (2018). Scientific computing: an introductory survey (Vol. 80). SIAM.
- Conte, S. D., u0026amp; De Boor, C. (2017). Elementary numerical analysis: an algorithmic approach (Vol. 78). SIAM.
Tidak ada komentar:
Posting Komentar
Relevant & Respectful Comments Only.