Skip to content

Very slow example for ProjectivePlaneCurve.ordinary_model() #35479

@tornaria

Description

@tornaria

Is there an existing issue for this?

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.

Did you read the documentation and troubleshoot guide?

  • I have read the documentation and troubleshoot guide

Environment

- **OS**: void linux
- **Sage Version**: 10.0.beta8 (same in 9.8)

Steps To Reproduce

There is a doctest in https://github.com/sagemath/sage/blob/10.0.beta8/src/sage/schemes/curves/projective_curve.py#L1383 which is too slow even for a # long time doctest.

sage: P.<x,y,z> = ProjectiveSpace(QQ, 2)
sage: C = Curve([(x^2 + y^2 - y*z - 2*z^2)*(y*z - x^2 + 2*z^2)*z + y^5], P)
sage: %time M = C.ordinary_model()
CPU times: user 3min 18s, sys: 1.38 s, total: 3min 20s
Wall time: 3min 21s

It turns out almost all the time is spent in MPolynomialIdeal_singular_repr.is_prime() (twice for the same ideal):

sage: K.<a> = QuadraticField(2)
sage: R.<x,y,z> = PolynomialRing(K)
sage: p = (9*x^5*y^3 + 30*x^4*y^4 + 25*x^3*y^5 + (-12*a + 27)*x^5*y^2*z + (-74*a + 90)*x^4*y^3*z + (-120*a + 75)*x^3*y^4*z + (-50*a)*x^2*y^5*z + (-24*a + 33)*x^5*y*z^2 + (-148*a + 178)*x^4*y^2*z^2 + (-240*a + 327)*x^3*y^3*z^2 + (-100*a + 232)*x^2*y^4*z^2 + 62*x*y^5*z^2 + (-14*a + 15)*x^5*z^3 + (-76*a + 118)*x^4*y*z^3 + (-204*a + 277)*x^3*y^2*z^3 + (-134*a + 232)*x^2*y^3*z^3 + (-74*a + 62)*x*y^4*z^3 + (-10*a)*y^5*z^3)
sage: I = ideal(p)
sage: %time I.is_prime()
CPU times: user 1min 38s, sys: 250 ms, total: 1min 38s
Wall time: 1min 39s
True

That is the same as

sage: %time p.is_prime()
CPU times: user 1min 38s, sys: 831 ms, total: 1min 38s
Wall time: 1min 39s
True

just because p.is_prime() is implemented essentially as ideal(p).is_prime().

But

sage: %time f = p.factor()
CPU times: user 4.1 ms, sys: 991 µs, total: 5.09 ms
Wall time: 5.14 ms
sage: len(f)
1

is way faster!

So I wonder:

  1. is there a way to factor ideals that is as fast as factoring polynomials?
  2. is there a way to test primality of an ideal without factoring?
  3. is there a way to avoid that ordinary_model() calls is_prime() twice for the same polynomial?

Expected Behavior

C.ordinary_model() is fast. Note that the comment in the doctest says # long time (5 seconds) so I guess something happened in between...

Actual Behavior

C.ordinary_model() is slow.

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions