5
$\begingroup$

I don't know Mathematica very well, I have an equation involving matrices of the following form: given two 5ドル\times5$ matrices $A,B$ where $B$ is nilpotent we want to find a matrix $X$ such that

k X + B.X-X.B + A = 0

for an integer $k$.

Is there a command solving such an equation? I tried with Solve and LinearSolve, but it does not work.

asked Aug 6 at 9:16
$\endgroup$
3
  • 2
    $\begingroup$ What operation is [B,X]? What does not work? $\endgroup$ Commented Aug 6 at 10:22
  • 1
    $\begingroup$ I guess [B,X] is supposed to be the commutator bracket. In Mathematica code that would be B.X - X.B. $\endgroup$ Commented Aug 6 at 11:01
  • $\begingroup$ yes exactly, it is the commutator. I have edited the question to clarify the notation $\endgroup$ Commented Aug 6 at 12:20

3 Answers 3

6
$\begingroup$

You can use LyapunovSolve which solves a.x + x.b = c:

SeedRandom[1] ;
A = RandomReal[{-1, 1}, {5, 5}];
B = RandomReal[{-1, 1}, {5, 5}];
k = RandomReal[{-1, 1}];
a = k * IdentityMatrix[5] + B ;
b = - B ;
c = - A ;
LyapunovSolve[a,b,c]
answered Aug 6 at 15:23
$\endgroup$
1
  • 3
    $\begingroup$ Awesome. This should be the accepted answer. $\endgroup$ Commented Aug 6 at 16:01
6
$\begingroup$

This is a linear equation in X, so you can solve it, in principle by writing out the system matrix and the right-hand side like this:

A = RandomReal[{-1, 1}, {5, 5}];
B = RandomReal[{-1, 1}, {5, 5}];
k = RandomReal[{-1, 1}, {5, 5}];
X = Array[x, {5, 5}];
matrix = D[Flatten[k X + B . X - X . B], {Flatten[X], 1}];
rhs = Flatten[-A];
solution = ArrayReshape[LinearSolve[matrix, rhs], {5, 5}]

Of course, there might be way more clever solutions to this. E.g., we have not exploited, yet, that B is nilpotent. Probably you are supposed to multiply with B a couple of times from the left and from the right so that several terms cancel and the remainder can be used to eliminate some variables in the matrix X. Maybe the Jordan decomposition might be helpful.

answered Aug 6 at 11:06
$\endgroup$
2
  • 1
    $\begingroup$ nice thanks, I guess that the key is to use the flatten/arrayreshape. $\endgroup$ Commented Aug 6 at 12:20
  • $\begingroup$ Yeah, Flatten reinterprets the 5ドル \times 5$-matrices as 25ドル$-vectors, D "linearizes" the system, and ArrayReshape undoes what Flatten did. $\endgroup$ Commented Aug 6 at 15:58
3
$\begingroup$

Without using any matrix theory just straightly writing an equation.

A = RandomInteger[{-10, 10}, {5, 5}];
B = RandomInteger[{-10, 10}, {5, 5}];
k = RandomInteger[{-10, 10}];
(* solution *)
# /. Solve[k # + B . # - # . B + A == 0] &@Array[x, Dimensions[A]]
(* verification *)
k # + B . # - # . B + A & /@ %

{{{0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, 
{0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}}}
answered Aug 6 at 14:33
$\endgroup$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.