1

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?

Martin Thoma
  • 113
  • 4

1 Answers1

6

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}} *)
b.gates.you.know.what
  • 20,103
  • 2
  • 43
  • 84