# What algorithm does Sage use for the product of two matrices?

(am new to Sage and programming in general as you can see. Feel free to expand your answer)

I want to find out how a matrix product is calculated.

```
M = random_matrix(ZZ, 10, density=1)
N = random_matrix(ZZ, 10, density=1)
M*N
```

Is it simply identical to `M.__mul__(N)`

in each case? Or does Sage switch to another algorithm if useful - `M._multiply_strassen(N)`

for example?

The star operation in

`M*M`

points to`M.__mul__`

- this is the called method, the algorithm which is finally taken depends on the class of`M`

and the specific implementation. A closer look at`M.__mul__??`

shows which logic, and following the logic and the further calls which algorithms are implemented. Possibly`M.__rmul__`

is also of interest in similar classes.