示例代码:
Clear["`*"];
f[x_, y_] := -(x - 1)^2 - (y + 1)^2;(*找到最大值点*)
maxPoint = Maximize[{f[x, y], -10 <= x <= 10 && -10 <= y <= 10 && x^2 + y^2 <= 10}, {x, y}](*绘制3D图形并标记最大值点*)
Y1 = Plot3D[f[x, y], {x, -10, 10}, {y, -10, 10}, Mesh -> {{{maxPoint[[2, 1, 2]], Blue}}, {{maxPoint[[2, 2, 2]], Black}}}, RegionFunction -> Function[{x, y, z}, x^2 + y^2 <= 10],(*BoxRatios\[Rule]Automatic,ColorFunction\[Rule]"Rainbow",*)PlotStyle -> Opacity[4/5], Mesh -> None];
Y2 = ListPointPlot3D[{{maxPoint[[2, 1, 2]], maxPoint[[2, 2, 2]], maxPoint[[1]]}}, PlotStyle -> {{PointSize[Large], Red}}];Show[Y1, Y2]
结果图如下: