18 | | The computation for `z1` works reasonably well and completes in under 2 seconds, but the one for `z2` takes over a minute on my system. Which I find really strange, since computing all roots and then choosing the right one should be ''more'' work, not ''less'' than just computing a single one. Should we change `QQbar.polynomial_root` to go via the list of all roots, or is there a better solution? |
| 18 | The computation for `z1` works reasonably well and completes in under 2 seconds, but the one for `z2` takes over a minute. Which is definitely wrong, since computing all roots and then choosing the right one should be ''more'' work, not ''less'' than just computing a single one! |
| 19 | |
| 20 | The reason for this is the time spent in the square-free decomposition (called from `sage/rings/polynomial/complex_roots.py`) which behave differently depending whether the polynomial is defined with coefficients in `QQ` or `AA` |
| 21 | {{{ |
| 22 | sage: %time _ = p4.squarefree_decomposition() |
| 23 | CPU times: user 807 µs, sys: 0 ns, total: 807 µs |
| 24 | Wall time: 883 µs |
| 25 | sage: %time _ = p4.change_ring(AA).squarefree_decomposition() |
| 26 | CPU times: user 40.1 s, sys: 3.21 ms, total: 40.1 s |
| 27 | Wall time: 40.1 s |
| 28 | }}} |