# I want to manipulate max(x/b,a) so that I end up with an expression with max(0,ab-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?

edit retag close merge delete

Sort by » oldest newest most voted

It 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.

more