Skip to content

Define minimal polynomial for any square matrix over any field #39697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions src/sage/matrix/matrix2.pyx
Original file line number Diff line number Diff line change
@@ -3035,6 +3035,61 @@ cdef class Matrix(Matrix1):
self.cache('minpoly', mp)
return mp

def minpoly_lin(self, var='x', **kwds):
r"""
Return the minimal polynomial of ``self``.

This uses a purely linear-algebraic algorithm (essentially
Gaussian elimination, applied to the powers of ``self``).
It is slow but it requires no factorization of polynomials.

EXAMPLES::

sage: # needs sage.rings.finite_rings
sage: A = matrix(GF(9, 'c'), 4, [1,1,0,0, 0,1,0,0, 0,0,5,0, 0,0,0,5])
sage: A.minpoly_lin()
x^3 + 2*x^2 + 2*x + 1
sage: A.minpoly_lin()(A) == 0
True
sage: CF = CyclotomicField()
sage: i = CF.gen(4)
sage: A = matrix(CF, 4, [1,1,0,0, 0,1,0,0, 0,0,1+i,0, 0,0,0,-i])
sage: A.minpoly_lin()
x^4 - 3*x^3 + (4 - E(4))*x^2 + (-3 + 2*E(4))*x + 1 - E(4)

The default variable name is `x`, but you can specify
another name::

sage: # needs sage.rings.finite_rings
sage: A.minpoly_lin('y')
y^4 - 3*y^3 + (4 - E(4))*y^2 + (-3 + 2*E(4))*y + 1 - E(4)
"""
f = self.fetch('minpoly')
if f is not None:
return f.change_variable_name(var)

n = self.nrows()
F = self.base_ring()
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
P = PolynomialRing(F, "x")
x = P.gen()
from sage.modules.free_module_element import vector
from sage.matrix.constructor import matrix

pow = self**0
pows = []
for k in range(n+1):
pows.append(vector(pow.list()))
pow *= self
Mpows = matrix(pows)
try:
cs = Mpows.solve_left(vector(pow.list()))
except ValueError:
continue
mp = x**(k+1) - P.sum(cs[i] * x**i for i in range(k+1))
self.cache('minpoly', mp)
return mp

def _test_minpoly(self, **options):
"""
Check that :meth:`minpoly` works.

Unchanged files with check annotations Beta

These formulas are automatically used if we ask to plot the grid of spherical
coordinates in terms of Cartesian coordinates::
sage: spherical.plot(cartesian, color={r:'red', th:'green', ph:'orange'})

Check warning on line 141 in src/doc/en/thematic_tutorials/vector_calculus/vector_calc_change.rst

GitHub Actions / Conda (ubuntu, Python 3.12)

Warning: slow doctest:

slow doctest:

Check warning on line 141 in src/doc/en/thematic_tutorials/vector_calculus/vector_calc_change.rst

GitHub Actions / Conda (ubuntu, Python 3.11)

Warning: slow doctest:

slow doctest:

Check warning on line 141 in src/doc/en/thematic_tutorials/vector_calculus/vector_calc_change.rst

GitHub Actions / Conda (ubuntu, Python 3.12, editable)

Warning: slow doctest:

slow doctest:
Graphics3d Object
.. PLOT::
The Laplacian of a vector field::
sage: Du = laplacian(u)

Check warning on line 235 in src/doc/en/thematic_tutorials/vector_calculus/vector_calc_curvilinear.rst

GitHub Actions / Conda (ubuntu, Python 3.12)

Warning: slow doctest:

slow doctest:

Check warning on line 235 in src/doc/en/thematic_tutorials/vector_calculus/vector_calc_curvilinear.rst

GitHub Actions / Conda (ubuntu, Python 3.11)

Warning: slow doctest:

slow doctest:

Check warning on line 235 in src/doc/en/thematic_tutorials/vector_calculus/vector_calc_curvilinear.rst

GitHub Actions / Conda (ubuntu, Python 3.12, editable)

Warning: slow doctest:

slow doctest:
sage: Du.display()
Delta(u) = ((r^2*d^2(u_r)/dr^2 + 2*r*d(u_r)/dr - 2*u_r(r, th, ph)
+ d^2(u_r)/dth^2 - 2*d(u_theta)/dth)*sin(th)^2 - ((2*u_theta(r, th, ph)
and also projective modules)::
sage: SGA = SymmetricGroupAlgebra(QQ, 5)
sage: for la in Partitions(SGA.n):

Check warning on line 1304 in src/sage/combinat/symmetric_group_algebra.py

GitHub Actions / Conda (ubuntu, Python 3.12)

Warning: slow doctest:

slow doctest:

Check warning on line 1304 in src/sage/combinat/symmetric_group_algebra.py

GitHub Actions / Conda (ubuntu, Python 3.11)

Warning: slow doctest:

slow doctest:

Check warning on line 1304 in src/sage/combinat/symmetric_group_algebra.py

GitHub Actions / Conda (ubuntu, Python 3.12, editable)

Warning: slow doctest:

slow doctest:
....: idem = SGA.ladder_idemponent(la)
....: assert idem^2 == idem
....: print(la, SGA.principal_ideal(idem).dimension())
::
sage: solution = H.self_surrounding(8, remove_incomplete_copies=False)

Check warning on line 1455 in src/sage/combinat/tiling.py

GitHub Actions / Conda (ubuntu, Python 3.12)

Warning: slow doctest:

slow doctest:
sage: G = sum([p.show2d() for p in solution], Graphics()) # needs sage.plot
"""
# Define the box to tile
sage: W.start()
sage: DC = DocTestController(DD, filename)
sage: reporter = DocTestReporter(DC)
sage: W.join() # Wait for worker to finish

Check warning on line 2196 in src/sage/doctest/forker.py

GitHub Actions / Conda (ubuntu, Python 3.12)

Warning: slow doctest:

slow doctest:

Check warning on line 2196 in src/sage/doctest/forker.py

GitHub Actions / Conda (ubuntu, Python 3.11)

Warning: slow doctest:

slow doctest:

Check warning on line 2196 in src/sage/doctest/forker.py

GitHub Actions / Conda (ubuntu, Python 3.12, editable)

Warning: slow doctest:

slow doctest:
sage: result = W.result_queue.get()
sage: reporter.report(FDS, False, W.exitcode, result, "")
[... tests, ...s wall]
....: except OSError:
....: print("Write end of pipe successfully closed")
Write end of pipe successfully closed
sage: W.join() # Wait for worker to finish

Check warning on line 2323 in src/sage/doctest/forker.py

GitHub Actions / Conda (ubuntu, Python 3.12)

Warning: slow doctest:

slow doctest:

Check warning on line 2323 in src/sage/doctest/forker.py

GitHub Actions / Conda (ubuntu, Python 3.11)

Warning: slow doctest:

slow doctest:

Check warning on line 2323 in src/sage/doctest/forker.py

GitHub Actions / Conda (ubuntu, Python 3.12, editable)

Warning: slow doctest:

slow doctest:
"""
super().start()
sage: W.start()
sage: while W.rmessages is not None:
....: W.read_messages()
sage: W.join()

Check warning on line 2359 in src/sage/doctest/forker.py

GitHub Actions / Conda (ubuntu, Python 3.12)

Warning: slow doctest:

slow doctest:

Check warning on line 2359 in src/sage/doctest/forker.py

GitHub Actions / Conda (ubuntu, Python 3.11)

Warning: slow doctest:

slow doctest:

Check warning on line 2359 in src/sage/doctest/forker.py

GitHub Actions / Conda (ubuntu, Python 3.12, editable)

Warning: slow doctest:

slow doctest:
sage: len(W.messages) > 0
True
"""
sage: FDS = FileDocTestSource(filename, DD)
sage: W = DocTestWorker(FDS, DD)
sage: W.start()
sage: W.join()

Check warning on line 2391 in src/sage/doctest/forker.py

GitHub Actions / Conda (ubuntu, Python 3.12)

Warning: slow doctest:

slow doctest:

Check warning on line 2391 in src/sage/doctest/forker.py

GitHub Actions / Conda (ubuntu, Python 3.11)

Warning: slow doctest:

slow doctest:

Check warning on line 2391 in src/sage/doctest/forker.py

GitHub Actions / Conda (ubuntu, Python 3.12, editable)

Warning: slow doctest:

slow doctest:
sage: W.save_result_output()
sage: sorted(W.result[1].keys())
['cputime', 'err', 'failures', 'optionals', 'tests', 'walltime', 'walltime_skips']
sage: P.<x,y>=ProjectiveSpace(QQbar, 1)
sage: E=EllipticCurve([1, 2])
sage: f=P.Lattes_map(E, 2)
sage: f.Lattes_to_curve(check_lattes=true)

Check warning on line 6977 in src/sage/dynamics/arithmetic_dynamics/projective_ds.py

GitHub Actions / Conda (ubuntu, Python 3.12)

Warning: slow doctest:

slow doctest:

Check warning on line 6977 in src/sage/dynamics/arithmetic_dynamics/projective_ds.py

GitHub Actions / Conda (ubuntu, Python 3.11)

Warning: slow doctest:

slow doctest:

Check warning on line 6977 in src/sage/dynamics/arithmetic_dynamics/projective_ds.py

GitHub Actions / Conda (ubuntu, Python 3.12, editable)

Warning: slow doctest:

slow doctest:
Elliptic Curve defined by y^2 = x^3 + x + 2 over Rational Field
"""
Exact value of the integral \(\displaystyle\int_{0}^{2}x^{2} +
1\,\mathrm{d}x=4.666666666666668\)
sage: test(interacts.calculus.function_tool)

Check warning on line 208 in src/sage/interacts/test_jupyter.rst

GitHub Actions / Conda (ubuntu, Python 3.12)

Warning: slow doctest:

slow doctest:

Check warning on line 208 in src/sage/interacts/test_jupyter.rst

GitHub Actions / Conda (ubuntu, Python 3.11)

Warning: slow doctest:

slow doctest:

Check warning on line 208 in src/sage/interacts/test_jupyter.rst

GitHub Actions / Conda (ubuntu, Python 3.12, editable)

Warning: slow doctest:

slow doctest:
...Interactive function <function function_tool at ...> with 7 widgets
f: EvalText(value='sin(x)', description='f')
g: EvalText(value='cos(x)', description='g')
sage: from sage.combinat.designs.orthogonal_arrays_find_recursive import find_recursive_construction
sage: from sage.combinat.designs.orthogonal_arrays import is_orthogonal_array
sage: count = 0
sage: for n in range(10,150):

Check warning on line 88 in src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx

GitHub Actions / Conda (ubuntu, Python 3.11)

Warning: slow doctest:

slow doctest:
....: k = designs.orthogonal_arrays.largest_available_k(n)
....: if find_recursive_construction(k,n):
....: count = count + 1
True
sage: F41 = FusionRing("F4", 1)
sage: fmats = F41.get_fmatrix()
sage: fmats.find_orthogonal_solution(verbose=False)

Check failure on line 879 in src/sage/algebras/fusion_rings/fusion_ring.py

GitHub Actions / Conda (ubuntu, Python 3.11)

Timed out

/home/runner/miniconda3/envs/sage-dev/lib/python3.11/site-packages/cysignals/signals.cpython-311-x86_64-linux-gnu.so(+0x805c)[0x7fc865c2a05c] /home/runner/miniconda3/envs/sage-dev/lib/python3.11/site-packages/cysignals/signals.cpython-311-x86_64-linux-gnu.so(+0x8129)[0x7fc865c2a129] /home/runner/miniconda3/envs/sage-dev/lib/python3.11/site-packages/cysignals/signals.cpython-311-x86_64-linux-gnu.so(+0xb156)[0x7fc865c2d156] /lib/x86_64-linux-gnu/libc.so.6(+0x45330)[0x7fc866245330] /home/runner/miniconda3/envs/sage-dev/lib/libgmp.so.10(__gmpn_add_n_x86_64+0x6b)[0x7fc865b4ab2b] ------------------------------------------------------------------------ Attaching gdb to process id 17958. Cannot find gdb installed GDB is not installed. Install gdb for enhanced tracebacks. ------------------------------------------------------------------------
sage: b = F41.basis()
sage: all(F41.s_ijconj(x, y) == F41._basecoer(F41.s_ij(x, y, base_coercion=False).conjugate()) for x in b for y in b)
True
sage: x = SR.var('x')
sage: n = ZZ.random_element(5, 5001)
sage: a = QQ.random_element().abs() + 5
sage: s = ( (n + 1)*ultraspherical(n + 1, a, x)

Check warning on line 2298 in src/sage/functions/orthogonal_polys.py

GitHub Actions / Conda (ubuntu, Python 3.12, editable)

Warning: slow doctest:

slow doctest:
....: - 2*x*(n + a)*ultraspherical(n, a, x)
....: + (n + 2*a - 1)*ultraspherical(n - 1, a, x) )
sage: s.expand().is_zero()
....: # when Singular improves the algorithm or hardware gets faster, increase n.
sage: f = z^n-2
sage: g = z^2-z-x^2*y-x*y^3
sage: alarm(0.5); f.quo_rem(g)

Check failure on line 5230 in src/sage/rings/polynomial/multi_polynomial_libsingular.pyx

GitHub Actions / Conda (ubuntu, Python 3.12, editable)

Timed out (and interrupt failed)

/home/runner/miniconda3/envs/sage-dev/lib/python3.12/site-packages/cysignals/signals.cpython-312-x86_64-linux-gnu.so(+0x8ecc)[0x7fde5d477ecc] /home/runner/miniconda3/envs/sage-dev/lib/python3.12/site-packages/cysignals/signals.cpython-312-x86_64-linux-gnu.so(+0x8f99)[0x7fde5d477f99] /home/runner/miniconda3/envs/sage-dev/lib/python3.12/site-packages/cysignals/signals.cpython-312-x86_64-linux-gnu.so(+0xb8e6)[0x7fde5d47a8e6] /lib/x86_64-linux-gnu/libc.so.6(+0x45330)[0x7fde5dc45330] /lib/x86_64-linux-gnu/libc.so.6(__lll_lock_wait_private+0x2b)[0x7fde5dc98f0b] /lib/x86_64-linux-gnu/libc.so.6(malloc+0x2d0)[0x7fde5dcad920] python3(+0x2a6907)[0x5649858fe907] python3(_Py_GetLocaleEncoding+0x46)[0x564985902d66] python3(_Py_GetLocaleEncodingObject+0x8)[0x5649859612a8] python3(+0x2e8d4e)[0x564985940d4e] python3(_PyObject_MakeTpCall+0x274)[0x56498585c714] python3(+0x2b6238)[0x56498590e238] python3(_PyObject_CallFunction_SizeT+0xaa)[0x56498592e7da] python3(+0x2dfee4)[0x564985937ee4] python3(+0x112f8e)[0x56498576af8e] python3(_PyObject_FastCallDictTstate+0x292)[0x56498585f3a2] python3(_PyObject_Call_Prepend+0x69)[0x56498588a6b9] python3(+0x30364b)[0x56498595b64b] python3(_PyObject_MakeTpCall+0x2bb)[0x56498585c75b] python3(+0x1126a1)[0x56498576a6a1] python3(_PyObject_FastCallDictTstate+0x1ee)[0x56498585f2fe] python3(+0x23229c)[0x56498588a29c] python3(_PyObject_MakeTpCall+0x274)[0x56498585c714] python3(+0x1126a1)[0x56498576a6a1] python3(PyEval_EvalCode+0xa1)[0x564985912741] python3(+0x2def1a)[0x564985936f1a] python3(+0x2d9d35)[0x564985931d35] python3(+0x2f2780)[0x56498594a780] python3(_PyRun_SimpleFileObject+0x1ce)[0x564985949dfe] python3(_PyRun_AnyFileObject+0x44)[0x564985949ac4] python3(Py_RunMain+0x2fe)[0x564985942dfe] python3(Py_BytesMain+0x37)[0x5649858fd0c7] /lib/x86_64-linux-gnu/libc.so.6(+0x2a1ca)[0x7fde5dc2a1ca] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x8b)[0x7fde5dc2a28b] python3(+0x2a4f71)[0x5649858fcf71] ------------------------------------------------------------------------
Traceback (most recent call last):
...
AlarmInterrupt
sage: while not G.is_strongly_connected():
....: shuffle(r)
....: G.add_edges(enumerate(r), loops=False)
sage: spectral_radius(G, 1e-10) # random # long time

Check warning on line 1186 in src/sage/graphs/base/static_sparse_graph.pyx

GitHub Actions / test-long (src/sage/[g-o]*)

Warning: slow doctest:

slow doctest:
(1.9997956006500042, 1.9998043797692782)
The algorithm takes care of multiple edges::
EXAMPLES::
sage: # long time, needs sage.modules sage.rings.finite_rings
sage: G = graphs.shortened_000_111_extended_binary_Golay_code_graph() # 25 s

Check warning on line 491 in src/sage/graphs/generators/distance_regular.pyx

GitHub Actions / test-long (src/sage/[g-o]*)

Warning: slow doctest:

slow doctest:
sage: G.is_distance_regular(True)
([21, 20, 16, 9, 2, 1, None], [None, 1, 2, 3, 16, 20, 21])
TESTS::
sage: # needs sage.modules sage.rings.finite_rings
sage: G = graphs.GrassmannGraph(2, 6, 3) # long time

Check warning on line 1103 in src/sage/graphs/generators/distance_regular.pyx

GitHub Actions / test-long (src/sage/[g-o]*)

Warning: slow doctest:

slow doctest:
sage: G.is_distance_regular(True) # long time
([98, 72, 32, None], [None, 1, 9, 49])
sage: G = graphs.GrassmannGraph(3, 4, 2)
62
sage: G.is_distance_regular(True)
([6, 5, 5, None], [None, 1, 1, 6])
sage: G = graphs.DoubleGrassmannGraph(3, 2) # long time # needs sage.rings.finite_rings

Check warning on line 1165 in src/sage/graphs/generators/distance_regular.pyx

GitHub Actions / test-long (src/sage/[g-o]*)

Warning: slow doctest:

slow doctest:
sage: G.order() # long time # needs sage.rings.finite_rings
2420
sage: G.is_distance_regular(True) # long time # needs sage.rings.finite_rings
Half 4 Cube: Graph on 8 vertices
sage: graph_with_classical_parameters(3, 2, 0, 2, 9) # needs sage.libs.gap
Symplectic Dual Polar Graph DSp(6, 2): Graph on 135 vertices
sage: graph_with_classical_parameters(3, 2, 2, 14, 7) # long time # needs sage.symbolic

Check warning on line 2150 in src/sage/graphs/generators/distance_regular.pyx

GitHub Actions / test-long (src/sage/[g-o]*)

Warning: slow doctest:

slow doctest:
Grassmann graph J_2(6, 3): Graph on 1395 vertices
sage: graph_with_classical_parameters(3, -2, -2, 6, 6) # optional - gap_package_atlasrep internet
Generalised hexagon of order (2, 8): Graph on 819 vertices
TESTS::
sage: for p in primes_first_n(7)[1:]: # long time

Check warning on line 515 in src/sage/groups/fqf_orthogonal.py

GitHub Actions / test-long (src/sage/[g-o]*)

Warning: slow doctest:

slow doctest:
....: q = matrix.diagonal(QQ, 3 * [2/p])
....: q = TorsionQuadraticForm(q)
....: assert q.orthogonal_group().order()==GO(3, p).order()
(True, 1)
sage: A3 = groups.presentation.Alternating(3); A3.order(), A3.as_permutation_group().is_cyclic()
(3, True)
sage: A8 = groups.presentation.Alternating(8); A8.order()

Check warning on line 492 in src/sage/groups/finitely_presented_named.py

GitHub Actions / test-long (src/sage/[g-o]*)

Warning: slow doctest:

slow doctest:
20160
"""
from sage.groups.perm_gps.permgroup_named import AlternatingGroup
[ 2 0 -1 -2 0 1]
[ 2 0 -1 2 0 -1]
sage: def numgps(n): return ZZ(libgap.NumberSmallGroups(n))
sage: all(SmallPermutationGroup(n,k).id() == [n,k]

Check warning on line 3516 in src/sage/groups/perm_gps/permgroup_named.py

GitHub Actions / test-long (src/sage/[g-o]*)

Warning: slow doctest:

slow doctest:
....: for n in [1..64] for k in [1..numgps(n)]) # long time (180s)
True
sage: H = SmallPermutationGroup(6,1)
EXAMPLES::
# The output is kind of random
sage: sorted(maxima._commands(verbose=False))

Check warning on line 307 in src/sage/interfaces/maxima_abstract.py

GitHub Actions / test-long (src/sage/[g-o]*)

Warning: slow doctest:

slow doctest:
[...
'display',
...
sage: ef = e.coframe()
sage: ef[1].display(), ef[2].display(), ef[3].display()
(e^1 = 1/y dx, e^2 = 1/z dy, e^3 = 1/x dz)
sage: nab.curvature_form(1,1,e) # long time

Check warning on line 2334 in src/sage/manifolds/differentiable/affine_connection.py

GitHub Actions / test-long (src/sage/[g-o]*)

Warning: slow doctest:

slow doctest:
2-form curvature (1,1) of connection nabla w.r.t. Vector frame
(M, (e_1,e_2,e_3)) on the 3-dimensional differentiable manifold M
sage: nab.curvature_form(1,1,e).display(e) # long time (if above is skipped)
And simplify every single entry (which is more effective that simplify
the whole matrix like above)::
sage: m.parent()([x.simplify_full() for x in m._list()]) # random # long time, needs sage.symbolic

Check warning on line 237 in src/sage/plot/plot3d/transform.pyx

GitHub Actions / test-long (src/sage/[p-z]*)

Warning: slow doctest:

slow doctest:
[ -(cos(theta) - 1)*x^2 + cos(theta) -(cos(theta) - 1)*sqrt(-x^2 - z^2 + 1)*x + sin(theta)*abs(z) -((cos(theta) - 1)*x*z^2 + sqrt(-x^2 - z^2 + 1)*sin(theta)*abs(z))/z]
[ -(cos(theta) - 1)*sqrt(-x^2 - z^2 + 1)*x - sin(theta)*abs(z) (cos(theta) - 1)*x^2 + (cos(theta) - 1)*z^2 + 1 -((cos(theta) - 1)*sqrt(-x^2 - z^2 + 1)*z*abs(z) - x*z*sin(theta))/abs(z)]
[ -((cos(theta) - 1)*x*z^2 - sqrt(-x^2 - z^2 + 1)*sin(theta)*abs(z))/z -((cos(theta) - 1)*sqrt(-x^2 - z^2 + 1)*z*abs(z) + x*z*sin(theta))/abs(z) -(cos(theta) - 1)*z^2 + cos(theta)]
sage: asy # long time
(4/3*sqrt(3)*sqrt(r)/sqrt(pi) + 47/216*sqrt(3)/(sqrt(pi)*sqrt(r)),
1, 4/3*sqrt(3)*sqrt(r)/sqrt(pi) + 47/216*sqrt(3)/(sqrt(pi)*sqrt(r)))
sage: F.relative_error(asy[0], alpha, [1, 2, 4, 8], asy[1]) # long time

Check warning on line 1597 in src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py

GitHub Actions / test-long (src/sage/[p-z]*)

Warning: slow doctest:

slow doctest:
[((3, 3, 2), 0.9812164307, [1.515572606], [-0.54458543...]),
((6, 6, 4), 1.576181132, [1.992989399], [-0.26444185...]),
((12, 12, 8), 2.485286378, [2.712196351], [-0.091301338...]),
sage: B = function('B')(*tuple(T))
sage: AB_derivs = {}
sage: M = matrix([[1, 2],[2, 1]])
sage: DD = diff_op(A, B, AB_derivs, T, M, 1, 2) # long time (see :issue:`35207`)

Check warning on line 3945 in src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py

GitHub Actions / test-long (src/sage/[p-z]*)

Warning: slow doctest:

slow doctest:
sage: sorted(DD) # long time
[(0, 0, 0), (0, 1, 0), (0, 1, 1), (0, 1, 2)]
sage: DD[(0, 1, 2)].number_of_operands() # long time
sage: tau = var('tau')
sage: phi = function('phi')
sage: asymptotic_expansions.ImplicitExpansion('Z', phi=phi, tau=tau, precision=3) # long time

Check warning on line 1097 in src/sage/rings/asymptotic/asymptotic_expansion_generators.py

GitHub Actions / test-long (src/sage/[p-z]*)

Warning: slow doctest:

slow doctest:
tau + (-sqrt(2)*sqrt(-tau*phi(tau)^2/(2*tau*diff(phi(tau), tau)^2
- tau*phi(tau)*diff(phi(tau), tau, tau)
- 2*phi(tau)*diff(phi(tau), tau))))*Z^(-1/2) + O(Z^(-1))
sage: TestSuite(J).run()
sage: TestSuite(K).run(max_runs=256) # long time (10s) # needs sage.rings.function_field sage.rings.number_field
sage: TestSuite(L).run(max_runs=8) # long time (25s) # needs sage.rings.function_field sage.rings.number_field

Check warning on line 129 in src/sage/rings/function_field/function_field.py

GitHub Actions / test-long (src/sage/[p-z]*)

Warning: slow doctest:

slow doctest:
sage: # needs sage.rings.finite_rings sage.rings.function_field
sage: TestSuite(M).run(max_runs=8) # long time (35s)

Check warning on line 132 in src/sage/rings/function_field/function_field.py

GitHub Actions / test-long (src/sage/[p-z]*)

Warning: slow doctest:

slow doctest:
sage: TestSuite(N).run(max_runs=8, skip='_test_derivation') # long time (15s)
sage: TestSuite(O).run()
sage: TestSuite(R).run()
sage: J = C.jacobian(model='km_large', base_div=h)
sage: G1 = J.group()
sage: K = k.extension(2)
sage: G2 = J.group(K)

Check warning on line 517 in src/sage/rings/function_field/jacobian_khuri_makdisi.py

GitHub Actions / test-long (src/sage/[p-z]*)

Warning: slow doctest:

slow doctest:
sage: G2.coerce_map_from(G1)
Jacobian group embedding map:
From: Group of rational points of Jacobian
sage: J = C.jacobian(model='km_large', base_div=h)
sage: G1 = J.group()
sage: K = k.extension(2)
sage: G2 = J.group(K)

Check warning on line 877 in src/sage/rings/function_field/jacobian_khuri_makdisi.py

GitHub Actions / test-long (src/sage/[p-z]*)

Warning: slow doctest:

slow doctest:
sage: G2.coerce_map_from(G1)
Jacobian group embedding map:
From: Group of rational points of Jacobian
sage: b = C([0,0,1]).place()
sage: J = C.jacobian(model='km_large', base_div=3*b)
sage: G = J.group()
sage: len([pt for pt in G]) # long time

Check warning on line 924 in src/sage/rings/function_field/jacobian_khuri_makdisi.py

GitHub Actions / test-long (src/sage/[p-z]*)

Warning: slow doctest:

slow doctest:
11
"""
d0 = self._base_div.degree()
sage: D1 = 3*infty2 + infty1 - 4*P
sage: D2 = F.divisor_group().zero()
sage: J = F.jacobian(model='km-small', base_div=4*P)
sage: J(D1) + J(D2) == J(D1)

Check warning on line 887 in src/sage/rings/function_field/khuri_makdisi.pyx

GitHub Actions / test-long (src/sage/[p-z]*)

Warning: slow doctest:

slow doctest:
True
"""
cdef int d0 = self.d0
sage: g
Simple matrix Lie algebra of type ['E', 7] over Rational Field
sage: len(g.basis()) # long time

Check warning on line 944 in src/sage/algebras/lie_algebras/classical_lie_algebra.py

GitHub Actions / test-long (src/sage/[a-f]*)

Warning: slow doctest:

slow doctest:
133
sage: TestSuite(g).run() # long time
"""
Check that randomly generated ideals decompose as expected::
sage: for d in ( m for m in range(400, 750) if is_squarefree(m) ): # long time (7s)

Check warning on line 4261 in src/sage/algebras/quatalg/quaternion_algebra.py

GitHub Actions / test-long (src/sage/[a-f]*)

Warning: slow doctest:

slow doctest:
....: A = QuaternionAlgebra(d)
....: O = A.maximal_order()
....: for _ in range(10):
TESTS::
sage: A = SteenrodAlgebra(7) # needs sage.combinat sage.modules
sage: A._test_antipode() # long time # needs sage.combinat sage.modules

Check warning on line 93 in src/sage/categories/super_hopf_algebras_with_basis.py

GitHub Actions / test-long (src/sage/[a-f]*)

Warning: slow doctest:

slow doctest:
"""
tester = self._tester(**options)
sage: bij = Bijectionist(sum(As, []), sum(Bs, []))
sage: bij.set_statistics((lambda x: x[0], lambda x: x[0]))
sage: bij.set_intertwining_relations((2, c1, c1), (1, c2, c2))
sage: l = list(bij.solutions_iterator()); len(l) # long time -- (2.7 seconds with SCIP on AMD Ryzen 5 PRO 3500U w/ Radeon Vega Mobile Gfx)

Check warning on line 3138 in src/sage/combinat/bijectionist.py

GitHub Actions / test-long (src/sage/[a-f]*)

Warning: slow doctest:

slow doctest:
64
A brute force check would be difficult::
sage: A = sum(As, [])
sage: respects_c1 = lambda s: all(c1(a1, a2) not in A or s[c1(a1, a2)] == c1(s[a1], s[a2]) for a1 in A for a2 in A)
sage: respects_c2 = lambda s: all(c2(a1) not in A or s[c2(a1)] == c2(s[a1]) for a1 in A)
sage: l2 = [s for s in it if respects_c1(s) and respects_c2(s)] # long time -- (17 seconds on AMD Ryzen 5 PRO 3500U w/ Radeon Vega Mobile Gfx)

Check warning on line 3166 in src/sage/combinat/bijectionist.py

GitHub Actions / test-long (src/sage/[a-f]*)

Warning: slow doctest:

slow doctest:
sage: sorted(l1, key=lambda s: tuple(s.items())) == l2 # long time
True
We factor out the long test from the ``TestSuite``::
sage: TestSuite(PP).run(skip='_test_enumerated_set_contains')
sage: PP._test_enumerated_set_contains() # long time

Check warning on line 128 in src/sage/combinat/backtrack.py

GitHub Actions / test-long (src/sage/[a-f]*)

Warning: slow doctest:

slow doctest:
"""
def __init__(self):
sage: TestSuite(C).run()
sage: C = crystals.AlcovePaths(['A',2,1],[1,0,0])
sage: TestSuite(C).run() #long time

Check warning on line 296 in src/sage/combinat/crystals/alcove_path.py

GitHub Actions / test-long (src/sage/[a-f]*)

Warning: slow doctest:

slow doctest:
sage: C = crystals.AlcovePaths(['A',2,1],[1,0],False)
sage: TestSuite(C).run(skip='_test_stembridge_local_axioms') #long time
Quiver on 10 vertices of type ['E', 8, [1, 1]]
sage: Q._mutation_type = None; Q
Quiver on 10 vertices
sage: Q.mutation_type() # long time

Check warning on line 934 in src/sage/combinat/cluster_algebra_quiver/quiver.py

GitHub Actions / test-long (src/sage/[a-f]*)

Warning: slow doctest:

slow doctest:
['E', 8, [1, 1]]
the not yet working affine type D (unless user has saved small classical quiver data)::
['E', 8, [1, 1]]
sage: dg = DiGraph( { 0:[3], 1:[0,4], 2:[0,6], 3:[1,2,7], 4:[3,8], 5:[2], 6:[3,5], 7:[4,6], 8:[7] } )
sage: ClusterQuiver( dg ).mutation_type() # long time

Check warning on line 958 in src/sage/combinat/cluster_algebra_quiver/quiver.py

GitHub Actions / test-long (src/sage/[a-f]*)

Warning: slow doctest:

slow doctest:
['E', 8, 1]
sage: dg = DiGraph( { 0:[3,9], 1:[0,4], 2:[0,6], 3:[1,2,7], 4:[3,8], 5:[2], 6:[3,5], 7:[4,6], 8:[7], 9:[1] } )
A seed for a cluster algebra of rank 10 of type ['E', 8, [1, 1]]
sage: S._mutation_type = S._quiver._mutation_type = None; S
A seed for a cluster algebra of rank 10
sage: S.mutation_type() # long time

Check warning on line 4173 in src/sage/combinat/cluster_algebra_quiver/cluster_seed.py

GitHub Actions / test-long (src/sage/[a-f]*)

Warning: slow doctest:

slow doctest:
['E', 8, [1, 1]]
- the not yet working affine type D::
sage: C = LinearCode(random_matrix(GF(47), 25, 35))
sage: from sage.doctest.util import ensure_interruptible_after
sage: with ensure_interruptible_after(0.5): C.canonical_representative() # needs sage.libs.gap

Check failure on line 791 in src/sage/coding/linear_code.py

GitHub Actions / test-long (src/sage/[a-f]*)

Timed out

/sage/local/var/lib/sage/venv-python3.12/lib/python3.12/site-packages/cysignals/signals.cpython-312-x86_64-linux-gnu.so(+0x9f94)[0x7f7e52015f94] /sage/local/var/lib/sage/venv-python3.12/lib/python3.12/site-packages/cysignals/signals.cpython-312-x86_64-linux-gnu.so(+0xa056)[0x7f7e52016056] /sage/local/var/lib/sage/venv-python3.12/lib/python3.12/site-packages/cysignals/signals.cpython-312-x86_64-linux-gnu.so(+0xc936)[0x7f7e52018936] /lib/x86_64-linux-gnu/libc.so.6(+0x45330)[0x7f7e531c5330] /lib/x86_64-linux-gnu/libc.so.6(+0x98d71)[0x7f7e53218d71] /lib/x86_64-linux-gnu/libc.so.6(+0xa4fb8)[0x7f7e53224fb8] python3(PyThread_acquire_lock_timed+0xcd)[0x61069d] python3[0x64ddea] python3[0x551598] python3(PyObject_Vectorcall+0x35)[0x549b85] python3(_PyEval_EvalFrameDefault+0xa89)[0x5d73c9] python3[0x54cd32] python3[0x549f57] python3(PyObject_CallFunctionObjArgs+0xa2)[0x549cd2] /sage/local/var/lib/sage/venv-python3.12/lib/python3.12/site-packages/coverage/tracer.cpython-312-x86_64-linux-gnu.so(+0x3669)[0x7f7e52caa669] python3[0x602b83] python3[0x6014f9] python3[0x601d8f] python3[0x69cc07] python3[0x496b46] python3[0x555b8f] python3[0x66c4e6] python3[0x551aa2] python3(PyObject_Vectorcall+0x35)[0x549b85] python3(_PyEval_EvalFrameDefault+0xa89)[0x5d73c9] python3[0x54cd94] python3(PyObject_Vectorcall+0x35)[0x549b85] python3(_PyEval_EvalFrameDefault+0x76b4)[0x5ddff4] python3(PyEval_EvalCode+0x15b)[0x5d58eb] python3[0x5d347c] python3(_PyEval_EvalFrameDefault+0x3f6a)[0x5da8aa] python3(_PyObject_Call_Prepend+0x18a)[0x54aa9a] python3[0x5a3628] python3(_PyObject_MakeTpCall+0x13e)[0x54924e] python3(_PyEval_EvalFrameDefault+0xa89)[0x5d73c9] python3(_PyObject_Call_Prepend+0xc2)[0x54a9d2] python3[0x59e09f] python3[0x599b63] python3(_PyObject_MakeTpCall+0x75)[0x549185] python3(_PyEval_EvalFrameDefault+0xa89)[0x5d73c9] python3(PyEval_EvalCode+0x15b)[0x5d58eb] python3[0x5d347c] python3[0x581f0d] python3(PyObject_Vectorcall+0x35)[0x549b85] python3(_PyEval_EvalFrameDefault+0xa89)[0x5d73c9] python3(PyEval_EvalCode+0x15b)[0x5d58eb] python3[0x5d347c] python3[0x581f0d] python3(PyObject_Vectorcall+0x35)[0x549b85] python3(_PyEval_EvalFrameDefault+0xa89)[0x5d73c9] python3[0x6bcce2] python3(Py_RunMain+0x232)[0x6bc912] python3(Py_BytesMain+0x2d)[0x6bc57d] /lib/x86_64-linux-gnu/libc.so.6(+0x2a1ca)[0x7f7e531aa1ca] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x8b)[0x7f7e531aa28b] python3(_start+0x25)[0x657ce5] ------------------------------------------------------------------------ Attaching gdb to process id 2579. Cannot find gdb installed GDB is not installed. Install gdb for enhanced tracebacks. ------------------------------------------------------------------------
"""
aut_group_can_label = self._canonize(equivalence)
return aut_group_can_label.get_canonical_form(), \