I am having issues 3d plotting a trivial function f(x,y) = max(x,y)
.
Here is the expected result from wolframalpha:
And here is the python code and errors:
from sympy import symbols
from sympy import Max
from sympy.plotting import plot3d
x,y = symbols("x y")
plot3d(Max(x,y))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.9/site-packages/sympy/plotting/plot.py", line 2171, in plot3d
plots.show()
File "/usr/lib/python3.9/site-packages/sympy/plotting/plot.py", line 219, in show
self._backend.show()
File "/usr/lib/python3.9/site-packages/sympy/plotting/plot.py", line 1401, in show
self.process_series()
File "/usr/lib/python3.9/site-packages/sympy/plotting/plot.py", line 1398, in process_series
self._process_series(series, ax, parent)
File "/usr/lib/python3.9/site-packages/sympy/plotting/plot.py", line 1240, in _process_series
x, y, z = s.get_meshes()
File "/usr/lib/python3.9/site-packages/sympy/plotting/plot.py", line 973, in get_meshes
mesh_z = f(mesh_x, mesh_y)
File "/usr/lib/python3.9/site-packages/sympy/plotting/experimental_lambdify.py", line 128, in __call__
results = self.vector_func(*temp_args)
File "/usr/lib/python3.9/site-packages/sympy/plotting/experimental_lambdify.py", line 267, in __call__
return self.lambda_func(*args, **kwargs)
File "<string>", line 1, in <lambda>
File "<__array_function__ internals>", line 5, in amax
File "/usr/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 2705, in amax
return _wrapreduction(a, np.maximum, 'max', axis, None, out,
File "/usr/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 87, in _wrapreduction
return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
TypeError: only integer scalar arrays can be converted to a scalar index
Sure, I can always evaluate the function on a grid and plot it by myself, but I was not expecting having to do that. Am I doing something wrong? If this is a sympy bug/limitation, how hard would it be to remove it?