Is it possible to tell Mathematica to assume a variable is a matrix, analogous to assuming a variable is real with the Assuming command?

  • 4
    $\begingroup$ you can use $Assumptions = m \[Element] Matrices[{d, d}, Reals]] or Assuming[m \[Element] Matrices[{d, d}, Reals], ...] $\endgroup$ – kglr Oct 17 '18 at 1:06
  • 1
    $\begingroup$ I think that such questions can't be answered productively without some context. Assuming does not affect every function. The right question is not "how to assume that a symbol is a matrix", but "how to do a certain operation with a symbolic matrix". So, what do you want to do exactly? $\endgroup$ – Szabolcs Oct 17 '18 at 8:41
  • $\begingroup$ See all the questions on this site along the lines of "I set x to be real, but Mathematica doesn't treat it as such!". That's because only certain functions take assumptions into account. If the assumption is about tensors, the set of functions that supports them is even more restricted. $\endgroup$ – Szabolcs Oct 17 '18 at 8:43

Matrices can be used as a domain just like Reals, Integers:

$Assumptions = Element[m1 | m2, Matrices[{d, d}, Reals, Symmetric[{1, 2}]]];

{d, d}

TensorDimensions[TensorProduct[m1, m2]]

{d, d, d, d}

Assuming[Element[v, Matrices[{d, d2}, Reals]], TensorDimensions[m v]]

{d, d2}

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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