I’m investigating if the use of matrix division operator ‘/’ may cause numerical instability in my program and cannot find much information on its underlying implementations. I know in Matlab, such backslash operator may call different algos such as QR, LU etc. depending on the specific matrices in use. Does Stan do something similar? I know I’m dividing a symmetric matrix, so I wasn’t sure if ‘/’ is the most efficient way to do it or if I should try and implement it myself. Many thanks.

If you have two matrices A and B then `/`

is the right division of B by A. Mathematically this is equivalent to B * inverse(A). However, using the division operator is more numerically stable because, you’re right, that it uses an LU and solve.

The code is in stan-math with the `mdivide_right()`

function which is aliased to `/`

in Stan

at math/mdivide_right.hpp at 2cf4310702eec1b14a355d883e704af0b788abd8 · stan-dev/math · GitHub

Check out the docs on this at:

5 Likes

Thank you. This is very helpful. May I suggest that the Stan documentation on matrix division mention a bit more on the underlying implementation, or provide a link that reference its source code on GitHub? It didn’t mention LU or anything else there for ‘/’ operators.