Menu ▾ ▴

#5654 gcd of co-prime expressions scales badly with algebraics

None
open
nobody
5
2026-10-06
2026-10-06
No

The GCD algorithm's computation time seems to scale exponentially in this example, where a cheap co-primality test could answer much faster:

(%i1) algebraic : true$

(%i2) v : expand((sqrt(2)*a*x^2+b*x+sqrt(3)*c)^2+%i*a*b)$

(%i3) showtime : true$
Evaluation took 0.0000 seconds (0.0000 elapsed) using 0 bytes.

(%i4) gcd(expand((x+%i)^2), v);
Evaluation took 0.0000 seconds (0.0001 elapsed) using 31.984 KB.
(%o4)                                  1

(%i5) gcd(expand((x+%i)^3), v);
Evaluation took 0.0000 seconds (0.0003 elapsed) using 735.563 KB.
(%o5)                                  1

(%i6) gcd(expand((x+%i)^4), v);
Evaluation took 0.0000 seconds (0.0097 elapsed) using 10.899 MB.
(%o6)                                  1

(%i7) gcd(expand((x+%i)^5), v);
Evaluation took 0.3125 seconds (0.3038 elapsed) using 854.896 MB.
(%o7)                                  1

(%i8) gcd(expand((x+%i)^6), v);
Evaluation took 3.8594 seconds (3.8526 elapsed) using 9704.915 MB.
(%o8)                                  1

(%i9) gcd(expand((x+%i)^7), v);
Evaluation took 31.6094 seconds (31.6197 elapsed) using 64627.339 MB.
(%o9)                                  1

Discussion


Log in to post a comment.