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
@@ -43,11 +43,11 @@ class SageKernelSpec:
|
|
43
43
|
sage: prefix = tmp_dir()
|
44
44
|
sage: spec = SageKernelSpec(prefix=prefix)
|
45
45
|
sage: spec._display_name # random output
|
46
|
-
'
|
46
|
+
'passagemath 6.9'
|
47
47
|
sage: spec.kernel_dir == SageKernelSpec(prefix=prefix).kernel_dir
|
48
48
|
True
|
49
49
|
"""
|
50
|
-
self._display_name = '
|
50
|
+
self._display_name = 'passagemath {0}'.format(SAGE_VERSION)
|
51
51
|
if prefix is None:
|
52
52
|
from sys import prefix
|
53
53
|
jupyter_dir = os.path.join(prefix, "share", "jupyter")
|
@@ -148,16 +148,14 @@ class SageKernelSpec:
|
|
148
148
|
sage: from sage.repl.ipython_kernel.install import SageKernelSpec
|
149
149
|
sage: spec = SageKernelSpec(prefix=tmp_dir())
|
150
150
|
sage: spec._kernel_cmd()
|
151
|
-
[
|
152
|
-
'--python',
|
151
|
+
[...
|
153
152
|
'-m',
|
154
153
|
'sage.repl.ipython_kernel',
|
155
154
|
'-f',
|
156
155
|
'{connection_file}']
|
157
156
|
"""
|
158
157
|
return [
|
159
|
-
|
160
|
-
'--python',
|
158
|
+
'python3',
|
161
159
|
'-m', 'sage.repl.ipython_kernel',
|
162
160
|
'-f', '{connection_file}',
|
163
161
|
]
|
@@ -173,7 +171,7 @@ class SageKernelSpec:
|
|
173
171
|
sage: from sage.repl.ipython_kernel.install import SageKernelSpec
|
174
172
|
sage: spec = SageKernelSpec(prefix=tmp_dir())
|
175
173
|
sage: spec.kernel_spec()
|
176
|
-
{'argv': ..., 'display_name': '
|
174
|
+
{'argv': ..., 'display_name': 'passagemath ...', 'language': 'sage'}
|
177
175
|
"""
|
178
176
|
return dict(
|
179
177
|
argv=self._kernel_cmd(),
|
@@ -265,7 +263,7 @@ class SageKernelSpec:
|
|
265
263
|
'(see https://docs.jupyter.org/en/latest/use/jupyter-directories.html)')
|
266
264
|
else:
|
267
265
|
from pathlib import Path
|
268
|
-
if Path(spec.argv[0]).resolve() != Path(os.path.join(SAGE_VENV, 'bin', 'sage')).resolve():
|
266
|
+
if spec.argv[0] != 'python3' and Path(spec.argv[0]).resolve() != Path(os.path.join(SAGE_VENV, 'bin', 'sage')).resolve():
|
269
267
|
warnings.warn(f'the kernel named {ident} does not seem to correspond to this '
|
270
268
|
'installation of SageMath; check your Jupyter configuration '
|
271
269
|
'(see https://docs.jupyter.org/en/latest/use/jupyter-directories.html)')
|
@@ -0,0 +1 @@
|
|
1
|
+
# sage_setup: distribution = sagemath-repl
|
@@ -0,0 +1,549 @@
|
|
1
|
+
# sage_setup: distribution = sagemath-repl
|
2
|
+
"""
|
3
|
+
This file (./calculus_doctest.sage) was *autogenerated* from ./calculus.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 ./calculus_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 ./calculus.tex, line 76::
|
12
|
+
|
13
|
+
sage: bool(arctan(1+abs(x)) == pi/2 - arctan(1/(1+abs(x))))
|
14
|
+
False
|
15
|
+
|
16
|
+
Sage example in ./calculus.tex, line 121::
|
17
|
+
|
18
|
+
sage: a, x = var('a, x'); y = cos(x+a) * (x+1); y
|
19
|
+
(x + 1)*cos(a + x)
|
20
|
+
sage: y.subs(a=-x); y.subs(x=pi/2, a=pi/3); y.subs(x=0.5, a=2.3)
|
21
|
+
x + 1
|
22
|
+
-1/4*sqrt(3)*(pi + 2)
|
23
|
+
-1.41333351100299
|
24
|
+
sage: y(a=-x); y(x=pi/2, a=pi/3); y(x=0.5, a=2.3)
|
25
|
+
x + 1
|
26
|
+
-1/4*sqrt(3)*(pi + 2)
|
27
|
+
-1.41333351100299
|
28
|
+
|
29
|
+
Sage example in ./calculus.tex, line 143::
|
30
|
+
|
31
|
+
sage: x, y, z = var('x, y, z') ; q = x*y + y*z + z*x
|
32
|
+
sage: bool(q(x=y, y=z, z=x) == q), bool(q(z=y)(y=x) == 3*x^2)
|
33
|
+
(True, True)
|
34
|
+
|
35
|
+
Sage example in ./calculus.tex, line 155::
|
36
|
+
|
37
|
+
sage: y, z = var('y, z'); f = x^3 + y^2 + z
|
38
|
+
sage: f.substitute(x^3 == y^2, z==1)
|
39
|
+
2*y^2 + 1
|
40
|
+
|
41
|
+
Sage example in ./calculus.tex, line 176::
|
42
|
+
|
43
|
+
sage: f(x)=(2*x+1)^3 ; f(-3)
|
44
|
+
-125
|
45
|
+
sage: f.expand()
|
46
|
+
x |--> 8*x^3 + 12*x^2 + 6*x + 1
|
47
|
+
|
48
|
+
Sage example in ./calculus.tex, line 193::
|
49
|
+
|
50
|
+
sage: y = var('y'); u = sin(x) + x*cos(y)
|
51
|
+
sage: v = u.function(x, y); v
|
52
|
+
(x, y) |--> x*cos(y) + sin(x)
|
53
|
+
sage: w(x, y) = u; w
|
54
|
+
(x, y) |--> x*cos(y) + sin(x)
|
55
|
+
|
56
|
+
Sage example in ./calculus.tex, line 240::
|
57
|
+
|
58
|
+
sage: x, y = SR.var('x,y')
|
59
|
+
sage: p = (x+y)*(x+1)^2
|
60
|
+
sage: p2 = p.expand(); p2
|
61
|
+
x^3 + x^2*y + 2*x^2 + 2*x*y + x + y
|
62
|
+
|
63
|
+
Sage example in ./calculus.tex, line 251::
|
64
|
+
|
65
|
+
sage: p2.collect(x)
|
66
|
+
x^3 + x^2*(y + 2) + x*(2*y + 1) + y
|
67
|
+
|
68
|
+
Sage example in ./calculus.tex, line 260::
|
69
|
+
|
70
|
+
sage: ((x+y+sin(x))^2).expand().collect(sin(x))
|
71
|
+
x^2 + 2*x*y + y^2 + 2*(x + y)*sin(x) + sin(x)^2
|
72
|
+
|
73
|
+
Sage example in ./calculus.tex, line 416::
|
74
|
+
|
75
|
+
sage: (x^x/x).simplify()
|
76
|
+
x^(x - 1)
|
77
|
+
|
78
|
+
Sage example in ./calculus.tex, line 426::
|
79
|
+
|
80
|
+
sage: f = (e^x-1) / (1+e^(x/2)); f.canonicalize_radical()
|
81
|
+
e^(1/2*x) - 1
|
82
|
+
|
83
|
+
Sage example in ./calculus.tex, line 435::
|
84
|
+
|
85
|
+
sage: f = cos(x)^6 + sin(x)^6 + 3 * sin(x)^2 * cos(x)^2
|
86
|
+
sage: f.simplify_trig()
|
87
|
+
1
|
88
|
+
|
89
|
+
Sage example in ./calculus.tex, line 447::
|
90
|
+
|
91
|
+
sage: f = cos(x)^6; f.reduce_trig()
|
92
|
+
1/32*cos(6*x) + 3/16*cos(4*x) + 15/32*cos(2*x) + 5/16
|
93
|
+
sage: f = sin(5 * x); f.expand_trig()
|
94
|
+
5*cos(x)^4*sin(x) - 10*cos(x)^2*sin(x)^3 + sin(x)^5
|
95
|
+
|
96
|
+
Sage example in ./calculus.tex, line 482::
|
97
|
+
|
98
|
+
sage: n = var('n'); f = factorial(n+1)/factorial(n)
|
99
|
+
sage: f.simplify_factorial()
|
100
|
+
n + 1
|
101
|
+
|
102
|
+
Sage example in ./calculus.tex, line 502::
|
103
|
+
|
104
|
+
sage: f = sqrt(abs(x)^2); f.canonicalize_radical()
|
105
|
+
abs(x)
|
106
|
+
sage: f = log(x*y); f.canonicalize_radical()
|
107
|
+
log(x) + log(y)
|
108
|
+
|
109
|
+
Sage example in ./calculus.tex, line 592::
|
110
|
+
|
111
|
+
sage: assume(x > 0); bool(sqrt(x^2) == x)
|
112
|
+
True
|
113
|
+
sage: forget(x > 0); bool(sqrt(x^2) == x)
|
114
|
+
False
|
115
|
+
sage: n = var('n'); assume(n, 'integer'); sin(n*pi)
|
116
|
+
0
|
117
|
+
|
118
|
+
Sage example in ./calculus.tex, line 600::
|
119
|
+
|
120
|
+
sage: forget(n, 'integer');
|
121
|
+
|
122
|
+
Sage example in ./calculus.tex, line 690::
|
123
|
+
|
124
|
+
sage: a = var('a')
|
125
|
+
sage: c = (a+1)^2 - (a^2+2*a+1)
|
126
|
+
|
127
|
+
Sage example in ./calculus.tex, line 700::
|
128
|
+
|
129
|
+
sage: eq = c * x == 0
|
130
|
+
|
131
|
+
Sage example in ./calculus.tex, line 707::
|
132
|
+
|
133
|
+
sage: eq2 = eq / c; eq2
|
134
|
+
x == 0
|
135
|
+
sage: solve(eq2, x)
|
136
|
+
[x == 0]
|
137
|
+
|
138
|
+
Sage example in ./calculus.tex, line 715::
|
139
|
+
|
140
|
+
sage: solve(eq, x)
|
141
|
+
[x == x]
|
142
|
+
|
143
|
+
Sage example in ./calculus.tex, line 725::
|
144
|
+
|
145
|
+
sage: expand(c)
|
146
|
+
0
|
147
|
+
|
148
|
+
Sage example in ./calculus.tex, line 738::
|
149
|
+
|
150
|
+
sage: c = cos(a)^2 + sin(a)^2 - 1
|
151
|
+
sage: eq = c*x == 0
|
152
|
+
sage: solve(eq, x)
|
153
|
+
[x == 0]
|
154
|
+
|
155
|
+
Sage example in ./calculus.tex, line 750::
|
156
|
+
|
157
|
+
sage: c.simplify_trig()
|
158
|
+
0
|
159
|
+
sage: c.is_zero()
|
160
|
+
True
|
161
|
+
|
162
|
+
Sage example in ./calculus.tex, line 839::
|
163
|
+
|
164
|
+
sage: z, phi = var('z, phi')
|
165
|
+
sage: eq = z**2 - 2/cos(phi)*z + 5/cos(phi)**2 - 4 == 0; eq
|
166
|
+
z^2 - 2*z/cos(phi) + 5/cos(phi)^2 - 4 == 0
|
167
|
+
|
168
|
+
Sage example in ./calculus.tex, line 852::
|
169
|
+
|
170
|
+
sage: eq.lhs()
|
171
|
+
z^2 - 2*z/cos(phi) + 5/cos(phi)^2 - 4
|
172
|
+
sage: eq.rhs()
|
173
|
+
0
|
174
|
+
|
175
|
+
Sage example in ./calculus.tex, line 861::
|
176
|
+
|
177
|
+
sage: solve(eq, z)
|
178
|
+
[z == -(2*sqrt(cos(phi)^2 - 1) - 1)/cos(phi),
|
179
|
+
z == (2*sqrt(cos(phi)^2 - 1) + 1)/cos(phi)]
|
180
|
+
|
181
|
+
Sage example in ./calculus.tex, line 871::
|
182
|
+
|
183
|
+
sage: y = var('y'); solve(y^7==y, y)
|
184
|
+
[y == 1/2*I*sqrt(3) + 1/2, y == 1/2*I*sqrt(3) - 1/2, y == -1,
|
185
|
+
y == -1/2*I*sqrt(3) - 1/2, y == -1/2*I*sqrt(3) + 1/2, y == 1, y == 0]
|
186
|
+
|
187
|
+
Sage example in ./calculus.tex, line 880::
|
188
|
+
|
189
|
+
sage: solve(x^2-1, x, solution_dict=True)
|
190
|
+
[{x: -1}, {x: 1}]
|
191
|
+
|
192
|
+
Sage example in ./calculus.tex, line 894::
|
193
|
+
|
194
|
+
sage: solve([x+y == 3, 2*x+2*y == 6], x, y)
|
195
|
+
[[x == -r1 + 3, y == r1]]
|
196
|
+
|
197
|
+
Sage example in ./calculus.tex, line 910::
|
198
|
+
|
199
|
+
sage: solve([cos(x)*sin(x) == 1/2, x+y == 0], x, y)
|
200
|
+
[[x == 1/4*pi + pi*z..., y == -1/4*pi - pi*z...]]
|
201
|
+
|
202
|
+
Sage example in ./calculus.tex, line 920::
|
203
|
+
|
204
|
+
sage: solve(x^2+x-1 > 0, x)
|
205
|
+
[[x < -1/2*sqrt(5) - 1/2], [x > 1/2*sqrt(5) - 1/2]]
|
206
|
+
|
207
|
+
Sage example in ./calculus.tex, line 943::
|
208
|
+
|
209
|
+
sage: x, y, z = var('x, y, z')
|
210
|
+
sage: solve([x^2 * y * z == 18, x * y^3 * z == 24,\
|
211
|
+
....: x * y * z^4 == 6], x, y, z)
|
212
|
+
[[x == 3, y == 2, z == 1],
|
213
|
+
[x == (1.3372150673296... - 2.685489874065...*I),
|
214
|
+
y == (-1.7004342714592... + 1.0528643257547...*I),
|
215
|
+
z == (0.93247222940435... - 0.36124166618715...*I)], ...]
|
216
|
+
|
217
|
+
Sage example in ./calculus.tex, line 975::
|
218
|
+
|
219
|
+
sage: expr = sin(x) + sin(2 * x) + sin(3 * x)
|
220
|
+
sage: solve(expr, x)
|
221
|
+
[sin(3*x) == -sin(2*x) - sin(x)]
|
222
|
+
|
223
|
+
Sage example in ./calculus.tex, line 983::
|
224
|
+
|
225
|
+
sage: find_root(expr, 0.1, pi) # abs tol 1e-12
|
226
|
+
2.0943951023931957
|
227
|
+
|
228
|
+
Sage example in ./calculus.tex, line 989::
|
229
|
+
|
230
|
+
sage: f = expr.simplify_trig(); f
|
231
|
+
2*(2*cos(x)^2 + cos(x))*sin(x)
|
232
|
+
sage: solve(f, x)
|
233
|
+
[x == 0, x == 2/3*pi, x == 1/2*pi]
|
234
|
+
|
235
|
+
Sage example in ./calculus.tex, line 1022::
|
236
|
+
|
237
|
+
sage: (x^3+2*x+1).roots(x)
|
238
|
+
[(-1/2*(1/18*sqrt(59)*sqrt(3) - 1/2)^(1/3)*(I*sqrt(3) + 1)
|
239
|
+
- 1/3*(I*sqrt(3) - 1)/(1/18*sqrt(59)*sqrt(3) - 1/2)^(1/3), 1),
|
240
|
+
(-1/2*(1/18*sqrt(59)*sqrt(3) - 1/2)^(1/3)*(-I*sqrt(3) + 1)
|
241
|
+
- 1/3*(-I*sqrt(3) - 1)/(1/18*sqrt(59)*sqrt(3) - 1/2)^(1/3), 1),
|
242
|
+
((1/18*sqrt(59)*sqrt(3) - 1/2)^(1/3)
|
243
|
+
- 2/3/(1/18*sqrt(59)*sqrt(3) - 1/2)^(1/3), 1)]
|
244
|
+
|
245
|
+
Sage example in ./calculus.tex, line 1058::
|
246
|
+
|
247
|
+
sage: (x^3+2*x+1).roots(x, ring=RR)
|
248
|
+
[(-0.453397651516404, 1)]
|
249
|
+
|
250
|
+
Sage example in ./calculus.tex, line 1062::
|
251
|
+
|
252
|
+
sage: (x^3+2*x+1).roots(x, ring=CC)
|
253
|
+
[(-0.453397651516404, 1),
|
254
|
+
(0.226698825758202 - 1.46771150871022*I, 1),
|
255
|
+
(0.226698825758202 + 1.46771150871022*I, 1)]
|
256
|
+
|
257
|
+
Sage example in ./calculus.tex, line 1086::
|
258
|
+
|
259
|
+
sage: solve(x^(1/x)==(1/x)^x, x)
|
260
|
+
[(1/x)^x == x^(1/x)]
|
261
|
+
|
262
|
+
Sage example in ./calculus.tex, line 1124::
|
263
|
+
|
264
|
+
sage: y = function('y')(x)
|
265
|
+
sage: desolve(diff(y,x,x) + x*diff(y,x) + y == 0, y, [0,0,1])
|
266
|
+
-1/2*I*sqrt(2)*sqrt(pi)*erf(1/2*I*sqrt(2)*x)*e^(-1/2*x^2)
|
267
|
+
|
268
|
+
Sage example in ./calculus.tex, line 1171::
|
269
|
+
|
270
|
+
sage: k, n = var('k, n')
|
271
|
+
sage: sum(k, k, 1, n).factor()
|
272
|
+
1/2*(n + 1)*n
|
273
|
+
|
274
|
+
Sage example in ./calculus.tex, line 1179::
|
275
|
+
|
276
|
+
sage: n, k, y = var('n, k, y')
|
277
|
+
sage: sum(binomial(n,k) * x^k * y^(n-k), k, 0, n)
|
278
|
+
(x + y)^n
|
279
|
+
|
280
|
+
Sage example in ./calculus.tex, line 1189::
|
281
|
+
|
282
|
+
sage: k, n = var('k, n')
|
283
|
+
sage: sum(binomial(n,k), k, 0, n),\
|
284
|
+
....: sum(k * binomial(n, k), k, 0, n),\
|
285
|
+
....: sum((-1)^k*binomial(n,k), k, 0, n)
|
286
|
+
(2^n, 2^(n - 1)*n, 0)
|
287
|
+
|
288
|
+
Sage example in ./calculus.tex, line 1199::
|
289
|
+
|
290
|
+
sage: a, q, k, n = var('a, q, k, n')
|
291
|
+
sage: sum(a*q^k, k, 0, n)
|
292
|
+
(a*q^(n + 1) - a)/(q - 1)
|
293
|
+
|
294
|
+
Sage example in ./calculus.tex, line 1212::
|
295
|
+
|
296
|
+
sage: assume(abs(q) < 1)
|
297
|
+
sage: sum(a*q^k, k, 0, infinity)
|
298
|
+
-a/(q - 1)
|
299
|
+
|
300
|
+
Sage example in ./calculus.tex, line 1218::
|
301
|
+
|
302
|
+
sage: forget(); assume(q > 1); sum(a*q^k, k, 0, infinity)
|
303
|
+
Traceback (most recent call last):
|
304
|
+
...
|
305
|
+
ValueError: Sum is divergent.
|
306
|
+
|
307
|
+
Sage example in ./calculus.tex, line 1300::
|
308
|
+
|
309
|
+
sage: limit((x**(1/3) - 2) / ((x + 19)**(1/3) - 3), x = 8)
|
310
|
+
9/4
|
311
|
+
sage: f(x) = (cos(pi/4-x)-tan(x))/(1-sin(pi/4 + x))
|
312
|
+
sage: limit(f(x), x = pi/4)
|
313
|
+
Infinity
|
314
|
+
|
315
|
+
Sage example in ./calculus.tex, line 1317::
|
316
|
+
|
317
|
+
sage: limit(f(x), x = pi/4, dir='minus')
|
318
|
+
+Infinity
|
319
|
+
sage: limit(f(x), x = pi/4, dir='plus')
|
320
|
+
-Infinity
|
321
|
+
|
322
|
+
Sage example in ./calculus.tex, line 1368::
|
323
|
+
|
324
|
+
sage: u(n) = n^100 / 100^n
|
325
|
+
sage: u(1.);u(2.);u(3.);u(4.);u(5.);u(6.);u(7.);u(8.);u(9.);u(10.)
|
326
|
+
0.0100000000000000
|
327
|
+
1.26765060022823e26
|
328
|
+
5.15377520732011e41
|
329
|
+
1.60693804425899e52
|
330
|
+
7.88860905221012e59
|
331
|
+
6.53318623500071e65
|
332
|
+
3.23447650962476e70
|
333
|
+
2.03703597633449e74
|
334
|
+
2.65613988875875e77
|
335
|
+
1.00000000000000e80
|
336
|
+
|
337
|
+
Sage example in ./calculus.tex, line 1389::
|
338
|
+
|
339
|
+
sage: plot(u(x), x, 1, 40)
|
340
|
+
Graphics object consisting of 1 graphics primitive
|
341
|
+
|
342
|
+
Sage example in ./calculus.tex, line 1407::
|
343
|
+
|
344
|
+
sage: v(x) = diff(u(x), x); sol = solve(v(x) == 0, x); sol
|
345
|
+
[x == 50/log(10), x == 0]
|
346
|
+
sage: floor(sol[0].rhs())
|
347
|
+
21
|
348
|
+
|
349
|
+
Sage example in ./calculus.tex, line 1420::
|
350
|
+
|
351
|
+
sage: limit(u(n), n=infinity)
|
352
|
+
0
|
353
|
+
sage: n0 = find_root(u(n) - 1e-8 == 0, 22, 1000); n0
|
354
|
+
105.07496210187252
|
355
|
+
|
356
|
+
Sage example in ./calculus.tex, line 1502::
|
357
|
+
|
358
|
+
sage: ((1+arctan(x))^(1/x)).series(x==0, 3)
|
359
|
+
(e) + (-1/2*e)*x + (1/8*e)*x^2 + Order(x^3)
|
360
|
+
|
361
|
+
Sage example in ./calculus.tex, line 1507::
|
362
|
+
|
363
|
+
sage: (ln(2*sin(x))).series(x==pi/6, 3)
|
364
|
+
(sqrt(3))*(-1/6*pi + x) + (-2)*(-1/6*pi + x)^2
|
365
|
+
+ Order(-1/216*(pi - 6*x)^3)
|
366
|
+
|
367
|
+
Sage example in ./calculus.tex, line 1520::
|
368
|
+
|
369
|
+
sage: (ln(2*sin(x))).series(x==pi/6, 3).truncate()
|
370
|
+
-1/18*(pi - 6*x)^2 - 1/6*sqrt(3)*(pi - 6*x)
|
371
|
+
|
372
|
+
Sage example in ./calculus.tex, line 1537::
|
373
|
+
|
374
|
+
sage: taylor((x**3+x)**(1/3) - (x**3-x)**(1/3), x, infinity, 2)
|
375
|
+
2/3/x
|
376
|
+
|
377
|
+
Sage example in ./calculus.tex, line 1577::
|
378
|
+
|
379
|
+
sage: tan(4*arctan(1/5)).simplify_trig()
|
380
|
+
120/119
|
381
|
+
sage: tan(pi/4+arctan(1/239)).simplify_trig()
|
382
|
+
120/119
|
383
|
+
|
384
|
+
Sage example in ./calculus.tex, line 1591::
|
385
|
+
|
386
|
+
sage: f = arctan(x).series(x, 10); f
|
387
|
+
1*x + (-1/3)*x^3 + 1/5*x^5 + (-1/7)*x^7 + 1/9*x^9 + Order(x^10)
|
388
|
+
sage: (16*f.subs(x==1/5) - 4*f.subs(x==1/239)).n(); pi.n()
|
389
|
+
3.14159268240440
|
390
|
+
3.14159265358979
|
391
|
+
|
392
|
+
Sage example in ./calculus.tex, line 1662::
|
393
|
+
|
394
|
+
sage: k = var('k')
|
395
|
+
sage: sum(1/k^2, k, 1, infinity),\
|
396
|
+
....: sum(1/k^4, k, 1, infinity),\
|
397
|
+
....: sum(1/k^5, k, 1, infinity)
|
398
|
+
(1/6*pi^2, 1/90*pi^4, zeta(5))
|
399
|
+
|
400
|
+
Sage example in ./calculus.tex, line 1689::
|
401
|
+
|
402
|
+
sage: s = 2*sqrt(2)/9801*(sum((factorial(4*k)) * (1103+26390*k) /
|
403
|
+
....: ((factorial(k)) ^ 4 * 396 ^ (4 * k)) for k in (0..11)))
|
404
|
+
sage: (1/s).n(digits=100)
|
405
|
+
3.141592653589793238462643383279502884197169399375105820974...
|
406
|
+
sage: (pi-1/s).n(digits=100).n()
|
407
|
+
-4.36415445739398e-96
|
408
|
+
|
409
|
+
Sage example in ./calculus.tex, line 1722::
|
410
|
+
|
411
|
+
sage: n = var('n'); u = sin(pi*(sqrt(4*n^2+1)-2*n))
|
412
|
+
sage: taylor(u, n, infinity, 3)
|
413
|
+
1/4*pi/n - 1/384*(6*pi + pi^3)/n^3
|
414
|
+
|
415
|
+
Sage example in ./calculus.tex, line 1762::
|
416
|
+
|
417
|
+
sage: diff(sin(x^2), x)
|
418
|
+
2*x*cos(x^2)
|
419
|
+
sage: function('f')(x); function('g')(x); diff(f(g(x)), x)
|
420
|
+
f(x)
|
421
|
+
g(x)
|
422
|
+
D[0](f)(g(x))*diff(g(x), x)
|
423
|
+
sage: diff(ln(f(x)), x)
|
424
|
+
diff(f(x), x)/f(x)
|
425
|
+
|
426
|
+
Sage example in ./calculus.tex, line 1780::
|
427
|
+
|
428
|
+
sage: f(x,y) = x*y + sin(x^2) + e^(-x); derivative(f, x)
|
429
|
+
(x, y) |--> 2*x*cos(x^2) + y - e^(-x)
|
430
|
+
sage: derivative(f, y)
|
431
|
+
(x, y) |--> x
|
432
|
+
|
433
|
+
Sage example in ./calculus.tex, line 1803::
|
434
|
+
|
435
|
+
sage: x, y = var('x, y'); f = ln(x**2+y**2) / 2
|
436
|
+
sage: delta = diff(f,x,2) + diff(f,y,2)
|
437
|
+
sage: delta.simplify_rational()
|
438
|
+
0
|
439
|
+
|
440
|
+
Sage example in ./calculus.tex, line 1854::
|
441
|
+
|
442
|
+
sage: sin(x).integral(x, 0, pi/2)
|
443
|
+
1
|
444
|
+
sage: integrate(1/(1+x^2), x)
|
445
|
+
arctan(x)
|
446
|
+
sage: integrate(1/(1+x^2), x, -infinity, infinity)
|
447
|
+
pi
|
448
|
+
sage: integrate(exp(-x**2), x, 0, infinity)
|
449
|
+
1/2*sqrt(pi)
|
450
|
+
|
451
|
+
Sage example in ./calculus.tex, line 1864::
|
452
|
+
|
453
|
+
sage: integrate(exp(-x), x, -infinity, infinity)
|
454
|
+
Traceback (most recent call last):
|
455
|
+
...
|
456
|
+
ValueError: Integral is divergent.
|
457
|
+
|
458
|
+
Sage example in ./calculus.tex, line 1878::
|
459
|
+
|
460
|
+
sage: u = var('u'); f = x * cos(u) / (u^2 + x^2)
|
461
|
+
sage: assume(x>0); f.integrate(u, 0, infinity)
|
462
|
+
1/2*pi*e^(-x)
|
463
|
+
sage: forget(); assume(x<0); f.integrate(u, 0, infinity)
|
464
|
+
-1/2*pi*e^x
|
465
|
+
|
466
|
+
Sage example in ./calculus.tex, line 1904::
|
467
|
+
|
468
|
+
sage: integral_numerical(sin(x)/x, 0, 1) # abs tol 1e-12
|
469
|
+
(0.946083070367183, 1.0503632079297087e-14)
|
470
|
+
sage: g = integrate(exp(-x**2), x, 0, infinity)
|
471
|
+
sage: g, g.n() # abs tol 1e-12
|
472
|
+
(1/2*sqrt(pi), 0.886226925452758)
|
473
|
+
sage: approx = integral_numerical(exp(-x**2), 0, infinity)
|
474
|
+
sage: approx # abs tol 1e-12
|
475
|
+
(0.8862269254527568, 1.714774436012769e-08)
|
476
|
+
sage: approx[0]-g.n() # abs tol 1e-12
|
477
|
+
-1.11022302462516e-15
|
478
|
+
|
479
|
+
Sage example in ./calculus.tex, line 2228::
|
480
|
+
|
481
|
+
sage: A = matrix(QQ, [[1,2],[3,4]]); A
|
482
|
+
[1 2]
|
483
|
+
[3 4]
|
484
|
+
|
485
|
+
Sage example in ./calculus.tex, line 2468::
|
486
|
+
|
487
|
+
sage: A = matrix(QQ, [[2,4,3],[-4,-6,-3],[3,3,1]])
|
488
|
+
sage: A.characteristic_polynomial()
|
489
|
+
x^3 + 3*x^2 - 4
|
490
|
+
sage: A.eigenvalues()
|
491
|
+
[1, -2, -2]
|
492
|
+
sage: A.minimal_polynomial().factor()
|
493
|
+
(x - 1) * (x + 2)^2
|
494
|
+
|
495
|
+
Sage example in ./calculus.tex, line 2487::
|
496
|
+
|
497
|
+
sage: A.eigenvectors_right()
|
498
|
+
[(1, [(1, -1, 1)], 1), (-2, [(1, -1, 0)], 2)]
|
499
|
+
|
500
|
+
Sage example in ./calculus.tex, line 2499::
|
501
|
+
|
502
|
+
sage: A.jordan_form(transformation=True)
|
503
|
+
(
|
504
|
+
[ 1| 0 0]
|
505
|
+
[--+-----] [ 1 1 1]
|
506
|
+
[ 0|-2 1] [-1 -1 0]
|
507
|
+
[ 0| 0 -2], [ 1 0 -1]
|
508
|
+
)
|
509
|
+
|
510
|
+
Sage example in ./calculus.tex, line 2533::
|
511
|
+
|
512
|
+
sage: A = matrix(QQ, [[1,-1/2],[-1/2,-1]])
|
513
|
+
sage: A.jordan_form()
|
514
|
+
Traceback (most recent call last):
|
515
|
+
...
|
516
|
+
RuntimeError: Some eigenvalue does not exist in Rational Field.
|
517
|
+
|
518
|
+
Sage example in ./calculus.tex, line 2543::
|
519
|
+
|
520
|
+
sage: A = matrix(QQ, [[1,-1/2],[-1/2,-1]])
|
521
|
+
sage: A.minimal_polynomial()
|
522
|
+
x^2 - 5/4
|
523
|
+
|
524
|
+
Sage example in ./calculus.tex, line 2557::
|
525
|
+
|
526
|
+
sage: R = QQ[sqrt(5)]
|
527
|
+
sage: A = A.change_ring(R)
|
528
|
+
sage: A.jordan_form(transformation=True, subdivide=False)
|
529
|
+
(
|
530
|
+
[ 1/2*sqrt5 0] [ 1 1]
|
531
|
+
[ 0 -1/2*sqrt5], [-sqrt5 + 2 sqrt5 + 2]
|
532
|
+
)
|
533
|
+
|
534
|
+
Sage example in ./calculus.tex, line 2597::
|
535
|
+
|
536
|
+
sage: K.<sqrt2> = NumberField(x^2 - 2)
|
537
|
+
sage: L.<sqrt3> = K.extension(x^2 - 3)
|
538
|
+
sage: A = matrix(L, [[2, sqrt2*sqrt3, sqrt2], \
|
539
|
+
....: [sqrt2*sqrt3, 3, sqrt3], \
|
540
|
+
....: [sqrt2, sqrt3, 1]])
|
541
|
+
sage: A.jordan_form(transformation=True)
|
542
|
+
(
|
543
|
+
[6|0|0]
|
544
|
+
[-+-+-]
|
545
|
+
[0|0|0] [ 1 1 0]
|
546
|
+
[-+-+-] [1/2*sqrt2*sqrt3 0 1]
|
547
|
+
[0|0|0], [ 1/2*sqrt2 -sqrt2 -sqrt3]
|
548
|
+
)
|
549
|
+
"""
|