Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to expand or solve an equation that contains matrices for a certain matrix, but it is not working:

$Assumptions = 
  {Element[X, Vectors[n]], Element[Zu, Vectors[n]], 
   Element[Fu, DiagonalMatrix[n]], Element[Y, Matrices[{n, n}, Reals]]};

Solve[Y.Fu.(Zu + X.Y) + (Zu + X.Y).Fu.Y + 2 λ X == 0, X]

ExpandAll[Y.Fu.(Zu + X.Y) + (Zu + X.Y).Fu.Y + 2 λ X]

Simplify[Y.Fu.(Zu + X.Y) + (Zu + X.Y).Fu.Y + 2 λ X]

None of the above inputs works. Am I doing something wrong or is it that Mathematica cannot solve for matrix equation symbolically?

share|improve this question
Anyway, Mathematica still lacks proper matrix symbolic manipulation, except for some basic stuff. You, me and many others are hoping it comes soon – Rojo Jan 30 '14 at 2:28
up vote 2 down vote accepted

Here is one way to proceed:

n = 3;
xvec = Array[x, n];
zvec = Array[z, n];
ymat = Array[y, {n, n}];
fumat = DiagonalMatrix[Array[fu, n]];

Solve[ymat.fumat.(zvec + xvec.ymat) + (zvec + xvec.ymat).fumat.ymat + 2 lam*xvec == 0, xvec]

The output is a fully symbolic answer for the terms of xvec, albeit not in as compact a form as one might wish.

The Assumptions command does not work as you wish. In particular, assumptions are not carried over from the first line to the later lines of your code. You can see this by looking at the FullForm of your variables.

share|improve this answer
Thank you very much I had already seen a similar answer, but I was looking if there is any way to gather them in matrices again? – Yannis Assael Jan 30 '14 at 2:18
I guess the only hope would be to try something in the Tensor commands: – bill s Jan 30 '14 at 2:30
Thanks but it uses assumptions I though the were the right case. Could you please give me an example of how this would work in my case or a similar one? – Yannis Assael Jan 30 '14 at 2:55
The difficulty is that there is no TensorSolve and regular commands (like Solve) don't honor the tensor assumptions. I have never used these commands. Maybe someone else has figured it out. – bill s Jan 30 '14 at 3:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.