I want to define simple matrix algebra (inspired by the following posts: Block Matrix Algebra with Mathematica ; How to define custom operators ).
I assume the funtion MatrixMult[A_,B_]
to be the matrix product. I surely can define some properties of this function, like linearity, associativity etc. (see referenced posts).
Now I want to solve simple matrix equation
Solve[MatrixMult[A, X]==B,X]
Obviously, the answer is
{{X -> InverseFunction[MatrixMult, 2, 2][A, B]}}
Now the question is how can I explicitly define that the inverse of my function is the following:
InverseFunction[MatrixMult, 2, 2][A_, B_] := MatrixMult[Inverse[A], B]
(the last line results in "Tag InverseFunction is Protected" error)
What are the most common pitfalls ...
thread and see the difference between=
and:=
when defining predicates. $\endgroup$Unprotect
, but still couldn't get it work. After I define the inverse function (withSetDelayed
) theSolve
function returns{}
. What do you mean by "change the name of your predicate"? $\endgroup$InverseFunction
is a built-in predicate, so you can't just use it overwrite it. $\endgroup$Solve
andInverseFunction
are meant to be used with scalars only. What you are asking for would not be useful in this specific situation. For symbolic matrix algebra, google for the NCAlgebra package. $\endgroup$Solve
won't even return theInverseFunction
any more.) What you could do instead is use a replacement rule that is not tied toInverseFunction
and apply it manually, i.e.result /. InverseFunction[MatrixMult, 2, 2][A_, B_] :> MatrixMult[Inverse[A], B]
. $\endgroup$