I am not sure if this is the right place to ask this question, but I believe there will be people here who do computations on computer algebra packages like Sage in their work. 
I have been using Sagemath to perform some matrix rank computations. It turns up a few bizarre results occasionally.


For example, I had to find the rank of a matrix ($100 \times 150$) with large integer entries (entries of magnitude in the range of $1$ to $10^{15}$). When I wrote the code with the matrix M declared as `matrix(ZZ, R, C)`, or as `matrix(QQ, R, C)`, it returns a rank of around 90 (which I believe is correct), whereas if I declare the matrix over the reals as `matrix(RR, R, C)`, it returns a rank of around 50, which I believe is too low based on some conjectures I have.


So, overall I am curious, what are the standard way(s) to implement rank computation (and does it differ based on reals, or rationals) and where can I read more about these? If these issues arise due to precision errors, how can I get around them? And more importantly, how do I know beforehand that my computation is susceptible to precision errors?
(I tried looking up the source code of Sagemath a couple of times, but I was quickly lost, so I hope someone can point me to the precise documentation/source code)



How do computer algebra packages like Sagemath implement rank of a matrix
I don't know what algorithm Sage actually uses, but computing rank over the integers is fun and easy: [Complexity of computing matrix rank over integers](https://mathoverflow.net/questions/63278/complexity-of-computing-matrix-rank-over-integers) . It is NOT so easy if you want good running time, and for that there are a number of papers of Arne Storjohann, which show that one can do it asymptotically as fast as for real matrices (a surprising result, in view of coefficient blow-up). Storjohann has actually implemented his algorithms, and I am sure Sage uses this or something like it.


*Chen, Zhuliang; Storjohann, Arne*, [**A BLAS based C library for exact linear algebra on integer matrices**](http://dx.doi.org/10.1145/1073884.1073899), Kauers, Manuel (ed.), Proceedings of the 2005 international symposium on symbolic and algebraic computation, ISSAC’05, Beijing, China, July 24--27, 2005. New York, NY: ACM Press (ISBN 1-59593-095-7). 92-99 (2005). [ZBL1360.65086](https://zbmath.org/?q=an:1360.65086).


As for the reals, the fastest way to compute rank is to compute the singular value decomposition, and throw away singular values below some cutoff (probably around $10^{-6}$). As pointed out by many in the comments, rank is very unstable, so unless you want the "pseudo-rank" (as above, defined by the size of the singular values), don't go there. 


