# Solving linear system with non-commuting coeffcients

Is there a way to solve a linear system of equations where the coefficients do not commute? (Warning: my two-days of looking so far suggest this may be an unsolved math problem, but I figured I could start here.)

For a minimal-working example:

$$\begin{array}{rcl} 0 & = & M_1 x_1 + M_2 x_2 + M_3 x_3 , \\ 0 & = & M_4 x_1 + M_5 x_2 + M_6 x_3 \end{array}$$ where $$M_i M_j \ne M_j M_i.$$ Is there an algorithmic way to solve this system?

In this case, a solution by hand is straightforward: $x_3 = f(M, M^{-1}) x_1$, and $x_2 = g(M, M^{-1}) x_1$, where $f$ and $g$ are some products and sums of the $M$'s and their inverses.

Can Mathematica do this for more complicated systems?

I've looked a little bit at the Groebner basis features of NCAlgebra (also mentioned in this question), but that doesn't look like it can go the whole way.

It looks to me like mathematicians have only solved such expressions when the $M$'s are the same, maybe? See this paper.

I have in mind specifically the case where the $M's$ are not matrices but rather some arbitrary operators acting on the $x$'s. In particular, in the equations I'm dealing with the $M$'s represent some relabeling of the (suppressed) arguments of the $x$'s. Something like $M_1 x_1 \equiv M_1[x_1({1,2,3,4})] = x_1[{3,1,2,4}]$; so the equations I care about are actually functional equations relating functions with different arguments.

Edit:

Including MWE of using NCAlgebra:

(* Set up equations *)
(* I used 'o' here instead of 'M'*)
(* and 'f' instead of 'x' *)
eqns = {
o ** f + o ** f + o ** f
,
o ** f + o ** f + o ** f
};
(* Useful for defining variables *)
ClearAll[or, os, fs]
or = Range[1, 6];
os = Join[o /@ or, oi /@ or];
fs = f /@ Range[1, 3];
(* Defining the variables *)
vars = Join[os, fs];
(* For the NCAlgebra package *)
SetNonCommutative[vars];
SetMonomialOrder[vars];
(* Defining the operator inverse equations *)
invEqns = Flatten[{o[#] ** oi[#] - 1, oi[#] ** o[#] - 1} & /@ or];
(* Find Groebner basis *)
NCMakeGB[Join[eqns, invEqns], 1]
(*
{o ** f + o ** f + o ** f,
o ** f + o ** f + o ** f, -1 + o ** oi, -1 +
oi ** o, -1 + o ** oi, -1 + oi ** o, -1 +
o ** oi, -1 + oi ** o, -1 + o ** oi, -1 +
oi ** o, -1 + o ** oi, -1 + oi ** o, -1 +
o ** oi, -1 + oi ** o,
f + oi ** o ** f + oi ** o ** f,
f + oi ** o ** f + oi ** o ** f}
*)


So the last line of the output gets f in the form I want, but it's not clear how to proceed from there.

• I think this is a math problem and not a Mathematica problem. – J. M.'s ennui Jul 19 '16 at 7:58
• That's totally possible. I've updated with the NCAlgebra (non)MWE. If it's still too math-y, I'll ask there. – jjstankowicz Jul 19 '16 at 8:02
• Is there a reason normal Gaussian elimination would not work? e.g. reduce the equations to $0 = x_1 + M_1^{-1}M_2x_2 + M_1^{-1}M_3x_3 = x_1 + M_4^{-1}M_5x_2 + M_4^{-1}M_6x_3$ and then cancelling $x_1$, and then repeating. Always multiply by the inverse of the first term in each equation, and remove it. This is probably the process you were describing doing "by hand", but I believe it is the same as standard elimination (and back-substitution, after). – Alex Meiburg Jul 19 '16 at 8:19
• @AlexMelberg Your method is good of course when it applies, but it assumes the operators have (one sided) inverses and that need not be the case in general. – Daniel Lichtblau Jul 19 '16 at 19:04

The reason why the Groebner basis calculation does not produce the answer you are seeking is because you need an ever growing set of assumptions on what can be inverted and not only the invertibility of the o's in order to move forward.

If you are fine with assuming all letters are invertible than you could try a symbolic matrix factorization. Using NCAlgebra version 5.0.0 you can set up the problem as follows:

M = {{o, o, o}, {o, o, o}} /. f_[i_] -> Subscript[f, i]
x = {f, f, f} /. f_[i_] -> Subscript[f, i]


The rule in the end is to work with Subscripts, which automatically treat all lowercase o's and f's as noncommutative. The problem you're trying to solve is the linear algebra problem $M x = 0$, a problem that can be solved by factoring $M$. A factorization suitable for symbolic computation is the $LU$ decomposition with complete pivoting:

{lu, p, q, rank} = NCLUDecompositionWithCompletePivoting[M];
{l, u} = GetLUMatrices[lu];


from which a solution can be calculated as:

sol = Thread[x[[q[[1 ;; rank]]]] -> -NCDot[NCInverse[u[[All, 1 ;; rank]]], u[[All, rank + 1 ;;]], x[[q[[rank + 1 ;;]]]]]]


The solution obtained this way requires the assumption that $o_5 - o_4 o_1^{-1} o_2$ is invertible, which was never part of the input during the Groebner basis calculation.