ACM Communications in Computer Algebra, Vol. 40, No. 4, Issue 198, December 2016 Fermat Benchmarks For Rational Expressions in Maple Michael Monagan and Roman Pearce Department of Mathematics Simon Fraser University Burnaby, Canada, V5A 1S6 {mmonagan,rpearcea}@cecm.sfu.ca Abstract We employ two techniques to dramatically improve Maple’s performance on the Fermat benchmarks for simplifying rational expressions. First, we factor expanded polynomials to ensure that gcds are identified and cancelled automatically. Second, we replace all expanded polynomials by new variables and normalize the result. To undo the substitutions, we use a C routine for sparse multivariate division by a set of polynomials. The resulting times for the first Fermat benchmark are a factor of 17x faster than Fermat and 39x faster than Magma. 1 Introduction We set out to improve Maple’s performance on the Fermat benchmarks for simplifying rational expres- sions, posted at https://home.bway.net/lewis/fermat/FerTest.html. Maple’s current performance is poor. The main command in Maple for simplifying rational expressions involving variables is the normal command. This command is called by the simplify command for rational expressions. One problem is that normal places rational expressions over a common denominator that is not the lcm. We can see what the normal command computes using the numer and denom commands. This is shown in the second step below. In the third step, normal cancels a gcd. 1 x 2 - 1 + 1 x 2 + x +2 + 1 x 2 +3x +2 ! 3x 4 +8x 3 + x 2 - 8x - 4 (x 2 - 1)(x 2 + x - 2)(x 3 +3x + 2) ! 3x +2 (x - 1)(x 2 +3x + 2) For multivariate polynomials, the numerator with the gcd in it may have significantly more terms. In the first Fermat benchmark, the gcd has 12 variables and 840 terms, so cancelling it at the end makes it much more expensive to expand the numerator. With the input in factored form, Maple detects factors that are already present and computes the result without any blowup. Maple can do this quickly because it stores a single simplified copy of each unique object. It identifies the common factors by their address in memory. 1 (x - 1)(x + 1) + 1 (x - 1)(x + 2) + 1 (x + 1)(x + 2) ! 3x +2 (x - 1)(x + 1)(x + 2) Factoring expanded polynomials as a first step allows Maple to complete the first Fermat problem in reasonable time, see Table 2. A second observation allows us to do even better. 188