Hey everyone!
I'm looking for help with a recent venture I'm planning to embark on.
I have been working on the SymPy codebase for about 6 months now. And my major contributions there have revolved around the solvers and polys modules which are for "solving systems of equations" and "manipulating polynomials" respectively.
Now the issue that has persisted for some time is the slowness of polynomial GCD computation in SymPy. And it slows down a lot of things under the hood consequently.
So, what I wanna do is, or at least take a significant step towards, is the bridging of FLINT and SymPy, since FLINT has its optimized C routines for GCD computation of both dense and sparse representations of polynomials over the integers i.e. ZZ and over the rationals i.e. QQ coefficient domains. SymPy has to work with more complicated domains than ZZ and QQ though,
BUT,
any implementation or GCD computation algorithms that can reduce to cases that are well handled (or rather I should say very well handled) by FLINT will make things immensely faster for SymPy.
Like, for example, it's not very difficult to reduce a polynomial system defined over ZZ_I to ZZ in SymPy, all we have to do is promote the imaginary unit 'I' to the generators as a symbol(jargon for variable in SymPy) and adjoin the minimal polynomial i.e. i**2 + 1 to the system.
Currently, in SymPy, the strategy for computing the GCD of sparse polynomials depends on the coefficient domain:
If the domain is ZZ, the heuristic polynomial GCD algorithm (HEUGCD) is used directly.
If the domain is QQ, denominators are cleared to reduce the polynomials to ZZ, and then HEUGCD is applied.
Otherwise, the dense implementation of the PRS (Polynomial Remainder Sequence) algorithm is used.
However, there are some inefficiencies with this approach:
HEUGCD may not be the best choice, even when working over ZZ.
The dense PRS implementation struggles when there are many generators because it applies itself recursively over multiple nested lists, leading to inefficiencies.
There have been mentions and discussions about how this bridging is pretty useful and a high priority. As of now, FLINT is alien to me since I’ve not had much experience using it unlike SymPy(reason why I came here looking for help).
I’d appreciate any guidance on how to initiate this integration. Are there existing approaches or recommendations for linking SymPy’s polynomial arithmetic with FLINT’s capabilities? Additionally, what would be a good roadmap for incrementally working toward this goal?
SymPy can really benefit from addition of modular GCD algorithms, especially with this bridging with FLINT where the algorithms that reduce to cases well handled by FLINT.
I’ve tried to keep this mail concise and not crowd it up, if you've read this far, I really appreciate it.
Eagerly looking forward to your insights!
Aasim
To view this discussion, visit https://groups.google.com/d/msgid/flint-devel/CAHVvXxTSV8ydux9ycL8jYCbg4mTr2g%3Dfm8Dfg49eW1tmLxho%3DQ%40mail.gmail.com.