## Benchmarks

This page shows how a very early version of Nemo compared to other computer algebra software on a very small selection of artificial benchmarks.

### Fateman benchmark

- f = 1 + x + y + z + t
- p = f^30
- time q = p*(p + 1)

This benchmark tests generic polynomial arithmetic. Note that we don't have a dedicated multivariate polynomial module in Nemo yet, so this and the next benchmark are done with nested univariate polynomial rings. Where possible we do the same thing in the other systems we time (Pari/GP is an exception).

SageMath 6.8 | Pari/GP 2.7.4 | Magma V2.21-4 | Nemo-0.3 |
---|---|---|---|

132s | 156s | 233s | 44s |

### Pearce benchmark

- f = (x + y + 2z^2 + 3t^3 + 5u^5 + 1)^16
- g = (u + t + 2z^2 + 3y^3 + 5x^5 + 1)^16
- time q = f*g

This benchmark is usually done with sparse multivariate polynomial arithmetic. We use it here with our recursive dense polynomial arithmetic (there is no sparse polynomial representation in Nemo yet).

Note: this is not fair to other packages that implement sparse multivariate polynomial arithmetic, as they could complete this benchmark faster if we used their sparse arithmetic. But that would not be a very meaningful benchmark if the aim is to measure the relative performance of the recursive dense polynomial arithmetic in Nemo. On the other hand, Pari/GP uses a sparse-recursive representation (similar to recursive-dense, but with dedicated zero objects in each ring).

SageMath 6.8 | Pari/GP 2.7.4 | Magma V2.21-4 | Nemo-0.3 |
---|---|---|---|

2900s | 798s | 647s | 167s |

### Resultant benchmark

- R
= GF(17^11) - S = R[y]
- T = S/(y^3 + 3x*y + 1)
- U = T[z]
- f = T(3y^2 + y + x)*z^2 + T((x + 2)*y^2 + x + 1)*z + T(4x*y + 3)
- g = T(7y^2 - y + 2x + 7)*z^2 + T(3y^2 + 4x + 1)*z + T((2x + 1)*y + 1)
- s = f^12
- t = (s + g)^12
- time r = resultant(s, t)

This benchmark is designed to test generics, division and computation of the resultant.

SageMath 6.8 | Pari/GP 2.7.4 | Magma V2.21-4 | Nemo-0.3 |
---|---|---|---|

179907s | N/A | 82s | 0.2s |

### Bernoulli polynomials

- R = QQ[x]
- S = R[[t]]
- u = t + O(t^1000)
- time r = (u*exp(x*u))/(exp(u)-1))

This benchmark is designed to test generic power series.

SageMath 6.8 | Pari/GP 2.7.4 | Magma V2.21-4 | Nemo-0.3 |
---|---|---|---|

161s | 235s | 4223s | 65s |

### Polynomials over number fields

- R, x = CyclotomicField(20)
- S = R[y]
- f = (3x^7 + x^4 - 3x + 1)*y^3 + (2x^6-x^5+4x^4-x^3+x^2-1)*y +(-3x^7+2x^6-x^5+3x^3-2x^2+x)
- time r = f^300

This benchmark is designed to test dense polynomials over number fields.

SageMath 6.8 | Pari/GP 2.7.4 | Magma V2.21-4 | Nemo-0.3 |
---|---|---|---|

6.92s | 0.21s | 0.70s | 0.13s |

### Determinant over a commutative ring

- n = 2003*1009
- R = (Z/nZ)[x]
- M is an 80x80 matrix with entries in R of random degree of at most 5 and coefficients in the range [-100, 100] modulo n
- time d = determinant(M)

This benchmark is designed to test determinant over a generic commutative ring. Note Pari cheats here and does divisions, which will occasionally cause it to fail on such examples.

Magma exhausts the memory on the machine after some hours. Timings indicate it uses an exponential algorithm which would take > 42369865294301626368s were it given infinite memory.

SageMath 6.8 | Pari/GP 2.7.4 | Magma V2.21-4 | Nemo-0.4 |
---|---|---|---|

43.5s | 456s | - | 7.5s |

### Determinant over a field

- K, a = NumberField(x^3 + 3x + 1)
- M is an 80x80 matrix with random entries in K of the form c_0 + c_1*a + c_2*a^2 with c_i in the range [-100, 100]
- time d = determinant(M)

This benchmark is designed to test determinant over a field where there is coefficient blowup.

SageMath 6.8 | Pari/GP 2.7.4 | Magma V2.21-4 | Nemo-0.4 |
---|---|---|---|

5893s | 21.9s | 5.3s | 2.4s |

### Determinant of a matrix over a polynomial ring

- M is an 40x40 matrix with random entries in ZZ[x] of the form c_0 + c_1*x + c_2*x^2 with c_i in the range [-20, 20]
- time d = determinant(M)

This benchmark is designed to test determinant over a polynomial ring over an integral domain.

SageMath 6.8 | Pari/GP 2.7.4 | Magma V2.21-4 | Nemo-0.4 |
---|---|---|---|

6.3s | 1.3s | 3.2s | 0.24s |

### Linear solving over a polynomial ring

- M is an 20x20 matrix with random entries in ZZ[x][y] that are quadratic polynomials in y with coefficients of the form c_0 + c_1*x + c_2*x^2 with c_i in the range [-20, 20], and b is a 20x1 matrix over the same ring
- time v, d = solve(M, b)

The computation finds a 20x1 matrix v over ZZ[x][y] and a denominator d in ZZ[x][y] such that Av = db.

This benchmark is designed to test linear solving over a generic polynomial ring.

SageMath exhausted the memory on the machine and didn't complete, possibly because it doesn't reduce the bivariate rational functions that result, at any stage. On the other hand, we were forcing SageMath to work in iterated univariate polynomial rings rather than a true bivariate polynomial ring, which may explain the slowdown and memory use.

Magma requires the computation to be performed over the fraction field.

SageMath 6.8 | Pari/GP 2.7.4 | Magma V2.21-4 | Nemo-0.4 |
---|---|---|---|

> 100000s | > 1300000s | 90s | 7s |

### Characteristic polynomial of a matrix over the integers

- M is an 80x80 matrix with random entries in ZZ in the range [-20, 20]
- time d = charpoly(M)

This benchmark doesn't really test Nemo but the underlying Flint library. However, the benchmark resulted from work done in Nemo that got moved into Flint. Julia code can be quite easy to port to C in certain circumstances.

SageMath 6.9 | Pari/GP 2.7.4 | Magma V2.21-4 | Giac-1.2.2 | Nemo-0.4 |
---|---|---|---|---|

0.20s | 0.58s | 0.06s | 0.06s | 0.04s |

### Minimal polynomial of a matrix over a gcd domain

- Let M be a 20x20 matrix with random entries in ZZ[x] of degree 2 with coefficients in the range [-20, 20], but such that the upper right and lower left quarters of the matrix are zero and the lower right quarter is identical to the upper left quarter
- Let P(r, d) denote a 20x20 identity matrix the zero entries of whose r-th row have been replaced with the value d
- Apply ten random similarity transforms M = P^{-1}MP to M where each P is a matrix of the form P(r, d) for r in the range [1, 20] and d in the range [-3:3]
- time d = minpoly(M)

This benchmark tests minimal polynomial over a gcd domain (i.e. not over a field).

Magma refuses to do this computation and Sage throws an exception. Pari/GP was terminated due to long running.

SageMath 6.9 | Pari/GP 2.7.4 | Magma V2.21-4 | Nemo-0.4 |
---|---|---|---|

-- | > 680000s | -- | 0.6s |

### Minimal polynomial of a matrix over a finite field

- Let R be a finite field of order 103^2
- Let M be a 80x80 matrix with random entries in R, but such that the upper right and lower left quarters of the matrix are zero and the lower right quarter is identical to the upper left quarter
- Let P(r, d) denote an 80x80 identity matrix the zero entries of whose r-th row have been replaced with the value d
- Apply ten random similarity transforms M = P^{-1}MP to M where each P is a matrix of the form P(r, d) for r in the range [1, 80] and d in the range [-3:3]
- time d = minpoly(M)

This benchmark tests minimal polynomial over a finite field, and finite field arithmetic.

Magma is so fast in this example because it uses Zech logarithms and because it just has very fast finite field arithmetic. We are currently using generic matrices over Flint finite field elements and we are not using Zech logarithms. Both are areas for future improvement.

SageMath 6.9 | Pari/GP 2.7.4 | Magma V2.21-4 | Nemo-0.4 |
---|---|---|---|

10.6s | 2515s | 0.005s | 0.4s |

### Minimal polynomial of a matrix over the integers

- Let M be a 80x80 matrix with random entries in ZZ in the range [-20, 20], but such that the upper right and lower left quarters of the matrix are zero and the lower right quarter is identical to the upper left quarter
- Let P(r, d) denote an 80x80 identity matrix the zero entries of whose r-th row have been replaced with the value d
- Apply ten random similarity transforms M = P^{-1}MP to M where each P is a matrix of the form P(r, d) for r in the range [1, 80] and d in the range [-3:3]
- time d = minpoly(M)

This benchmark doesn't really test Nemo, but Flint. However the implementation was a result of work carried out first in Nemo and then ported to Flint.

Pari/GP eventually exhausted the memory on the machine and did not complete.

SageMath 6.9 | Pari/GP 2.7.4 | Magma V2.21-4 | Nemo-0.4 |
---|---|---|---|

0.07s | > 600000s | 0.05s | 0.04s |

*Last updated: 2021-11-03 17:01:42 GMT*

*Contact: nemo-devel mailing list.*

Logo background due to Giacomo Merculiano.