Freivalds' algorithm (named after Rūsiņš Mārtiņš Freivalds) is a probabilistic randomized algorithm used to verify matrix multiplication. Given three n × n matrices , , and , a general problem is to verify whether . A naïve algorithm would compute the product explicitly and compare term by term whether this product equals . However, the best known matrix multiplication algorithm runs in time. Freivalds' algorithm utilizes randomization in order to reduce this time bound to [1] with high probability. In time the algorithm can verify a matrix product with probability of failure less than .

The algorithm

edit

Input

edit

Three n × n matrices , , and .

Output

edit

Yes, if ; No, otherwise.

Procedure

edit
  1. Generate an n × 1 random 0/1 vector .
  2. Compute .
  3. Output "Yes" if ; "No," otherwise.

Error

edit

If , then the algorithm always returns "Yes". If , then the probability that the algorithm returns "Yes" is less than or equal to one half. This is called one-sided error.

By iterating the algorithm k times and returning "Yes" only if all iterations yield "Yes", a runtime of and error probability of is achieved.

Example

edit

Suppose one wished to determine whether:

A random two-element vector with entries equal to 0 or 1 is selected – say  – and used to compute:

This yields the zero vector, suggesting the possibility that AB = C. However, if in a second trial the vector is selected, the result becomes:

The result is nonzero, proving that in fact AB ≠ C.

There are four two-element 0/1 vectors, and half of them give the zero vector in this case ( and ), so the chance of randomly selecting these in two trials (and falsely concluding that AB=C) is 1/22 or 1/4. In the general case, the proportion of r yielding the zero vector may be less than 1/2, and a larger number of trials (such as 20) would be used, rendering the probability of error very small.

Error analysis

edit

Let p equal the probability of error. We claim that if A × B = C, then p = 0, and if A × BC, then p ≤ 1/2.

Case A × B = C

edit

This is regardless of the value of , since it uses only that . Hence the probability for error in this case is:

Case A × BC

edit

Let such that

Where

.

Since , we have that some element of is nonzero. Suppose that the element . By the definition of matrix multiplication, we have:

.

For some constant . Using Bayes' theorem, we can partition over :

We use that:

Plugging these in the equation (1), we get:

Therefore,

This completes the proof.

Ramifications

edit

Simple algorithmic analysis shows that the running time of this algorithm is (in big O notation). This beats the classical deterministic algorithm's runtime of (or if using fast matrix multiplication). The error analysis also shows that if the algorithm is run times, an error bound of less than can be achieved, an exponentially small quantity. The algorithm is also fast in practice due to wide availability of fast implementations for matrix-vector products. Therefore, utilization of randomized algorithms can speed up a very slow deterministic algorithm.

Freivalds' algorithm frequently arises in introductions to probabilistic algorithms because of its simplicity and how it illustrates the superiority of probabilistic algorithms in practice for some problems.

See also

edit

References

edit
  1. ^ Raghavan, Prabhakar (1997). "Randomized algorithms". ACM Computing Surveys. 28: 33–37. doi:10.1145/234313.234327. S2CID 207196543.

📚 Artikel Terkait di Wikipedia

Rūsiņš Mārtiņš Freivalds

inductive inference, and quantum computing. He is best known for Freivalds' algorithm, a simple randomized procedure to check matrix multiplication in

Freivalds

Freivalds is a surname. Notable people with the surname include: Laila Freivalds (born 1942), Swedish politician Rūsiņš Mārtiņš Freivalds (1942–2016)

List of algorithms

Coppersmith–Winograd algorithm: square matrix multiplication Freivalds' algorithm: a randomized algorithm used to verify matrix multiplication Strassen algorithm: faster

Matrix multiplication algorithm

multiplication algorithms with an exponent slightly above 2.77, but in return with a much smaller hidden constant coefficient. Freivalds' algorithm is a simple

Computational complexity of matrix multiplication

complexity of mathematical operations CYK algorithm § Valiant's algorithm Freivalds' algorithm, a simple Monte Carlo algorithm that, given matrices A, B and C,

With high probability

randomizations. Freivalds' algorithm: a randomized algorithm for verifying matrix multiplication. It runs faster than deterministic algorithms WHP. Treap:

Intransitive dice

D_{2}>\{D_{1},D_{6}\}\ {\text{and}}\ D_{1}>\{D_{6},D_{5}\}} . Blotto games Freivalds' algorithm Go First Dice Nontransitive game Rock paper scissors Condorcet's

List of numerical analysis topics

especially suitable for processors laid out in a 2d grid Freivalds' algorithm — a randomized algorithm for checking the result of a multiplication Matrix decompositions: