10000 Make Sequence pretty-printed in IPython by user202729 · Pull Request #39027 · sagemath/sage · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Make Sequence pretty-printed in IPython #39027

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

Merged
merged 12 commits into from
Jan 4, 2025
16 changes: 3 additions & 13 deletions src/doc/de/tutorial/programming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,9 @@ aussehen könnten. Hier sind einige Beispiele:
sqrt(2)
sage: V = VectorSpace(QQ,2)
sage: V.basis()
[
(1, 0),
(0, 1)
]
[(1, 0), (0, 1)]
sage: basis(V)
[
(1, 0),
(0, 1)
]
[(1, 0), (0, 1)]
sage: M = MatrixSpace(GF(7), 2); M
Full MatrixSpace of 2 by 2 dense matrices over Finite Field of size 7
sage: A = M([1,2,3,4]); A
Expand Down Expand Up @@ -425,11 +419,7 @@ Vektorräumen. Es ist wichtig, dass sie nicht verändert werden können.
::

sage: V = QQ^3; B = V.basis(); B
[
(1, 0, 0),
(0, 1, 0),
(0, 0, 1)
]
[(1, 0, 0), (0, 1, 0), (0, 0, 1)]
sage: type(B)
<class 'sage.structure.sequence.Sequence_generic'>
sage: B[0] = B[1]
Expand Down
45 changes: 17 additions & 28 deletions src/doc/de/tutorial/tour_advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ die Kurven als irreduzible Komponenten der Vereinigung zurück erhalten.
Affine Plane Curve over Rational Field defined by
x^5 + x^3*y^2 + x^2*y^3 + y^5 - x^3 - y^3 - x^2 - y^2 + 1
sage: D.irreducible_components()
[
Closed subscheme of Affine Space of dimension 2 over Rational Field defined by:
x^2 + y^2 - 1,
Closed subscheme of Affine Space of dimension 2 over Rational Field defined by:
x^3 + y^3 - 1
]
[Closed subscheme of Affine Space of dimension 2 over Rational Field defined by:
x^2 + y^2 - 1,
Closed subscheme of Affine Space of dimension 2 over Rational Field defined by:
x^3 + y^3 - 1]

Wir können auch alle Punkte im Schnitt der beiden Kurven finden, indem
wir diese schneiden und dann die irreduziblen Komponenten berechnen.
Expand All @@ -36,17 +34,15 @@ wir diese schneiden und dann die irreduziblen Komponenten berechnen.

sage: V = C2.intersection(C3)
sage: V.irreducible_components()
[
Closed subscheme of Affine Space of dimension 2 over Rational Field defined by:
y,
x - 1,
Closed subscheme of Affine Space of dimension 2 over Rational Field defined by:
y - 1,
x,
Closed subscheme of Affine Space of dimension 2 over Rational Field defined by:
x + y + 2,
2*y^2 + 4*y + 3
]
[Closed subscheme of Affine Space of dimension 2 over Rational Field defined by:
y,
x - 1,
Closed subscheme of Affine Space of dimension 2 over Rational Field defined by:
y - 1,
x,
Closed subscheme of Affine Space of dimension 2 over Rational Field defined by:
x + y + 2,
2*y^2 + 4*y + 3]

Also sind zum Beispiel :math:`(1,0)` und :math:`(0,1)` auf beiden
Kurven (wie man sofort sieht), genauso wie bestimmte (quadratischen)
Expand Down Expand Up @@ -333,10 +329,8 @@ Faktorisierung des Moduls entsprechen.
[1, 2, 2, 1, 1, 2, 2, 1]

sage: G.decomposition()
[
Group of Dirichlet characters modulo 3 with values in Cyclotomic Field of order 6 and degree 2,
Group of Dirichlet characters modulo 7 with values in Cyclotomic Field of order 6 and degree 2
]
[Group of Dirichlet characters modulo 3 with values in Cyclotomic Field of order 6 and degree 2,
Group of Dirichlet characters modulo 7 with values in Cyclotomic Field of order 6 and degree 2]

Als nächstes konstruieren wir die Gruppe der Dirichlet-Charaktere
mod 20, jedoch mit Werten in :math:`\QQ(i)`:
Expand Down Expand Up @@ -465,9 +459,7 @@ Nun berechnen wir ein paar charakteristische Polynome und
[-2 0]
[ 0 -2]
sage: S.q_expansion_basis(10)
[
q - 2*q^2 - q^3 + 2*q^4 + q^5 + 2*q^6 - 2*q^7 - 2*q^9 + O(q^10)
]
[q - 2*q^2 - q^3 + 2*q^4 + q^5 + 2*q^6 - 2*q^7 - 2*q^9 + O(q^10)]

Wir können sogar Räume von Modulsymbolen mit Charakteren berechnen.

Expand All @@ -487,10 +479,7 @@ Wir können sogar Räume von Modulsymbolen mit Charakteren berechnen.
sage: S.T(2).charpoly('x').factor()
< BEA9 /td> (x + zeta6 + 1)^2
sage: S.q_expansion_basis(10)
[
q + (-zeta6 - 1)*q^2 + (2*zeta6 - 2)*q^3 + zeta6*q^4 + (-2*zeta6 + 1)*q^5
+ (-2*zeta6 + 4)*q^6 + (2*zeta6 - 1)*q^8 - zeta6*q^9 + O(q^10)
]
[q + (-zeta6 - 1)*q^2 + (2*zeta6 - 2)*q^3 + zeta6*q^4 + (-2*zeta6 + 1)*q^5 + (-2*zeta6 + 4)*q^6 + (2*zeta6 - 1)*q^8 - zeta6*q^9 + O(q^10)]

Hier ist ein weiteres Beispiel davon wie Sage mit den Operationen von
Hecke-Operatoren auf dem Raum von Modulformen rechnen kann.
Expand Down
6 changes: 1 addition & 5 deletions src/doc/de/tutorial/tour_linalg.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ Sage kann auch Eigenwerte und Eigenvektoren berechnen::
[-2*I, 2*I]
sage: B = matrix([[1, 3], [3, 1]])
sage: B.eigenvectors_left()
[(4, [
(1, 1)
], 1), (-2, [
(1, -1)
], 1)]
[(4, [(1, 1)], 1), (-2, [(1, -1)], 1)]

(Die Syntax der Ausgabe von ``eigenvectors_left`` ist eine Liste von
Tripeln: (Eigenwert, Eigenvektor, Vielfachheit).) Eigenwerte und
Expand Down
61 changes: 26 additions & 35 deletions src/doc/en/constructions/linear_algebra.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ one can create a subspace. Note the basis computed by Sage is
sage: V = VectorSpace(GF(2),8)
sage: S = V.subspace([V([1,1,0,0,0,0,0,0]),V([1,0,0,0,0,1,1,0])])
sage: S.basis()
[
(1, 0, 0, 0, 0, 1, 1, 0),
(0, 1, 0, 0, 0, 1, 1, 0)
]
[(1, 0, 0, 0, 0, 1, 1, 0), (0, 1, 0, 0, 0, 1, 1, 0)]
sage: S.dimension()
2

Expand Down Expand Up @@ -205,26 +202,21 @@ gives matrices :math:`D` and :math:`P` such that :math:`AP=PD` (resp.
sage: A.eigenvalues()
[3, 2, 1]
sage: A.eigenvectors_right()
[(3, [
(0, 0, 1)
], 1), (2, [
(1, 1, 0)
], 1), (1, [
(1, 0, 0)
], 1)]
[(3, [(0, 0, 1)], 1), (2, [(1, 1, 0)], 1), (1, [(1, 0, 0)], 1)]

sage: A.eigenspaces_right()
[
(3, Vector space of degree 3 and dimension 1 over Rational Field
User basis matrix:
[0 0 1]),
(2, Vector space of degree 3 and dimension 1 over Rational Field
User basis matrix:
[1 1 0]),
(1, Vector space of degree 3 and dimension 1 over Rational Field
User basis matrix:
[1 0 0])
]
[(3,
Vector space of degree 3 and dimension 1 over Rational Field
User basis matrix:
[0 0 1]),
(2,
Vector space of degree 3 and dimension 1 over Rational Field
User basis matrix:
[1 1 0]),
(1,
Vector space of degree 3 and dimension 1 over Rational Field
User basis matrix:
[1 0 0])]

sage: D, P = A.eigenmatrix_right()
sage: D
Expand Down Expand Up @@ -256,20 +248,19 @@ floating point entries (over ``CDF`` and ``RDF``) can be obtained with the
sage: MS = MatrixSpace(QQ, 2, 2)
sage: A = MS([1,-4,1, -1])
sage: A.eigenspaces_left(format='all')
[
(-1.732050807568878?*I, Vector space of degree 2 and dimension 1 over Algebraic Field
User basis matrix:
[ 1 -1 - 1.732050807568878?*I]),
(1.732050807568878?*I, Vector space of degree 2 and dimension 1 over Algebraic Field
User basis matrix:
[ 1 -1 + 1.732050807568878?*I])
]
[(-1.732050807568878?*I,
Vector space of degree 2 and dimension 1 over Algebraic Field
User basis matrix:
[ 1 -1 - 1.732050807568878?*I]),
(1.732050807568878?*I,
Vector space of degree 2 and dimension 1 over Algebraic Field
User basis matrix:
[ 1 -1 + 1.732050807568878?*I])]
sage: A.eigenspaces_left(format='galois')
[
(a0, Vector space of degree 2 and dimension 1 over Number Field in a0 with defining polynomial x^2 + 3
User basis matrix:
[ 1 a0 - 1])
]
[(a0,
Vector space of degree 2 and dimension 1 over Number Field in a0 with defining polynomial x^2 + 3
User basis matrix:
[ 1 a0 - 1])]

Another approach is to use the interface with Maxima:

Expand Down
6 changes: 1 addition & 5 deletions src/doc/en/prep/Quickstarts/Graphs-and-Discrete.rst
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,7 @@ Start with a generator matrix over :math:`\ZZ/2\ZZ`.
::

sage: D.basis()
[
(1, 0, 1, 0, 1, 0, 1),
(0, 1, 1, 0, 0, 1, 1),
(0, 0, 0, 1, 1, 1, 1)
]
[(1, 0, 1, 0, 1, 0, 1), (0, 1, 1, 0, 0, 1, 1), (0, 0, 0, 1, 1, 1, 1)]

::

Expand Down
5 changes: 1 addition & 4 deletions src/doc/en/prep/Quickstarts/Linear-Algebra.rst
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,7 @@ of the matrix)::
Or we can get the basis vectors explicitly as a list of vectors::

sage: V.basis()
[
(1, 0, -1/3),
(0, 1, -2/3)
]
[(1, 0, -1/3), (0, 1, -2/3)]

.. note::
Kernels are **vector spaces** and bases are "\ **echelonized**\ "
Expand Down
< 10000 td class="blob-code blob-code-deletion js-file-line"> q^16 + 96*q^17 + O(q^18)
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,31 @@ rather nice diagonal shape.
::

sage: victor_miller_basis(24, 6)
[
1 + 52416000*q^3 + 39007332000*q^4 + 6609020221440*q^5 + O(q^6),
q + 195660*q^3 + 12080128*q^4 + 44656110*q^5 + O(q^6),
q^2 - 48*q^3 + 1080*q^4 - 15040*q^5 + O(q^6)
]
[1 + 52416000*q^3 + 39007332000*q^4 + 6609020221440*q^5 + O(q^6),
q + 195660*q^3 + 12080128*q^4 + 44656110*q^5 + O(q^6),
q^2 - 48*q^3 + 1080*q^4 - 15040*q^5 + O(q^6)]
sage: from sage.modular.dims import dimension_modular_forms
sage: dimension_modular_forms(1,200)
17
sage: B = victor_miller_basis(200, 18) #5 seconds
sage: B
[
1 + 79288314420681734048660707200000*q^17 + O(q^18),
q + 2687602718106772837928968846869*q^17 + O(q^18),
...
]
[1 + 79288314420681734048660707200000*q^17 + O(q^18),
q + 2687602718106772837928968846869*q^17 + O(q^18),
q^2 + 85789116961248834349485762560*q^17 + O(q^18),
q^3 + 2567045661341737693075080984*q^17 + O(q^18),
q^4 + 71629117222531314878690304*q^17 + O(q^18),
q^5 + 1852433650992110376992650*q^17 + O(q^18),
q^6 + 44081333191517147315712*q^17 + O(q^18),
q^7 + 956892703246212300900*q^17 + O(q^18),
q^8 + 18748755998771700480*q^17 + O(q^18),
q^9 + 327218645736859401*q^17 + O(q^18),
q^10 + 5001104379048960*q^17 + O(q^18),
q^11 + 65427591611128*q^17 + O(q^18),
q^12 + 709488619776*q^17 + O(q^18),
q^13 + 6070433286*q^17 + O(q^18),
q^14 + 37596416*q^17 + O(q^18),
q^15 + 138420*q^17 + O(q^18),
q^16 + 96*q^17 + O(q^18)]

Note: Craig Citro has made the above computation an order of
magnitude faster in code he has not quite got into Sage yet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ compute some basic invariants.
::

sage: D = J0(39).decomposition(); D
[
Simple abelian subvariety 39a(1,39) of dimension 1 of J0(39),
Simple abelian subvariety 39b(1,39) of dimension 2 of J0(39)
]
[Simple abelian subvariety 39a(1,39) of dimension 1 of J0(39),
Simple abelian subvariety 39b(1,39) of dimension 2 of J0(39)]
sage: D[1].lattice()
Free module of degree 6 and rank 4 over Integer Ring
Echelon basis matrix:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,11 @@ and :math:`k` is the weight.
sage: S = CuspForms(Gamma0(25),4, prec=15); S
Cuspidal subspace of dimension 5 of Modular Forms space ...
sage: S.basis()
[
q + q^9 - 8*q^11 - 8*q^14 + O(q^15),
q^2 - q^7 - q^8 - 7*q^12 + 7*q^13 + O(q^15),
q^3 + q^7 - 2*q^8 - 6*q^12 - 5*q^13 + O(q^15),
q^4 - q^6 - 3*q^9 + 5*q^11 - 2*q^14 + O(q^15),
q^5 - 4*q^10 + O(q^15)
]
[q + q^9 - 8*q^11 - 8*q^14 + O(q^15),
q^2 - q^7 - q^8 - 7*q^12 + 7*q^13 + O(q^15),
q^3 + q^7 - 2*q^8 - 6*q^12 - 5*q^13 + O(q^15),
q^4 - q^6 - 3*q^9 + 5*q^11 - 2*q^14 + O(q^15),
q^5 - 4*q^10 + O(q^15)]

Dimension Formulas
~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -200,9 +198,7 @@ described later.
::

sage: CuspForms(DirichletGroup(5).0, 5).basis()
[
q + (-zeta4 - 1)*q^2 + (6*zeta4 - 6)*q^3 - ... + O(q^6)
]
[q + (-zeta4 - 1)*q^2 + (6*zeta4 - 6)*q^3 - 14*zeta4*q^4 + (15*zeta4 + 20)*q^5 + O(q^6)]


Dirichlet Characters
Expand Down Expand Up @@ -296,12 +292,10 @@ Hecke operator :math:`T_n`, and to compute the subspace

sage: M = ModularForms(Gamma0(11),4)
sage: M.basis()
[
q + 3*q^3 - 6*q^4 - 7*q^5 + O(q^6),
q^2 - 4*q^3 + 2*q^4 + 8*q^5 + O(q^6),
1 + O(q^6),
q + 9*q^2 + 28*q^3 + 73*q^4 + 126*q^5 + O(q^6)
]
[q + 3*q^3 - 6*q^4 - 7*q^5 + O(q^6),
q^2 - 4*q^3 + 2*q^4 + 8*q^5 + O(q^6),
1 + O(q^6),
q + 9*q^2 + 28*q^3 + 73*q^4 + 126*q^5 + O(q^6)]
sage: M.hecke_matrix(2)
[0 2 0 0]
[1 2 0 0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,18 @@ You can also enumerate all complex embeddings of a number field:
::

sage: K.complex_embeddings()
[
Ring morphism:
From: Number Field in a with defining polynomial x^3 - 2
To: Complex Field with 53 bits of precision
Defn: a |--> -0.629960524947437 - 1.09112363597172*I,
Ring morphism:
From: Number Field in a with defining polynomial x^3 - 2
To: Complex Field with 53 bits of precision
Defn: a |--> -0.629960524947437 + 1.09112363597172*I,
Ring morphism:
From: Number Field in a with defining polynomial x^3 - 2
To: Complex Field with 53 bits of precision
Defn: a |--> 1.25992104989487
]
[Ring morphism:
From: Number Field in a with defining polynomial x^3 - 2
To: Complex Field with 53 bits of precision
Defn: a |--> -0.629960524947437 - 1.09112363597172*I,
Ring morphism:
From: Number Field in a with defining polynomial x^3 - 2
To: Complex Field with 53 bits of precision
Defn: a |--> -0.629960524947437 + 1.09112363597172*I,
Ring morphism:
From: Number Field in a with defining polynomial x^3 - 2
To: Complex Field with 53 bits of precision
Defn: a |--> 1.25992104989487]


Class Numbers and Class Groups
Expand Down
Loading
Loading
0