Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Possible Duplicate:
Why don't * and ^ work as I expected on matrices?

When I enter this

Inverse[{{-112, 49, 2, 283}, {-138, 5, 3, 359}, {-20, 0, 0, 6}, {-40, -20, 0, 12}}] *
        {{-112, 49, 2, 283}, {-138, 5, 3, 359}, {-20, 0, 0, 6}, {-40, -20, 0, 12}}

I don't get the identity matrix, but this output:

mathematica output

Can anybody explain why and how I can fix it?

share|improve this question

marked as duplicate by F'x, Leonid Shifrin, J. M. Sep 10 '12 at 9:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

add comment

1 Answer 1

up vote 5 down vote accepted

You need to use Dot for matrix multiplication; * gives element-wise multiplication.

mat = {{-112, 49, 2, 283}, {-138, 5, 3, 359}, {-20, 0, 0, 6}, {-40, -20, 0, 12}} ;

Dot[mat, Inverse[mat]]

(* {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}} *)
share|improve this answer
4  
The OP's confusion might be due to the fact that in MATLAB, * performs matrix multiplication, while .* performs Hadamard multiplication. In Mathematica, OTOH, * is Hadamard multiplication, while . is the operator for matrix multiplication. Common trip-up... –  J. M. Sep 10 '12 at 8:32
add comment

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