<jupyter_start><jupyter_text>고윳값 분해<jupyter_code># 연습문제 3.3.1
B = np.array([[2,3],[2,1]])

lambda1 = 4
# v1 = np.array([3/np.sqrt(13), 2/np.sqrt(13)])
v1 = np.array([[3],[2]])

lambda2 = -1
v2 = np.array([-1/np.sqrt(2), 1/np.sqrt(2)])
# v2 = np.array([[-1],[1]])

# print(B @ v1, "\n", lambda1 * v1)
print(np.array_equal(B@v1, lambda1*v1))
print(np.array_equal(B@v2, lambda2*v2))<jupyter_output>True
True<jupyter_text>Numpy를 사용한 고유분해<jupyter_code># eig()

A = np.array([[1,-2],[2,-3]])
w1, v1 = np.linalg.eig(A)
print(w1,"\n", v1)
B = np.array([[2,3],[2,1]])
w2, v2 = np.linalg.eig(B)
print(w2, "\n", v2)
C = np.array([[0,-1],[1,0]])
w3, v3 = np.linalg.eig(C)
print(w3, "\n" ,v3) #복소수 계산
D = np.array([[2,1],[1,2]])
w4, v4 = np.linalg.eig(D)
print(w4,"\n",v4)
E = np.array([[2,3],[2,1]])
w5, v5 = np.linalg.eig(E)
print(w5,"\n",v5)
F = np.array([[1,1],[0,1]])
w6, v6 = np.linalg.eig(F)
print(w6,"\n",v6)<jupyter_output>[1. 1.] 
 [[ 1.00000000e+00 -1.00000000e+00]
 [ 0.00000000e+00  2.22044605e-16]]<jupyter_text>대각화<jupyter_code>v2
v2_inv = np.linalg.inv(v2)
v2_inv
v2 @ np.diag(w2) @ v2_inv
ww,VV = np.linalg.eig(np.array([[2,3],[2,1]]))
VV_inv = np.linalg.inv(VV)
VV_inv
vv @ np.diag(ww) @ vv_inv
bb, vv2 = np.linalg.eig(np.array([[1,1],[0,1]]))
print(vv2)
vv2_inv = np.linalg.inv(vv2)
vv2_inv
vv2 @ np.diag(bb) @ vv2_inv
print(np.linalg.matrix_rank(vv2))
W, S = np.linalg.eig(np.array([[2,5],[3,4]]))
print(S)
S_inv = np.linalg.inv(S)
print(S_inv)
print(np.diag(W))
print(S @ np.diag(W) @ S_inv)
print(np.linalg.matrix_rank(S))<jupyter_output>[[-0.85749293 -0.70710678]
 [ 0.51449576 -0.70710678]]
[[-0.72886899  0.72886899]
 [-0.53033009 -0.88388348]]
[[-1.  0.]
 [ 0.  7.]]
[[2. 5.]
 [3. 4.]]
2
{'fraction_non_alphanumeric': 0.27588235294117647, 'fraction_numerical': 0.1411764705882353, 'mean_word_length': 4.7272727272727275, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 3, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '331368', 'license': 'MIT', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1019, 'n_words': 134, 'path': 'MATH/03_eigenvalue_decomposition.ipynb', 'repo_name': 'CATERINA-SEUL/Data-Science-School', 'size': '1700'}