# Is A./B different from B.\A?

269 views (last 30 days)
Oliver Woodford on 17 Jun 2015
Edited: Stephen Cobeldick on 17 Jun 2015
Given two matrices, A and B, will A./B ever give a different answer from B.\A, or are these two expressions equivalent?
It seems that even for complex numbers they return the same thing. E.g.
>> A = sqrt(randn(3));
>> B = sqrt(randn(3));
>> isequal(A./B, B.\A)
ans = 1

Stephen Cobeldick on 17 Jun 2015
>> 2./3
ans =
0.6667
>> 2.\3
ans =
1.5000
The documentation clearly states what each function does:
Ingrid on 17 Jun 2015
Stephen, what he is asking is something else namely
>> 2./3
ans =
0.6667
>> 3.\2
ans =
0.6667
so I think they will always give the same result
Stephen Cobeldick on 17 Jun 2015
According to the documentation A.\B and B./A are the same:
• ldivide: " B.\A divides each element of A by the corresponding element of B"
• rdivide: " A./B divides each element of A by the corresponding element of B"
Unless the definition of "divide" is different, then these should be the same.

James Tursa on 17 Jun 2015
I can't think of any reason why one would ever get different results for numeric types. I suppose there might be speed differences if one form used multi-threading and the other form didn't, but in tests I just ran they both appeared to take about the same amount of time.
User defined classes could of course overload them differently.

Alberto on 17 Jun 2015
Both are pointwise, but A./B divides every element in A by the same element in B. A.\B divides every element in B by the same element in A.

#### 1 Comment

Oliver Woodford on 17 Jun 2015