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.
Files changed (96) hide show
  1. passagemath_repl-10.5.29.data/data/share/jupyter/kernels/sagemath/kernel.json +1 -0
  2. passagemath_repl-10.5.29.data/data/share/jupyter/kernels/sagemath/logo-64x64.png +0 -0
  3. passagemath_repl-10.5.29.data/data/share/jupyter/kernels/sagemath/logo.svg +352 -0
  4. {passagemath_repl-10.5.27.dist-info → passagemath_repl-10.5.29.dist-info}/METADATA +38 -13
  5. {passagemath_repl-10.5.27.dist-info → passagemath_repl-10.5.29.dist-info}/RECORD +95 -24
  6. {passagemath_repl-10.5.27.dist-info → passagemath_repl-10.5.29.dist-info}/top_level.txt +1 -0
  7. sage/ext_data/all__sagemath_repl.py +1 -0
  8. sage/interfaces/all__sagemath_repl.py +1 -0
  9. sage/repl/ipython_kernel/install.py +6 -8
  10. sage/tests/books/__init__.py +2 -0
  11. sage/tests/books/computational-mathematics-with-sagemath/__init__.py +1 -0
  12. sage/tests/books/computational-mathematics-with-sagemath/calculus_doctest.py +549 -0
  13. sage/tests/books/computational-mathematics-with-sagemath/combinat_doctest.py +1053 -0
  14. sage/tests/books/computational-mathematics-with-sagemath/domaines_doctest.py +443 -0
  15. sage/tests/books/computational-mathematics-with-sagemath/float_doctest.py +477 -0
  16. sage/tests/books/computational-mathematics-with-sagemath/graphique_doctest.py +254 -0
  17. sage/tests/books/computational-mathematics-with-sagemath/graphtheory_doctest.py +418 -0
  18. sage/tests/books/computational-mathematics-with-sagemath/integration_doctest.py +290 -0
  19. sage/tests/books/computational-mathematics-with-sagemath/linalg_doctest.py +454 -0
  20. sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py +421 -0
  21. sage/tests/books/computational-mathematics-with-sagemath/lp_doctest.py +234 -0
  22. sage/tests/books/computational-mathematics-with-sagemath/mpoly_doctest.py +560 -0
  23. sage/tests/books/computational-mathematics-with-sagemath/nonlinear_doctest.py +490 -0
  24. sage/tests/books/computational-mathematics-with-sagemath/numbertheory_doctest.py +155 -0
  25. sage/tests/books/computational-mathematics-with-sagemath/polynomes_doctest.py +405 -0
  26. sage/tests/books/computational-mathematics-with-sagemath/premierspas_doctest.py +180 -0
  27. sage/tests/books/computational-mathematics-with-sagemath/programmation_doctest.py +662 -0
  28. sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py +392 -0
  29. sage/tests/books/computational-mathematics-with-sagemath/sol/__init__.py +1 -0
  30. sage/tests/books/computational-mathematics-with-sagemath/sol/calculus_doctest.py +264 -0
  31. sage/tests/books/computational-mathematics-with-sagemath/sol/combinat_doctest.py +217 -0
  32. sage/tests/books/computational-mathematics-with-sagemath/sol/domaines_doctest.py +59 -0
  33. sage/tests/books/computational-mathematics-with-sagemath/sol/float_doctest.py +141 -0
  34. sage/tests/books/computational-mathematics-with-sagemath/sol/graphique_doctest.py +105 -0
  35. sage/tests/books/computational-mathematics-with-sagemath/sol/graphtheory_doctest.py +53 -0
  36. sage/tests/books/computational-mathematics-with-sagemath/sol/integration_doctest.py +56 -0
  37. sage/tests/books/computational-mathematics-with-sagemath/sol/linalg_doctest.py +56 -0
  38. sage/tests/books/computational-mathematics-with-sagemath/sol/linsolve_doctest.py +25 -0
  39. sage/tests/books/computational-mathematics-with-sagemath/sol/lp_doctest.py +47 -0
  40. sage/tests/books/computational-mathematics-with-sagemath/sol/mpoly_doctest.py +115 -0
  41. sage/tests/books/computational-mathematics-with-sagemath/sol/nonlinear_doctest.py +111 -0
  42. sage/tests/books/computational-mathematics-with-sagemath/sol/numbertheory_doctest.py +167 -0
  43. sage/tests/books/computational-mathematics-with-sagemath/sol/polynomes_doctest.py +107 -0
  44. sage/tests/books/computational-mathematics-with-sagemath/sol/recequadiff_doctest.py +58 -0
  45. sage/tests/books/judson-abstract-algebra/__init__.py +1 -0
  46. sage/tests/books/judson-abstract-algebra/actions-sage-exercises.py +51 -0
  47. sage/tests/books/judson-abstract-algebra/actions-sage.py +173 -0
  48. sage/tests/books/judson-abstract-algebra/algcodes-sage.py +130 -0
  49. sage/tests/books/judson-abstract-algebra/boolean-sage.py +269 -0
  50. sage/tests/books/judson-abstract-algebra/cosets-sage-exercises.py +87 -0
  51. sage/tests/books/judson-abstract-algebra/cosets-sage.py +170 -0
  52. sage/tests/books/judson-abstract-algebra/crypt-sage.py +151 -0
  53. sage/tests/books/judson-abstract-algebra/cyclic-sage.py +450 -0
  54. sage/tests/books/judson-abstract-algebra/domains-sage.py +163 -0
  55. sage/tests/books/judson-abstract-algebra/fields-sage.py +299 -0
  56. sage/tests/books/judson-abstract-algebra/finite-sage.py +108 -0
  57. sage/tests/books/judson-abstract-algebra/galois-sage.py +484 -0
  58. sage/tests/books/judson-abstract-algebra/groups-sage.py +280 -0
  59. sage/tests/books/judson-abstract-algebra/homomorph-sage-exercises.py +65 -0
  60. sage/tests/books/judson-abstract-algebra/homomorph-sage.py +200 -0
  61. sage/tests/books/judson-abstract-algebra/integers-sage.py +197 -0
  62. sage/tests/books/judson-abstract-algebra/isomorph-sage.py +172 -0
  63. sage/tests/books/judson-abstract-algebra/normal-sage.py +133 -0
  64. sage/tests/books/judson-abstract-algebra/permute-sage.py +319 -0
  65. sage/tests/books/judson-abstract-algebra/poly-sage.py +300 -0
  66. sage/tests/books/judson-abstract-algebra/rings-sage.py +413 -0
  67. sage/tests/books/judson-abstract-algebra/sets-sage.py +163 -0
  68. sage/tests/books/judson-abstract-algebra/struct-sage.py +63 -0
  69. sage/tests/books/judson-abstract-algebra/sylow-sage.py +250 -0
  70. sage/tests/books/judson-abstract-algebra/vect-sage-exercises.py +48 -0
  71. sage/tests/books/judson-abstract-algebra/vect-sage.py +211 -0
  72. sage/tests/memcheck/__init__.py +1 -0
  73. sage/tests/memcheck/run_tests.py +25 -0
  74. sage/tests/memcheck/run_tests_in_valgrind.py +36 -0
  75. sage/tests/memcheck/symbolic_expression.py +12 -0
  76. sage/tests/memcheck/verify_no_leak.py +28 -0
  77. sage/tests/all.py +0 -0
  78. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-cachegrind +0 -0
  79. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-callgrind +0 -0
  80. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-cleaner +0 -0
  81. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-coverage +0 -0
  82. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-eval +0 -0
  83. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-fixdoctests +0 -0
  84. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-inline-fortran +0 -0
  85. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-ipynb2rst +0 -0
  86. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-ipython +0 -0
  87. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-massif +0 -0
  88. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-notebook +0 -0
  89. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-omega +0 -0
  90. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-preparse +0 -0
  91. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-run +0 -0
  92. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-run-cython +0 -0
  93. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-runtests +0 -0
  94. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-startuptime.py +0 -0
  95. {passagemath_repl-10.5.27.data → passagemath_repl-10.5.29.data}/scripts/sage-valgrind +0 -0
  96. {passagemath_repl-10.5.27.dist-info → passagemath_repl-10.5.29.dist-info}/WHEEL +0 -0
@@ -0,0 +1,25 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ """
3
+ This file (./sol/linsolve_doctest.sage) was *autogenerated* from ./sol/linsolve.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/linsolve_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/linsolve.tex, line 72::
12
+
13
+ sage: m = random_matrix(RDF,4)
14
+ sage: a = transpose(m)*m
15
+ sage: c = a.cholesky()
16
+ sage: U,S,V = c.SVD()
17
+ sage: X = U*S*transpose(U)
18
+
19
+ Sage example in ./sol/linsolve.tex, line 84::
20
+
21
+ sage: M = (X*X-a)
22
+ sage: all(abs(M[i,j]) < 10^-13
23
+ ....: for i in range(4) for j in range(4) )
24
+ True
25
+ """
@@ -0,0 +1,47 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ """
3
+ This file (./sol/lp_doctest.sage) was *autogenerated* from ./sol/lp.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/lp_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/lp.tex, line 1::
12
+
13
+ sage: sage.numerical.backends.generic_backend.default_solver = "Glpk"
14
+
15
+ Sage example in ./sol/lp.tex, line 28::
16
+
17
+ sage: l = [28, 10, -89, 69, 42, -37, 76, 78, -40, 92, -93, 45]
18
+ sage: p = MixedIntegerLinearProgram()
19
+ sage: b = p.new_variable(binary = True)
20
+ sage: p.add_constraint(p.sum([ v*b[v] for v in l ]) == 0)
21
+ sage: p.add_constraint(p.sum([ b[v] for v in l ]) >= 1)
22
+ sage: p.solve()
23
+ 0.0
24
+ sage: b = p.get_values(b, convert=ZZ, tolerance=1e-3)
25
+ sage: len([v for v in b if b[v] == 1])
26
+ 5
27
+ sage: sum([v for v in b if b[v] == 1])
28
+ 0
29
+
30
+ Sage example in ./sol/lp.tex, line 64::
31
+
32
+ sage: g = graphs.PetersenGraph()
33
+ sage: p = MixedIntegerLinearProgram(maximization = False)
34
+ sage: b = p.new_variable(binary = True)
35
+ sage: for v in g:
36
+ ....: p.add_constraint( p.sum([b[u] for u in g.neighbors(v)])
37
+ ....: + b[v] >= 1)
38
+ sage: p.set_objective( p.sum([ b[v] for v in g ]) )
39
+ sage: p.solve()
40
+ 3.0
41
+ sage: b = p.get_values(b, convert=ZZ, tolerance=1e-3)
42
+ sage: dom = [v for v in b if b[v] == 1]
43
+ sage: len(dom)
44
+ 3
45
+ sage: all((v in dom or any(g.has_edge(x,v) for x in dom)) for v in g)
46
+ True
47
+ """
@@ -0,0 +1,115 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ """
3
+ This file (./sol/mpoly_doctest.sage) was *autogenerated* from ./sol/mpoly.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/mpoly_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/mpoly.tex, line 27::
12
+
13
+ sage: ring = QQ['x,y,z']; deg = 2
14
+ sage: tmp1 = [(x,)*deg for x in (1,) + ring.gens()]; tmp1
15
+ [(1, 1), (x, x), (y, y), (z, z)]
16
+ sage: tmp2 = flatten(tmp1); tmp2
17
+ [1, 1, x, x, y, y, z, z]
18
+ sage: monomials = Subsets(tmp2, deg, submultiset=True); monomials
19
+ SubMultiset of [1, 1, x, x, y, y, z, z] of size 2
20
+ sage: monomials.list()
21
+ [[1, 1], [1, x], [1, y], [1, z], [x, x], [x, y], [x, z], [y, y], [y, z], [z, z]]
22
+
23
+ Sage example in ./sol/mpoly.tex, line 98::
24
+
25
+ sage: ['x%d' % n for n in [2,3,5,7]]
26
+ ['x2', 'x3', 'x5', 'x7']
27
+ sage: R = PolynomialRing(QQ, ['x%d' % n for n in primes(40)])
28
+ sage: R.inject_variables()
29
+ Defining x2, x3, x5, x7, x11, x13, x17, x19, x23, x29, x31, x37
30
+
31
+ Sage example in ./sol/mpoly.tex, line 116::
32
+
33
+ sage: R.<x,y,z> = QQ[]
34
+ sage: J = R.ideal(x^2*y*z-18, x*y^3*z-24, x*y*z^4-6)
35
+ sage: J.variety(AA)
36
+ [{z: 1, y: 2, x: 3}]
37
+
38
+ Sage example in ./sol/mpoly.tex, line 124::
39
+
40
+ sage: V = J.variety(QQbar)
41
+ sage: [u for u in V if all(a in AA for a in u.values())]
42
+ [{z: 1, y: 2, x: 3}]
43
+
44
+ Sage example in ./sol/mpoly.tex, line 137::
45
+
46
+ sage: M = matrix([ [p.degree(v) for v in (x,y,z)]
47
+ ....: for p in J.gens()]); M
48
+ [2 1 1]
49
+ [1 3 1]
50
+ [1 1 4]
51
+
52
+ Sage example in ./sol/mpoly.tex, line 146::
53
+
54
+ sage: M.det()
55
+ 17
56
+
57
+ Sage example in ./sol/mpoly.tex, line 154::
58
+
59
+ sage: M.change_ring(GF(17)).right_kernel()
60
+ Vector space of degree 3 and dimension 1 over Finite Field of size 17
61
+ Basis matrix:
62
+ [1 9 6]
63
+
64
+ Sage example in ./sol/mpoly.tex, line 166::
65
+
66
+ sage: L.<a> = QQ[sqrt(2-sqrt(3))]; L
67
+ Number Field in a with defining polynomial x^4 - 4*x^2 + 1 with a = 0.5176380902050415?
68
+ sage: R.<x,y> = QQ[]
69
+ sage: J1 = (x^2 + y^2 - 1, 16*x^2*y^2 - 1)*R
70
+ sage: sorted(J1.variety(L), key=str)
71
+ [{y: -1/2*a, x: -1/2*a^3 + 2*a},
72
+ {y: -1/2*a, x: 1/2*a^3 - 2*a},
73
+ {y: -1/2*a^3 + 2*a, x: -1/2*a},
74
+ {y: -1/2*a^3 + 2*a, x: 1/2*a},
75
+ {y: 1/2*a, x: -1/2*a^3 + 2*a},
76
+ {y: 1/2*a, x: 1/2*a^3 - 2*a},
77
+ {y: 1/2*a^3 - 2*a, x: -1/2*a},
78
+ {y: 1/2*a^3 - 2*a, x: 1/2*a}]
79
+
80
+ Sage example in ./sol/mpoly.tex, line 191::
81
+
82
+ sage: R.<x,y> = QQ[]; J2 = (x^2+y^2-1, 4*x^2*y^2-1)*R
83
+ sage: basis = J2.normal_basis(); basis
84
+ [x*y^3, y^3, x*y^2, y^2, x*y, y, x, 1]
85
+
86
+ Sage example in ./sol/mpoly.tex, line 200::
87
+
88
+ sage: xbasis = [(x*p).reduce(J2) for p in basis]; xbasis
89
+ [1/4*y, x*y^3, 1/4, x*y^2, -y^3 + y, x*y, -y^2 + 1, x]
90
+ sage: mat = matrix([ [xp[q] for q in basis]
91
+ ....: for xp in xbasis])
92
+ sage: mat
93
+ [ 0 0 0 0 0 1/4 0 0]
94
+ [ 1 0 0 0 0 0 0 0]
95
+ [ 0 0 0 0 0 0 0 1/4]
96
+ [ 0 0 1 0 0 0 0 0]
97
+ [ 0 -1 0 0 0 1 0 0]
98
+ [ 0 0 0 0 1 0 0 0]
99
+ [ 0 0 0 -1 0 0 0 1]
100
+ [ 0 0 0 0 0 0 1 0]
101
+
102
+ Sage example in ./sol/mpoly.tex, line 219::
103
+
104
+ sage: charpoly = mat.characteristic_polynomial(); charpoly
105
+ x^8 - 2*x^6 + 3/2*x^4 - 1/2*x^2 + 1/16
106
+ sage: solve(SR(charpoly), SR(x))
107
+ [x == -1/2*sqrt(2), x == 1/2*sqrt(2)]
108
+
109
+ Sage example in ./sol/mpoly.tex, line 278::
110
+
111
+ sage: R.<s, c, u, v> = PolynomialRing(QQ, order='lex')
112
+ sage: Rel = ideal(u-(s+c), v-(2*s*c+c^2-s^2), s^2+c^2-1)
113
+ sage: Rel.reduce(s^6)
114
+ 1/16*u^2*v^2 - 3/8*u^2*v + 7/16*u^2 + 1/8*v^2 - 1/8*v - 1/8
115
+ """
@@ -0,0 +1,111 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ """
3
+ This file (./sol/nonlinear_doctest.sage) was *autogenerated* from ./sol/nonlinear.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/nonlinear_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/nonlinear.tex, line 17::
12
+
13
+ sage: def intervalgen(f, phi, s, t):
14
+ ....: assert (f(s) * f(t) < 0), \
15
+ ....: 'Wrong arguments: f(%s) * f(%s) >= 0)'%(s, t)
16
+ ....: yield s
17
+ ....: yield t
18
+ ....: while 1:
19
+ ....: u = phi(s, t)
20
+ ....: yield u
21
+ ....: fu = f(u)
22
+ ....: if fu == 0:
23
+ ....: return
24
+ ....: if fu * f(s) < 0:
25
+ ....: t = u
26
+ ....: else:
27
+ ....: s = u
28
+
29
+ Sage example in ./sol/nonlinear.tex, line 40::
30
+
31
+ sage: f(x) = 4 * x - 1
32
+ sage: a, b = 0, 1
33
+ sage: phi(s, t) = (s + t) / 2
34
+ sage: list(intervalgen(f, phi, a, b))
35
+ [0, 1, 1/2, 1/4]
36
+
37
+ Sage example in ./sol/nonlinear.tex, line 49::
38
+
39
+ sage: from types import GeneratorType, FunctionType
40
+ sage: def checklength(u, v, w, prec):
41
+ ....: return abs(v - u) < 2 * prec
42
+ sage: def iterate(series, check=checklength, prec=10^-5, maxit=100):
43
+ ....: assert isinstance(series, GeneratorType)
44
+ ....: assert isinstance(check, FunctionType)
45
+ ....: niter = 2
46
+ ....: v, w = next(series), next(series)
47
+ ....: while (niter <= maxit):
48
+ ....: niter += 1
49
+ ....: u, v, w = v, w, next(series)
50
+ ....: if check(u, v, w, prec):
51
+ ....: print('After {0} iterations: {1}'.format(niter, w))
52
+ ....: return
53
+ ....: print('Failed after {0} iterations'.format(maxit))
54
+
55
+ Sage example in ./sol/nonlinear.tex, line 76::
56
+
57
+ sage: f(x) = 4 * sin(x) - exp(x) / 2 + 1
58
+ sage: a, b = RR(-pi), RR(pi)
59
+ sage: def phi(s, t): return RR.random_element(s, t)
60
+ sage: random = intervalgen(f, phi, a, b)
61
+ sage: iterate(random, maxit=10000) # random
62
+ After 19 iterations: 2.15848379485564
63
+
64
+ Sage example in ./sol/nonlinear.tex, line 93::
65
+
66
+ sage: basering.<x> = PolynomialRing(SR, 'x')
67
+ sage: p = x^2 + x
68
+ sage: p.roots(multiplicities=False)
69
+ [-1, 0]
70
+
71
+ Sage example in ./sol/nonlinear.tex, line 101::
72
+
73
+ sage: from collections import deque
74
+ sage: basering = PolynomialRing(SR, 'x')
75
+ sage: q, method = None, None
76
+ sage: def quadraticgen(f, r, s):
77
+ ....: global q, method
78
+ ....: t = r - f(r) / f.derivative()(r)
79
+ ....: method = 'newton'
80
+ ....: yield t
81
+ ....: pts = deque([(p, f(p)) for p in (r, s, t)], maxlen=3)
82
+ ....: while True:
83
+ ....: q = basering.lagrange_polynomial(pts)
84
+ ....: roots = [r for r in q.roots(multiplicities=False) \
85
+ ....: if CC(r).is_real()]
86
+ ....: approx = None
87
+ ....: for root in roots:
88
+ ....: if (root - pts[2][0]) * (root - pts[1][0]) < 0:
89
+ ....: approx = root
90
+ ....: break
91
+ ....: elif (root - pts[0][0]) * (root - pts[1][0]) < 0:
92
+ ....: pts.pop()
93
+ ....: approx = root
94
+ ....: break
95
+ ....: if approx:
96
+ ....: method = 'quadratic'
97
+ ....: else:
98
+ ....: method = 'dichotomy'
99
+ ....: approx = (pts[1][0] + pts[2][0]) / 2
100
+ ....: pts.append((approx, f(approx)))
101
+ ....: yield pts[2][0]
102
+
103
+ Sage example in ./sol/nonlinear.tex, line 141::
104
+
105
+ sage: basering = PolynomialRing(SR, 'x')
106
+ sage: a, b = pi/2, pi
107
+ sage: f(x) = 4 * sin(x) - exp(x) / 2 + 1
108
+ sage: generator = quadraticgen(f, a, b)
109
+ sage: next(generator)
110
+ 1/2*pi - (e^(1/2*pi) - 10)*e^(-1/2*pi)
111
+ """
@@ -0,0 +1,167 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ """
3
+ This file (./sol/numbertheory_doctest.sage) was *autogenerated* from ./sol/numbertheory.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/numbertheory_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/numbertheory.tex, line 9::
12
+
13
+ sage: def enum_carmichael(N, verbose=True):
14
+ ....: p = 3; s = 0
15
+ ....: while p^3 <= N:
16
+ ....: s += enum_carmichael_p(N, p, verbose); p = next_prime(p)
17
+ ....: return s
18
+
19
+ Sage example in ./sol/numbertheory.tex, line 26::
20
+
21
+ sage: def enum_carmichael_p (n, p, verbose):
22
+ ....: a = p; m = p*(p-1); q = p; s = 0
23
+ ....: while p*q^2 <= n:
24
+ ....: q = next_prime(q)
25
+ ....: s += enum_carmichael_pq(n, a, m, p, q, verbose)
26
+ ....: return s
27
+
28
+ Sage example in ./sol/numbertheory.tex, line 52::
29
+
30
+ sage: def enum_carmichael_pq(n, a, m, p, q, verbose):
31
+ ....: if (a-q) % gcd(m,q*(q-1)) != 0: return 0
32
+ ....: s = 0
33
+ ....: a = crt (a, q, m, q*(q-1)); m = lcm(m,q*(q-1))
34
+ ....: while a <= p*q^2: a += m
35
+ ....: for t in range(a, n+1, m):
36
+ ....: r = t // (p*q)
37
+ ....: if is_prime(r) and t % (r-1) == 1:
38
+ ....: if verbose:
39
+ ....: print((p*q*r, factor(p*q*r)))
40
+ ....: s += 1
41
+ ....: return s
42
+
43
+ Sage example in ./sol/numbertheory.tex, line 68::
44
+
45
+ sage: enum_carmichael(10^4)
46
+ (561, 3 * 11 * 17)
47
+ (1105, 5 * 13 * 17)
48
+ (2465, 5 * 17 * 29)
49
+ (1729, 7 * 13 * 19)
50
+ (2821, 7 * 13 * 31)
51
+ (8911, 7 * 19 * 67)
52
+ (6601, 7 * 23 * 41)
53
+ 7
54
+ sage: enum_carmichael(10^5, False)
55
+ 12
56
+ sage: enum_carmichael(10^6, False)
57
+ 23
58
+ sage: enum_carmichael(10^7, False)
59
+ 47
60
+
61
+ Sage example in ./sol/numbertheory.tex, line 94::
62
+
63
+ sage: def aliq(n):
64
+ ....: l = [n]
65
+ ....: while n != 1:
66
+ ....: n = sigma(n) - n
67
+ ....: if n in l: break
68
+ ....: l.append(n)
69
+ ....: return l
70
+ sage: l = aliq(840) # long time
71
+ sage: len(l), l[:5], l[-5:] # long time
72
+ (748, [840, 2040, 4440, 9240, 25320], [2714, 1606, 1058, 601, 1])
73
+
74
+ Sage example in ./sol/numbertheory.tex, line 106::
75
+
76
+ sage: p = points([(i, log(l[i])/log(10)) for i in range(len(l))]) # long time
77
+
78
+ Sage example in ./sol/numbertheory.tex, line 173::
79
+
80
+ sage: def rk_aux(xc, yc, d, r2):
81
+ ....: s = 0
82
+ ....: xmin = ceil((xc - sqrt(r2))/d)
83
+ ....: xmax = floor((xc + sqrt(r2))/d)
84
+ ....: for x in range(xmin,xmax+1):
85
+ ....: r3 = r2 - (d*x-xc)^2 # (d*y-yc)^2 <= r2 - (d*x-xc)^2
86
+ ....: ymin = ceil((yc - sqrt(r3))/d)
87
+ ....: ymax = floor((yc + sqrt(r3))/d)
88
+ ....: s += ymax + 1 - ymin
89
+ ....: return s
90
+
91
+ Sage example in ./sol/numbertheory.tex, line 219::
92
+
93
+ sage: def rk(k): # returns (r_k^2, xc, yc)
94
+ ....: if k == 2: return 1/4, 1/2, 0
95
+ ....: dmax = (2*sqrt(k/pi)).n(); xamax = (sqrt(2*k/pi)).n()
96
+ ....: sol = (dmax/2)^2, 0, 0, 0
97
+ ....: for xa in range(0, floor(xamax)+1):
98
+ ....: # if xa=0, ya > 0 since A should differ from O
99
+ ....: yamin = max(xa, 1)
100
+ ....: for ya in range(yamin, floor(sqrt(dmax^2-xa^2))+1):
101
+ ....: xbmin = 0 # we want xb*ya <= xa^2+ya^2
102
+ ....: if xa == 0:
103
+ ....: xbmin = 1 # O, A, B should not be aligned
104
+ ....: xbmax = min(floor(dmax), floor((xa*xa+ya*ya)/ya))
105
+ ....: for xb in range(xbmin, xbmax+1):
106
+ ....: ybmax = floor(sqrt(dmax^2-xb^2))
107
+ ....: if xa > 0: # we want xb*ya+yb*xa <= xa^2+ya^2
108
+ ....: tmp = floor((xa*xa+ya*ya-xb*ya)/xa)
109
+ ....: ybmax = min(ybmax, tmp)
110
+ ....: # if xb=0, yb > 0 since B should differ from O
111
+ ....: ybmin = 0
112
+ ....: if xb == 0:
113
+ ....: ybmin = 1
114
+ ....: for yb in range(ybmin,ybmax+1):
115
+ ....: d = 2*abs(xb*ya - xa*yb)
116
+ ....: if d != 0:
117
+ ....: ra2 = xa^2+ya^2; rb2 = xb^2+yb^2
118
+ ....: xc = abs(ra2*yb - rb2*ya)
119
+ ....: yc = abs(rb2*xa - ra2*xb)
120
+ ....: r2 = ra2*rb2*((xa-xb)^2+(ya-yb)^2)
121
+ ....: m = rk_aux(xc,yc,d,r2)
122
+ ....: if m >= k and r2/d^2 < sol[0]:
123
+ ....: sol = r2/d^2, xc/d, yc/d
124
+ ....: return sol
125
+
126
+ Sage example in ./sol/numbertheory.tex, line 253::
127
+
128
+ sage: for k in range(2,10): print((k, rk(k)))
129
+ (2, (1/4, 1/2, 0))
130
+ (3, (1/2, 1/2, 1/2))
131
+ (4, (1/2, 1/2, 1/2))
132
+ (5, (1, 0, 1))
133
+ (6, (5/4, 1/2, 1))
134
+ (7, (25/16, 3/4, 1))
135
+ (8, (2, 1, 1))
136
+ (9, (2, 1, 1))
137
+
138
+ Sage example in ./sol/numbertheory.tex, line 283::
139
+
140
+ sage: def plotrk(k):
141
+ ....: r2, x0, y0 = rk(k); r = n(sqrt(r2))
142
+ ....: var('x, y')
143
+ ....: c = implicit_plot((x-x0)^2+(y-y0)^2-r2,
144
+ ....: (x, x0-r-1/2, x0+r+1/2),(y, y0-r-1/2, y0+r+1/2))
145
+ ....: center = points([(x0,y0)], pointsize=50, color='black')
146
+ ....: # we want (i-x0)^2+(j-y0)^2 <= r2
147
+ ....: # thus |i-x0| <= r and |j-y0| <= r2 - (i-x0)^2
148
+ ....: l = [(i, j) for i in range(ceil(x0-r), floor(x0+r)+1)
149
+ ....: for j in range(ceil(y0-sqrt(r^2-(i-x0)^2)),
150
+ ....: floor(y0+sqrt(r2-(i-x0)^2))+1)]
151
+ ....: d = points(l, pointsize=100)
152
+ ....: return (c+center+d).show(aspect_ratio=1, axes=True)
153
+
154
+ Sage example in ./sol/numbertheory.tex, line 377::
155
+
156
+ sage: x1, x2, s2 = var('x1, x2, s2')
157
+ sage: n1 = 9; C1 = integrate(x1^n1, x1, x2, s2); C1
158
+ 1/10*s2^10 - 1/10*x2^10
159
+
160
+ Sage example in ./sol/numbertheory.tex, line 390::
161
+
162
+ sage: x3, s3 = var('x3, s3')
163
+ sage: n2 = 7; C2 = integrate(C1.subs(s2=s3-x2)*x2^n2, x2, x3, s3/2); C2
164
+ 44923/229417943040*s3^18 - 1/80*s3^10*x3^8 + 1/9*s3^9*x3^9 - 9/20*s3^8*x3^10
165
+ + 12/11*s3^7*x3^11 - 7/4*s3^6*x3^12 + 126/65*s3^5*x3^13 - 3/2*s3^4*x3^14
166
+ + 4/5*s3^3*x3^15 - 9/32*s3^2*x3^16 + 1/17*s3*x3^17
167
+ """
@@ -0,0 +1,107 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ """
3
+ This file (./sol/polynomes_doctest.sage) was *autogenerated* from ./sol/polynomes.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/polynomes_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/polynomes.tex, line 10::
12
+
13
+ sage: x = polygen(QQ, 'y'); y = polygen(QQ, 'x')
14
+
15
+ Sage example in ./sol/polynomes.tex, line 78::
16
+
17
+ sage: T = sage.symbolic.function_factory.function('T', nargs=2)
18
+ sage: def to_chebyshev_basis(pol):
19
+ ....: (x,) = pol.variables()
20
+ ....: res = 0
21
+ ....: for n in range(pol.degree(), -1, -1):
22
+ ....: quo, pol = pol.quo_rem(chebyshev_T(n, x))
23
+ ....: res += quo * T(n, x)
24
+ ....: return res
25
+
26
+ Sage example in ./sol/polynomes.tex, line 105::
27
+
28
+ sage: x = polygen(QQ)
29
+ sage: p = 4*x^6 + 4*x^5 + 1/9*x^4 - 2*x^3 + 2/19*x^2 + 1
30
+ sage: p_cheb = to_chebyshev_basis(p); p_cheb
31
+ 1/8*T(6, x) + 1/4*T(5, x) + 55/72*T(4, x) + 3/4*T(3, x) +
32
+ 2713/1368*T(2, x) + T(1, x) + 1069/456*T(0, x)
33
+ sage: p_cheb.substitute_function(T, chebyshev_T).expand()
34
+ 4*x^6 + 4*x^5 + 1/9*x^4 - 2*x^3 + 2/19*x^2 + 1
35
+
36
+ Sage example in ./sol/polynomes.tex, line 131::
37
+
38
+ sage: def mydiv(u, v, n):
39
+ ....: v0 = v.constant_coefficient()
40
+ ....: quo = 0; rem = u
41
+ ....: for k in range(n+1):
42
+ ....: c = rem[0]/v0
43
+ ....: rem = (rem - c*v) >> 1 # shifting the coefficients
44
+ ....: quo += c*x^k
45
+ ....: return quo, rem
46
+
47
+ Sage example in ./sol/polynomes.tex, line 161::
48
+
49
+ sage: def mydiv2(u, v, n):
50
+ ....: x = u.parent().gen()
51
+ ....: quo = (u / (v + O(x^(n+1)))).polynomial()
52
+ ....: rem = (u - quo*v) >> (n+1)
53
+ ....: return quo, rem
54
+
55
+ Sage example in ./sol/polynomes.tex, line 179::
56
+
57
+ sage: x = polygen(QQ)
58
+ sage: u = -5*x^10 + 7/2*x^9 + 3*x^8 - x^6 - 1/3*x^5 - x^4 - 1/2*x^3 + 15*x^2 - 1/42*x + 2
59
+ sage: v = 3*x^4 + 3/8*x^3 - 1/2*x^2 + x + 5/2
60
+ sage: n = 8
61
+ sage: q, r = mydiv(u, v, n)
62
+ sage: u - q*v - x^(n+1)*r
63
+ 0
64
+ sage: q, r = mydiv2(u, v, n)
65
+ sage: u - q*v - x^(n+1)*r
66
+ 0
67
+
68
+ Sage example in ./sol/polynomes.tex, line 296::
69
+
70
+ sage: Poly.<x> = Integers(10^5)[]
71
+ sage: P = x^1000 - 23*x^729 + 5*x^2 - 12*x - 7
72
+ sage: Quo.<s> = Poly.quo(P)
73
+ sage: op = s^(10^10000) # long time
74
+ sage: add(op[n]*(n+7) for n in range(1000)) # long time
75
+ 63477
76
+
77
+ Sage example in ./sol/polynomes.tex, line 383::
78
+
79
+ sage: from sage.matrix.berlekamp_massey import berlekamp_massey
80
+ sage: berlekamp_massey([1, 1, 2, 3, 8, 11, 34, 39, 148, 127])
81
+ x^3 - 5*x + 2
82
+
83
+ Sage example in ./sol/polynomes.tex, line 408::
84
+
85
+ sage: R.<x> = GF(17)[]
86
+ sage: pairs = [(0,-1), (1,0), (2,7), (3,5)]
87
+ sage: s = R(QQ['x'].lagrange_polynomial(pairs)); s
88
+ 6*x^3 + 2*x^2 + 10*x + 16
89
+ sage: [s(i) for i in range(4)]
90
+ [16, 0, 7, 5]
91
+
92
+ Sage example in ./sol/polynomes.tex, line 428::
93
+
94
+ sage: s.rational_reconstruction(mul(x-i for i in range(4)), 1, 2)
95
+ (15*x + 2, x^2 + 11*x + 15)
96
+
97
+ Sage example in ./sol/polynomes.tex, line 454::
98
+
99
+ sage: S.<x> = PowerSeriesRing(QQ)
100
+ sage: t = S(0)
101
+ sage: for i in range(7): # here t is correct up to degree 2i+1
102
+ ....: # with O(x^15) we prevent the truncation order to grow
103
+ ....: t = (1+t^2).integral() + O(x^15)
104
+ sage: t
105
+ x + 1/3*x^3 + 2/15*x^5 + 17/315*x^7 + 62/2835*x^9 + 1382/155925*x^11
106
+ + 21844/6081075*x^13 + O(x^15)
107
+ """
@@ -0,0 +1,58 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ """
3
+ This file (./sol/recequadiff_doctest.sage) was *autogenerated* from ./sol/recequadiff.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/recequadiff_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/recequadiff.tex, line 16::
12
+
13
+ sage: x = var('x')
14
+ sage: y = function('y')(x)
15
+ sage: ed = (desolve(y*diff(y,x)/sqrt(1+y^2) == sin(x),y)); ed
16
+ sqrt(y(x)^2 + 1) == _C - cos(x)
17
+
18
+ Sage example in ./sol/recequadiff.tex, line 27::
19
+
20
+ sage: c = ed.variables()[0]
21
+ sage: assume(c-cos(x) > 0)
22
+ sage: sol = solve(ed,y) ; sol
23
+ [y(x) == -sqrt(_C^2 - 2*_C*cos(x) + cos(x)^2 - 1),
24
+ y(x) == sqrt(_C^2 - 2*_C*cos(x) + cos(x)^2 - 1)]
25
+
26
+ Sage example in ./sol/recequadiff.tex, line 34::
27
+
28
+ sage: P = Graphics()
29
+ sage: for j in [0,1]:
30
+ ....: for k in range(0,20,2):
31
+ ....: P += plot(sol[j].substitute(c==2+0.25*k).rhs(),x,-3,3)
32
+ sage: P
33
+ Graphics object consisting of 20 graphics primitives
34
+
35
+ Sage example in ./sol/recequadiff.tex, line 52::
36
+
37
+ sage: sol = desolve(diff(y,x)==sin(x)/cos(y), y, show_method=True)
38
+ sage: sol
39
+ [sin(y(x)) == _C - cos(x), 'separable']
40
+ sage: solve(sol[0],y)
41
+ [y(x) == -arcsin(-_C + cos(x))]
42
+
43
+ Sage example in ./sol/recequadiff.tex, line 80::
44
+
45
+ sage: x = var('x')
46
+ sage: y = function('y')(x)
47
+ sage: id(x) = x
48
+ sage: u = function('u')(x)
49
+ sage: d = diff(u*id,x)
50
+ sage: DE = (x*y*d == x**2+y**2).substitute(y == u*id)
51
+ sage: eq = desolve(DE,u)
52
+ sage: sol = solve(eq,u)
53
+ sage: sol
54
+ [u(x) == -sqrt(2*_C + 2*log(x)), u(x) == sqrt(2*_C + 2*log(x))]
55
+ sage: Y = [x*sol[0].rhs() , x*sol[1].rhs()]
56
+ sage: Y[0]
57
+ -sqrt(2*_C + 2*log(x))*x
58
+ """
@@ -0,0 +1 @@
1
+ # sage_setup: distribution = sagemath-repl
@@ -0,0 +1,51 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ ## Sage Doctest File ##
3
+ #**************************************#
4
+ #* Generated from PreTeXt source *#
5
+ #* on 2017-08-24T11:43:34-07:00 *#
6
+ #* *#
7
+ #* http://mathbook.pugetsound.edu *#
8
+ #* *#
9
+ #**************************************#
10
+ ##
11
+ """
12
+ Please contact Rob Beezer (beezer@ups.edu) with
13
+ any test failures here that need to be changed
14
+ as a result of changes accepted into Sage. You
15
+ may edit/change this file in any sensible way, so
16
+ that development work may procede. Your changes
17
+ may later be replaced by the authors of "Abstract
18
+ Algebra: Theory and Applications" when the text is
19
+ updated, and a replacement of this file is proposed
20
+ for review.
21
+ """
22
+ ##
23
+ ## To execute doctests in these files, run
24
+ ## $ $SAGE_ROOT/sage -t <directory-of-these-files>
25
+ ## or
26
+ ## $ $SAGE_ROOT/sage -t <a-single-file>
27
+ ##
28
+ ## Replace -t by "-tp n" for parallel testing,
29
+ ## "-tp 0" will use a sensible number of threads
30
+ ##
31
+ ## See: http://www.sagemath.org/doc/developer/doctesting.html
32
+ ## or run $ $SAGE_ROOT/sage --advanced for brief help
33
+ ##
34
+ ## Generated at 2017-08-24T11:43:34-07:00
35
+ ## From "Abstract Algebra"
36
+ ## At commit 26d3cac0b4047f4b8d6f737542be455606e2c4b4
37
+ ##
38
+ ## Exercises 14.8 Sage Exercises
39
+ ##
40
+ r"""
41
+ ~~~~~~~~~~~~~~~~~~~~~~ ::
42
+
43
+ sage: G = Graph([(1,2), (2,3), (3,1)])
44
+ sage: G.plot() # not tested
45
+
46
+ ~~~~~~~~~~~~~~~~~~~~~~ ::
47
+
48
+ sage: G = graphs.CycleGraph(8)
49
+ sage: G.add_edges([(0,2),(1,3),(4,6),(5,7)])
50
+ sage: G.plot() # not tested
51
+ """