# NCAlgebra to Mathematica Standard form

Is there any way to convert the output of NCAlgebra to standard Mathematica form?

For example

<< NC

<< NCAlgebra

MatrixForm[m = {{a, b, c}, {d, e, f}, {g, h, i}}];
NCInverse[m][[1, 1]]


The output is

    a^(-1) ** (1 - b ** (e - d ** a^(-1) ** b)^(-1) ** (-d ** a^(-1) - (f - d ** a^(-1) ** c) ** (i - g ** a^(-1) ** c - (h - g ** a^(-1) ** b) ** (e - d ** a^(-1) ** b)^(-1) ** (f - d ** a^(-1) ** c))^(-1) ** (-g ** a^(-1) + (h - g ** a^(-1) ** b) ** (e - d ** a^(-1) ** b)^(-1) ** d ** a^(-1))) - c ** (i - g ** a^(-1) ** c - (h - g ** a^(-1) ** b) ** (e - d ** a^(-1) ** b)^(-1) ** (f - d ** a^(-1) ** c))^(-1) ** (-g ** a^(-1) + (h - g ** a^(-1) ** b) ** (e - d ** a^(-1) ** b)^(-1) ** d ** a^(-1)))


I want to change the output to standard form of Mathematica like

Inverse[a].(1-b.Inverse[e-d.Inverse[a].b]...

• This is tricky, especially if you want it to work with letters that will be substituted by matrices. The main trouble is that things like a + b ** c will be expanded incorrectly: b**c will be added entrywise to the entries a. We have an internal routine for doing that in NCAlgebra but I never thought it was good enough to be made public. Dec 11, 2018 at 6:54

While I am not familiar with NCAlgebra, the following seems to work:

result /. {inv -> Inverse, NonCommutativeMultiply -> Dot}
(* Inverse[
a].(1 - b.Inverse[
e - d.Inverse[
a].b].(-d.Inverse[a] - (f - d.Inverse[a].c).Inverse[
i - g.Inverse[a].c - (h - g.Inverse[a].b).Inverse[
e - d.Inverse[a].b].(f - d.Inverse[a].c)].(-g.Inverse[
a] + (h - g.Inverse[a].b).Inverse[
e - d.Inverse[a].b].d.Inverse[a])) -
c.Inverse[
i - g.Inverse[a].c - (h - g.Inverse[a].b).Inverse[
e - d.Inverse[a].b].(f - d.Inverse[a].c)].(-g.Inverse[
a] + (h - g.Inverse[a].b).Inverse[
e - d.Inverse[a].b].d.Inverse[a])) *)


Note that NCAlgebra produces inv[a] when inverting a. This is formatted as $a^{-1}$, but the underlying structure is just inv. You can see this using FullForm.