Post Reply 
[BUG]: matrices
12-18-2013, 08:44 AM
Post: #1
[BUG]: matrices
I have two matrices:
M0:[[1,1],[0.24,0.86]]
M1:[[274,233,331],[120.32,112.96,151.36]]

I calculate M1/M0:
Home view: [[186,141,215],[88,92,116]]
CAS view: [[274,233],[501.33,131.35]]]

The CAS view is wrong and I don't even know how the Prime gets confused...
Find all posts by this user
Quote this message in a reply
12-18-2013, 02:29 PM
Post: #2
RE: [BUG]: matrices
(12-18-2013 08:44 AM)Tugdual Wrote:  The CAS view is wrong and I don't even know how the Prime gets confused...
It's not wrong, it's pointwise division. One should never write A/B for inv(B)*A because matrix multiplication is not commutative and A/B is ambiguous with A*inv(B). Use inv and multiplication.
Find all posts by this user
Quote this message in a reply
12-18-2013, 02:32 PM
Post: #3
RE: [BUG]: matrices
Use M0^-1*M1. When you "divide" a matrix by another matrix, you are actually pre-multiplying the numerator matrix by the inverse of the denominator matrix.
Find all posts by this user
Quote this message in a reply
12-18-2013, 10:34 PM
Post: #4
RE: [BUG]: matrices
Thanks for your answers which I understood but I still struggle with something.
M0 is a 2x2 matrix so will M0^-1 be.
M1 is dimension 2x3

you cannot calculate M1 * M0^-1 and even CAS returns a dimension error.
So what the heck is that 2x2 matrix returned by CAS?
There is no possible confusion, I shall expect the correct result or no result at all.
Find all posts by this user
Quote this message in a reply
12-18-2013, 11:05 PM
Post: #5
RE: [BUG]: matrices
It looks like CAS has done an element by element division of M1 by the corresponding elements of M0. So you get [[274/1, 233/1],[120.32/0.24,112.96/0.86]] with column 3 of matrix M1 truncated. This is basically the result of using the ./ operator i.e. M1 ./ M0, so perhaps that is what CAS thought you wanted to do. Again, you used an incorrect form here, and it's not a problem with CAS.
Find all posts by this user
Quote this message in a reply
12-18-2013, 11:11 PM
Post: #6
RE: [BUG]: matrices
Thanks Michael, good observation. Now at least we have the beginning of an explanation.
Find all posts by this user
Quote this message in a reply
12-19-2013, 08:53 AM
Post: #7
RE: [BUG]: matrices
I'm modifying the CAS code so that you will get inv(M0)*M1 with a warning for this misleading notation.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)