# 3D plot not working, find max/min points [closed]

Im trying to plot this graph in mathematica: (x+y)sin(x-y)

And this is my in- and output:

Plot3D[(x + y) (Sin[x - y]), {x, -50, 50}, {y, -50, 50}]


The output is this:

My goal is to find how many max/min and saddle points there are in R2 of the function. How can I get that answer from the graph?

• Use Sin instead of sin.
– Syed
Commented May 23, 2023 at 10:54
• Okay it's working now, but how can I determine how many max/min points there are? Commented May 23, 2023 at 10:57
• I think you should first start by looking at a smaller segment of the plot then try to determine algebraically the min and max points. Looks to me they are along the digaonal lines y=ax+b periodic in sin(x-y).
– josh
Commented May 23, 2023 at 12:29
• Change coordinates $u=x+y$, $v=x-y$, and optimize $u \sin v$, that is, solve $\sin v = 0,\ u \cos v = 0$, which is fairly easy by inspection. Commented May 26, 2023 at 17:00

First, to see what is going on, a simpler example:

eq = {D[f[x, y], x] == 0,
D[f[x, y], y] == 0, -5 <= x <= 5, -5 <= y <= 5};
sol = Solve[eq, {x, y}] // N

Show[Plot3D[(x + y) (Sin[x - y]), {x, -5, 5}, {y, -5, 5}]
, Graphics3D[{PointSize[0.03], Point[{x, y, f[x, y]} /. sol]}]]


We only have saddle points, no minima or maxima.

Now for the original problem: How many saddle points are in R^2?

f[x_, y_] = (x + y) Sin[x - y];
eq = {D[f[x, y], x] == 0, D[f[x, y], y] == 0};
Reduce[eq, {x, y}]


Therefore there are an infinity of saddle points on the diagonal x==-y and x== c1 Pi and x== (c1+1/2) Pi.