# Given small symmetric matrix A, calculate cofactor for large matrix B made using A.

$$A = \begin{bmatrix} a_1 & a_2 & a_3\\ a_2 & a_4 & a_5\\ a_3 & a_5 & a_6 \end{bmatrix}$$ $$B = \begin{bmatrix} -1 & -1 & -1\\ -1 & -1 & -1\\ -1 & -1 & -1 \end{bmatrix}$$ how to calculate cofactor of matrix $$C= \begin{bmatrix} A & B & B\\ B & A & B\\ B & B & A \end{bmatrix}$$ size of $$A$$ is $$N \times N$$, $$A$$ is symmetric matrix,
matrix $$A$$ is repeated in matrix $$C$$,$$K$$ times only on diagonal of $$C$$.
E.g.,$$A= \begin{bmatrix} 2 & 3 \\ 3 & 8 \\ \end{bmatrix}$$ if $$k=2$$ , then $$C = \begin{bmatrix} 2 & 3 & -1 & -1 \\ 3 & 8 & -1 & -1\\ -1 & -1 & 2 & 3\\ -1 & -1 & 3 & 8\\ \end{bmatrix}$$ how to calculate cofactor of $$C_{11}$$
I tried to solve this question using diagonal method of calculating determinants, i could find the repeating pattern but could not convert it into equation, please help me in converting into algebraic equation.

• Isn't this the same as another question that was posted 7 hours ago? If you are the asker of these two questions, please delete one of them. Anyway, you can find the cofactors using Sherman-Morrison formula. – user1551 Aug 8 '19 at 18:12
• I'm voting to close this question as off-topic because this question is a duplicate of math.stackexchange.com/questions/3317108/… by the same author. – ja72 Aug 8 '19 at 18:30
• sry i dont know about same question asked before, it is just coincidence, i will delete the question – user8794581 Aug 8 '19 at 18:33
• @user1551 could you please explain a little bit more, i read the wiki but could not get proper insight of the question – user8794581 Aug 8 '19 at 18:35
• @user8794581 Write your $C=\operatorname{diag}(A-B,A-B,A-B)-ee^T$ where $e=(1,\ldots,1)^T\in\mathbb R^9$. Then you may use Sherman-Morrison formula to find $C^{-1}$. Multiply it by $\det(C)$, you get $\operatorname{adj}(C)$. Taking transpose, you get the cofactor matrix. – user1551 Aug 8 '19 at 18:40

This is a rank-one update of $$\operatorname{diag}(A-B,\,\ldots,\,A-B)$$. You can use Sherman-Morrison formula and the determinant formula for rank-one update to deal with it. With patience, you should get $$\operatorname{adj}(C) =\det(Z)^{K-2}\pmatrix{ X+Y&Y&\cdots&Y\\ Y&X+Y&\ddots&\vdots\\ \vdots&\ddots&\ddots&Y\\ Y&\cdots&Y&X+Y}$$ when $$K\ge2$$, where \begin{align} Z&=A-B,\\ X&=\left(\det(Z)-Ke^T\operatorname{adj}(Z)e\right)\operatorname{adj}(Z),\\ Y&=\operatorname{adj}(Z)E\operatorname{adj}(Z) \end{align} with $$e=(1,\ldots,1)^T\in\mathbb R^N$$ being the all-one vector and $$E=ee^T$$ being the $$N\times N$$ all-one matrix. Now take the transpose of $$\operatorname{adj}(C)$$ to get the cofactor matrix.
• so in my case if i want $C_{11}$, so my answer is det(z) ^(k-2) *( $X_{11}$ + $Y_{11}$), am i right – user8794581 Aug 9 '19 at 2:21
• @user8794581 This answer works for any square matrix $A$. If your $A$ is symmetric, of course there is no need to take transpose to get the cofactors. And yes, $C_{11}=\det(Z)^{K-2}(X_{11}+Y_{11})$. By the way, $B=-E$. – user1551 Aug 9 '19 at 8:45
• how to modify this equation to get only $X_{11}$ and $Y_{11}$,as matrix may contain large elements,so i could work under modulo prime p.also which method can be used to find adj(Z) , i tried gaussian elimination but it requires numerical values,so any fast algorithm in O(n^4) which is independent of values and only requires computation on indices. – user8794581 Aug 9 '19 at 17:55