GSOC 2025: Enhancing Multivariate Polynomial Arithmetic and Factorization in SymPy

175 views
Skip to first unread message

Pratyksh Gupta

unread,
Feb 7, 2025, 12:50:46 PM2/7/25
to sympy

Hello SymPy developers,

I am excited to share my interest in contributing to SymPy by enhancing its capabilities in multivariate polynomial arithmetic and factorization. Currently, SymPy utilizes Kronecker's method for multivariate polynomial factorization, which, while a solid foundation, lacks the efficiency needed for practical applications. I propose implementing more advanced algorithms, such as Wang's EEZ-GCD or Gao's approach using partial differential equations, to boost the efficiency and usability of multivariate polynomial operations in SymPy.

My main question is: Does expanding SymPy's support for efficient multivariate polynomial arithmetic and factorization fit within the project's current development roadmap and priorities?

If this aligns with SymPy's objectives, I am eager to contribute to this initiative. I have a strong background in algebra and computational mathematics, which I believe will be valuable in addressing this challenge. I am ready to delve into the implementation details, research state-of-the-art algorithms, and develop a concrete plan to integrate these enhancements into SymPy.

To help facilitate this process, I would greatly appreciate any guidance on:

Recommended resources or existing work within SymPy that I should review 

Thank you for your time and consideration. I look forward to your response and am excited about the opportunity to contribute to SymPy's development.

Best regards,  

Pratyksh Gupta.

Oscar Benjamin

unread,
Feb 7, 2025, 5:01:21 PM2/7/25
to sy...@googlegroups.com
Improving SymPy's multivariate polynomial algorithms does fit with
SymPy's development roadmap but the top priority item here is making
use of FLINT via python-flint. You can install the latest development
version of python-flint from the scientific Python nightly wheels
index with:

pip install -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
python-flint

https://anaconda.org/scientific-python-nightly-wheels/python-flint

Once you have that you can use it for multivariate polynomials:

In [3]: from flint import fmpz_mpoly_ctx

In [4]: ctx = fmpz_mpoly_ctx.get(['x', 'y'])

In [5]: x, y = ctx.gens()

In [6]: p = x**2 - y**2

In [7]: p
Out[7]: x^2 - y^2

In [8]: p.factor()
Out[8]: (1, [(x + y, 1), (x - y, 1)])

This is much faster than SymPy's Python implementations for things
like arithmetic, gcd, factor etc and has good implementations of good
algorithms for all the most important operations.

What is needed is for SymPy to make use of this when python-flint is
installed for multivariate polynomials similar to this PR which was
for univariate polynomials:

https://github.com/sympy/sympy/pull/25722

The outcome of that is the three classes in polyclasses.py:

https://github.com/sympy/sympy/blob/master/sympy/polys/polyclasses.py

There are DMP, DMP_Python and DUP_Flint with the latter being the
class that uses python-flint but it is only for univariate
polynomials. What is needed is to have DMP_Flint there for
multivariate polynomials based on FLINT but more importantly the first
thing needed is to have versions of PolyRing and PolyElement based on
python-flint. The first thing that is needed is that this code needs
to have alternate versions that can use FLINT:

https://github.com/sympy/sympy/blob/master/sympy/polys/rings.py

Making it so that SymPy uses FLINT via python-flint for things like
multivariate polynomials is top of the priority list in my development
roadmap. There are many more things besides just multivariate
polynomials in FLINT and python-flint that SymPy should make use of as
well.
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/sympy/8d38e2ee-bdc5-416b-a50c-bfb993558127n%40googlegroups.com.

Pratyksh Gupta

unread,
Feb 7, 2025, 10:51:32 PM2/7/25
to sympy

Dear Oscar,

Thank you for your detailed response and for outlining the priority of integrating FLINT via python-flint for multivariate polynomials. I truly appreciate the guidance and the resources you have shared.

Given that this is at the top of SymPy's development roadmap, I am eager to contribute to this effort with my whole heart. I will start by exploring python-flint. reviewing the existing integration in SymPy, and understanding the necessary modifications to rings.py and polyclasses.py.

Best Regards,

Pratyksh

Pratyksh Gupta

unread,
Mar 7, 2025, 3:06:38 PM3/7/25
to sympy

Dear Oscar,


Thank you for the detailed response and for outlining the priority of integrating python-flint for multivariate polynomials. I have started exploring python-flint and reviewing the existing integration in SymPy.


I had a few questions regarding the implementation:

1. Should DMP_Flint follow the same structure as DUP_Flint, or are there any specific considerations for handling multivariate polynomials efficiently ?

2. For integrating PolyRing and PolyElement, should I strictly follow the approach in polyclasses.py, or are there design differences to account for ?

3. Are there existing benchmark tests for comparing performance improvements with python-flint? If not, what key operations (e.g., gcd, factor) should we focus on for measuring efficiency gains ?

4. Is there an ongoing discussion or PR related to this work that I should follow or contribute to ?


I’d appreciate any insights on these aspects before I begin structuring the implementation. Looking forward to your guidance!


Best regards,

Pratyksh Gupta

Reply all
Reply to author
Forward
0 new messages