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,51 @@
1
+ # sage_setup: distribution = sagemath-symbolics
2
+ from sage.symbolic.ring import var as _var
3
+
4
+ a = _var('a')
5
+ b = _var('b')
6
+ c = _var('c')
7
+ d = _var('d')
8
+ f = _var('f')
9
+ g = _var('g')
10
+ h = _var('h')
11
+ j = _var('j')
12
+ k = _var('k')
13
+ l = _var('l')
14
+ m = _var('m')
15
+ n = _var('n')
16
+ o = _var('o')
17
+ p = _var('p')
18
+ q = _var('q')
19
+ r = _var('r')
20
+ s = _var('s')
21
+ t = _var('t')
22
+ u = _var('u')
23
+ v = _var('v')
24
+ w = _var('w')
25
+ x = _var('x')
26
+ y = _var('y')
27
+ z = _var('z')
28
+ A = _var('A')
29
+ B = _var('B')
30
+ C = _var('C')
31
+ D = _var('D')
32
+ E = _var('E')
33
+ F = _var('F')
34
+ G = _var('G')
35
+ H = _var('H')
36
+ J = _var('J')
37
+ K = _var('K')
38
+ L = _var('L')
39
+ M = _var('M')
40
+ N = _var('N')
41
+ P = _var('P')
42
+ Q = _var('Q')
43
+ R = _var('R')
44
+ S = _var('S')
45
+ T = _var('T')
46
+ U = _var('U')
47
+ V = _var('V')
48
+ W = _var('W')
49
+ X = _var('X')
50
+ Y = _var('Y')
51
+ Z = _var('Z')
sage/calculus/tests.py ADDED
@@ -0,0 +1,225 @@
1
+ # sage_setup: distribution = sagemath-symbolics
2
+ r"""
3
+ Calculus Tests and Examples
4
+
5
+ Compute the Christoffel symbol.
6
+
7
+ ::
8
+
9
+ sage: var('r t theta phi')
10
+ (r, t, theta, phi)
11
+ sage: m = matrix(SR, [[(1-1/r),0,0,0],[0,-(1-1/r)^(-1),0,0],[0,0,-r^2,0],[0,0,0,-r^2*(sin(theta))^2]])
12
+ sage: m
13
+ [ -1/r + 1 0 0 0]
14
+ [ 0 1/(1/r - 1) 0 0]
15
+ [ 0 0 -r^2 0]
16
+ [ 0 0 0 -r^2*sin(theta)^2]
17
+
18
+ ::
19
+
20
+ sage: def christoffel(i, j, k, vars, g):
21
+ ....: s = 0
22
+ ....: ginv = g^(-1)
23
+ ....: for l in range(g.nrows()):
24
+ ....: s = s + (1/2)*ginv[k,l]*(g[j,l].diff(vars[i])+g[i,l].diff(vars[j])-g[i,j].diff(vars[l]))
25
+ ....: return s
26
+
27
+ ::
28
+
29
+ sage: christoffel(3,3,2, [t,r,theta,phi], m)
30
+ -cos(theta)*sin(theta)
31
+ sage: X = christoffel(1,1,1,[t,r,theta,phi],m)
32
+ sage: X
33
+ 1/2/(r^2*(1/r - 1))
34
+ sage: X.rational_simplify()
35
+ -1/2/(r^2 - r)
36
+
37
+ Some basic things::
38
+
39
+ sage: f(x,y) = x^3 + sinh(1/y)
40
+ sage: f
41
+ (x, y) |--> x^3 + sinh(1/y)
42
+ sage: f^3
43
+ (x, y) |--> (x^3 + sinh(1/y))^3
44
+ sage: (f^3).expand()
45
+ (x, y) |--> x^9 + 3*x^6*sinh(1/y) + 3*x^3*sinh(1/y)^2 + sinh(1/y)^3
46
+
47
+ A polynomial over a symbolic base ring::
48
+
49
+ sage: R = SR['x']
50
+ sage: f = R([1/sqrt(2), 1/(4*sqrt(2))])
51
+ sage: f
52
+ 1/8*sqrt(2)*x + 1/2*sqrt(2)
53
+ sage: -f
54
+ -1/8*sqrt(2)*x - 1/2*sqrt(2)
55
+ sage: (-f).degree()
56
+ 1
57
+
58
+ A big product. Notice that simplifying simplifies the product further::
59
+
60
+ sage: A = exp(I*pi/7)
61
+ sage: b = A^14
62
+ sage: b
63
+ 1
64
+
65
+ We check a statement made at the beginning of Friedlander and
66
+ Joshi's book on Distributions::
67
+
68
+ sage: f(x) = sin(x^2)
69
+ sage: g(x) = cos(x) + x^3
70
+ sage: u = f(x+t) + g(x-t)
71
+ sage: u
72
+ -(t - x)^3 + cos(-t + x) + sin((t + x)^2)
73
+ sage: u.diff(t,2) - u.diff(x,2)
74
+ 0
75
+
76
+ Restoring variables after they have been turned into functions::
77
+
78
+ sage: x = function('x')
79
+ sage: type(x)
80
+ <class 'sage.symbolic.function_factory...NewSymbolicFunction'>
81
+ sage: x(2/3)
82
+ x(2/3)
83
+ sage: restore('x')
84
+ sage: sin(x).variables()
85
+ (x,)
86
+
87
+ MATHEMATICA: Some examples of integration and differentiation taken
88
+ from some Mathematica docs::
89
+
90
+ sage: var('x n a')
91
+ (x, n, a)
92
+ sage: diff(x^n, x) # the output looks funny, but is correct
93
+ n*x^(n - 1)
94
+ sage: diff(x^2 * log(x+a), x)
95
+ 2*x*log(a + x) + x^2/(a + x)
96
+ sage: derivative(arctan(x), x)
97
+ 1/(x^2 + 1)
98
+ sage: derivative(x^n, x, 3)
99
+ (n - 1)*(n - 2)*n*x^(n - 3)
100
+ sage: derivative( function('f')(x), x)
101
+ diff(f(x), x)
102
+ sage: diff( 2*x*f(x^2), x)
103
+ 4*x^2*D[0](f)(x^2) + 2*f(x^2)
104
+ sage: integrate( 1/(x^4 - a^4), x)
105
+ -1/2*arctan(x/a)/a^3 - 1/4*log(a + x)/a^3 + 1/4*log(-a + x)/a^3
106
+ sage: expand(integrate(log(1-x^2), x))
107
+ x*log(-x^2 + 1) - 2*x + log(x + 1) - log(x - 1)
108
+
109
+ This is an apparent regression in Maxima 5.39.0, although
110
+ the antiderivative is correct, assuming we work with
111
+ (poly)logs of complex argument. More convenient form is
112
+ 1/2*log(x^2)*log(-x^2 + 1) + 1/2*dilog(-x^2 + 1).
113
+ See also https://sourceforge.net/p/maxima/bugs/3275/::
114
+
115
+ sage: integrate(log(1-x^2)/x, x)
116
+ log(-x)*log(x + 1) + log(x)*log(-x + 1) + dilog(x + 1) + dilog(-x + 1)
117
+
118
+ No problems here::
119
+
120
+ sage: integrate(exp(1-x^2),x)
121
+ 1/2*sqrt(pi)*erf(x)*e
122
+ sage: integrate(sin(x^2),x)
123
+ 1/16*sqrt(pi)*((I + 1)*sqrt(2)*erf((1/2*I + 1/2)*sqrt(2)*x) + (I - 1)*sqrt(2)*erf((1/2*I - 1/2)*sqrt(2)*x) - (I - 1)*sqrt(2)*erf(sqrt(-I)*x) + (I + 1)*sqrt(2)*erf((-1)^(1/4)*x))
124
+
125
+ sage: integrate((1-x^2)^n,x) # long time
126
+ x*hypergeometric((1/2, -n), (3/2,), x^2*exp_polar(2*I*pi))
127
+ sage: integrate(x^x,x)
128
+ integrate(x^x, x)
129
+ sage: integrate(1/(x^3+1),x)
130
+ 1/3*sqrt(3)*arctan(1/3*sqrt(3)*(2*x - 1)) - 1/6*log(x^2 - x + 1) + 1/3*log(x + 1)
131
+ sage: integrate(1/(x^3+1), x, 0, 1)
132
+ 1/9*sqrt(3)*pi + 1/3*log(2)
133
+
134
+ ::
135
+
136
+ sage: forget()
137
+ sage: c = var('c')
138
+ sage: assume(c > 0)
139
+ sage: integrate(exp(-c*x^2), x, -oo, oo)
140
+ sqrt(pi)/sqrt(c)
141
+ sage: forget()
142
+
143
+ Other examples that now (:issue:`27958`) work::
144
+
145
+ sage: integrate(log(x)*exp(-x^2), x) # long time
146
+ 1/2*sqrt(pi)*erf(x)*log(x) - x*hypergeometric((1/2, 1/2), (3/2, 3/2), -x^2)
147
+
148
+ sage: integrate(log(1+sqrt(1+4*x)/2)/x, x, 0, 1)
149
+ Traceback (most recent call last):
150
+ ...
151
+ ValueError: Integral is divergent.
152
+
153
+ The following is an example of integral that Mathematica
154
+ can do, but Sage currently cannot do::
155
+
156
+ sage: integrate(ceil(x^2 + floor(x)), x, 0, 5, algorithm='maxima')
157
+ integrate(ceil(x^2) + floor(x), x, 0, 5)
158
+
159
+ MAPLE: The basic differentiation and integration examples in the
160
+ Maple documentation::
161
+
162
+ sage: diff(sin(x), x)
163
+ cos(x)
164
+ sage: diff(sin(x), y)
165
+ 0
166
+ sage: diff(sin(x), x, 3)
167
+ -cos(x)
168
+ sage: diff(x*sin(cos(x)), x)
169
+ -x*cos(cos(x))*sin(x) + sin(cos(x))
170
+ sage: diff(tan(x), x)
171
+ tan(x)^2 + 1
172
+ sage: f = function('f'); f
173
+ f
174
+ sage: diff(f(x), x)
175
+ diff(f(x), x)
176
+ sage: diff(f(x,y), x, y)
177
+ diff(f(x, y), x, y)
178
+ sage: diff(f(x,y), x, y) - diff(f(x,y), y, x)
179
+ 0
180
+ sage: g = function('g')
181
+ sage: var('x y z')
182
+ (x, y, z)
183
+ sage: diff(g(x,y,z), x,z,z)
184
+ diff(g(x, y, z), x, z, z)
185
+ sage: integrate(sin(x), x)
186
+ -cos(x)
187
+ sage: integrate(sin(x), x, 0, pi)
188
+ 2
189
+
190
+ ::
191
+
192
+ sage: var('a b')
193
+ (a, b)
194
+ sage: integrate(sin(x), x, a, b)
195
+ cos(a) - cos(b)
196
+
197
+ ::
198
+
199
+ sage: integrate( x/(x^3-1), x)
200
+ 1/3*sqrt(3)*arctan(1/3*sqrt(3)*(2*x + 1)) - 1/6*log(x^2 + x + 1) + 1/3*log(x - 1)
201
+ sage: integrate(exp(-x^2), x)
202
+ 1/2*sqrt(pi)*erf(x)
203
+ sage: integrate(exp(-x^2)*log(x), x) # long time
204
+ 1/2*sqrt(pi)*erf(x)*log(x) - x*hypergeometric((1/2, 1/2), (3/2, 3/2), -x^2)
205
+ sage: f = exp(-x^2)*log(x)
206
+ sage: f.nintegral(x, 0, 999)
207
+ (-0.87005772672831..., 7.5584...e-10, 567, 0)
208
+ sage: integral(1/sqrt(2*t^4 - 3*t^2 - 2), t, 2, 3) # long time # todo: maple can do this
209
+ integrate(1/(sqrt(2*t^2 + 1)*sqrt(t^2 - 2)), t, 2, 3)
210
+ sage: integral(integral(x*y^2, x, 0, y), y, -2, 2)
211
+ 32/5
212
+
213
+ We verify several standard differentiation rules::
214
+
215
+ sage: function('f, g')
216
+ (f, g)
217
+ sage: diff(f(t)*g(t),t)
218
+ g(t)*diff(f(t), t) + f(t)*diff(g(t), t)
219
+ sage: diff(f(t)/g(t), t)
220
+ diff(f(t), t)/g(t) - f(t)*diff(g(t), t)/g(t)^2
221
+ sage: diff(f(t) + g(t), t)
222
+ diff(f(t), t) + diff(g(t), t)
223
+ sage: diff(c*f(t), t)
224
+ c*diff(f(t), t)
225
+ """
sage/calculus/var.pyx ADDED
@@ -0,0 +1,401 @@
1
+ # sage_setup: distribution = sagemath-symbolics
2
+ # cython: old_style_globals=True
3
+ """
4
+ Symbolic variables
5
+ """
6
+
7
+ from sage.symbolic.function_factory import function as new_function
8
+ from sage.symbolic.ring import SR
9
+
10
+
11
+ def var(*args, **kwds):
12
+ r"""
13
+ Create a symbolic variable with the name *s*.
14
+
15
+ INPUT:
16
+
17
+ - ``args`` -- a single string ``var('x y')``, a list of strings
18
+ ``var(['x','y'])``, or multiple strings ``var('x', 'y')``. A
19
+ single string can be either a single variable name, or a space
20
+ or comma separated list of variable names. In a list or tuple of
21
+ strings, each entry is one variable. If multiple arguments are
22
+ specified, each argument is taken to be one variable. Spaces
23
+ before or after variable names are ignored.
24
+
25
+ - ``kwds`` -- keyword arguments can be given to specify domain and
26
+ custom latex_name for variables; see EXAMPLES for usage
27
+
28
+ .. NOTE::
29
+
30
+ The new variable is both returned and automatically injected
31
+ into the global namespace. If you need a symbolic variable in
32
+ library code, you must use either ``SR.var()``
33
+ or ``SR.symbol()``.
34
+
35
+ OUTPUT:
36
+
37
+ If a single symbolic variable was created, the variable
38
+ itself. Otherwise, a tuple of symbolic variables. The variable
39
+ names are checked to be valid Python identifiers and a
40
+ :exc:`ValueError` is raised otherwise.
41
+
42
+ EXAMPLES:
43
+
44
+ Here are the different ways to define three variables ``x``, ``y``,
45
+ and ``z`` in a single line::
46
+
47
+ sage: var('x y z')
48
+ (x, y, z)
49
+ sage: var('x, y, z')
50
+ (x, y, z)
51
+ sage: var(['x', 'y', 'z'])
52
+ (x, y, z)
53
+ sage: var('x', 'y', 'z')
54
+ (x, y, z)
55
+ sage: var('x'), var('y'), var(z)
56
+ (x, y, z)
57
+
58
+ We define some symbolic variables::
59
+
60
+ sage: var('n xx yy zz')
61
+ (n, xx, yy, zz)
62
+
63
+ Then we make an algebraic expression out of them::
64
+
65
+ sage: f = xx^n + yy^n + zz^n; f
66
+ xx^n + yy^n + zz^n
67
+
68
+ By default, var returns a complex variable. To define real or positive
69
+ variables we can specify the domain as::
70
+
71
+ sage: x = var('x', domain=RR); x; x.conjugate()
72
+ x
73
+ x
74
+ sage: y = var('y', domain='real'); y.conjugate()
75
+ y
76
+ sage: y = var('y', domain='positive'); y.abs()
77
+ y
78
+
79
+ Custom latex expression can be assigned to variable::
80
+
81
+ sage: x = var('sui', latex_name='s_{u,i}'); x._latex_()
82
+ '{s_{u,i}}'
83
+
84
+ In notebook, we can also colorize latex expression::
85
+
86
+ sage: x = var('sui', latex_name='\\color{red}{s_{u,i}}'); x._latex_()
87
+ '{\\color{red}{s_{u,i}}}'
88
+
89
+ We can substitute a new variable name for n::
90
+
91
+ sage: f(n = var('sigma'))
92
+ xx^sigma + yy^sigma + zz^sigma
93
+
94
+ If you make an important built-in variable into a symbolic variable,
95
+ you can get back the original value using restore::
96
+
97
+ sage: var('QQ RR')
98
+ (QQ, RR)
99
+ sage: QQ
100
+ QQ
101
+ sage: restore('QQ')
102
+ sage: QQ
103
+ Rational Field
104
+
105
+ We make two new variables separated by commas::
106
+
107
+ sage: var('theta, gamma')
108
+ (theta, gamma)
109
+ sage: theta^2 + gamma^3
110
+ gamma^3 + theta^2
111
+
112
+ The new variables are of type Expression, and belong
113
+ to the symbolic expression ring::
114
+
115
+ sage: type(theta)
116
+ <class 'sage.symbolic.expression.Expression'>
117
+ sage: parent(theta)
118
+ Symbolic Ring
119
+ """
120
+ if len(args) == 1:
121
+ name = args[0]
122
+ else:
123
+ name = args
124
+ G = globals() # this is the reason the code must be in Cython.
125
+ v = SR.var(name, **kwds)
126
+ if isinstance(v, tuple):
127
+ for x in v:
128
+ G[repr(x)] = x
129
+ else:
130
+ G[repr(v)] = v
131
+ return v
132
+
133
+
134
+ def function(s, **kwds):
135
+ r"""
136
+ Create a formal symbolic function with the name *s*.
137
+
138
+ INPUT:
139
+
140
+ - ``nargs=0`` -- number of arguments the function accepts, defaults to
141
+ variable number of arguments, or 0
142
+ - ``latex_name`` -- name used when printing in latex mode
143
+ - ``conversions`` -- dictionary specifying names of this function in
144
+ other systems, this is used by the interfaces internally during conversion
145
+ - ``eval_func`` -- method used for automatic evaluation
146
+ - ``evalf_func`` -- method used for numeric evaluation
147
+ - ``evalf_params_first`` -- boolean to indicate if parameters should be
148
+ evaluated numerically before calling the custom evalf function
149
+ - ``conjugate_func`` -- method used for complex conjugation
150
+ - ``real_part_func`` -- method used when taking real parts
151
+ - ``imag_part_func`` -- method used when taking imaginary parts
152
+ - ``derivative_func`` -- method to be used for (partial) derivation
153
+ This method should take a keyword argument deriv_param specifying
154
+ the index of the argument to differentiate w.r.t
155
+ - ``tderivative_func`` -- method to be used for derivatives
156
+ - ``power_func`` -- method used when taking powers
157
+ This method should take a keyword argument power_param specifying
158
+ the exponent
159
+ - ``series_func`` -- method used for series expansion
160
+ This method should expect keyword arguments
161
+ - ``order`` -- order for the expansion to be computed
162
+ - ``var`` -- variable to expand w.r.t.
163
+ - ``at`` -- expand at this value
164
+ - ``print_func`` -- method for custom printing
165
+ - ``print_latex_func`` -- method for custom printing in latex mode
166
+
167
+ Note that custom methods must be instance methods, i.e., expect the instance
168
+ of the symbolic function as the first argument.
169
+
170
+ .. NOTE::
171
+
172
+ The new function is both returned and automatically injected
173
+ into the global namespace. If you use this function in library
174
+ code, it is better to use sage.symbolic.function_factory.function,
175
+ since it will not touch the global namespace.
176
+
177
+ EXAMPLES:
178
+
179
+ We create a formal function called supersin ::
180
+
181
+ sage: function('supersin')
182
+ supersin
183
+
184
+ We can immediately use supersin in symbolic expressions::
185
+
186
+ sage: y, z, A = var('y z A')
187
+ sage: supersin(y+z) + A^3
188
+ A^3 + supersin(y + z)
189
+
190
+ We can define other functions in terms of supersin::
191
+
192
+ sage: g(x,y) = supersin(x)^2 + sin(y/2)
193
+ sage: g
194
+ (x, y) |--> supersin(x)^2 + sin(1/2*y)
195
+ sage: g.diff(y)
196
+ (x, y) |--> 1/2*cos(1/2*y)
197
+ sage: k = g.diff(x); k
198
+ (x, y) |--> 2*supersin(x)*diff(supersin(x), x)
199
+
200
+ We create a formal function of one variable, write down
201
+ an expression that involves first and second derivatives,
202
+ and extract off coefficients::
203
+
204
+ sage: r, kappa = var('r,kappa')
205
+ sage: psi = function('psi', nargs=1)(r); psi
206
+ psi(r)
207
+ sage: g = 1/r^2*(2*r*psi.derivative(r,1) + r^2*psi.derivative(r,2)); g
208
+ (r^2*diff(psi(r), r, r) + 2*r*diff(psi(r), r))/r^2
209
+ sage: g.expand()
210
+ 2*diff(psi(r), r)/r + diff(psi(r), r, r)
211
+ sage: g.coefficient(psi.derivative(r,2))
212
+ 1
213
+ sage: g.coefficient(psi.derivative(r,1))
214
+ 2/r
215
+
216
+ Custom typesetting of symbolic functions in LaTeX, either using latex_name
217
+ keyword::
218
+
219
+ sage: function('riemann', latex_name='\\mathcal{R}')
220
+ riemann
221
+ sage: latex(riemann(x))
222
+ \mathcal{R}\left(x\right)
223
+
224
+ or passing a custom callable function that returns a latex expression::
225
+
226
+ sage: mu,nu = var('mu,nu')
227
+ sage: def my_latex_print(self, *args): return "\\psi_{%s}"%(', '.join(map(latex, args)))
228
+ sage: function('psi', print_latex_func=my_latex_print)
229
+ psi
230
+ sage: latex(psi(mu,nu))
231
+ \psi_{\mu, \nu}
232
+
233
+ Defining custom methods for automatic or numeric evaluation, derivation,
234
+ conjugation, etc. is supported::
235
+
236
+ sage: def ev(self, x): return 2*x
237
+ sage: foo = function("foo", nargs=1, eval_func=ev)
238
+ sage: foo(x)
239
+ 2*x
240
+ sage: foo = function("foo", nargs=1, eval_func=lambda self, x: 5)
241
+ sage: foo(x)
242
+ 5
243
+ sage: def ef(self, x): pass
244
+ sage: bar = function("bar", nargs=1, eval_func=ef)
245
+ sage: bar(x)
246
+ bar(x)
247
+
248
+ sage: def evalf_f(self, x, parent=None, algorithm=None): return 6
249
+ sage: foo = function("foo", nargs=1, evalf_func=evalf_f)
250
+ sage: foo(x)
251
+ foo(x)
252
+ sage: foo(x).n()
253
+ 6
254
+
255
+ sage: foo = function("foo", nargs=1, conjugate_func=ev)
256
+ sage: foo(x).conjugate()
257
+ 2*x
258
+
259
+ sage: def deriv(self, *args, **kwds): print("{} {}".format(args, kwds)); return args[kwds['diff_param']]^2
260
+ sage: foo = function("foo", nargs=2, derivative_func=deriv)
261
+ sage: foo(x,y).derivative(y)
262
+ (x, y) {'diff_param': 1}
263
+ y^2
264
+
265
+ sage: def pow(self, x, power_param=None): print("{} {}".format(x, power_param)); return x*power_param
266
+ sage: foo = function("foo", nargs=1, power_func=pow)
267
+ sage: foo(y)^(x+y)
268
+ y x + y
269
+ (x + y)*y
270
+
271
+ sage: from pprint import pformat
272
+ sage: def expand(self, *args, **kwds):
273
+ ....: print("{} {}".format(args, pformat(kwds)))
274
+ ....: return sum(args[0]^i for i in range(kwds['order']))
275
+ sage: foo = function("foo", nargs=1, series_func=expand)
276
+ sage: foo(y).series(y, 5)
277
+ (y,) {'at': 0, 'options': 0, 'order': 5, 'var': y}
278
+ y^4 + y^3 + y^2 + y + 1
279
+
280
+ sage: def my_print(self, *args):
281
+ ....: return "my args are: " + ', '.join(map(repr, args))
282
+ sage: foo = function('t', nargs=2, print_func=my_print)
283
+ sage: foo(x,y^z)
284
+ my args are: x, y^z
285
+
286
+ sage: latex(foo(x,y^z))
287
+ t\left(x, y^{z}\right)
288
+ sage: foo = function('t', nargs=2, print_latex_func=my_print)
289
+ sage: foo(x,y^z)
290
+ t(x, y^z)
291
+ sage: latex(foo(x,y^z))
292
+ my args are: x, y^z
293
+ sage: foo = function('t', nargs=2, latex_name='foo')
294
+ sage: latex(foo(x,y^z))
295
+ foo\left(x, y^{z}\right)
296
+
297
+ Chain rule::
298
+
299
+ sage: def print_args(self, *args, **kwds): print("args: {}".format(args)); print("kwds: {}".format(kwds)); return args[0]
300
+ sage: foo = function('t', nargs=2, tderivative_func=print_args)
301
+ sage: foo(x,x).derivative(x)
302
+ args: (x, x)
303
+ kwds: {'diff_param': x}
304
+ x
305
+ sage: foo = function('t', nargs=2, derivative_func=print_args)
306
+ sage: foo(x,x).derivative(x)
307
+ args: (x, x)
308
+ kwds: {'diff_param': 0}
309
+ args: (x, x)
310
+ kwds: {'diff_param': 1}
311
+ 2*x
312
+
313
+ Since Sage 4.0, basic arithmetic with unevaluated functions is no
314
+ longer supported::
315
+
316
+ sage: x = var('x')
317
+ sage: f = function('f')
318
+ sage: 2*f
319
+ Traceback (most recent call last):
320
+ ...
321
+ TypeError: unsupported operand parent(s) for *: 'Integer Ring' and '<class 'sage.symbolic.function_factory...NewSymbolicFunction'>'
322
+
323
+ You now need to evaluate the function in order to do the arithmetic::
324
+
325
+ sage: 2*f(x)
326
+ 2*f(x)
327
+
328
+ Since Sage 4.0, you need to use :meth:`substitute_function` to
329
+ replace all occurrences of a function with another::
330
+
331
+ sage: var('a, b')
332
+ (a, b)
333
+ sage: cr = function('cr')
334
+ sage: f = cr(a)
335
+ sage: g = f.diff(a).integral(b)
336
+ sage: g
337
+ b*diff(cr(a), a)
338
+ sage: g.substitute_function(cr, cos)
339
+ -b*sin(a)
340
+
341
+ sage: g.substitute_function(cr, (sin(x) + cos(x)).function(x))
342
+ b*(cos(a) - sin(a))
343
+
344
+ TESTS:
345
+
346
+ Make sure that :issue:`15860` is fixed and whitespaces are removed::
347
+
348
+ sage: function('A, B')
349
+ (A, B)
350
+ sage: B
351
+ B
352
+ """
353
+ G = globals() # this is the reason the code must be in Cython.
354
+ v = new_function(s, **kwds)
355
+ if isinstance(v, tuple):
356
+ for x in v:
357
+ G[repr(x)] = x
358
+ else:
359
+ G[repr(v)] = v
360
+ return v
361
+
362
+
363
+ def clear_vars():
364
+ """
365
+ Delete all 1-letter symbolic variables that are predefined at
366
+ startup of Sage.
367
+
368
+ Any one-letter global variables that are not symbolic variables
369
+ are not cleared.
370
+
371
+ EXAMPLES::
372
+
373
+ sage: var('x y z')
374
+ (x, y, z)
375
+ sage: (x+y)^z
376
+ (x + y)^z
377
+ sage: k = 15
378
+ sage: clear_vars()
379
+ sage: (x+y)^z
380
+ Traceback (most recent call last):
381
+ ...
382
+ NameError: name 'x' is not defined
383
+ sage: expand((e + i)^2)
384
+ e^2 + 2*I*e - 1
385
+ sage: k
386
+ 15
387
+ """
388
+ from sage.structure.element import Expression
389
+
390
+ G = globals()
391
+ for i in list(range(65, 65 + 26)) + list(range(97, 97 + 26)):
392
+ chr_i = chr(i)
393
+ if chr_i in G and isinstance(G[chr_i], Expression) and G[chr_i].is_symbol():
394
+ # We check to see if there is a corresponding pyobject
395
+ # associated with the expression. This will work for
396
+ # constants which we want to keep, but will fail for
397
+ # variables that we want to delete.
398
+ try:
399
+ G[chr(i)].pyobject()
400
+ except TypeError:
401
+ del G[chr(i)]
@@ -0,0 +1,6 @@
1
+ # sage_setup: distribution = sagemath-symbolics
2
+ from sage.misc.lazy_import import lazy_import
3
+
4
+ lazy_import('sage.dynamics.complex_dynamics.mandel_julia',
5
+ ["mandelbrot_plot", "external_ray", "kneading_sequence", "julia_plot"])
6
+ del lazy_import
@@ -0,0 +1,5 @@
1
+ # sage_setup: distribution = sagemath-symbolics
2
+ from sage.misc.lazy_import import lazy_import
3
+ lazy_import("sage.dynamics.complex_dynamics.mandel_julia",
4
+ ["mandelbrot_plot", "external_ray", "kneading_sequence", "julia_plot"])
5
+ del lazy_import