1
+ # sage.doctest: needs sage.symbolic
1
2
r"""
2
3
Symbolic minimum and maximum
3
4
7
8
8
9
Here you can see some differences::
9
10
10
- sage: max(x, x^2) # needs sage.symbolic
11
+ sage: max(x, x^2)
11
12
x
12
- sage: max_symbolic(x, x^2) # needs sage.symbolic
13
+ sage: max_symbolic(x, x^2)
13
14
max(x, x^2)
14
- sage: f(x) = max_symbolic(x, x^2); f(1/2) # needs sage.symbolic
15
+ sage: f(x) = max_symbolic(x, x^2); f(1/2)
15
16
1/2
16
17
17
18
This works as expected for more than two entries::
18
19
19
- sage: # needs sage.symbolic
20
20
sage: max(3, 5, x)
21
21
5
22
22
sage: min(3, 5, x)
@@ -48,7 +48,6 @@ def eval_helper(self, this_f, builtin_f, initial_val, args):
48
48
"""
49
49
EXAMPLES::
50
50
51
- sage: # needs sage.symbolic
52
51
sage: max_symbolic(3, 5, x) # indirect doctest
53
52
max(x, 5)
54
53
sage: max_symbolic([5.0r]) # indirect doctest
@@ -93,20 +92,20 @@ def __call__(self, *args, **kwds):
93
92
"""
94
93
EXAMPLES::
95
94
96
- sage: max_symbolic(3, 5, x) # needs sage.symbolic
95
+ sage: max_symbolic(3, 5, x)
97
96
max(x, 5)
98
- sage: max_symbolic(3, 5, x, hold=True) # needs sage.symbolic
97
+ sage: max_symbolic(3, 5, x, hold=True)
99
98
max(3, 5, x)
100
- sage: max_symbolic([3, 5, x]) # needs sage.symbolic
99
+ sage: max_symbolic([3, 5, x])
101
100
max(x, 5)
102
101
103
102
::
104
103
105
- sage: min_symbolic(3, 5, x) # needs sage.symbolic
104
+ sage: min_symbolic(3, 5, x)
106
105
min(x, 3)
107
- sage: min_symbolic(3, 5, x, hold=True) # needs sage.symbolic
106
+ sage: min_symbolic(3, 5, x, hold=True)
108
107
min(3, 5, x)
109
- sage: min_symbolic([3, 5, x]) # needs sage.symbolic
108
+ sage: min_symbolic([3, 5, x])
110
109
min(x, 3)
111
110
112
111
TESTS:
@@ -120,7 +119,6 @@ def __call__(self, *args, **kwds):
120
119
121
120
Check if a single argument which is not iterable works::
122
121
123
- sage: # needs sage.symbolic
124
122
sage: max_symbolic(None)
125
123
Traceback (most recent call last):
126
124
...
@@ -161,13 +159,13 @@ def __init__(self):
161
159
r"""
162
160
Symbolic `\max` function.
163
161
164
- The Python builtin :func:`max` function does not work as expected when symbolic
165
- expressions are given as arguments. This function delays evaluation
166
- until all symbolic arguments are substituted with values.
162
+ The Python builtin :func:`max` function does not work as
163
+ expected when symbolic expressions are given as
164
+ arguments. This function delays evaluation until all symbolic
165
+ arguments are substituted with values.
167
166
168
167
EXAMPLES::
169
168
170
- sage: # needs sage.symbolic
171
169
sage: max_symbolic(3, x)
172
170
max(3, x)
173
171
sage: max_symbolic(3, x).subs(x=5)
@@ -179,11 +177,11 @@ def __init__(self):
179
177
180
178
TESTS::
181
179
182
- sage: loads(dumps(max_symbolic(x, 5))) # needs sage.symbolic
180
+ sage: loads(dumps(max_symbolic(x, 5)))
183
181
max(x, 5)
184
- sage: latex(max_symbolic(x, 5)) # needs sage.symbolic
182
+ sage: latex(max_symbolic(x, 5))
185
183
\max\left(x, 5\right)
186
- sage: max_symbolic(x, 5)._sympy_() # needs sympy sage.symbolic
184
+ sage: max_symbolic(x, 5)._sympy_() # needs sympy
187
185
Max(5, x)
188
186
"""
189
187
BuiltinFunction .__init__ (self , 'max' , nargs = 0 , latex_name = r"\max" ,
@@ -193,7 +191,6 @@ def _eval_(self, *args):
193
191
"""
194
192
EXAMPLES::
195
193
196
- sage: # needs sage.symbolic
197
194
sage: t = max_symbolic(x, 5); t
198
195
max(x, 5)
199
196
sage: t.subs(x=3) # indirect doctest
@@ -222,7 +219,6 @@ def _evalf_(self, *args, **kwds):
222
219
"""
223
220
EXAMPLES::
224
221
225
- sage: # needs sage.symbolic
226
222
sage: t = max_symbolic(sin(x), cos(x))
227
223
sage: t.subs(x=1).n(200)
228
224
0.84147098480789650665250232163029899962256306079837106567275
@@ -239,10 +235,11 @@ def _evalf_(self, *args, **kwds):
239
235
We can usually integrate these expressions, but can't
240
236
guarantee a symbolic answer in closed form::
241
237
242
- sage: f = max_symbolic(sin(x), cos(x)) # needs sage.symbolic
243
- sage: r = integral(f, x, 0, 1) # needs sage.symbolic
238
+ sage: # long time
239
+ sage: f = max_symbolic(sin(x), cos(x))
240
+ sage: r = integral(f, x, 0, 1)
244
241
...
245
- sage: r.n() # abs tol 1e-8 # needs sage.symbolic
242
+ sage: r.n() # abs tol 1e-8
246
243
0.873911256504955
247
244
"""
248
245
return max_symbolic (args )
@@ -262,7 +259,6 @@ def __init__(self):
262
259
263
260
EXAMPLES::
264
261
265
- sage: # needs sage.symbolic
266
262
sage: min_symbolic(3, x)
267
263
min(3, x)
268
264
sage: min_symbolic(3, x).subs(x=5)
@@ -274,11 +270,11 @@ def __init__(self):
274
270
275
271
TESTS::
276
272
277
- sage: loads(dumps(min_symbolic(x, 5))) # needs sage.symbolic
273
+ sage: loads(dumps(min_symbolic(x, 5)))
278
274
min(x, 5)
279
- sage: latex(min_symbolic(x, 5)) # needs sage.symbolic
275
+ sage: latex(min_symbolic(x, 5))
280
276
\min\left(x, 5\right)
281
- sage: min_symbolic(x, 5)._sympy_() # needs sympy sage.symbolic
277
+ sage: min_symbolic(x, 5)._sympy_() # needs sympy
282
278
Min(5, x)
283
279
"""
284
280
BuiltinFunction .__init__ (self , 'min' , nargs = 0 , latex_name = r"\min" ,
@@ -288,7 +284,6 @@ def _eval_(self, *args):
288
284
"""
289
285
EXAMPLES::
290
286
291
- sage: # needs sage.symbolic
292
287
sage: t = min_symbolic(x, 5); t
293
288
min(x, 5)
294
289
sage: t.subs(x=3) # indirect doctest
@@ -317,7 +312,6 @@ def _evalf_(self, *args, **kwds):
317
312
"""
318
313
EXAMPLES::
319
314
320
- sage: # needs sage.symbolic
321
315
sage: t = min_symbolic(sin(x), cos(x))
322
316
sage: t.subs(x=1).n(200)
323
317
0.54030230586813971740093660744297660373231042061792222767010
0 commit comments