passagemath-symbolics 10.6.37__cp314-cp314t-macosx_13_0_arm64.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 (172) hide show
  1. passagemath_symbolics/.dylibs/libgmp.10.dylib +0 -0
  2. passagemath_symbolics/__init__.py +3 -0
  3. passagemath_symbolics-10.6.37.dist-info/METADATA +187 -0
  4. passagemath_symbolics-10.6.37.dist-info/RECORD +172 -0
  5. passagemath_symbolics-10.6.37.dist-info/WHEEL +6 -0
  6. passagemath_symbolics-10.6.37.dist-info/top_level.txt +3 -0
  7. sage/all__sagemath_symbolics.py +17 -0
  8. sage/calculus/all.py +14 -0
  9. sage/calculus/calculus.py +2826 -0
  10. sage/calculus/desolvers.py +1866 -0
  11. sage/calculus/predefined.py +51 -0
  12. sage/calculus/tests.py +225 -0
  13. sage/calculus/var.cpython-314t-darwin.so +0 -0
  14. sage/calculus/var.pyx +401 -0
  15. sage/dynamics/all__sagemath_symbolics.py +6 -0
  16. sage/dynamics/complex_dynamics/all.py +5 -0
  17. sage/dynamics/complex_dynamics/mandel_julia.py +765 -0
  18. sage/dynamics/complex_dynamics/mandel_julia_helper.cpython-314t-darwin.so +0 -0
  19. sage/dynamics/complex_dynamics/mandel_julia_helper.pyx +1035 -0
  20. sage/ext/all__sagemath_symbolics.py +1 -0
  21. sage/ext_data/kenzo/CP2.txt +45 -0
  22. sage/ext_data/kenzo/CP3.txt +349 -0
  23. sage/ext_data/kenzo/CP4.txt +4774 -0
  24. sage/ext_data/kenzo/README.txt +49 -0
  25. sage/ext_data/kenzo/S4.txt +20 -0
  26. sage/ext_data/magma/latex/latex.m +1021 -0
  27. sage/ext_data/magma/latex/latex.spec +1 -0
  28. sage/ext_data/magma/sage/basic.m +356 -0
  29. sage/ext_data/magma/sage/sage.spec +1 -0
  30. sage/ext_data/magma/spec +9 -0
  31. sage/geometry/all__sagemath_symbolics.py +8 -0
  32. sage/geometry/hyperbolic_space/all.py +5 -0
  33. sage/geometry/hyperbolic_space/hyperbolic_coercion.py +743 -0
  34. sage/geometry/hyperbolic_space/hyperbolic_constants.py +5 -0
  35. sage/geometry/hyperbolic_space/hyperbolic_geodesic.py +2409 -0
  36. sage/geometry/hyperbolic_space/hyperbolic_interface.py +206 -0
  37. sage/geometry/hyperbolic_space/hyperbolic_isometry.py +1082 -0
  38. sage/geometry/hyperbolic_space/hyperbolic_model.py +1502 -0
  39. sage/geometry/hyperbolic_space/hyperbolic_point.py +621 -0
  40. sage/geometry/riemannian_manifolds/all.py +7 -0
  41. sage/geometry/riemannian_manifolds/parametrized_surface3d.py +1632 -0
  42. sage/geometry/riemannian_manifolds/surface3d_generators.py +461 -0
  43. sage/interfaces/all__sagemath_symbolics.py +1 -0
  44. sage/interfaces/magma.py +3017 -0
  45. sage/interfaces/magma_free.py +92 -0
  46. sage/interfaces/maple.py +1397 -0
  47. sage/interfaces/mathematica.py +1345 -0
  48. sage/interfaces/mathics.py +1312 -0
  49. sage/interfaces/sympy.py +1398 -0
  50. sage/interfaces/sympy_wrapper.py +197 -0
  51. sage/interfaces/tides.py +938 -0
  52. sage/libs/all__sagemath_symbolics.py +6 -0
  53. sage/manifolds/all.py +7 -0
  54. sage/manifolds/calculus_method.py +555 -0
  55. sage/manifolds/catalog.py +437 -0
  56. sage/manifolds/chart.py +4019 -0
  57. sage/manifolds/chart_func.py +3419 -0
  58. sage/manifolds/continuous_map.py +2183 -0
  59. sage/manifolds/continuous_map_image.py +155 -0
  60. sage/manifolds/differentiable/affine_connection.py +2475 -0
  61. sage/manifolds/differentiable/all.py +1 -0
  62. sage/manifolds/differentiable/automorphismfield.py +1383 -0
  63. sage/manifolds/differentiable/automorphismfield_group.py +604 -0
  64. sage/manifolds/differentiable/bundle_connection.py +1445 -0
  65. sage/manifolds/differentiable/characteristic_cohomology_class.py +1840 -0
  66. sage/manifolds/differentiable/chart.py +1241 -0
  67. sage/manifolds/differentiable/curve.py +1028 -0
  68. sage/manifolds/differentiable/de_rham_cohomology.py +541 -0
  69. sage/manifolds/differentiable/degenerate.py +559 -0
  70. sage/manifolds/differentiable/degenerate_submanifold.py +1671 -0
  71. sage/manifolds/differentiable/diff_form.py +1658 -0
  72. sage/manifolds/differentiable/diff_form_module.py +1062 -0
  73. sage/manifolds/differentiable/diff_map.py +1315 -0
  74. sage/manifolds/differentiable/differentiable_submanifold.py +291 -0
  75. sage/manifolds/differentiable/examples/all.py +1 -0
  76. sage/manifolds/differentiable/examples/euclidean.py +2517 -0
  77. sage/manifolds/differentiable/examples/real_line.py +897 -0
  78. sage/manifolds/differentiable/examples/sphere.py +1186 -0
  79. sage/manifolds/differentiable/examples/symplectic_space.py +187 -0
  80. sage/manifolds/differentiable/examples/symplectic_space_test.py +40 -0
  81. sage/manifolds/differentiable/integrated_curve.py +4035 -0
  82. sage/manifolds/differentiable/levi_civita_connection.py +841 -0
  83. sage/manifolds/differentiable/manifold.py +4254 -0
  84. sage/manifolds/differentiable/manifold_homset.py +1826 -0
  85. sage/manifolds/differentiable/metric.py +3032 -0
  86. sage/manifolds/differentiable/mixed_form.py +1507 -0
  87. sage/manifolds/differentiable/mixed_form_algebra.py +559 -0
  88. sage/manifolds/differentiable/multivector_module.py +800 -0
  89. sage/manifolds/differentiable/multivectorfield.py +1520 -0
  90. sage/manifolds/differentiable/poisson_tensor.py +268 -0
  91. sage/manifolds/differentiable/pseudo_riemannian.py +755 -0
  92. sage/manifolds/differentiable/pseudo_riemannian_submanifold.py +1839 -0
  93. sage/manifolds/differentiable/scalarfield.py +1343 -0
  94. sage/manifolds/differentiable/scalarfield_algebra.py +472 -0
  95. sage/manifolds/differentiable/symplectic_form.py +910 -0
  96. sage/manifolds/differentiable/symplectic_form_test.py +220 -0
  97. sage/manifolds/differentiable/tangent_space.py +412 -0
  98. sage/manifolds/differentiable/tangent_vector.py +616 -0
  99. sage/manifolds/differentiable/tensorfield.py +4665 -0
  100. sage/manifolds/differentiable/tensorfield_module.py +963 -0
  101. sage/manifolds/differentiable/tensorfield_paral.py +2450 -0
  102. sage/manifolds/differentiable/tensorfield_paral_test.py +16 -0
  103. sage/manifolds/differentiable/vector_bundle.py +1728 -0
  104. sage/manifolds/differentiable/vectorfield.py +1717 -0
  105. sage/manifolds/differentiable/vectorfield_module.py +2445 -0
  106. sage/manifolds/differentiable/vectorframe.py +1832 -0
  107. sage/manifolds/family.py +270 -0
  108. sage/manifolds/local_frame.py +1490 -0
  109. sage/manifolds/manifold.py +3090 -0
  110. sage/manifolds/manifold_homset.py +452 -0
  111. sage/manifolds/operators.py +359 -0
  112. sage/manifolds/point.py +994 -0
  113. sage/manifolds/scalarfield.py +3718 -0
  114. sage/manifolds/scalarfield_algebra.py +629 -0
  115. sage/manifolds/section.py +3111 -0
  116. sage/manifolds/section_module.py +831 -0
  117. sage/manifolds/structure.py +229 -0
  118. sage/manifolds/subset.py +2764 -0
  119. sage/manifolds/subsets/all.py +1 -0
  120. sage/manifolds/subsets/closure.py +131 -0
  121. sage/manifolds/subsets/pullback.py +885 -0
  122. sage/manifolds/topological_submanifold.py +891 -0
  123. sage/manifolds/trivialization.py +733 -0
  124. sage/manifolds/utilities.py +1348 -0
  125. sage/manifolds/vector_bundle.py +1342 -0
  126. sage/manifolds/vector_bundle_fiber.py +332 -0
  127. sage/manifolds/vector_bundle_fiber_element.py +111 -0
  128. sage/matrix/all__sagemath_symbolics.py +1 -0
  129. sage/matrix/matrix_symbolic_dense.cpython-314t-darwin.so +0 -0
  130. sage/matrix/matrix_symbolic_dense.pxd +6 -0
  131. sage/matrix/matrix_symbolic_dense.pyx +1022 -0
  132. sage/matrix/matrix_symbolic_sparse.cpython-314t-darwin.so +0 -0
  133. sage/matrix/matrix_symbolic_sparse.pxd +6 -0
  134. sage/matrix/matrix_symbolic_sparse.pyx +1029 -0
  135. sage/modules/all__sagemath_symbolics.py +1 -0
  136. sage/modules/vector_callable_symbolic_dense.py +105 -0
  137. sage/modules/vector_symbolic_dense.py +116 -0
  138. sage/modules/vector_symbolic_sparse.py +118 -0
  139. sage/rings/all__sagemath_symbolics.py +4 -0
  140. sage/rings/asymptotic/all.py +6 -0
  141. sage/rings/asymptotic/asymptotic_expansion_generators.py +1485 -0
  142. sage/rings/asymptotic/asymptotic_ring.py +4858 -0
  143. sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py +4153 -0
  144. sage/rings/asymptotic/growth_group.py +5373 -0
  145. sage/rings/asymptotic/growth_group_cartesian.py +1400 -0
  146. sage/rings/asymptotic/term_monoid.py +5237 -0
  147. sage/rings/function_field/all__sagemath_symbolics.py +2 -0
  148. sage/rings/polynomial/all__sagemath_symbolics.py +1 -0
  149. sage/symbolic/all.py +15 -0
  150. sage/symbolic/assumptions.py +985 -0
  151. sage/symbolic/benchmark.py +93 -0
  152. sage/symbolic/callable.py +459 -0
  153. sage/symbolic/complexity_measures.py +35 -0
  154. sage/symbolic/constants.py +1287 -0
  155. sage/symbolic/expression_conversion_algebraic.py +310 -0
  156. sage/symbolic/expression_conversion_sympy.py +317 -0
  157. sage/symbolic/expression_conversions.py +1713 -0
  158. sage/symbolic/function_factory.py +355 -0
  159. sage/symbolic/integration/all.py +1 -0
  160. sage/symbolic/integration/external.py +270 -0
  161. sage/symbolic/integration/integral.py +1115 -0
  162. sage/symbolic/maxima_wrapper.py +162 -0
  163. sage/symbolic/operators.py +267 -0
  164. sage/symbolic/random_tests.py +462 -0
  165. sage/symbolic/relation.py +1907 -0
  166. sage/symbolic/ring.cpython-314t-darwin.so +0 -0
  167. sage/symbolic/ring.pxd +5 -0
  168. sage/symbolic/ring.pyx +1396 -0
  169. sage/symbolic/subring.py +1025 -0
  170. sage/symbolic/symengine.py +19 -0
  171. sage/symbolic/tests.py +40 -0
  172. sage/symbolic/units.py +1470 -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,555 @@
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
+ if expression.is_zero:
314
+ return True
315
+ return False
316
+
317
+ def set(self, method):
318
+ r"""
319
+ Set the currently active calculus method.
320
+
321
+ - ``method`` -- string defining the calculus method
322
+
323
+ EXAMPLES::
324
+
325
+ sage: from sage.manifolds.calculus_method import CalculusMethod
326
+ sage: cm = CalculusMethod(base_field_type='complex')
327
+ sage: cm
328
+ Available calculus methods (* = current):
329
+ - SR (default) (*)
330
+ - sympy
331
+ sage: cm.set('sympy')
332
+ sage: cm
333
+ Available calculus methods (* = current):
334
+ - SR (default)
335
+ - sympy (*)
336
+ sage: cm.set('lala')
337
+ Traceback (most recent call last):
338
+ ...
339
+ NotImplementedError: method lala not implemented
340
+ """
341
+ if method not in self._methods:
342
+ raise NotImplementedError("method {} not ".format(method) + "implemented")
343
+ self._current = method
344
+
345
+ def current(self):
346
+ r"""
347
+ Return the active calculus method as a string.
348
+
349
+ OUTPUT:
350
+
351
+ String defining the calculus method; one of
352
+
353
+ - ``'SR'`` -- Sage's default symbolic engine (Symbolic Ring)
354
+ - ``'sympy'`` -- SymPy
355
+
356
+ EXAMPLES::
357
+
358
+ sage: from sage.manifolds.calculus_method import CalculusMethod
359
+ sage: cm = CalculusMethod(); cm
360
+ Available calculus methods (* = current):
361
+ - SR (default) (*)
362
+ - sympy
363
+ sage: cm.current()
364
+ 'SR'
365
+ sage: cm.set('sympy')
366
+ sage: cm.current()
367
+ 'sympy'
368
+ """
369
+ return self._current
370
+
371
+ def set_simplify_function(self, simplifying_func, method=None):
372
+ r"""
373
+ Set the simplifying function associated to a given calculus method.
374
+
375
+ INPUT:
376
+
377
+ - ``simplifying_func`` -- either the string ``'default'`` for restoring
378
+ the default simplifying function or a function ``f`` of a single
379
+ argument ``expr`` such that ``f(expr)`` returns an object of the same
380
+ type as ``expr`` (hopefully the simplified version of ``expr``), this
381
+ type being
382
+
383
+ - :class:`~sage.symbolic.expression.Expression` if ``method`` = ``'SR'``
384
+ - a SymPy type if ``method`` = ``'sympy'``
385
+
386
+ - ``method`` -- (default: ``None``) string defining the calculus method
387
+ for which ``simplifying_func`` is provided; must be one of
388
+
389
+ - ``'SR'``: Sage's default symbolic engine (Symbolic Ring)
390
+ - ``'sympy'``: SymPy
391
+ - ``None``: the currently active calculus method of ``self`` is
392
+ assumed
393
+
394
+ EXAMPLES:
395
+
396
+ On a real manifold, the default simplifying function is
397
+ :func:`~sage.manifolds.utilities.simplify_chain_real` when the
398
+ calculus method is ``SR``::
399
+
400
+ sage: from sage.manifolds.calculus_method import CalculusMethod
401
+ sage: cm = CalculusMethod(base_field_type='real'); cm
402
+ Available calculus methods (* = current):
403
+ - SR (default) (*)
404
+ - sympy
405
+ sage: cm.simplify_function() is \
406
+ ....: sage.manifolds.utilities.simplify_chain_real
407
+ True
408
+
409
+ Let us change it to :func:`~sage.calculus.functional.simplify`::
410
+
411
+ sage: cm.set_simplify_function(simplify)
412
+ sage: cm.simplify_function() is simplify
413
+ True
414
+
415
+ Since ``SR`` is the current calculus method, the above is equivalent
416
+ to::
417
+
418
+ sage: cm.set_simplify_function(simplify, method='SR')
419
+ sage: cm.simplify_function(method='SR') is simplify
420
+ True
421
+
422
+ We revert to the default simplifying function by::
423
+
424
+ sage: cm.set_simplify_function('default')
425
+
426
+ Then we are back to::
427
+
428
+ sage: cm.simplify_function() is \
429
+ ....: sage.manifolds.utilities.simplify_chain_real
430
+ True
431
+ """
432
+ if method is None:
433
+ method = self._current
434
+ if simplifying_func == 'default':
435
+ # the default function is restored
436
+ self._simplify_dict[method] = self._simplify_dict_default[method]
437
+ else:
438
+ self._simplify_dict[method] = simplifying_func
439
+
440
+ def simplify_function(self, method=None):
441
+ r"""
442
+ Return the simplifying function associated to a given calculus method.
443
+
444
+ The simplifying function is that used in all computations involved
445
+ with the calculus method.
446
+
447
+ INPUT:
448
+
449
+ - ``method`` -- (default: ``None``) string defining the calculus method
450
+ for which ``simplifying_func`` is provided; must be one of
451
+
452
+ - ``'SR'``: Sage's default symbolic engine (Symbolic Ring)
453
+ - ``'sympy'``: SymPy
454
+ - ``None``: the currently active calculus method of ``self`` is
455
+ assumed
456
+
457
+ OUTPUT: the simplifying function
458
+
459
+ EXAMPLES::
460
+
461
+ sage: from sage.manifolds.calculus_method import CalculusMethod
462
+ sage: cm = CalculusMethod()
463
+ sage: cm
464
+ Available calculus methods (* = current):
465
+ - SR (default) (*)
466
+ - sympy
467
+ sage: cm.simplify_function() # random (memory address)
468
+ <function simplify_chain_real at 0x7f958d5b6758>
469
+
470
+ The output stands for the function
471
+ :func:`~sage.manifolds.utilities.simplify_chain_real`::
472
+
473
+ sage: cm.simplify_function() is \
474
+ ....: sage.manifolds.utilities.simplify_chain_real
475
+ True
476
+
477
+ Since ``SR`` is the default calculus method, we have::
478
+
479
+ sage: cm.simplify_function() is cm.simplify_function(method='SR')
480
+ True
481
+
482
+ The simplifying function associated with ``sympy`` is
483
+ :func:`~sage.manifolds.utilities.simplify_chain_real_sympy`::
484
+
485
+ sage: cm.simplify_function(method='sympy') # random (memory address)
486
+ <function simplify_chain_real_sympy at 0x7f0b35a578c0>
487
+ sage: cm.simplify_function(method='sympy') is \
488
+ ....: sage.manifolds.utilities.simplify_chain_real_sympy
489
+ True
490
+
491
+ On complex manifolds, the simplifying functions are
492
+ :func:`~sage.manifolds.utilities.simplify_chain_generic`
493
+ and :func:`~sage.manifolds.utilities.simplify_chain_generic_sympy`
494
+ for respectively ``SR`` and ``sympy``::
495
+
496
+ sage: cmc = CalculusMethod(base_field_type='complex')
497
+ sage: cmc.simplify_function(method='SR') is \
498
+ ....: sage.manifolds.utilities.simplify_chain_generic
499
+ True
500
+ sage: cmc.simplify_function(method='sympy') is \
501
+ ....: sage.manifolds.utilities.simplify_chain_generic_sympy
502
+ True
503
+
504
+ Note that the simplifying functions can be customized via
505
+ :meth:`set_simplify_function`.
506
+ """
507
+ if method is None:
508
+ method = self._current
509
+ return self._simplify_dict[method]
510
+
511
+ def reset(self):
512
+ r"""
513
+ Set the current calculus method to the default one.
514
+
515
+ EXAMPLES::
516
+
517
+ sage: from sage.manifolds.calculus_method import CalculusMethod
518
+ sage: cm = CalculusMethod(base_field_type='complex')
519
+ sage: cm
520
+ Available calculus methods (* = current):
521
+ - SR (default) (*)
522
+ - sympy
523
+ sage: cm.set('sympy')
524
+ sage: cm
525
+ Available calculus methods (* = current):
526
+ - SR (default)
527
+ - sympy (*)
528
+ sage: cm.reset()
529
+ sage: cm
530
+ Available calculus methods (* = current):
531
+ - SR (default) (*)
532
+ - sympy
533
+ """
534
+ self._current = self._default
535
+
536
+ def _repr_(self):
537
+ r"""
538
+ String representation of the object.
539
+
540
+ TESTS::
541
+
542
+ sage: from sage.manifolds.calculus_method import CalculusMethod
543
+ sage: cm = CalculusMethod(base_field_type='complex')
544
+ sage: cm._repr_()
545
+ 'Available calculus methods (* = current):\n - SR (default) (*)\n - sympy'
546
+ """
547
+ resu = 'Available calculus methods (* = current):\n'
548
+ for method in self._methods:
549
+ resu += ' - {}'.format(method)
550
+ if method == self._default:
551
+ resu += ' (default)'
552
+ if method == self._current:
553
+ resu += ' (*)'
554
+ resu += '\n'
555
+ return resu[:-1]