```python

```


```python
import sympy as sm
i,j,k,l,m,n = sm.symbols('i j k l m n',cls=sm.Idx)
# Minor matrix
M1 = sm.MatrixSymbol('A',m,n)
M2 = sm.MatrixSymbol('B',m,n)
T = sm.Matrix([[1,2,3],[2,2,5],[3,3,2]])
T.det()

A = sm.Matrix(M1.subs([(m,3),(n,3)]))
B = sm.Matrix(M2.subs([(m,2),(n,2)]))

# minor matrix
A.minorMatrix(0,0)
B.minorMatrix(0,0)
A.minor(0,0)
B.minor(0,0)

# cofactor matrix
B.cofactorMatrix()
A.cofactorMatrix()

# aejoin matrix
A.adjugate()
B.adjugate()

# determinat
A.det()
B.det()

# inverse
(1/A.det()*(A*A.cofactorMatrix().T))
(1/A.det())*(A.adjugate())
```




$\displaystyle \left[\begin{matrix}\frac{A_{1, 1} A_{2, 2} - A_{1, 2} A_{2, 1}}{A_{0, 0} A_{1, 1} A_{2, 2} - A_{0, 0} A_{1, 2} A_{2, 1} - A_{0, 1} A_{1, 0} A_{2, 2} + A_{0, 1} A_{1, 2} A_{2, 0} + A_{0, 2} A_{1, 0} A_{2, 1} - A_{0, 2} A_{1, 1} A_{2, 0}} & \frac{- A_{0, 1} A_{2, 2} + A_{0, 2} A_{2, 1}}{A_{0, 0} A_{1, 1} A_{2, 2} - A_{0, 0} A_{1, 2} A_{2, 1} - A_{0, 1} A_{1, 0} A_{2, 2} + A_{0, 1} A_{1, 2} A_{2, 0} + A_{0, 2} A_{1, 0} A_{2, 1} - A_{0, 2} A_{1, 1} A_{2, 0}} & \frac{A_{0, 1} A_{1, 2} - A_{0, 2} A_{1, 1}}{A_{0, 0} A_{1, 1} A_{2, 2} - A_{0, 0} A_{1, 2} A_{2, 1} - A_{0, 1} A_{1, 0} A_{2, 2} + A_{0, 1} A_{1, 2} A_{2, 0} + A_{0, 2} A_{1, 0} A_{2, 1} - A_{0, 2} A_{1, 1} A_{2, 0}}\\\frac{- A_{1, 0} A_{2, 2} + A_{1, 2} A_{2, 0}}{A_{0, 0} A_{1, 1} A_{2, 2} - A_{0, 0} A_{1, 2} A_{2, 1} - A_{0, 1} A_{1, 0} A_{2, 2} + A_{0, 1} A_{1, 2} A_{2, 0} + A_{0, 2} A_{1, 0} A_{2, 1} - A_{0, 2} A_{1, 1} A_{2, 0}} & \frac{A_{0, 0} A_{2, 2} - A_{0, 2} A_{2, 0}}{A_{0, 0} A_{1, 1} A_{2, 2} - A_{0, 0} A_{1, 2} A_{2, 1} - A_{0, 1} A_{1, 0} A_{2, 2} + A_{0, 1} A_{1, 2} A_{2, 0} + A_{0, 2} A_{1, 0} A_{2, 1} - A_{0, 2} A_{1, 1} A_{2, 0}} & \frac{- A_{0, 0} A_{1, 2} + A_{0, 2} A_{1, 0}}{A_{0, 0} A_{1, 1} A_{2, 2} - A_{0, 0} A_{1, 2} A_{2, 1} - A_{0, 1} A_{1, 0} A_{2, 2} + A_{0, 1} A_{1, 2} A_{2, 0} + A_{0, 2} A_{1, 0} A_{2, 1} - A_{0, 2} A_{1, 1} A_{2, 0}}\\\frac{A_{1, 0} A_{2, 1} - A_{1, 1} A_{2, 0}}{A_{0, 0} A_{1, 1} A_{2, 2} - A_{0, 0} A_{1, 2} A_{2, 1} - A_{0, 1} A_{1, 0} A_{2, 2} + A_{0, 1} A_{1, 2} A_{2, 0} + A_{0, 2} A_{1, 0} A_{2, 1} - A_{0, 2} A_{1, 1} A_{2, 0}} & \frac{- A_{0, 0} A_{2, 1} + A_{0, 1} A_{2, 0}}{A_{0, 0} A_{1, 1} A_{2, 2} - A_{0, 0} A_{1, 2} A_{2, 1} - A_{0, 1} A_{1, 0} A_{2, 2} + A_{0, 1} A_{1, 2} A_{2, 0} + A_{0, 2} A_{1, 0} A_{2, 1} - A_{0, 2} A_{1, 1} A_{2, 0}} & \frac{A_{0, 0} A_{1, 1} - A_{0, 1} A_{1, 0}}{A_{0, 0} A_{1, 1} A_{2, 2} - A_{0, 0} A_{1, 2} A_{2, 1} - A_{0, 1} A_{1, 0} A_{2, 2} + A_{0, 1} A_{1, 2} A_{2, 0} + A_{0, 2} A_{1, 0} A_{2, 1} - A_{0, 2} A_{1, 1} A_{2, 0}}\end{matrix}\right]$




```python
A.adjugate()
```




$\displaystyle \left[\begin{matrix}A_{1, 1} A_{2, 2} - A_{1, 2} A_{2, 1} & - A_{0, 1} A_{2, 2} + A_{0, 2} A_{2, 1} & A_{0, 1} A_{1, 2} - A_{0, 2} A_{1, 1}\\- A_{1, 0} A_{2, 2} + A_{1, 2} A_{2, 0} & A_{0, 0} A_{2, 2} - A_{0, 2} A_{2, 0} & - A_{0, 0} A_{1, 2} + A_{0, 2} A_{1, 0}\\A_{1, 0} A_{2, 1} - A_{1, 1} A_{2, 0} & - A_{0, 0} A_{2, 1} + A_{0, 1} A_{2, 0} & A_{0, 0} A_{1, 1} - A_{0, 1} A_{1, 0}\end{matrix}\right]$




```python
sm.Sum(A[i,j]*A[j,k],(j,0,2))
A.cofactor(0,0)
```




$\displaystyle A_{1, 1} A_{2, 2} - A_{1, 2} A_{2, 1}$




```python
# minor (소행열 식)
T.minor(0,1)
```




$\displaystyle -11$




```python
# cofactor (여인수)
T.cofactor(0,1)
```




$\displaystyle 11$




```python
# cofactor matrix(여인수 행열)
T.cofactorMatrix()/T.det()
```




$\displaystyle \left[\begin{matrix}-1 & 1 & 0\\\frac{5}{11} & - \frac{7}{11} & \frac{3}{11}\\\frac{4}{11} & \frac{1}{11} & - \frac{2}{11}\end{matrix}\right]$



# inverse
> ### $
AA^{-1} = I, \quad A^{-1} = B \\
A\vec{x} = \vec{k} 
\\ \Rightarrow (A^{-1}A)\vec{x} = A^{-1}\vec{k}
\\ \therefore \vec{x} = A^{-1}\vec{k}
$
> ### 1차원 : 길이로 나눈다
>> ### $ A = \Big[ a_{11} \Big], x = [x_{11}], k = [k_{11}] 
\\ \quad \because A^{-1} = (a_{11})^{-1} = frac{1}{a_{11}} \\
\mapsto Ax = b \to x_{11} = \frac{k_{11}}{a_{11}}$
> ### 2차원 : ()으로 나눈다
>> ### $
A = \left[ \begin{array}{}
a_{11} & a_{12} \\ a_{21} & a_{22}
\end{array}\right]
= \left[ \begin{array}{}
a & b \\ c &  d
\end{array}\right]
\\ A\vec{x} = \vec{k} \Rightarrow 
\left[ \begin{array}{}
a & b \\ c & d
\end{array}\right]
\left[ \begin{array}{}
x \\ y
\end{array}\right]
=
\left[ \begin{array}{}
u \\ v
\end{array}\right]
$



```python
# adjoin marix(수반행열) = cofactor matrix.transpose()
# ad - bc 
T.adjugate()
a+bi c+di
[ab] [cd] [real imag]
ad - bc 
```




$\displaystyle \left[\begin{matrix}-11 & 5 & 4\\11 & -7 & 1\\0 & 3 & -2\end{matrix}\right]$




```python
T.adjugate()/T.det()
```




$\displaystyle \left[\begin{matrix}-1 & \frac{5}{11} & \frac{4}{11}\\1 & - \frac{7}{11} & \frac{1}{11}\\0 & \frac{3}{11} & - \frac{2}{11}\end{matrix}\right]$




```python
T.det()
```




$\displaystyle 0$




```python

```

9e8f3c2348bce3ac8a22b8bb2f226bce04328614
ipynb
Jupyter Notebook
python/Matrices/adjoint-adjuagate.ipynb
karng87/nasm_game
a97fdb09459efffc561d2122058c348c93f1dc87
MIT
python/Matrices/adjoint-adjuagate.ipynb
karng87/nasm_game
a97fdb09459efffc561d2122058c348c93f1dc87
MIT
python/Matrices/adjoint-adjuagate.ipynb
karng87/nasm_game
a97fdb09459efffc561d2122058c348c93f1dc87
MIT
Qwen/Qwen-72B
1. YES
2. YES