Ask Your Question

Revision history [back]

The issue is the following: the Python builtin max does something like

if a < b:
    return b
else return a

Here, x and y are symbols, hence neither x<y nor y<x is True:

sage: var('x,y')
sage: bool(x<y)
False
sage: bool(y<x)
False

Hence:

sage: max(x,y)
x

Which explains your plot.

What you need is either to use max_symbolic function:

sage: max_symbolic(x,y)
max(x, y)

sage: plot3d(max_symbolic(x,y), (x, -5, 5), (y, -5, 5))

Or to define the max as a Python function (not a symbolic expression), with one of the three equivalent syntaxes:

sage: f = lambda a,b : max(a,b)

sage: f = max

sage: def f(a,b):
....:     return max(a,b)

Then,

sage: plot3d(f, (-5, 5), (-5, 5))