passagemath-repl 10.5.27__py3-none-any.whl → 10.5.29__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- passagemath_repl-10.5.29.data/data/share/jupyter/kernels/sagemath/kernel.json +1 -0
- passagemath_repl-10.5.29.data/data/share/jupyter/kernels/sagemath/logo-64x64.png +0 -0
- passagemath_repl-10.5.29.data/data/share/jupyter/kernels/sagemath/logo.svg +352 -0
- {passagemath_repl-10.5.27.dist-info → passagemath_repl-10.5.29.dist-info}/METADATA +38 -13
- {passagemath_repl-10.5.27.dist-info → passagemath_repl-10.5.29.dist-info}/RECORD +95 -24
- {passagemath_repl-10.5.27.dist-info → passagemath_repl-10.5.29.dist-info}/top_level.txt +1 -0
- sage/ext_data/all__sagemath_repl.py +1 -0
- sage/interfaces/all__sagemath_repl.py +1 -0
- sage/repl/ipython_kernel/install.py +6 -8
- sage/tests/books/__init__.py +2 -0
- sage/tests/books/computational-mathematics-with-sagemath/__init__.py +1 -0
- sage/tests/books/computational-mathematics-with-sagemath/calculus_doctest.py +549 -0
- sage/tests/books/computational-mathematics-with-sagemath/combinat_doctest.py +1053 -0
- sage/tests/books/computational-mathematics-with-sagemath/domaines_doctest.py +443 -0
- sage/tests/books/computational-mathematics-with-sagemath/float_doctest.py +477 -0
- sage/tests/books/computational-mathematics-with-sagemath/graphique_doctest.py +254 -0
- sage/tests/books/computational-mathematics-with-sagemath/graphtheory_doctest.py +418 -0
- sage/tests/books/computational-mathematics-with-sagemath/integration_doctest.py +290 -0
- sage/tests/books/computational-mathematics-with-sagemath/linalg_doctest.py +454 -0
- sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py +421 -0
- sage/tests/books/computational-mathematics-with-sagemath/lp_doctest.py +234 -0
- sage/tests/books/computational-mathematics-with-sagemath/mpoly_doctest.py +560 -0
- sage/tests/books/computational-mathematics-with-sagemath/nonlinear_doctest.py +490 -0
- sage/tests/books/computational-mathematics-with-sagemath/numbertheory_doctest.py +155 -0
- sage/tests/books/computational-mathematics-with-sagemath/polynomes_doctest.py +405 -0
- sage/tests/books/computational-mathematics-with-sagemath/premierspas_doctest.py +180 -0
- sage/tests/books/computational-mathematics-with-sagemath/programmation_doctest.py +662 -0
- sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py +392 -0
- sage/tests/books/computational-mathematics-with-sagemath/sol/__init__.py +1 -0
- sage/tests/books/computational-mathematics-with-sagemath/sol/calculus_doctest.py +264 -0
- sage/tests/books/computational-mathematics-with-sagemath/sol/combinat_doctest.py +217 -0
- sage/tests/books/computational-mathematics-with-sagemath/sol/domaines_doctest.py +59 -0
- sage/tests/books/computational-mathematics-with-sagemath/sol/float_doctest.py +141 -0
- sage/tests/books/computational-mathematics-with-sagemath/sol/graphique_doctest.py +105 -0
- sage/tests/books/computational-mathematics-with-sagemath/sol/graphtheory_doctest.py +53 -0
- sage/tests/books/computational-mathematics-with-sagemath/sol/integration_doctest.py +56 -0
- sage/tests/books/computational-mathematics-with-sagemath/sol/linalg_doctest.py +56 -0
- sage/tests/books/computational-mathematics-with-sagemath/sol/linsolve_doctest.py +25 -0
- sage/tests/books/computational-mathematics-with-sagemath/sol/lp_doctest.py +47 -0
- sage/tests/books/computational-mathematics-with-sagemath/sol/mpoly_doctest.py +115 -0
- sage/tests/books/computational-mathematics-with-sagemath/sol/nonlinear_doctest.py +111 -0
- sage/tests/books/computational-mathematics-with-sagemath/sol/numbertheory_doctest.py +167 -0
- sage/tests/books/computational-mathematics-with-sagemath/sol/polynomes_doctest.py +107 -0
- sage/tests/books/computational-mathematics-with-sagemath/sol/recequadiff_doctest.py +58 -0
- sage/tests/books/judson-abstract-algebra/__init__.py +1 -0
- sage/tests/books/judson-abstract-algebra/actions-sage-exercises.py +51 -0
- sage/tests/books/judson-abstract-algebra/actions-sage.py +173 -0
- sage/tests/books/judson-abstract-algebra/algcodes-sage.py +130 -0
- sage/tests/books/judson-abstract-algebra/boolean-sage.py +269 -0
- sage/tests/books/judson-abstract-algebra/cosets-sage-exercises.py +87 -0
- sage/tests/books/judson-abstract-algebra/cosets-sage.py +170 -0
- sage/tests/books/judson-abstract-algebra/crypt-sage.py +151 -0
- sage/tests/books/judson-abstract-algebra/cyclic-sage.py +450 -0
- sage/tests/books/judson-abstract-algebra/domains-sage.py +163 -0
- sage/tests/books/judson-abstract-algebra/fields-sage.py +299 -0
- sage/tests/books/judson-abstract-algebra/finite-sage.py +108 -0
- sage/tests/books/judson-abstract-algebra/galois-sage.py +484 -0
- sage/tests/books/judson-abstract-algebra/groups-sage.py +280 -0
- sage/tests/books/judson-abstract-algebra/homomorph-sage-exercises.py +65 -0
- sage/tests/books/judson-abstract-algebra/homomorph-sage.py +200 -0
- sage/tests/books/judson-abstract-algebra/integers-sage.py +197 -0
- sage/tests/books/judson-abstract-algebra/isomorph-sage.py +172 -0
- sage/tests/books/judson-abstract-algebra/normal-sage.py +133 -0
- sage/tests/books/judson-abstract-algebra/permute-sage.py +319 -0
- sage/tests/books/judson-abstract-algebra/poly-sage.py +300 -0
- sage/tests/books/judson-abstract-algebra/rings-sage.py +413 -0
- sage/tests/books/judson-abstract-algebra/sets-sage.py +163 -0
- sage/tests/books/judson-abstract-algebra/struct-sage.py +63 -0
- sage/tests/books/judson-abstract-algebra/sylow-sage.py +250 -0
- sage/tests/books/judson-abstract-algebra/vect-sage-exercises.py +48 -0
- sage/tests/books/judson-abstract-algebra/vect-sage.py +211 -0
- sage/tests/memcheck/__init__.py +1 -0
- sage/tests/memcheck/run_tests.py +25 -0
- sage/tests/memcheck/run_tests_in_valgrind.py +36 -0
- sage/tests/memcheck/symbolic_expression.py +12 -0
- sage/tests/memcheck/verify_no_leak.py +28 -0
- sage/tests/all.py +0 -0
- {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-cachegrind +0 -0
- {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-callgrind +0 -0
- {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-cleaner +0 -0
- {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-coverage +0 -0
- {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-eval +0 -0
- {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-fixdoctests +0 -0
- {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-inline-fortran +0 -0
- {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-ipynb2rst +0 -0
- {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-ipython +0 -0
- {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-massif +0 -0
- {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-notebook +0 -0
- {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-omega +0 -0
- {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-preparse +0 -0
- {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-run +0 -0
- {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-run-cython +0 -0
- {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-runtests +0 -0
- {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-startuptime.py +0 -0
- {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-valgrind +0 -0
- {passagemath_repl-10.5.27.dist-info → passagemath_repl-10.5.29.dist-info}/WHEEL +0 -0
@@ -0,0 +1,217 @@
|
|
1
|
+
# sage_setup: distribution = sagemath-repl
|
2
|
+
"""
|
3
|
+
This file (./sol/combinat_doctest.sage) was *autogenerated* from ./sol/combinat.tex,
|
4
|
+
with sagetex.sty version 2011/05/27 v2.3.1.
|
5
|
+
It contains the contents of all the sageexample environments from this file.
|
6
|
+
You should be able to doctest this file with:
|
7
|
+
sage -t ./sol/combinat_doctest.sage
|
8
|
+
It is always safe to delete this file; it is not used in typesetting your
|
9
|
+
document.
|
10
|
+
|
11
|
+
Sage example in ./sol/combinat.tex, line 15::
|
12
|
+
|
13
|
+
sage: Suits = FiniteEnumeratedSet(
|
14
|
+
....: ["Hearts", "Diamonds", "Spades", "Clubs"])
|
15
|
+
sage: Values = FiniteEnumeratedSet([2, 3, 4, 5, 6, 7, 8, 9, 10,
|
16
|
+
....: "Jack", "Queen", "King", "Ace"])
|
17
|
+
sage: FourOfaKind = cartesian_product([Arrangements(Values,2), Suits])
|
18
|
+
|
19
|
+
Sage example in ./sol/combinat.tex, line 34::
|
20
|
+
|
21
|
+
sage: FourOfaKind.list()
|
22
|
+
[([2, 3], 'Hearts'),
|
23
|
+
([2, 3], 'Diamonds'),
|
24
|
+
...
|
25
|
+
(['Ace', 'King'], 'Clubs')]
|
26
|
+
|
27
|
+
Sage example in ./sol/combinat.tex, line 51::
|
28
|
+
|
29
|
+
sage: FourOfaKind.cardinality()
|
30
|
+
624
|
31
|
+
|
32
|
+
Sage example in ./sol/combinat.tex, line 66::
|
33
|
+
|
34
|
+
sage: Cards = cartesian_product([Values, Suits])
|
35
|
+
sage: Hands = Subsets(Cards, 5)
|
36
|
+
sage: FourOfaKind.cardinality() / Hands.cardinality()
|
37
|
+
1/4165
|
38
|
+
|
39
|
+
Sage example in ./sol/combinat.tex, line 86::
|
40
|
+
|
41
|
+
sage: StraightFlush = cartesian_product([range(1, 11), Suits])
|
42
|
+
sage: StraightFlush.cardinality()
|
43
|
+
40
|
44
|
+
|
45
|
+
Sage example in ./sol/combinat.tex, line 98::
|
46
|
+
|
47
|
+
sage: AllFlush = cartesian_product([Subsets(Values,5),Suits])
|
48
|
+
sage: AllFlush.cardinality() - StraightFlush.cardinality()
|
49
|
+
5108
|
50
|
+
|
51
|
+
Sage example in ./sol/combinat.tex, line 113::
|
52
|
+
|
53
|
+
sage: _ / Hands.cardinality()
|
54
|
+
1277/649740
|
55
|
+
sage: float(_)
|
56
|
+
0.001965401545233478
|
57
|
+
|
58
|
+
Sage example in ./sol/combinat.tex, line 153::
|
59
|
+
|
60
|
+
sage: Word(['a','b','b','a','a','b','a']).evaluation_dict()
|
61
|
+
{'a': 4, 'b': 3}
|
62
|
+
|
63
|
+
Sage example in ./sol/combinat.tex, line 170::
|
64
|
+
|
65
|
+
sage: def is_full_hand(hand):
|
66
|
+
....: suits = Word([value for (value, suit) in hand])
|
67
|
+
....: repetitions = sorted(suits.evaluation_dict().values())
|
68
|
+
....: return repetitions == [2,3]
|
69
|
+
sage: is_full_hand({(5, 'Diamonds'), (6, 'Diamonds'), (6, 'Hearts'),
|
70
|
+
....: (5, 'Spades'), (1, 'Spades')})
|
71
|
+
False
|
72
|
+
sage: is_full_hand({(3, 'Clubs'), (3, 'Spades'), (3, 'Hearts'),
|
73
|
+
....: (2, 'Clubs'), (2, 'Spades')})
|
74
|
+
True
|
75
|
+
|
76
|
+
Sage example in ./sol/combinat.tex, line 200::
|
77
|
+
|
78
|
+
sage: def estimate_proportion(S, predicate, n):
|
79
|
+
....: count = 0
|
80
|
+
....: for i in range(n):
|
81
|
+
....: if predicate(S.random_element()):
|
82
|
+
....: count += 1
|
83
|
+
....: return count/n
|
84
|
+
|
85
|
+
Sage example in ./sol/combinat.tex, line 212::
|
86
|
+
|
87
|
+
sage: float(estimate_proportion(Hands, is_full_hand, 10000)) # random
|
88
|
+
0.0014
|
89
|
+
|
90
|
+
Sage example in ./sol/combinat.tex, line 229::
|
91
|
+
|
92
|
+
sage: FullHands = cartesian_product([Arrangements(Values, 2),
|
93
|
+
....: Subsets(Suits, 3), Subsets(Suits, 2)])
|
94
|
+
|
95
|
+
Sage example in ./sol/combinat.tex, line 242::
|
96
|
+
|
97
|
+
sage: [sorted(v) for v in FullHands.first()]
|
98
|
+
[[2, 3], ['Diamonds', 'Hearts', 'Spades'], ['Diamonds', 'Hearts']]
|
99
|
+
|
100
|
+
Sage example in ./sol/combinat.tex, line 252::
|
101
|
+
|
102
|
+
sage: float(FullHands.cardinality() / Hands.cardinality())
|
103
|
+
0.0014405762304921968
|
104
|
+
|
105
|
+
Sage example in ./sol/combinat.tex, line 312::
|
106
|
+
|
107
|
+
sage: C = Compositions(5,length=3)
|
108
|
+
sage: C.cardinality
|
109
|
+
<bound method ..._cardinality_from_iterator ...>
|
110
|
+
|
111
|
+
Sage example in ./sol/combinat.tex, line 322::
|
112
|
+
|
113
|
+
sage: IntegerVectors(5,3).list()
|
114
|
+
[[5, 0, 0], [4, 1, 0], [4, 0, 1], [3, 2, 0], [3, 1, 1], [3, 0, 2],
|
115
|
+
...
|
116
|
+
[0, 4, 1], [0, 3, 2], [0, 2, 3], [0, 1, 4], [0, 0, 5]]
|
117
|
+
|
118
|
+
Sage example in ./sol/combinat.tex, line 328::
|
119
|
+
|
120
|
+
sage: OrderedSetPartitions(3).cardinality()
|
121
|
+
13
|
122
|
+
sage: OrderedSetPartitions(3).list()
|
123
|
+
[[{1}, {2}, {3}], [{1}, {3}, {2}], [{2}, {1}, {3}], [{3}, {1}, {2}],
|
124
|
+
...
|
125
|
+
[{1, 2}, {3}], [{1, 3}, {2}], [{2, 3}, {1}], [{1, 2, 3}]]
|
126
|
+
sage: OrderedSetPartitions(3,2).random_element() # random
|
127
|
+
[{1, 3}, {2}]
|
128
|
+
|
129
|
+
Sage example in ./sol/combinat.tex, line 338::
|
130
|
+
|
131
|
+
sage: StandardTableaux([3,2]).cardinality()
|
132
|
+
5
|
133
|
+
sage: StandardTableaux([3,2]).an_element()
|
134
|
+
[[1, 3, 5], [2, 4]]
|
135
|
+
|
136
|
+
Sage example in ./sol/combinat.tex, line 350::
|
137
|
+
|
138
|
+
sage: list(AlternatingSignMatrices(1))
|
139
|
+
[[1]]
|
140
|
+
sage: list(AlternatingSignMatrices(2))
|
141
|
+
[
|
142
|
+
[1 0] [0 1]
|
143
|
+
[0 1], [1 0]
|
144
|
+
]
|
145
|
+
|
146
|
+
Sage example in ./sol/combinat.tex, line 361::
|
147
|
+
|
148
|
+
sage: list(AlternatingSignMatrices(3))
|
149
|
+
[
|
150
|
+
[1 0 0] [0 1 0] [1 0 0] [ 0 1 0] [0 0 1] [0 1 0] [0 0 1]
|
151
|
+
[0 1 0] [1 0 0] [0 0 1] [ 1 -1 1] [1 0 0] [0 0 1] [0 1 0]
|
152
|
+
[0 0 1], [0 0 1], [0 1 0], [ 0 1 0], [0 1 0], [1 0 0], [1 0 0]
|
153
|
+
]
|
154
|
+
|
155
|
+
Sage example in ./sol/combinat.tex, line 383::
|
156
|
+
|
157
|
+
sage: GF(2)^5
|
158
|
+
Vector space of dimension 5 over Finite Field of size 2
|
159
|
+
sage: _.cardinality()
|
160
|
+
32
|
161
|
+
|
162
|
+
Sage example in ./sol/combinat.tex, line 400::
|
163
|
+
|
164
|
+
sage: (2^3-2^0)*(2^3-2^1)*(2^3-2^2)
|
165
|
+
168
|
166
|
+
|
167
|
+
Sage example in ./sol/combinat.tex, line 406::
|
168
|
+
|
169
|
+
sage: GL(3,2)
|
170
|
+
General Linear Group of degree 3 over Finite Field of size 2
|
171
|
+
sage: _.cardinality()
|
172
|
+
168
|
173
|
+
|
174
|
+
Sage example in ./sol/combinat.tex, line 423::
|
175
|
+
|
176
|
+
sage: from sage.combinat.q_analogues import q_factorial
|
177
|
+
sage: q = 2; n = 3
|
178
|
+
sage: q^(n*(n-1)/2) * (q-1)^n * q_factorial(n,q)
|
179
|
+
168
|
180
|
+
sage: q = 3; n = 5
|
181
|
+
sage: GL(n, q).cardinality()
|
182
|
+
475566474240
|
183
|
+
sage: q^(n*(n-1)/2) * (q-1)^n * q_factorial(n,q)
|
184
|
+
475566474240
|
185
|
+
|
186
|
+
Sage example in ./sol/combinat.tex, line 537::
|
187
|
+
|
188
|
+
sage: def C(n):
|
189
|
+
....: if n == 1:
|
190
|
+
....: yield BinaryTree()
|
191
|
+
....: elif n > 1:
|
192
|
+
....: for k in range(1,n):
|
193
|
+
....: for t1 in C(k):
|
194
|
+
....: for t2 in C(n-k):
|
195
|
+
....: yield BinaryTree([t1,t2])
|
196
|
+
|
197
|
+
Sage example in ./sol/combinat.tex, line 549::
|
198
|
+
|
199
|
+
sage: list(C(1))
|
200
|
+
[.]
|
201
|
+
sage: list(C(2))
|
202
|
+
[[., .]]
|
203
|
+
sage: list(C(3))
|
204
|
+
[[., [., .]],
|
205
|
+
[[., .], .]]
|
206
|
+
sage: list(C(4))
|
207
|
+
[[., [., [., .]]],
|
208
|
+
[., [[., .], .]],
|
209
|
+
[[., .], [., .]],
|
210
|
+
[[., [., .]], .],
|
211
|
+
[[[., .], .], .]]
|
212
|
+
|
213
|
+
Sage example in ./sol/combinat.tex, line 566::
|
214
|
+
|
215
|
+
sage: [len(list(C(n))) for n in range(9)]
|
216
|
+
[0, 1, 1, 2, 5, 14, 42, 132, 429]
|
217
|
+
"""
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# sage_setup: distribution = sagemath-repl
|
2
|
+
"""
|
3
|
+
This file (./sol/domaines_doctest.sage) was *autogenerated* from ./sol/domaines.tex,
|
4
|
+
with sagetex.sty version 2011/05/27 v2.3.1.
|
5
|
+
It contains the contents of all the sageexample environments from this file.
|
6
|
+
You should be able to doctest this file with:
|
7
|
+
sage -t ./sol/domaines_doctest.sage
|
8
|
+
It is always safe to delete this file; it is not used in typesetting your
|
9
|
+
document.
|
10
|
+
|
11
|
+
Sage example in ./sol/domaines.tex, line 4::
|
12
|
+
|
13
|
+
sage: def ndigits(x): return x.ndigits()
|
14
|
+
sage: o = 720; ndigits(o)
|
15
|
+
3
|
16
|
+
|
17
|
+
Sage example in ./sol/domaines.tex, line 28::
|
18
|
+
|
19
|
+
sage: a = Reals(17)(pi); b = Reals(42)(pi)
|
20
|
+
sage: type(a) == type(b)
|
21
|
+
True
|
22
|
+
sage: parent(a), parent(b)
|
23
|
+
(Real Field with 17 bits of precision, Real Field with 42 bits of precision)
|
24
|
+
|
25
|
+
Sage example in ./sol/domaines.tex, line 46::
|
26
|
+
|
27
|
+
sage: a = 0.1; b = 0.1*1
|
28
|
+
sage: type(a), type(b)
|
29
|
+
(<... 'sage.rings.real_mpfr.RealLiteral'>, <... 'sage.rings.real_mpfr.RealNumber'>)
|
30
|
+
sage: parent(a) == parent(b)
|
31
|
+
True
|
32
|
+
|
33
|
+
Sage example in ./sol/domaines.tex, line 70::
|
34
|
+
|
35
|
+
sage: Reals(100)(a)-1/10
|
36
|
+
0.00000000000000000000000000000
|
37
|
+
sage: Reals(100)(b)-1/10
|
38
|
+
5.5511151231257629805955278152e-18
|
39
|
+
|
40
|
+
Sage example in ./sol/domaines.tex, line 80::
|
41
|
+
|
42
|
+
sage: E = CombinatorialFreeModule(QQ, [1,2,3])
|
43
|
+
sage: H = Hom(E,E); H.rename('H')
|
44
|
+
sage: C = E.category(); C
|
45
|
+
Category of finite dimensional vector spaces with basis over Rational Field
|
46
|
+
sage: phi1 = E.module_morphism(on_basis=lambda i: E.term(i), codomain=E)
|
47
|
+
sage: phi2 = E.module_morphism(on_basis=lambda i: E.term(i),
|
48
|
+
....: triangular='lower', codomain=E)
|
49
|
+
sage: phi3 = E.module_morphism(diagonal=lambda i: 1, codomain=E,
|
50
|
+
....: category=C)
|
51
|
+
sage: phi1.parent() == phi2.parent() == phi3.parent() == H
|
52
|
+
True
|
53
|
+
sage: type(phi1)
|
54
|
+
<class 'sage.modules.with_basis.morphism.ModuleMorphismByLinearity_with_category'>
|
55
|
+
sage: type(phi2)
|
56
|
+
<class 'sage.modules.with_basis.morphism.TriangularModuleMorphismByLinearity_with_category'>
|
57
|
+
sage: type(phi3)
|
58
|
+
<class 'sage.modules.with_basis.morphism.DiagonalModuleMorphism_with_category'>
|
59
|
+
"""
|
@@ -0,0 +1,141 @@
|
|
1
|
+
# sage_setup: distribution = sagemath-repl
|
2
|
+
"""
|
3
|
+
This file (./sol/float_doctest.sage) was *autogenerated* from ./sol/float.tex,
|
4
|
+
with sagetex.sty version 2011/05/27 v2.3.1.
|
5
|
+
It contains the contents of all the sageexample environments from this file.
|
6
|
+
You should be able to doctest this file with:
|
7
|
+
sage -t ./sol/float_doctest.sage
|
8
|
+
It is always safe to delete this file; it is not used in typesetting your
|
9
|
+
document.
|
10
|
+
|
11
|
+
Sage example in ./sol/float.tex, line 17::
|
12
|
+
|
13
|
+
sage: R100=RealField(100)
|
14
|
+
sage: x=R100(10^30)
|
15
|
+
sage: x>2^99
|
16
|
+
True
|
17
|
+
sage: x<2^100
|
18
|
+
True
|
19
|
+
|
20
|
+
Sage example in ./sol/float.tex, line 48::
|
21
|
+
|
22
|
+
sage: e=2^100
|
23
|
+
sage: s1=10^30
|
24
|
+
sage: significand=[]
|
25
|
+
sage: nbdigits=0 # number of significant digits
|
26
|
+
sage: while s1>0:
|
27
|
+
....: e/=2
|
28
|
+
....: if e<=s1:
|
29
|
+
....: significand.append(1)
|
30
|
+
....: s1-=e
|
31
|
+
....: else:
|
32
|
+
....: significand.append(0)
|
33
|
+
....: nbdigits+=1
|
34
|
+
sage: print(significand)
|
35
|
+
[1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0,
|
36
|
+
1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0,
|
37
|
+
0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1,
|
38
|
+
1, 1, 1, 0, 1, 0, 1, 0, 0, 1]
|
39
|
+
sage: print("number of significant digits: " + str(nbdigits))
|
40
|
+
number of significant digits: 70
|
41
|
+
|
42
|
+
Sage example in ./sol/float.tex, line 86::
|
43
|
+
|
44
|
+
sage: R100=RealField(100)
|
45
|
+
sage: x=R100(10^30)
|
46
|
+
sage: s,m,e = x.sign_mantissa_exponent()
|
47
|
+
sage: s,m,e
|
48
|
+
(1, 1000000000000000000000000000000, 0)
|
49
|
+
|
50
|
+
Sage example in ./sol/float.tex, line 126::
|
51
|
+
|
52
|
+
sage: var("u0 u1 u2 alpha beta gamma n")
|
53
|
+
(u0, u1, u2, alpha, beta, gamma, n)
|
54
|
+
sage: recurrence = lambda a,b: 111-1130/a+3000/(a*b)
|
55
|
+
sage: gener1 = lambda n: (alpha*100^n+beta*6^n+gamma*5^n)
|
56
|
+
sage: solGen = lambda n: gener1(n+1)/gener1(n)
|
57
|
+
|
58
|
+
Sage example in ./sol/float.tex, line 137::
|
59
|
+
|
60
|
+
sage: u2 = recurrence(u1,u0)
|
61
|
+
sage: s = [u2==solGen(2),u1==solGen(1),u0==solGen(0)]
|
62
|
+
sage: t = [s[i].substitute(u0=2,u1=-4) for i in range(0,3)]
|
63
|
+
|
64
|
+
Sage example in ./sol/float.tex, line 143::
|
65
|
+
|
66
|
+
sage: solve(t,alpha,beta,gamma)
|
67
|
+
[[alpha == 0, beta == -3/4*r1, gamma == r1]]
|
68
|
+
|
69
|
+
Sage example in ./sol/float.tex, line 157::
|
70
|
+
|
71
|
+
sage: alpha=0
|
72
|
+
sage: beta = -3/4*gamma
|
73
|
+
sage: final=solGen(n)-recurrence(solGen(n-1),solGen(n-2))
|
74
|
+
sage: final.simplify_full()
|
75
|
+
0
|
76
|
+
|
77
|
+
Sage example in ./sol/float.tex, line 179::
|
78
|
+
|
79
|
+
sage: def recur(x1, x0):
|
80
|
+
....: return 111 - 1130/x1 + 3000/(x0*x1)
|
81
|
+
|
82
|
+
Sage example in ./sol/float.tex, line 190::
|
83
|
+
|
84
|
+
sage: u0 = 2.
|
85
|
+
sage: u1 = -4.
|
86
|
+
sage: for i in range(1,25):
|
87
|
+
....: x = recur(u1,u0)
|
88
|
+
....: print((i, x))
|
89
|
+
....: u0 = u1
|
90
|
+
....: u1 = x
|
91
|
+
(1, 18.5000000000000)
|
92
|
+
(2, 9.37837837837838)
|
93
|
+
(3, 7.80115273775217)
|
94
|
+
(4, 7.15441448097533)
|
95
|
+
(5, 6.80678473692481)
|
96
|
+
(6, 6.59263276872179)
|
97
|
+
..................
|
98
|
+
(23, 99.9999986592167)
|
99
|
+
(24, 99.9999999193218)
|
100
|
+
|
101
|
+
Sage example in ./sol/float.tex, line 229::
|
102
|
+
|
103
|
+
sage: var("x")
|
104
|
+
x
|
105
|
+
sage: solve(x==recurrence(x,x),x)
|
106
|
+
[x == 100, x == 5, x == 6]
|
107
|
+
|
108
|
+
Sage example in ./sol/float.tex, line 256::
|
109
|
+
|
110
|
+
sage: RL = RealField(5000)
|
111
|
+
sage: u0 = RL(2)
|
112
|
+
sage: u1 = RL(-4)
|
113
|
+
sage: for i in range(1,2500):
|
114
|
+
....: x = recur(u1,u0)
|
115
|
+
....: u0 = u1
|
116
|
+
....: u1= x
|
117
|
+
sage: x
|
118
|
+
100.00000000000000000000000000000000000000000000000000000...
|
119
|
+
|
120
|
+
Sage example in ./sol/float.tex, line 281::
|
121
|
+
|
122
|
+
sage: u0 = 2
|
123
|
+
sage: u1 = -4
|
124
|
+
sage: for i in range(1,2500):
|
125
|
+
....: x = recur(u1,u0)
|
126
|
+
....: u0 = u1
|
127
|
+
....: u1 = x
|
128
|
+
sage: float(x)
|
129
|
+
6.0
|
130
|
+
|
131
|
+
Sage example in ./sol/float.tex, line 325::
|
132
|
+
|
133
|
+
sage: f = lambda x: x^2
|
134
|
+
sage: g = lambda x: x*x
|
135
|
+
sage: sage.rings.real_mpfi.printing_style = 'brackets'
|
136
|
+
sage: I = RIF(-1,1)
|
137
|
+
sage: f(I)
|
138
|
+
[0.0000000000000000 .. 1.0000000000000000]
|
139
|
+
sage: g(I)
|
140
|
+
[-1.0000000000000000 .. 1.0000000000000000]
|
141
|
+
"""
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# sage_setup: distribution = sagemath-repl
|
2
|
+
"""
|
3
|
+
This file (./sol/graphique_doctest.sage) was *autogenerated* from ./sol/graphique.tex,
|
4
|
+
with sagetex.sty version 2011/05/27 v2.3.1.
|
5
|
+
It contains the contents of all the sageexample environments from this file.
|
6
|
+
You should be able to doctest this file with:
|
7
|
+
sage -t ./sol/graphique_doctest.sage
|
8
|
+
It is always safe to delete this file; it is not used in typesetting your
|
9
|
+
document.
|
10
|
+
|
11
|
+
Sage example in ./sol/graphique.tex, line 3::
|
12
|
+
|
13
|
+
sage: reset()
|
14
|
+
|
15
|
+
Sage example in ./sol/graphique.tex, line 10::
|
16
|
+
|
17
|
+
sage: t = var('t'); liste = [a + cos(t) for a in srange(0, 2, 0.1)]
|
18
|
+
sage: g = polar_plot(liste, (t, 0, 2 * pi)); g.show(aspect_ratio = 1)
|
19
|
+
|
20
|
+
Sage example in ./sol/graphique.tex, line 38::
|
21
|
+
|
22
|
+
sage: f = lambda x: abs(x**2 - 1/4)
|
23
|
+
sage: def liste_pts(u0, n):
|
24
|
+
....: u = u0; liste = [[u0,0]]
|
25
|
+
....: for k in range(n):
|
26
|
+
....: v, u = u, f(u)
|
27
|
+
....: liste.extend([[v,u], [u,u]])
|
28
|
+
....: return(liste)
|
29
|
+
sage: g = line(liste_pts(1.1, 8), rgbcolor = (.9,0,0))
|
30
|
+
sage: g += line(liste_pts(-.4, 8), rgbcolor = (.01,0,0))
|
31
|
+
sage: g += line(liste_pts(1.3, 3), rgbcolor = (.5,0,0))
|
32
|
+
sage: g += plot(f, -1, 3, rgbcolor = 'blue')
|
33
|
+
sage: g += plot(x, -1, 3, rgbcolor = 'green')
|
34
|
+
sage: g.show(aspect_ratio = 1, ymin = -.2, ymax = 3)
|
35
|
+
|
36
|
+
Sage example in ./sol/graphique.tex, line 78::
|
37
|
+
|
38
|
+
sage: x = var('x'); y = function('y')
|
39
|
+
sage: DE = x^2 * diff(y(x), x) - y(x) == 0
|
40
|
+
sage: desolve(DE, y(x))
|
41
|
+
_C*e^(-1/x)
|
42
|
+
sage: g = plot([c*e^(-1/x) for c in srange(-8, 8, 0.4)], (x, -3, 3))
|
43
|
+
sage: y = var('y')
|
44
|
+
sage: g += plot_vector_field((x^2, y), (x,-3,3), (y,-5,5))
|
45
|
+
sage: g.show() # not tested, known bug, see :issue:`32657`
|
46
|
+
|
47
|
+
Sage example in ./sol/graphique.tex, line 124::
|
48
|
+
|
49
|
+
sage: from sage.calculus.desolvers import desolve_system_rk4
|
50
|
+
sage: f = lambda x, y: [a*x-b*x*y,-c*y+d*b*x*y]
|
51
|
+
sage: x, y, t = var('x, y, t')
|
52
|
+
sage: a, b, c, d = 1., 0.1, 1.5, 0.75
|
53
|
+
sage: P = desolve_system_rk4(f(x,y), [x,y],\
|
54
|
+
....: ics=[0,10,5], ivar=t, end_points=15)
|
55
|
+
sage: Ql = [[i,j] for i,j,k in P]; p = line(Ql, color='red')
|
56
|
+
sage: p += text("Rabbits", (12,37), fontsize=10, color='red')
|
57
|
+
sage: Qr = [[i,k] for i,j,k in P]; p += line(Qr, color='blue')
|
58
|
+
sage: p += text("Foxes", (12,7), fontsize=10, color='blue')
|
59
|
+
sage: p.axes_labels(["time", "population"])
|
60
|
+
sage: p.show(gridlines = True)
|
61
|
+
|
62
|
+
Sage example in ./sol/graphique.tex, line 154::
|
63
|
+
|
64
|
+
sage: n = 10; L = srange(6, 18, 12 / n); R = srange(3, 9, 6 / n)
|
65
|
+
sage: def g(x, y): v = vector(f(x, y)); return v / v.norm()
|
66
|
+
sage: q = plot_vector_field(g(x, y), (x, 0, 60), (y, 0, 36))
|
67
|
+
sage: for j in range(n):
|
68
|
+
....: P = desolve_system_rk4(f(x,y), [x,y],
|
69
|
+
....: ics=[0,L[j],R[j]], ivar=t, end_points=15)
|
70
|
+
....: Q = [[j,k] for i,j,k in P]
|
71
|
+
....: q += line(Q, color=hue(.8-j/(2*n)))
|
72
|
+
sage: q.axes_labels(["rabbits", "foxes"]); q.show()
|
73
|
+
|
74
|
+
Sage example in ./sol/graphique.tex, line 185::
|
75
|
+
|
76
|
+
sage: from scipy import integrate
|
77
|
+
sage: def dX_dt(X, t=0): return [X[1], 0.5*X[1] - X[0] - X[1]^3]
|
78
|
+
sage: t = srange(0, 40, 0.01); x0 = srange(-2, 2, 0.1); y0 = 2.5
|
79
|
+
sage: CI = [[i, y0] for i in x0] + [[i, -y0] for i in x0]
|
80
|
+
sage: def g(x, y): v = vector(dX_dt([x, y])); return v / v.norm()
|
81
|
+
sage: x, y = var('x, y'); n = len(CI)
|
82
|
+
sage: q = plot_vector_field(g(x, y), (x, -3, 3), (y, -y0, y0))
|
83
|
+
sage: for j in range(n): # long time
|
84
|
+
....: X = integrate.odeint(dX_dt, CI[j], t)
|
85
|
+
....: q += line(X, color=(1.7*j/(4*n),1.5*j/(4*n),1-3*j/(8*n)))
|
86
|
+
sage: X = integrate.odeint(dX_dt, [0.01,0], t)
|
87
|
+
sage: q += line(X, color = 'red'); q.show()
|
88
|
+
|
89
|
+
Sage example in ./sol/graphique.tex, line 234::
|
90
|
+
|
91
|
+
sage: from scipy import integrate
|
92
|
+
sage: t = srange(0, 40, 0.2)
|
93
|
+
sage: n = 35; CI_cart = [[4, .2 * i] for i in range(n)]
|
94
|
+
sage: CI = list(map(lambda x: [sqrt(x[0]^2+x[1]^2),
|
95
|
+
....: pi - arctan(x[1]/x[0])], CI_cart))
|
96
|
+
sage: for alpha in [0.1, 0.5, 1, 1.25]: # long time
|
97
|
+
....: dX_dt = lambda X, t=0: [cos(X[1])*(1-1/X[0]^2),
|
98
|
+
....: -sin(X[1]) * (1/X[0]+1/X[0]^3) + 2*alpha/X[0]^2]
|
99
|
+
....: q = circle((0, 0), 1, fill=True, rgbcolor='purple')
|
100
|
+
....: for j in range(n):
|
101
|
+
....: X = integrate.odeint(dX_dt, CI[j], t)
|
102
|
+
....: Y = [[u[0]*cos(u[1]), u[0]*sin(u[1])] for u in X]
|
103
|
+
....: q += line(Y, xmin = -4, xmax = 4, color='blue')
|
104
|
+
....: q.show(aspect_ratio = 1, axes = False)
|
105
|
+
"""
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# sage_setup: distribution = sagemath-repl
|
2
|
+
"""
|
3
|
+
This file (./sol/graphtheory_doctest.sage) was *autogenerated* from ./sol/graphtheory.tex,
|
4
|
+
with sagetex.sty version 2011/05/27 v2.3.1.
|
5
|
+
It contains the contents of all the sageexample environments from this file.
|
6
|
+
You should be able to doctest this file with:
|
7
|
+
sage -t ./sol/graphtheory_doctest.sage
|
8
|
+
It is always safe to delete this file; it is not used in typesetting your
|
9
|
+
document.
|
10
|
+
|
11
|
+
Sage example in ./sol/graphtheory.tex, line 5::
|
12
|
+
|
13
|
+
sage: def circulant(n, d):
|
14
|
+
....: g = Graph(n)
|
15
|
+
....: for u in range(n):
|
16
|
+
....: for c in range(d):
|
17
|
+
....: g.add_edge(u,(u+c)%n)
|
18
|
+
....: return g
|
19
|
+
|
20
|
+
Sage example in ./sol/graphtheory.tex, line 19::
|
21
|
+
|
22
|
+
sage: def kneser(n, k):
|
23
|
+
....: g = Graph()
|
24
|
+
....: g.add_vertices(Subsets(n,k))
|
25
|
+
....: for u in g:
|
26
|
+
....: for v in g:
|
27
|
+
....: if not u & v:
|
28
|
+
....: g.add_edge(u,v)
|
29
|
+
....: return g
|
30
|
+
|
31
|
+
Sage example in ./sol/graphtheory.tex, line 33::
|
32
|
+
|
33
|
+
sage: def kneser(n, k):
|
34
|
+
....: g = Graph()
|
35
|
+
....: sommets = Set(range(n))
|
36
|
+
....: g.add_vertices(Subsets(sommets,k))
|
37
|
+
....: for u in g:
|
38
|
+
....: for v in Subsets(sommets - u,k):
|
39
|
+
....: g.add_edge(u,v)
|
40
|
+
....: return g
|
41
|
+
|
42
|
+
Sage example in ./sol/graphtheory.tex, line 59::
|
43
|
+
|
44
|
+
sage: g = graphs.PetersenGraph()
|
45
|
+
sage: def optimal_order(g):
|
46
|
+
....: order = []
|
47
|
+
....: for color_class in sorted(g.coloring()):
|
48
|
+
....: for v in color_class:
|
49
|
+
....: order.append(v)
|
50
|
+
....: return order
|
51
|
+
sage: optimal_order(g)
|
52
|
+
[0, 2, 6, 1, 3, 5, 9, 4, 7, 8]
|
53
|
+
"""
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# sage_setup: distribution = sagemath-repl
|
2
|
+
"""
|
3
|
+
This file (./sol/integration_doctest.sage) was *autogenerated* from ./sol/integration.tex,
|
4
|
+
with sagetex.sty version 2011/05/27 v2.3.1.
|
5
|
+
It contains the contents of all the sageexample environments from this file.
|
6
|
+
You should be able to doctest this file with:
|
7
|
+
sage -t ./sol/integration_doctest.sage
|
8
|
+
It is always safe to delete this file; it is not used in typesetting your
|
9
|
+
document.
|
10
|
+
|
11
|
+
Sage example in ./sol/integration.tex, line 22::
|
12
|
+
|
13
|
+
sage: x = var('x')
|
14
|
+
sage: def NCRule(n):
|
15
|
+
....: P = prod([x - j for j in range(n)])
|
16
|
+
....: return [integrate(P / (x-i), x, 0, n-1) \
|
17
|
+
....: / (P/(x-i)).subs(x=i) for i in range(n)]
|
18
|
+
|
19
|
+
Sage example in ./sol/integration.tex, line 35::
|
20
|
+
|
21
|
+
sage: def QuadNC(f, a, b, n):
|
22
|
+
....: W = NCRule(n)
|
23
|
+
....: ret = 0
|
24
|
+
....: for i in range(n):
|
25
|
+
....: ret += f(a + (b-a)/(n-1)*i) * W[i]
|
26
|
+
....: return (b-a)/(n-1)*ret
|
27
|
+
|
28
|
+
Sage example in ./sol/integration.tex, line 49::
|
29
|
+
|
30
|
+
sage: QuadNC(lambda u: 1, 0, 1, 12)
|
31
|
+
1
|
32
|
+
sage: N(QuadNC(sin, 0, pi, 10))
|
33
|
+
1.99999989482634
|
34
|
+
|
35
|
+
Sage example in ./sol/integration.tex, line 59::
|
36
|
+
|
37
|
+
sage: numerical_integral(x * log(1+x), 0, 1)
|
38
|
+
(0.25, 2.7755575615628914e-15)
|
39
|
+
sage: N(QuadNC(lambda x: x * log(1+x), 0, 1, 19)) # abs tol 2e-14
|
40
|
+
0.250000000000001
|
41
|
+
sage: numerical_integral(sqrt(1-x^2), 0, 1) # abs tol 2e-14
|
42
|
+
(0.7853981677264822, 9.042725224536535e-07)
|
43
|
+
sage: N(pi/4)
|
44
|
+
0.785398163397448
|
45
|
+
sage: N(QuadNC(lambda x: sqrt(1-x^2), 0, 1, 20))
|
46
|
+
0.784586419900198
|
47
|
+
|
48
|
+
Sage example in ./sol/integration.tex, line 74::
|
49
|
+
|
50
|
+
sage: [N(QuadNC(lambda x: x * log(1+x), 0, 1, n) - 1/4) # abs tol 3e-16
|
51
|
+
....: for n in [2, 8, 16]]
|
52
|
+
[0.0965735902799726, 1.17408932933522e-7, 2.13449050101566e-13]
|
53
|
+
sage: [N(QuadNC(lambda x: sqrt(1-x^2), 0, 1, n) - pi/4) # abs tol 1e-13
|
54
|
+
....: for n in [2, 8, 16]]
|
55
|
+
[-0.285398163397448, -0.00524656673640445, -0.00125482109302663]
|
56
|
+
"""
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# sage_setup: distribution = sagemath-repl
|
2
|
+
"""
|
3
|
+
This file (./sol/linalg_doctest.sage) was *autogenerated* from ./sol/linalg.tex,
|
4
|
+
with sagetex.sty version 2011/05/27 v2.3.1.
|
5
|
+
It contains the contents of all the sageexample environments from this file.
|
6
|
+
You should be able to doctest this file with:
|
7
|
+
sage -t ./sol/linalg_doctest.sage
|
8
|
+
It is always safe to delete this file; it is not used in typesetting your
|
9
|
+
document.
|
10
|
+
|
11
|
+
Sage example in ./sol/linalg.tex, line 89::
|
12
|
+
|
13
|
+
sage: A = matrix(GF(7),[[0,0,3,0,0],[1,0,6,0,0],[0,1,5,0,0],
|
14
|
+
....: [0,0,0,0,5],[0,0,0,1,5]])
|
15
|
+
sage: P = A.minpoly(); P
|
16
|
+
x^5 + 4*x^4 + 3*x^2 + 3*x + 1
|
17
|
+
sage: P.factor()
|
18
|
+
(x^2 + 2*x + 2) * (x^3 + 2*x^2 + x + 4)
|
19
|
+
|
20
|
+
Sage example in ./sol/linalg.tex, line 100::
|
21
|
+
|
22
|
+
sage: e1 = identity_matrix(GF(7),5)[0]
|
23
|
+
sage: e4 = identity_matrix(GF(7),5)[3]
|
24
|
+
sage: A.transpose().maxspin(e1)
|
25
|
+
[(1, 0, 0, 0, 0), (0, 1, 0, 0, 0), (0, 0, 1, 0, 0)]
|
26
|
+
sage: A.transpose().maxspin(e4)
|
27
|
+
[(0, 0, 0, 1, 0), (0, 0, 0, 0, 1)]
|
28
|
+
sage: A.transpose().maxspin(e1 + e4)
|
29
|
+
[(1, 0, 0, 1, 0), (0, 1, 0, 0, 1), (0, 0, 1, 5, 5),
|
30
|
+
(3, 6, 5, 4, 2), (1, 5, 3, 3, 0)]
|
31
|
+
|
32
|
+
Sage example in ./sol/linalg.tex, line 168::
|
33
|
+
|
34
|
+
sage: def Similar(A, B):
|
35
|
+
....: F1, U1 = A.frobenius_form(2)
|
36
|
+
....: F2, U2 = B.frobenius_form(2)
|
37
|
+
....: if F1 == F2:
|
38
|
+
....: return True, ~U2*U1
|
39
|
+
....: else:
|
40
|
+
....: return False, F1 - F2
|
41
|
+
sage: B = matrix(ZZ, [[0,1,4,0,4],[4,-2,0,-4,-2],[0,0,0,2,1],
|
42
|
+
....: [-4,2,2,0,-1],[-4,-2,1,2,0]])
|
43
|
+
sage: U = matrix(ZZ, [[3,3,-9,-14,40],[-1,-2,4,2,1],[2,4,-7,-1,-13],
|
44
|
+
....: [-1,0,1,4,-15],[-4,-13,26,8,30]])
|
45
|
+
sage: A = (U^-1 * B * U).change_ring(ZZ)
|
46
|
+
sage: ok, V = Similar(A, B); ok
|
47
|
+
True
|
48
|
+
sage: V
|
49
|
+
[ 1 2824643/1601680 -6818729/1601680 -43439399/11211760 73108601/11211760]
|
50
|
+
[ 0 342591/320336 -695773/320336 -2360063/11211760 -10291875/2242352]
|
51
|
+
[ 0 -367393/640672 673091/640672 -888723/4484704 15889341/4484704]
|
52
|
+
[ 0 661457/3203360 -565971/3203360 13485411/22423520 -69159661/22423520]
|
53
|
+
[ 0 -4846439/3203360 7915157/3203360 -32420037/22423520 285914347/22423520]
|
54
|
+
sage: ok, V = Similar(2*A, B); ok
|
55
|
+
False
|
56
|
+
"""
|