ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 23 May 2016 03:20:55 +0200Functions returning unexpected results for symbolic expressionshttps://ask.sagemath.org/question/33259/functions-returning-unexpected-results-for-symbolic-expressions/The functions `min` and `max` are evaluated using Python builtin functions, and need to be replaced by `min_symbolic` and `max_symbolic` to handle symbolic expressions. Sage overrides other Python functions, for example `ceil` and `floor`, and presumably all Sage defined functions behave as expected with symbolic expressions as arguments. `abs` in particular is an explicit alias of `abs_symbolic`.
What other commonly used functions fall back on Python builtin functions and produce unexpected results when handling symbolic expressions?Fri, 29 Apr 2016 22:53:33 +0200https://ask.sagemath.org/question/33259/functions-returning-unexpected-results-for-symbolic-expressions/Answer by paulmasson for <p>The functions <code>min</code> and <code>max</code> are evaluated using Python builtin functions, and need to be replaced by <code>min_symbolic</code> and <code>max_symbolic</code> to handle symbolic expressions. Sage overrides other Python functions, for example <code>ceil</code> and <code>floor</code>, and presumably all Sage defined functions behave as expected with symbolic expressions as arguments. <code>abs</code> in particular is an explicit alias of <code>abs_symbolic</code>.</p>
<p>What other commonly used functions fall back on Python builtin functions and produce unexpected results when handling symbolic expressions?</p>
https://ask.sagemath.org/question/33259/functions-returning-unexpected-results-for-symbolic-expressions/?answer=33499#post-id-33499I've found two common functions that do not handle symbolic expressions: `int` and `round`.
For example, one can produce valid output with either `plot(ceil(x))` or `plot(floor(x))`, but not with `plot(int(x))` or `plot(round(x))`.
If anyone else knows of other functions that create similar issues, please post additional answers.Sat, 21 May 2016 23:35:34 +0200https://ask.sagemath.org/question/33259/functions-returning-unexpected-results-for-symbolic-expressions/?answer=33499#post-id-33499Comment by slelievre for <p>I've found two common functions that do not handle symbolic expressions: <code>int</code> and <code>round</code>.</p>
<p>For example, one can produce valid output with either <code>plot(ceil(x))</code> or <code>plot(floor(x))</code>, but not with <code>plot(int(x))</code> or <code>plot(round(x))</code>.</p>
<p>If anyone else knows of other functions that create similar issues, please post additional answers.</p>
https://ask.sagemath.org/question/33259/functions-returning-unexpected-results-for-symbolic-expressions/?comment=33516#post-id-33516Regarding `int`, it is not really a function, it just converts the input to the Python built-in type `int` (Python integers). It is therefore likely that `long`, `float`, `complex`, will behave the same. See [https://docs.python.org/2.4/lib/typesnumeric.html](https://docs.python.org/2.4/lib/typesnumeric.html)Mon, 23 May 2016 03:20:55 +0200https://ask.sagemath.org/question/33259/functions-returning-unexpected-results-for-symbolic-expressions/?comment=33516#post-id-33516