passagemath-symbolics 10.8.1a1__cp314-cp314t-musllinux_1_2_aarch64.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 (181) hide show
  1. passagemath_symbolics/__init__.py +3 -0
  2. passagemath_symbolics-10.8.1a1.dist-info/METADATA +186 -0
  3. passagemath_symbolics-10.8.1a1.dist-info/RECORD +181 -0
  4. passagemath_symbolics-10.8.1a1.dist-info/WHEEL +5 -0
  5. passagemath_symbolics-10.8.1a1.dist-info/top_level.txt +3 -0
  6. sage/all__sagemath_symbolics.py +17 -0
  7. sage/calculus/all.py +14 -0
  8. sage/calculus/calculus.py +2838 -0
  9. sage/calculus/desolvers.py +1864 -0
  10. sage/calculus/predefined.py +51 -0
  11. sage/calculus/tests.py +225 -0
  12. sage/calculus/var.cpython-314t-aarch64-linux-musl.so +0 -0
  13. sage/calculus/var.pyx +401 -0
  14. sage/dynamics/all__sagemath_symbolics.py +6 -0
  15. sage/dynamics/complex_dynamics/all.py +5 -0
  16. sage/dynamics/complex_dynamics/mandel_julia.py +765 -0
  17. sage/dynamics/complex_dynamics/mandel_julia_helper.cpython-314t-aarch64-linux-musl.so +0 -0
  18. sage/dynamics/complex_dynamics/mandel_julia_helper.pyx +1034 -0
  19. sage/ext/all__sagemath_symbolics.py +1 -0
  20. sage/ext_data/kenzo/CP2.txt +45 -0
  21. sage/ext_data/kenzo/CP3.txt +349 -0
  22. sage/ext_data/kenzo/CP4.txt +4774 -0
  23. sage/ext_data/kenzo/README.txt +49 -0
  24. sage/ext_data/kenzo/S4.txt +20 -0
  25. sage/ext_data/magma/latex/latex.m +1021 -0
  26. sage/ext_data/magma/latex/latex.spec +1 -0
  27. sage/ext_data/magma/sage/basic.m +356 -0
  28. sage/ext_data/magma/sage/sage.spec +1 -0
  29. sage/ext_data/magma/spec +9 -0
  30. sage/geometry/all__sagemath_symbolics.py +8 -0
  31. sage/geometry/hyperbolic_space/all.py +5 -0
  32. sage/geometry/hyperbolic_space/hyperbolic_coercion.py +755 -0
  33. sage/geometry/hyperbolic_space/hyperbolic_constants.py +5 -0
  34. sage/geometry/hyperbolic_space/hyperbolic_geodesic.py +2419 -0
  35. sage/geometry/hyperbolic_space/hyperbolic_interface.py +206 -0
  36. sage/geometry/hyperbolic_space/hyperbolic_isometry.py +1083 -0
  37. sage/geometry/hyperbolic_space/hyperbolic_model.py +1502 -0
  38. sage/geometry/hyperbolic_space/hyperbolic_point.py +621 -0
  39. sage/geometry/riemannian_manifolds/all.py +7 -0
  40. sage/geometry/riemannian_manifolds/parametrized_surface3d.py +1632 -0
  41. sage/geometry/riemannian_manifolds/surface3d_generators.py +461 -0
  42. sage/interfaces/all__sagemath_symbolics.py +1 -0
  43. sage/interfaces/magma.py +2991 -0
  44. sage/interfaces/magma_free.py +90 -0
  45. sage/interfaces/maple.py +1402 -0
  46. sage/interfaces/mathematica.py +1345 -0
  47. sage/interfaces/mathics.py +1312 -0
  48. sage/interfaces/sympy.py +1398 -0
  49. sage/interfaces/sympy_wrapper.py +197 -0
  50. sage/interfaces/tides.py +938 -0
  51. sage/libs/all__sagemath_symbolics.py +6 -0
  52. sage/manifolds/all.py +7 -0
  53. sage/manifolds/calculus_method.py +553 -0
  54. sage/manifolds/catalog.py +437 -0
  55. sage/manifolds/chart.py +4010 -0
  56. sage/manifolds/chart_func.py +3416 -0
  57. sage/manifolds/continuous_map.py +2183 -0
  58. sage/manifolds/continuous_map_image.py +155 -0
  59. sage/manifolds/differentiable/affine_connection.py +2475 -0
  60. sage/manifolds/differentiable/all.py +1 -0
  61. sage/manifolds/differentiable/automorphismfield.py +1383 -0
  62. sage/manifolds/differentiable/automorphismfield_group.py +604 -0
  63. sage/manifolds/differentiable/bundle_connection.py +1445 -0
  64. sage/manifolds/differentiable/characteristic_cohomology_class.py +1840 -0
  65. sage/manifolds/differentiable/chart.py +1241 -0
  66. sage/manifolds/differentiable/curve.py +1028 -0
  67. sage/manifolds/differentiable/de_rham_cohomology.py +541 -0
  68. sage/manifolds/differentiable/degenerate.py +559 -0
  69. sage/manifolds/differentiable/degenerate_submanifold.py +1668 -0
  70. sage/manifolds/differentiable/diff_form.py +1660 -0
  71. sage/manifolds/differentiable/diff_form_module.py +1062 -0
  72. sage/manifolds/differentiable/diff_map.py +1315 -0
  73. sage/manifolds/differentiable/differentiable_submanifold.py +291 -0
  74. sage/manifolds/differentiable/examples/all.py +1 -0
  75. sage/manifolds/differentiable/examples/euclidean.py +2517 -0
  76. sage/manifolds/differentiable/examples/real_line.py +897 -0
  77. sage/manifolds/differentiable/examples/sphere.py +1186 -0
  78. sage/manifolds/differentiable/examples/symplectic_space.py +187 -0
  79. sage/manifolds/differentiable/examples/symplectic_space_test.py +40 -0
  80. sage/manifolds/differentiable/integrated_curve.py +4035 -0
  81. sage/manifolds/differentiable/levi_civita_connection.py +841 -0
  82. sage/manifolds/differentiable/manifold.py +4254 -0
  83. sage/manifolds/differentiable/manifold_homset.py +1826 -0
  84. sage/manifolds/differentiable/metric.py +3032 -0
  85. sage/manifolds/differentiable/mixed_form.py +1507 -0
  86. sage/manifolds/differentiable/mixed_form_algebra.py +559 -0
  87. sage/manifolds/differentiable/multivector_module.py +800 -0
  88. sage/manifolds/differentiable/multivectorfield.py +1522 -0
  89. sage/manifolds/differentiable/poisson_tensor.py +268 -0
  90. sage/manifolds/differentiable/pseudo_riemannian.py +755 -0
  91. sage/manifolds/differentiable/pseudo_riemannian_submanifold.py +1839 -0
  92. sage/manifolds/differentiable/scalarfield.py +1343 -0
  93. sage/manifolds/differentiable/scalarfield_algebra.py +472 -0
  94. sage/manifolds/differentiable/symplectic_form.py +912 -0
  95. sage/manifolds/differentiable/symplectic_form_test.py +220 -0
  96. sage/manifolds/differentiable/tangent_space.py +412 -0
  97. sage/manifolds/differentiable/tangent_vector.py +616 -0
  98. sage/manifolds/differentiable/tensorfield.py +4665 -0
  99. sage/manifolds/differentiable/tensorfield_module.py +963 -0
  100. sage/manifolds/differentiable/tensorfield_paral.py +2450 -0
  101. sage/manifolds/differentiable/tensorfield_paral_test.py +16 -0
  102. sage/manifolds/differentiable/vector_bundle.py +1725 -0
  103. sage/manifolds/differentiable/vectorfield.py +1717 -0
  104. sage/manifolds/differentiable/vectorfield_module.py +2445 -0
  105. sage/manifolds/differentiable/vectorframe.py +1832 -0
  106. sage/manifolds/family.py +270 -0
  107. sage/manifolds/local_frame.py +1490 -0
  108. sage/manifolds/manifold.py +3090 -0
  109. sage/manifolds/manifold_homset.py +452 -0
  110. sage/manifolds/operators.py +359 -0
  111. sage/manifolds/point.py +994 -0
  112. sage/manifolds/scalarfield.py +3718 -0
  113. sage/manifolds/scalarfield_algebra.py +629 -0
  114. sage/manifolds/section.py +3111 -0
  115. sage/manifolds/section_module.py +831 -0
  116. sage/manifolds/structure.py +229 -0
  117. sage/manifolds/subset.py +2721 -0
  118. sage/manifolds/subsets/all.py +1 -0
  119. sage/manifolds/subsets/closure.py +131 -0
  120. sage/manifolds/subsets/pullback.py +883 -0
  121. sage/manifolds/topological_submanifold.py +891 -0
  122. sage/manifolds/trivialization.py +733 -0
  123. sage/manifolds/utilities.py +1348 -0
  124. sage/manifolds/vector_bundle.py +1347 -0
  125. sage/manifolds/vector_bundle_fiber.py +332 -0
  126. sage/manifolds/vector_bundle_fiber_element.py +111 -0
  127. sage/matrix/all__sagemath_symbolics.py +1 -0
  128. sage/matrix/matrix_symbolic_dense.cpython-314t-aarch64-linux-musl.so +0 -0
  129. sage/matrix/matrix_symbolic_dense.pxd +6 -0
  130. sage/matrix/matrix_symbolic_dense.pyx +1030 -0
  131. sage/matrix/matrix_symbolic_sparse.cpython-314t-aarch64-linux-musl.so +0 -0
  132. sage/matrix/matrix_symbolic_sparse.pxd +6 -0
  133. sage/matrix/matrix_symbolic_sparse.pyx +1038 -0
  134. sage/modules/all__sagemath_symbolics.py +1 -0
  135. sage/modules/vector_callable_symbolic_dense.py +105 -0
  136. sage/modules/vector_symbolic_dense.py +116 -0
  137. sage/modules/vector_symbolic_sparse.py +118 -0
  138. sage/rings/all__sagemath_symbolics.py +4 -0
  139. sage/rings/asymptotic/all.py +6 -0
  140. sage/rings/asymptotic/asymptotic_expansion_generators.py +1485 -0
  141. sage/rings/asymptotic/asymptotic_ring.py +4858 -0
  142. sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py +4106 -0
  143. sage/rings/asymptotic/growth_group.py +5373 -0
  144. sage/rings/asymptotic/growth_group_cartesian.py +1400 -0
  145. sage/rings/asymptotic/term_monoid.py +5205 -0
  146. sage/rings/function_field/all__sagemath_symbolics.py +2 -0
  147. sage/rings/polynomial/all__sagemath_symbolics.py +1 -0
  148. sage/symbolic/all.py +15 -0
  149. sage/symbolic/assumptions.py +987 -0
  150. sage/symbolic/benchmark.py +93 -0
  151. sage/symbolic/callable.py +456 -0
  152. sage/symbolic/callable.pyi +66 -0
  153. sage/symbolic/comparison_impl.pyi +38 -0
  154. sage/symbolic/complexity_measures.py +35 -0
  155. sage/symbolic/constants.py +1286 -0
  156. sage/symbolic/constants_c_impl.pyi +10 -0
  157. sage/symbolic/expression_conversion_algebraic.py +310 -0
  158. sage/symbolic/expression_conversion_sympy.py +317 -0
  159. sage/symbolic/expression_conversions.py +1727 -0
  160. sage/symbolic/function_factory.py +355 -0
  161. sage/symbolic/function_factory.pyi +41 -0
  162. sage/symbolic/getitem_impl.pyi +24 -0
  163. sage/symbolic/integration/all.py +1 -0
  164. sage/symbolic/integration/external.py +271 -0
  165. sage/symbolic/integration/integral.py +1075 -0
  166. sage/symbolic/maxima_wrapper.py +162 -0
  167. sage/symbolic/operators.py +267 -0
  168. sage/symbolic/operators.pyi +61 -0
  169. sage/symbolic/pynac_constant_impl.pyi +13 -0
  170. sage/symbolic/pynac_function_impl.pyi +8 -0
  171. sage/symbolic/random_tests.py +461 -0
  172. sage/symbolic/relation.py +2062 -0
  173. sage/symbolic/ring.cpython-314t-aarch64-linux-musl.so +0 -0
  174. sage/symbolic/ring.pxd +5 -0
  175. sage/symbolic/ring.pyi +110 -0
  176. sage/symbolic/ring.pyx +1393 -0
  177. sage/symbolic/series_impl.pyi +10 -0
  178. sage/symbolic/subring.py +1025 -0
  179. sage/symbolic/symengine.py +19 -0
  180. sage/symbolic/tests.py +40 -0
  181. sage/symbolic/units.py +1468 -0
@@ -0,0 +1,6 @@
1
+ # sage_setup: distribution = sagemath-symbolics
2
+
3
+ try:
4
+ from sage.libs.all__sagemath_giac import *
5
+ except ImportError:
6
+ pass
sage/manifolds/all.py ADDED
@@ -0,0 +1,7 @@
1
+ # sage_setup: distribution = sagemath-symbolics
2
+ from sage.misc.lazy_import import lazy_import
3
+
4
+ lazy_import('sage.manifolds.manifold', 'Manifold')
5
+ lazy_import('sage.manifolds.differentiable.examples.euclidean', 'EuclideanSpace')
6
+ lazy_import('sage.manifolds', 'catalog', 'manifolds')
7
+ del lazy_import
@@ -0,0 +1,553 @@
1
+ # sage_setup: distribution = sagemath-symbolics
2
+ r"""
3
+ Coordinate calculus methods
4
+
5
+ The class :class:`CalculusMethod` governs the calculus methods (symbolic and
6
+ numerical) used for coordinate computations on manifolds.
7
+
8
+ AUTHORS:
9
+
10
+ - Marco Mancini (2017): initial version
11
+ - Eric Gourgoulhon (2019): add :meth:`~CalculusMethod.set_simplify_function`
12
+ and various accessors
13
+ """
14
+
15
+ # *****************************************************************************
16
+ # Copyright (C) 2015 Marco Mancini <marco.mancini@obspm.fr>
17
+ #
18
+ # Distributed under the terms of the GNU General Public License (GPL)
19
+ # as published by the Free Software Foundation; either version 2 of
20
+ # the License, or (at your option) any later version.
21
+ # https://www.gnu.org/licenses/
22
+ # *****************************************************************************
23
+ from sage.manifolds.utilities import (
24
+ simplify_chain_generic,
25
+ simplify_chain_generic_sympy,
26
+ simplify_chain_real,
27
+ simplify_chain_real_sympy,
28
+ )
29
+ from sage.misc.latex import latex
30
+ from sage.structure.sage_object import SageObject
31
+ from sage.symbolic.ring import SR
32
+
33
+ try:
34
+ import sympy
35
+ from sympy import latex as sympy_latex
36
+ except ImportError:
37
+ sympy_latex = None
38
+
39
+
40
+ # Conversion functions
41
+ def _SR_to_Sympy(expression):
42
+ r"""
43
+ Convert an expression from ``SR`` to ``sympy``.
44
+
45
+ In the case where the expression is already ``sympy``, it is simply
46
+ returned.
47
+
48
+ INPUT:
49
+
50
+ - ``expression`` -- ``SR`` or ``sympy`` symbolic expression
51
+
52
+ OUTPUT: ``expression`` -- ``sympy`` symbolic expression
53
+
54
+ EXAMPLES::
55
+
56
+ sage: from sage.manifolds.calculus_method import _SR_to_Sympy
57
+ sage: a = x^2 + sin(x)^2; a
58
+ x^2 + sin(x)^2
59
+ sage: type(a)
60
+ <class 'sage.symbolic.expression.Expression'>
61
+ sage: b = _SR_to_Sympy(a); b
62
+ x**2 + sin(x)**2
63
+ sage: type(b)
64
+ <class 'sympy.core.add.Add'>
65
+
66
+ An already ``sympy`` expression is unchanged::
67
+
68
+ sage: _SR_to_Sympy(b) is b
69
+ True
70
+ """
71
+ # Nothing to do if expression is already a SymPy object:
72
+ if isinstance(expression, sympy.Basic):
73
+ return expression
74
+ return SR(expression)._sympy_()
75
+
76
+
77
+ def _Sympy_to_SR(expression):
78
+ r"""
79
+ Convert an expression from ``sympy`` to ``SR``.
80
+
81
+ In the case where the expression is already ``SR``, it is simply returned.
82
+
83
+ INPUT:
84
+
85
+ - ``expression`` -- ``sympy`` symbolic expression
86
+
87
+ OUTPUT: ``expression`` -- ``SR`` or ``sympy`` symbolic expression
88
+
89
+ EXAMPLES::
90
+
91
+ sage: from sage.manifolds.calculus_method import _Sympy_to_SR, _SR_to_Sympy
92
+ sage: a = x^2 + sin(x)^2
93
+ sage: type(a)
94
+ <class 'sage.symbolic.expression.Expression'>
95
+ sage: b = _SR_to_Sympy(a); b
96
+ x**2 + sin(x)**2
97
+ sage: type(b)
98
+ <class 'sympy.core.add.Add'>
99
+ sage: _Sympy_to_SR(b) == a
100
+ x^2 + sin(x)^2 == x^2 + sin(x)^2
101
+ sage: bool(_)
102
+ True
103
+ """
104
+ try:
105
+ return SR(expression)
106
+ except Exception:
107
+ # If SR cannot transform a sympy expression this is because it is a
108
+ # sympy abstract function
109
+ a = expression._sage_()
110
+ # As all sage objects have a ._sage_ operator, they have to be
111
+ # caught
112
+ if type(a) is type(expression):
113
+ raise TypeError
114
+ return a
115
+
116
+
117
+ class CalculusMethod(SageObject):
118
+ r"""
119
+ Control of calculus backends used on coordinate charts of manifolds.
120
+
121
+ This class stores the possible calculus methods and permits to switch
122
+ between them, as well as to change the simplifying functions associated
123
+ with them.
124
+ For the moment, only two calculus backends are implemented:
125
+
126
+ - Sage's symbolic engine (Pynac + Maxima), implemented via the
127
+ Symbolic Ring ``SR``
128
+ - SymPy engine, denoted ``sympy`` hereafter
129
+
130
+ INPUT:
131
+
132
+ - ``current`` -- (default: ``None``) string defining the calculus method
133
+ that will be considered as the active one, until it is changed by
134
+ :meth:`set`; must be one of
135
+
136
+ - ``'SR'``: Sage's default symbolic engine (Symbolic Ring)
137
+ - ``'sympy'``: SymPy
138
+ - ``None``: the default calculus method (``'SR'``)
139
+
140
+ - ``base_field_type`` -- (default: ``'real'``) base field type of the
141
+ manifold (cf.
142
+ :meth:`~sage.manifolds.manifold.TopologicalManifold.base_field_type`)
143
+
144
+ EXAMPLES::
145
+
146
+ sage: from sage.manifolds.calculus_method import CalculusMethod
147
+ sage: cm = CalculusMethod()
148
+
149
+ In the display, the currently active method is pointed out with a star::
150
+
151
+ sage: cm
152
+ Available calculus methods (* = current):
153
+ - SR (default) (*)
154
+ - sympy
155
+
156
+ It can be changed with :meth:`set`::
157
+
158
+ sage: cm.set('sympy')
159
+ sage: cm
160
+ Available calculus methods (* = current):
161
+ - SR (default)
162
+ - sympy (*)
163
+
164
+ while :meth:`reset` brings back to the default::
165
+
166
+ sage: cm.reset()
167
+ sage: cm
168
+ Available calculus methods (* = current):
169
+ - SR (default) (*)
170
+ - sympy
171
+
172
+ See :meth:`simplify_function` for the default simplification algorithms
173
+ associated with each calculus method and :meth:`set_simplify_function` for
174
+ introducing a new simplification algorithm.
175
+ """
176
+
177
+ _default = 'SR' # default calculus method
178
+ _methods = ('SR', 'sympy') # implemented methods
179
+ _tranf = {'SR': _Sympy_to_SR, 'sympy': _SR_to_Sympy} # translators
180
+
181
+ def __init__(self, current=None, base_field_type='real'):
182
+ r"""
183
+ Initialize ``self``.
184
+
185
+ TESTS::
186
+
187
+ sage: from sage.manifolds.calculus_method import CalculusMethod
188
+ sage: cm = CalculusMethod(base_field_type='complex')
189
+ sage: cm
190
+ Available calculus methods (* = current):
191
+ - SR (default) (*)
192
+ - sympy
193
+ """
194
+ self._current = self._default if current is None else current
195
+ # Initialization of the dictionary of simplifying functions:
196
+ self._simplify_dict = {}
197
+ if base_field_type == 'real':
198
+ self._simplify_dict['sympy'] = simplify_chain_real_sympy
199
+ self._simplify_dict['SR'] = simplify_chain_real
200
+ else:
201
+ self._simplify_dict['sympy'] = simplify_chain_generic_sympy
202
+ self._simplify_dict['SR'] = simplify_chain_generic
203
+ # The default simplifying functions are saved:
204
+ self._simplify_dict_default = self._simplify_dict.copy()
205
+ self._latex_dict = {'sympy': sympy_latex, 'SR': latex}
206
+
207
+ def simplify(self, expression, method=None):
208
+ r"""
209
+ Apply the simplifying function associated with a given calculus method
210
+ to a symbolic expression.
211
+
212
+ INPUT:
213
+
214
+ - ``expression`` -- symbolic expression to simplify
215
+
216
+ - ``method`` -- (default: ``None``) string defining the calculus method
217
+ to use; must be one of
218
+
219
+ - ``'SR'``: Sage's default symbolic engine (Symbolic Ring)
220
+ - ``'sympy'``: SymPy
221
+ - ``None``: the current calculus method of ``self`` is used
222
+
223
+ OUTPUT: the simplified version of ``expression``
224
+
225
+ EXAMPLES::
226
+
227
+ sage: M = Manifold(2, 'M', structure='topological')
228
+ sage: X.<x, y> = M.chart()
229
+ sage: f = x^2 + sin(x)^2 + cos(x)^2
230
+ sage: from sage.manifolds.calculus_method import CalculusMethod
231
+ sage: cm = CalculusMethod(base_field_type='real')
232
+ sage: cm.simplify(f)
233
+ x^2 + 1
234
+
235
+ Using a weaker simplifying function, like
236
+ :func:`~sage.calculus.functional.simplify`, does not succeed in this
237
+ case::
238
+
239
+ sage: cm.set_simplify_function(simplify)
240
+ sage: cm.simplify(f)
241
+ x^2 + cos(x)^2 + sin(x)^2
242
+
243
+ Back to the default simplifying function
244
+ (:func:`~sage.manifolds.utilities.simplify_chain_real` in the present
245
+ case)::
246
+
247
+ sage: cm.set_simplify_function('default')
248
+ sage: cm.simplify(f)
249
+ x^2 + 1
250
+
251
+ A ``SR`` expression, such as ``f``, cannot be simplified when the
252
+ current calculus method is ``sympy``::
253
+
254
+ sage: cm.set('sympy')
255
+ sage: cm.simplify(f)
256
+ Traceback (most recent call last):
257
+ ...
258
+ AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'...
259
+
260
+ In the present case, one should either transform ``f`` to a SymPy
261
+ object::
262
+
263
+ sage: cm.simplify(f._sympy_())
264
+ x**2 + 1
265
+
266
+ or force the calculus method to be ``'SR'``::
267
+
268
+ sage: cm.simplify(f, method='SR')
269
+ x^2 + 1
270
+ """
271
+ if method is None:
272
+ method = self._current
273
+ return self._simplify_dict[method](expression)
274
+
275
+ def is_trivial_zero(self, expression, method=None):
276
+ r"""
277
+ Check if an expression is trivially equal to zero without any
278
+ simplification.
279
+
280
+ INPUT:
281
+
282
+ - ``expression`` -- expression
283
+
284
+ - ``method`` -- (default: ``None``) string defining the calculus method
285
+ to use; if ``None`` the current calculus method of ``self`` is used
286
+
287
+ OUTPUT: ``True`` is expression is trivially zero, ``False`` elsewhere
288
+
289
+ EXAMPLES::
290
+
291
+ sage: from sage.manifolds.calculus_method import CalculusMethod
292
+ sage: cm = CalculusMethod(base_field_type='real')
293
+ sage: f = sin(x) - sin(x)
294
+ sage: cm.is_trivial_zero(f)
295
+ True
296
+ sage: cm.is_trivial_zero(f._sympy_(), method='sympy')
297
+ True
298
+
299
+ ::
300
+
301
+ sage: f = sin(x)^2 + cos(x)^2 - 1
302
+ sage: cm.is_trivial_zero(f)
303
+ False
304
+ sage: cm.is_trivial_zero(f._sympy_(), method='sympy')
305
+ False
306
+ """
307
+ if method is None:
308
+ method = self._current
309
+ if method == 'SR':
310
+ return expression.is_trivial_zero()
311
+ elif method == 'sympy':
312
+ # we have to test SymPy's is_zero because it could be 'NoneType'
313
+ return bool(expression.is_zero)
314
+
315
+ def set(self, method):
316
+ r"""
317
+ Set the currently active calculus method.
318
+
319
+ - ``method`` -- string defining the calculus method
320
+
321
+ EXAMPLES::
322
+
323
+ sage: from sage.manifolds.calculus_method import CalculusMethod
324
+ sage: cm = CalculusMethod(base_field_type='complex')
325
+ sage: cm
326
+ Available calculus methods (* = current):
327
+ - SR (default) (*)
328
+ - sympy
329
+ sage: cm.set('sympy')
330
+ sage: cm
331
+ Available calculus methods (* = current):
332
+ - SR (default)
333
+ - sympy (*)
334
+ sage: cm.set('lala')
335
+ Traceback (most recent call last):
336
+ ...
337
+ NotImplementedError: method lala not implemented
338
+ """
339
+ if method not in self._methods:
340
+ raise NotImplementedError("method {} not ".format(method) + "implemented")
341
+ self._current = method
342
+
343
+ def current(self):
344
+ r"""
345
+ Return the active calculus method as a string.
346
+
347
+ OUTPUT:
348
+
349
+ String defining the calculus method; one of
350
+
351
+ - ``'SR'`` -- Sage's default symbolic engine (Symbolic Ring)
352
+ - ``'sympy'`` -- SymPy
353
+
354
+ EXAMPLES::
355
+
356
+ sage: from sage.manifolds.calculus_method import CalculusMethod
357
+ sage: cm = CalculusMethod(); cm
358
+ Available calculus methods (* = current):
359
+ - SR (default) (*)
360
+ - sympy
361
+ sage: cm.current()
362
+ 'SR'
363
+ sage: cm.set('sympy')
364
+ sage: cm.current()
365
+ 'sympy'
366
+ """
367
+ return self._current
368
+
369
+ def set_simplify_function(self, simplifying_func, method=None):
370
+ r"""
371
+ Set the simplifying function associated to a given calculus method.
372
+
373
+ INPUT:
374
+
375
+ - ``simplifying_func`` -- either the string ``'default'`` for restoring
376
+ the default simplifying function or a function ``f`` of a single
377
+ argument ``expr`` such that ``f(expr)`` returns an object of the same
378
+ type as ``expr`` (hopefully the simplified version of ``expr``), this
379
+ type being
380
+
381
+ - :class:`~sage.symbolic.expression.Expression` if ``method`` = ``'SR'``
382
+ - a SymPy type if ``method`` = ``'sympy'``
383
+
384
+ - ``method`` -- (default: ``None``) string defining the calculus method
385
+ for which ``simplifying_func`` is provided; must be one of
386
+
387
+ - ``'SR'``: Sage's default symbolic engine (Symbolic Ring)
388
+ - ``'sympy'``: SymPy
389
+ - ``None``: the currently active calculus method of ``self`` is
390
+ assumed
391
+
392
+ EXAMPLES:
393
+
394
+ On a real manifold, the default simplifying function is
395
+ :func:`~sage.manifolds.utilities.simplify_chain_real` when the
396
+ calculus method is ``SR``::
397
+
398
+ sage: from sage.manifolds.calculus_method import CalculusMethod
399
+ sage: cm = CalculusMethod(base_field_type='real'); cm
400
+ Available calculus methods (* = current):
401
+ - SR (default) (*)
402
+ - sympy
403
+ sage: cm.simplify_function() is \
404
+ ....: sage.manifolds.utilities.simplify_chain_real
405
+ True
406
+
407
+ Let us change it to :func:`~sage.calculus.functional.simplify`::
408
+
409
+ sage: cm.set_simplify_function(simplify)
410
+ sage: cm.simplify_function() is simplify
411
+ True
412
+
413
+ Since ``SR`` is the current calculus method, the above is equivalent
414
+ to::
415
+
416
+ sage: cm.set_simplify_function(simplify, method='SR')
417
+ sage: cm.simplify_function(method='SR') is simplify
418
+ True
419
+
420
+ We revert to the default simplifying function by::
421
+
422
+ sage: cm.set_simplify_function('default')
423
+
424
+ Then we are back to::
425
+
426
+ sage: cm.simplify_function() is \
427
+ ....: sage.manifolds.utilities.simplify_chain_real
428
+ True
429
+ """
430
+ if method is None:
431
+ method = self._current
432
+ if simplifying_func == 'default':
433
+ # the default function is restored
434
+ self._simplify_dict[method] = self._simplify_dict_default[method]
435
+ else:
436
+ self._simplify_dict[method] = simplifying_func
437
+
438
+ def simplify_function(self, method=None):
439
+ r"""
440
+ Return the simplifying function associated to a given calculus method.
441
+
442
+ The simplifying function is that used in all computations involved
443
+ with the calculus method.
444
+
445
+ INPUT:
446
+
447
+ - ``method`` -- (default: ``None``) string defining the calculus method
448
+ for which ``simplifying_func`` is provided; must be one of
449
+
450
+ - ``'SR'``: Sage's default symbolic engine (Symbolic Ring)
451
+ - ``'sympy'``: SymPy
452
+ - ``None``: the currently active calculus method of ``self`` is
453
+ assumed
454
+
455
+ OUTPUT: the simplifying function
456
+
457
+ EXAMPLES::
458
+
459
+ sage: from sage.manifolds.calculus_method import CalculusMethod
460
+ sage: cm = CalculusMethod()
461
+ sage: cm
462
+ Available calculus methods (* = current):
463
+ - SR (default) (*)
464
+ - sympy
465
+ sage: cm.simplify_function() # random (memory address)
466
+ <function simplify_chain_real at 0x7f958d5b6758>
467
+
468
+ The output stands for the function
469
+ :func:`~sage.manifolds.utilities.simplify_chain_real`::
470
+
471
+ sage: cm.simplify_function() is \
472
+ ....: sage.manifolds.utilities.simplify_chain_real
473
+ True
474
+
475
+ Since ``SR`` is the default calculus method, we have::
476
+
477
+ sage: cm.simplify_function() is cm.simplify_function(method='SR')
478
+ True
479
+
480
+ The simplifying function associated with ``sympy`` is
481
+ :func:`~sage.manifolds.utilities.simplify_chain_real_sympy`::
482
+
483
+ sage: cm.simplify_function(method='sympy') # random (memory address)
484
+ <function simplify_chain_real_sympy at 0x7f0b35a578c0>
485
+ sage: cm.simplify_function(method='sympy') is \
486
+ ....: sage.manifolds.utilities.simplify_chain_real_sympy
487
+ True
488
+
489
+ On complex manifolds, the simplifying functions are
490
+ :func:`~sage.manifolds.utilities.simplify_chain_generic`
491
+ and :func:`~sage.manifolds.utilities.simplify_chain_generic_sympy`
492
+ for respectively ``SR`` and ``sympy``::
493
+
494
+ sage: cmc = CalculusMethod(base_field_type='complex')
495
+ sage: cmc.simplify_function(method='SR') is \
496
+ ....: sage.manifolds.utilities.simplify_chain_generic
497
+ True
498
+ sage: cmc.simplify_function(method='sympy') is \
499
+ ....: sage.manifolds.utilities.simplify_chain_generic_sympy
500
+ True
501
+
502
+ Note that the simplifying functions can be customized via
503
+ :meth:`set_simplify_function`.
504
+ """
505
+ if method is None:
506
+ method = self._current
507
+ return self._simplify_dict[method]
508
+
509
+ def reset(self):
510
+ r"""
511
+ Set the current calculus method to the default one.
512
+
513
+ EXAMPLES::
514
+
515
+ sage: from sage.manifolds.calculus_method import CalculusMethod
516
+ sage: cm = CalculusMethod(base_field_type='complex')
517
+ sage: cm
518
+ Available calculus methods (* = current):
519
+ - SR (default) (*)
520
+ - sympy
521
+ sage: cm.set('sympy')
522
+ sage: cm
523
+ Available calculus methods (* = current):
524
+ - SR (default)
525
+ - sympy (*)
526
+ sage: cm.reset()
527
+ sage: cm
528
+ Available calculus methods (* = current):
529
+ - SR (default) (*)
530
+ - sympy
531
+ """
532
+ self._current = self._default
533
+
534
+ def _repr_(self):
535
+ r"""
536
+ String representation of the object.
537
+
538
+ TESTS::
539
+
540
+ sage: from sage.manifolds.calculus_method import CalculusMethod
541
+ sage: cm = CalculusMethod(base_field_type='complex')
542
+ sage: cm._repr_()
543
+ 'Available calculus methods (* = current):\n - SR (default) (*)\n - sympy'
544
+ """
545
+ resu = 'Available calculus methods (* = current):\n'
546
+ for method in self._methods:
547
+ resu += ' - {}'.format(method)
548
+ if method == self._default:
549
+ resu += ' (default)'
550
+ if method == self._current:
551
+ resu += ' (*)'
552
+ resu += '\n'
553
+ return resu[:-1]