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

Asked by Oliver Woodford

### Oliver Woodford (view profile)

on 17 Jun 2015
Latest activity Edited by Stephen Cobeldick

### Stephen Cobeldick (view profile)

on 17 Jun 2015
Accepted Answer by James Tursa

### James Tursa (view profile)

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

### Stephen Cobeldick (view profile)

on 17 Jun 2015
>> 2./3
ans =
0.6667
>> 2.\3
ans =
1.5000
The documentation clearly states what each function does:
Ingrid

### Ingrid (view profile)

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

### Stephen Cobeldick (view profile)

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 (view profile)

Answer by James Tursa

### James Tursa (view profile)

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 (view profile)

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.

Oliver Woodford

on 17 Jun 2015