0

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

lotus2019
  • 2,091
  • 5
  • 10
  • 2
    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. – userrandrand Oct 03 '22 at 17:02
  • Thank you for your suggestion. Could you take a look at my EDIT? @userrandrand – lotus2019 Oct 04 '22 at 15:21
  • 1
    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. – user293787 Oct 04 '22 at 16:32
  • I think one of the issues here is that the nature of A, whether it be a number, function or matrix does not really matter in the example provided. In the link you gave the question was interesting because there were two matrices A and B that do not necessarily commute so A could not be treated as an ordinary variable. But if there is only A then the formula is the same as if A was a variable on the real line. – userrandrand Oct 04 '22 at 17:02
  • 1
    I don't use this package, but why not try things like /.a ** a ** a ** a ** a ->0 – Lacia Oct 04 '22 at 17:08
  • 1
    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. – userrandrand Oct 04 '22 at 17:18
  • @user293787 I think asking "How to derive this with the help of Mathematica" is definitely on topic, but what's confusing and frustrating (at least for me) is, OP keeps asking the same class of question i.e. deduction related to symbolic matrix (to be precise, mainly abstract matrix) again and again while seems to learn little from the answers (s)he obtains. – xzczd Oct 05 '22 at 03:13
  • I don't want to be rude, but with all due respect, it seems to me that OP is asking questions just for self-deception. ("Ah, I've posted another question, so I've made some effort. ") But keeping asking question without enough effort to understand the obtained answers won't help, especially for questions related to abstract matrix, because it's quite clear that the built-in support for abstract matrix in Mathematica is rather incomplete (at least for now), so advanced technique is almost always necessary to achieve what you want. – xzczd Oct 05 '22 at 03:29
  • 1
    @userrandrand The Null is caused by the << NC` at the end of NCSeries[…] line, obviously a simple mistake. – xzczd Oct 05 '22 at 05:48
  • Why are you so angry? Or are you used to blaming others? Most of the people who come to this forum to ask questions are not "experts" like you. For them, MMA may at best be a mathematical tool to help them solve mathematical problems encountered in physics or engineering. And most of them may not have much time and energy to study MMA code. Or maybe not smart enough to understand and write code, or even not interested in code. But you can't blame and ridicule these people for these reasons. So please give more tolerance and understanding rather than blame.@xzczd – lotus2019 Oct 05 '22 at 12:28
  • I'm not blaming, I'm admonishing. No one is born to be expert, not everybody is quick learner, but so far I see little effort from you learning the core language. Perhaps what you're thinking is, "Oh, I again obtain answers I can't understand. But I don't have time and energy to look into it! Let me ask another similar question, perhaps this time I'll obtain a simpler answer! " Then here's my closing advice: good understanding for core language is necessary for any serious work, persisting in resolving problem only with built-in super functions is impratical and a waste of time and energy. – xzczd Oct 05 '22 at 15:50
  • Anyway, it's your choice. And I won't vote to close or downvote as long as the questions are on-topic. – xzczd Oct 05 '22 at 15:51
  • Then I also admonish you not to judge others' intentions without knowing the situation. People who ask questions here are not all for learning the core language of MMA. The goal of learning MMA varies from person to person. Many people are only familiar with some MMA functions for routine use, which can solve common mathematical problems. The next time they encounter the same problems, they can directly copy the MMA code. And you say "I don't want to be rude,...". With all due respect, it is rude to make uncomfortable comments. You should learn how to get along well with others. @xzczd – lotus2019 Oct 06 '22 at 01:04
  • Thanks for your suggestion, but I'm not interested in getting along well with people coming here just for copying codes, just as you're not interested in learning the core language. – xzczd Oct 06 '22 at 04:13
  • I also don't want you to comment on my question and say something irrelevant and uncomfortable. @xzczd – lotus2019 Oct 06 '22 at 04:38
  • If you think my comments are against the rule of site, feel free to contact the moderator. – xzczd Oct 06 '22 at 04:40
  • I have no interest in what you said. Bye. @xzczd – lotus2019 Oct 06 '22 at 04:41

1 Answers1

1

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

lotus2019
  • 2,091
  • 5
  • 10
  • 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 ? – userrandrand Oct 05 '22 at 16:54
  • Yes, I want to make the code more universal. @userrandrand – lotus2019 Oct 06 '22 at 01:09
  • 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 – userrandrand Oct 06 '22 at 04:44