Symbolic minimum and maximum#
Sage provides a symbolic maximum and minimum due to the fact that the
Python builtin max()
and min()
are not able to deal with variables
as users might expect. These functions wait to evaluate if there are variables.
Here you can see some differences:
sage: max(x, x^2)
x
sage: max_symbolic(x, x^2)
max(x, x^2)
sage: f(x) = max_symbolic(x, x^2); f(1/2)
1/2
This works as expected for more than two entries:
sage: max(3, 5, x)
5
sage: min(3, 5, x)
3
sage: max_symbolic(3, 5, x)
max(x, 5)
sage: min_symbolic(3, 5, x)
min(x, 3)
- class sage.functions.min_max.MaxSymbolic#
Bases:
MinMax_base
Symbolic \(\max\) function.
The Python builtin
max()
function does not work as expected when symbolic expressions are given as arguments. This function delays evaluation until all symbolic arguments are substituted with values.EXAMPLES:
sage: max_symbolic(3, x) max(3, x) sage: max_symbolic(3, x).subs(x=5) 5 sage: max_symbolic(3, 5, x) max(x, 5) sage: max_symbolic([3, 5, x]) max(x, 5)
- class sage.functions.min_max.MinMax_base#
Bases:
BuiltinFunction
- eval_helper(this_f, builtin_f, initial_val, args)#
EXAMPLES:
sage: max_symbolic(3, 5, x) # indirect doctest max(x, 5) sage: max_symbolic([5.0r]) # indirect doctest 5.0 sage: min_symbolic(3, 5, x) min(x, 3) sage: min_symbolic([5.0r]) # indirect doctest 5.0
- class sage.functions.min_max.MinSymbolic#
Bases:
MinMax_base
Symbolic \(\min\) function.
The Python builtin
min()
function does not work as expected when symbolic expressions are given as arguments. This function delays evaluation until all symbolic arguments are substituted with values.EXAMPLES:
sage: min_symbolic(3, x) min(3, x) sage: min_symbolic(3, x).subs(x=5) 3 sage: min_symbolic(3, 5, x) min(x, 3) sage: min_symbolic([3, 5, x]) min(x, 3)