Freivalds' algorithm (named after Rūsiņš Mārtiņš Freivalds) is a probabilistic randomized algorithm used to verify matrix multiplication. Given three n × n matrices A {\displaystyle A} , B {\displaystyle B} , and C {\displaystyle C} , a general problem is to verify whether A × B = C {\displaystyle A\times B=C} . A naïve algorithm would compute the product A × B {\displaystyle A\times B} explicitly and compare term by term whether this product equals C {\displaystyle C} . However, the best known matrix multiplication algorithm runs in O ( n 2.3729 ) {\displaystyle O(n^{2.3729})} time. Freivalds' algorithm utilizes randomization in order to reduce this time bound to O ( n 2 ) {\displaystyle O(n^{2})} with high probability. In O ( k n 2 ) {\displaystyle O(kn^{2})} time the algorithm can verify a matrix product with probability of failure less than 2 − k {\displaystyle 2^{-k}} .