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. – Sektor Mar 03 '14 at 10:22Unprotect, but still couldn't get it work. After I define the inverse function (withSetDelayed) theSolvefunction returns{}. What do you mean by "change the name of your predicate"? – bcp Mar 03 '14 at 10:59InverseFunctionis a built-in predicate, so you can't just use it overwrite it. – Sektor Mar 03 '14 at 11:05SolveandInverseFunctionare 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. – Szabolcs Mar 03 '14 at 14:30SolveandInverseFunctionused with scalars only. (I will not try to substitute any actual matrices intoA, Betc.). (I am aware of NCAlgebra package) – bcp Mar 03 '14 at 15:35Solvewon't even return theInverseFunctionany more.) What you could do instead is use a replacement rule that is not tied toInverseFunctionand apply it manually, i.e.result /. InverseFunction[MatrixMult, 2, 2][A_, B_] :> MatrixMult[Inverse[A], B]. – Szabolcs Mar 03 '14 at 21:34