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