Theorem 2.1. Suppose that $M$ is an $A$-module generated by $n$ elements, and that $\varphi \in \text{Hom}_A(M,M)$; let $I$ be an ideal of $A$ such that $\varphi(M) \subset IM$. Then there is a relation of the form: $$ \varphi^n + a_1 \varphi^{n-1} + \dots + a_{n-1} \varphi + a_n = 0, $$ with $a_i \in I$ for $1 \leq i \leq n$ (where both sides are considered as endomorphisms of $M$).
Proof. Let $M = A w_1 + \dots Aw_n$. By the assumption $\varphi(M) \subset IM$ there exist $a_{ij} \in I$ such that $\varphi(w_i) = \sum_{j=1}^n a_{ij} w_j$. This can be rewritten $\sum_{j=1}^n (\varphi \delta_{ij} - a_{ij}) w_j = 0, \ i=1..n$. The coefficients of this systme of linear equations can be viewed as a square matrix $(\varphi \delta_{ij} - a_{ij})$ of elements of $A'[\varphi]$, the commutative subring of the endomorphisms ring $E = \text{Hom}_A(M,M)$ generated by the image $A'$ of $A$ under $a \mapsto (x \mapsto ax)$, together with $\varphi$. Let $b_{ij}$ denote its $(i,j)$th cofactor, and $d$ its determinant. Multiply the equation through by $b_{ik}$ and sum over $i$: $$ \sum_{i=1}^n b_{ik}(\sum_{j=1}^n (\varphi \delta_{ij} - a_{ij}) w_j ) = 0 $$
For example, if $B = (\varphi \delta_{ij} - a_{ij})$ is a $3 \times 3$ matrix we have:
$$
B = -\begin{pmatrix}
a_{11} - \varphi & a_{12} & a_{13} \\
a_{21} & a_{22} -\varphi & a_{23} \\
a_{31} & a_{32} & a_{33} - \varphi
\end{pmatrix}
$$
Then for example at $i = 1$ we have the following cofactors: $$ b_{11} = -\det\begin{pmatrix} a_{22} - \varphi & a_{23} \\ a_{32} & a_{33} - \varphi \end{pmatrix}, b_{12} = \det\begin{pmatrix} a_{21} & a_{23} \\ a_{31} & a_{33} - \varphi \end{pmatrix}, b_{13} = -\det\begin{pmatrix} a_{21} & a_{22} - \varphi \\ a_{31} & a_{32} \end{pmatrix} $$ Then the sum:
$$ \sum_{i=1}^n b_{ik} \sum_{j=1}^n B_{ij} w_j = 0 \iff \\ \sum_{j=1}^n \sum_{i=1}^n b_{ik} B_{ij} w_j = 0 \iff \\ \sum_{j=1}^n (\det B) w_j = 0 \iff \\ (\det B) \sum_{j=1}^n w_j = 0 \ \ \textbf{( wrong here )} $$
I believe it should be $(\det B) w_j = 0, \ \forall j=1..n$ instead, as in this lecture video.
I followed the recipe to multiply by $b_{ik}$ and sum over $i$ and I get the wrong answer. Please help me find where I've made a mistake.