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.Thu, 11 Dec 2014 19:37:34 +0100I want to manipulate max(x/b,a) so that I end up with an expression with max(0,ab-x)https://ask.sagemath.org/question/25215/i-want-to-manipulate-maxxba-so-that-i-end-up-with-an-expression-with-max0ab-x/On paper I would factor 1/b and then subtract and add x and end up with the expression I am looking for.
1/b max(x, ab)
1/b {max(0,ab-x) + x}
Is there a way to do this in sage?Thu, 11 Dec 2014 00:11:18 +0100https://ask.sagemath.org/question/25215/i-want-to-manipulate-maxxba-so-that-i-end-up-with-an-expression-with-max0ab-x/Comment by slelievre for <p>On paper I would factor 1/b and then subtract and add x and end up with the expression I am looking for.</p>
<p>1/b max(x, ab)</p>
<p>1/b {max(0,ab-x) + x}</p>
<p>Is there a way to do this in sage?</p>
https://ask.sagemath.org/question/25215/i-want-to-manipulate-maxxba-so-that-i-end-up-with-an-expression-with-max0ab-x/?comment=25227#post-id-25227You seem to be assuming that b is positive.Thu, 11 Dec 2014 19:37:34 +0100https://ask.sagemath.org/question/25215/i-want-to-manipulate-maxxba-so-that-i-end-up-with-an-expression-with-max0ab-x/?comment=25227#post-id-25227Answer by slelievre for <p>On paper I would factor 1/b and then subtract and add x and end up with the expression I am looking for.</p>
<p>1/b max(x, ab)</p>
<p>1/b {max(0,ab-x) + x}</p>
<p>Is there a way to do this in sage?</p>
https://ask.sagemath.org/question/25215/i-want-to-manipulate-maxxba-so-that-i-end-up-with-an-expression-with-max0ab-x/?answer=25226#post-id-25226It seems that for now `max` is not a symbolic function, ie, when you type `max(x/b, a)`, this is not kept as a symbolic expression involving the symbolic function `max`. Instead, it is immediately evaluated (using some form of comparison on symbolic expressions.
sage: var('a b x')
(a, b, x)
sage: expr = max(x/b,a)
sage: expr
x/b
I think there is some ticket about making more functions symbolic in Sage, it would be worth checking if `max` is among the functions targeted by that ticket.
One obstacle might be that `max` is a standard Python function and there are objections to modifying it in Sage. This obstacle is a problem for Sage in other areas too, such as interval arithmetic.Thu, 11 Dec 2014 19:32:52 +0100https://ask.sagemath.org/question/25215/i-want-to-manipulate-maxxba-so-that-i-end-up-with-an-expression-with-max0ab-x/?answer=25226#post-id-25226