Skip to content

Instantly share code, notes, and snippets.

@kyoro1
Created November 11, 2015 12:05
Show Gist options
  • Save kyoro1/dc2b5113a603f512e1a8 to your computer and use it in GitHub Desktop.
Save kyoro1/dc2b5113a603f512e1a8 to your computer and use it in GitHub Desktop.
PythonでHermite行列とその固有値を求めてみる ref: http://qiita.com/kyoro1/items/8d324ea9f44a8d9e756d
A^{\dagger}=A
A=\left(
\begin{matrix}
1 & 2+\sqrt{-1} \\
2-\sqrt{-1} & 4
\end{matrix}
\right), B:=A^{\dagger}
> import numpy as np
> A = np.array([[1,2+1j],[2-1j,4]])
> B = np.conjugate(A.T) #転置とって、複素共役!
> A
array([[ 1.+0.j, 2.+1.j],
[ 2.-1.j, 4.+0.j]])
> B
array([[ 1.-0.j, 2.+1.j],
[ 2.-1.j, 4.-0.j]])
> A-B
array([[ 0.+0.j, 0.+0.j],
[ 0.+0.j, 0.+0.j]]) #OK!ま、見りゃわかるか、って感じカモですが、、、
\begin{eqnarray}
\det(\lambda I_2-A) &=& (\lambda-1)(\lambda-4)-(2+\sqrt{-1})(2-\sqrt{-1})\\
&=& \lambda^2-5\lambda+4-5 \\
&=& \lambda^2-5\lambda-1
\end{eqnarray}
\lambda = \frac{5\pm\sqrt{25-4\times(-1)}}{2}=\frac{5\pm\sqrt{29}}{2}
> eigen_value, eigen_vector = np.linalg.eig(A)
> eigen_value
array([-0.1925824 -3.07382855e-18j, 5.1925824 -2.18970776e-16j])
> (5-np.sqrt(29))/2
-0.19258240356725187
> (5+np.sqrt(29))/2
5.1925824035672523
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment