Suppose we want to solve a linear system like

$$\left\lbrack\begin{array}{cc}M& S\\ -S^\mathrm{T}&0 \end{array} \right\rbrack \left\lbrack \begin{array}{c} x\\y\end{array}\right\rbrack = \left\lbrack\begin{array}{c} f\\g \end{array} \right\rbrack$$ for $x$ and $y$. Where $M\in \mathbb{R}^{n\times n}$ is symmetric positive definite, $S\in \mathbb{R}^{n\times m}$ is full rank and $x,y,f,g$ are all vectors of compatible size. It is straightforward to find the solution of this system by hand as

$$y =(S^\mathrm{T} M^{-1} S)^{-1}(S^\mathrm{T} M^{-1} f + g)$$ \begin{align*} x=& M^{-1}(f-S y)\\ =& (I- M^{-1}(S^\mathrm{T} M^{-1} S)^{-1} S^{\mathrm{T}})M^{-1}f\\ &-M^{-1}(S^\mathrm{T} M^{-1} S)^{-1} g. \end{align*}

Is there a way I can make Mathematica do this? I ask because I would like closed forms of more complicated block matrix systems.

  • 1
    $\begingroup$ NCAlgebra might be what you are looking for — see here . $\endgroup$ Commented Oct 7, 2015 at 16:36
  • $\begingroup$ @StephenLuttrell please, show an example $\endgroup$
    – ayr
    Commented Sep 5, 2022 at 14:31

1 Answer 1


NCAlgebra has been updated since I wrote my comment above in 2015. I have had a look at the current documentation at NCAlgebra Documentation, and in the “Most Basic Commands” section there is NCMatrixDecompositions, and under that there are NCUpperTriangularSolve and NCLowerTriangularSolve. I have not actually tried these out myself, but their names strongly suggest that they would solve the above symbolic matrix equation.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.