0
$\begingroup$

Let A is a nilpotent matrix.

$\boldsymbol{A}^l=\mathbf{0}$

To derive

$(\boldsymbol{I}-\boldsymbol{A})^{-1}=\boldsymbol{?}$

The answer in the textbook is

$(\boldsymbol{I}-\boldsymbol{A})^{-1}=\boldsymbol{I}+\boldsymbol{A}+\boldsymbol{A}^2+\cdots+\boldsymbol{A}^{l-1}$

Here's my code:

Let l=5, i.e, $\boldsymbol{A}^5=\mathbf{0}$

Clear["Global`*"];
Idm = IdentityMatrix[k];
t = Inverse[Idm - mA];
m0 = 0;
$Assumptions = mA \[Element] Matrices[{k, k}, Reals];
$Assumptions = MatrixPower[mA, 5] == m0;
TensorExpand[t]

MatrixPower[-mA + IdentityMatrix[k], -1]

or k=3, l=5,

Clear["Global`*"];
Idm = IdentityMatrix[3];
t = Inverse[Idm - mA];
m0 = ConstantArray[0, {3, 3}];
$Assumptions = mA \[Element] Matrices[{3, 3}, Reals];
$Assumptions = MatrixPower[mA, 5] == m0;
TensorExpand[t]

$\left\{\left\{\frac{1}{1-3 m A}-\frac{2 m A}{1-3 m A}, \frac{m A}{1-3 m A}, \frac{m A}{1-3 m A}\right\},\left\{\frac{m A}{1-3 m A}, \frac{1}{1-3 m A}-\frac{2 m A}{1-3 m A}, \frac{m A}{1-3 m A}\right\},\left\{\frac{m A}{1-3 m A}, \frac{m A}{1-3 m A}, \frac{1}{1-3 m A}-\frac{m A}{1-3 m A}\right\}\right\}$

How to 'Series expand' abstract matrix expression by MMA code?

In this question, i.e $(\boldsymbol{I}-\boldsymbol{A})^{-1}=\boldsymbol{I}+\boldsymbol{A}+\boldsymbol{A}^2+\cdots+\boldsymbol{A}^{l-1}$

EDIT

I used the NCAlgebra program to write the code (Refer to https://mathematica.stackexchange.com/a/191397/69835), which is very close to the answer I want. How to simplify the final result based on the assumptions given in the question?

Let l=5, i.e, $\boldsymbol{A}^5=\mathbf{0}$

Clear["Global`*"];
<< NC`
<< NCAlgebra`


NCSeries[f_, {x_, x0_, n_}] := Block[{h}, SetNonCommutative[h];
   Plus @@ (Table[1/i!, {i, 0, n}]*
        NestList[NCDirectionalD[#, {x, h}] &, f, n]) /. x -> x0 /. 
    h -> x] 

f = inv[1 - a];

FullSimplify[NCSeries[f, {a, 0, 7}], 
 Assumptions -> a ** a ** a ** a ** a == 0]

1 + a + a ** a + a ** a ** a + a ** a ** a ** a + a ** a ** a ** a ** a ** a + a ** a ** a ** a ** a ** a ** a

The result I hope to get is

1 + a + a ** a + a ** a ** a + a ** a ** a ** a

$\endgroup$
17
  • 2
    $\begingroup$ No matter the object, you can always do a series expansion by multiplying the object by a variable like t, expanding in t and then replacing t by 1. The expansion in terms of t can either be done using Series or by taking derivatives using the formula for the coefficients of a Taylor expansion. The question is how do you want to encode the object. If everything is purely symbolic then you could just code A like any other variable and maybe use NonCommutativeMultiply if there are matrices that do not commute with A. From the abstract point of view, all that matters is the algebra. $\endgroup$ Oct 3, 2022 at 17:02
  • 1
    $\begingroup$ Dear OP, I think using Mathematica to produce a formal result that a human can easily derive by hand is kind of useless. Say somebody provides an implementation, how are we going to decide if it is a useful and interesting implementation, if we already know the answer? I therefore voted to close the question as needing clarity, because I do not see a clear question for which we do not already know the answer. $\endgroup$
    – user293787
    Oct 4, 2022 at 16:32
  • 1
    $\begingroup$ I don't use this package, but why not try things like /.a ** a ** a ** a ** a ->0 $\endgroup$
    – Lacia
    Oct 4, 2022 at 17:08
  • 1
    $\begingroup$ I did not try your code (because I do not want to try understanding those packages at the moment) and I do not know why there is a Null in the first output. The NonCommutativeMultiply is unnecessary in this case because A commutes with A. To answer you last question you can use 1 + a + a ** a + a ** a ** a + a ** a ** a ** a + a ** a ** a ** a ** a ** a + a ** a ** a ** a ** a ** a ** a /. NonCommutativeMultiply[p : a ..] /; Length[List@p] > 4 -> 0 where p can be replaced by another name. That removes all terms that have more than 4 a's in the multiplication. $\endgroup$ Oct 4, 2022 at 17:18
  • 1
    $\begingroup$ @userrandrand The Null is caused by the << NC` at the end of NCSeries[…] line, obviously a simple mistake. $\endgroup$
    – xzczd
    Oct 5, 2022 at 5:48

1 Answer 1

1
$\begingroup$

We can do computation of abstract matrix using an external package called NCAlgebra.

http://math.ucsd.edu/~ncalg/

The Mathematica substitute commands, e.g. ReplaceAll (/.) and ReplaceRepeated (//.), are not reliable in NCAlgebra, so we must use NC versions of these commands, i.e, NCReplaceAll:

Let l=5, i.e, $\boldsymbol{A}^5=\mathbf{0}$

Clear["Global`*"];
<< NC`
<< NCAlgebra`

NCSeries[f_, {x_, x0_, n_}] := Block[{h}, SetNonCommutative[h];
  Plus @@ (Table[1/i!, {i, 0, n}]*
       NestList[NCDirectionalD[#, {x, h}] &, f, n]) /. x -> x0 /. 
   h -> x]

f = inv[1 - a];

NCReplaceAll[NCSeries[f, {a, 0, 10}], a ** a ** a ** a ** a -> 0]

1 + a + a ** a + a ** a ** a + a ** a ** a ** a

Finally, the NC results can be converted to MMA results:

% /. {NonCommutativeMultiply -> Dot}

1 + a + a . a + a . a . a + a . a . a . a

$\endgroup$
3
  • $\begingroup$ Sorry but I still not understand why something like Normal@Series[(1 - a)^(-1), {a, 0, 4}] /. a^j_ :> Dot @@ ConstantArray[a, j] is not enough for your purpose. Are you going to consider more complicated cases with two matrices a and b after ? $\endgroup$ Oct 5, 2022 at 16:54
  • $\begingroup$ Yes, I want to make the code more universal. @userrandrand $\endgroup$
    – lotus2019
    Oct 6, 2022 at 1:09
  • $\begingroup$ I see. I ended up searching around Mathematica stack exchange for methods to do Matrix calculus and in particular Matrix derivatives. I did not find a general purpose package but I compiled all the methods I found in this answer $\endgroup$ Oct 6, 2022 at 4:44

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.