=================================================================
Manipulate[
{{xmin, xmax}, {ymin, ymax}} = {{-2, 2}, {-2, 2}};
isize = Medium;
zmin = NMinimize[{f[x, y], {xmin <= x <= xmax,
ymin <= y <= ymax}}, {x, y}][[1]];
zmax = NMaximize[{f[x, y], {xmin <= x <= xmax,
ymin <= y <= ymax}}, {x, y}][[1]];
zlevel = -2(* zmin - 1.5 (zmax-zmin)*);
Show[
Plot3D[f[x, y], {x, xmin, xmax}, {y, ymin, ymax},
ImageSize -> isize, PlotStyle -> Opacity[.5],
PlotRange -> {xmin, xmax}
],
Graphics3D[{Red, Arrowheads[Large], PointSize[Large],
Thickness[Large]
, Point[{point[[1]], point[[2]], f[point[[1]], point[[2]]]}]
, Arrow[{ per = 0;
{point[[1]] - per D[f[x, y], x] /. {x -> point[[1]],
y -> point[[2]]},
point[[2]] - per D[f[x, y], y] /. {x -> point[[1]],
y -> point[[2]]},
f[point[[1]], point[[2]]] + per},
{point[[1]] + D[f[x, y], x] /. {x -> point[[1]],
y -> point[[2]]},
point[[2]] + D[f[x, y], y] /. {x -> point[[1]],
y -> point[[2]]},
f[point[[1]], point[[2]]] - 1}
}]
}]
,
Graphics3D[{
Texture[
ContourPlot[f[x, y], {x, xmin, xmax}, {y, ymin, ymax},
Axes -> False, PlotRangePadding -> 0, Frame -> False,
Epilog -> {Red, Arrowheads[Large], PointSize[Large],
Thickness[Large], Point[{point[[1]], point[[2]]}]
, Arrow[{{point[[1]], point[[2]]},
{point[[1]] + D[f[x, y], x] /. {x -> point[[1]],
y -> point[[2]]},
point[[2]] + D[f[x, y], y] /. {x -> point[[1]],
y -> point[[2]]}}
}]
}
]]
, EdgeForm[],
Polygon[{{xmin, ymin, zlevel}, {xmax, ymin, zlevel}, {xmax, ymax,
zlevel}, {xmin, ymax, zlevel}},
VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]},
Lighting -> "Neutral"
]
, PlotRange -> All, BoxRatios -> {1, 1, 1}, FaceGrids -> {Back, Left}
]
,
Row[{Style["f", Italic], "(", Style["x", Italic], ",",
Style["y", Italic], ") ="}],
{{f, Function[{x1, y1}, 2 - (x1/2)^2 - (y1/2)^2], ""}, {
Function[{x1, y1}, 2 - (x1/2)^2 - (y1/2)^2] ->
TraditionalForm[2 - (x/2)^2 - (y/2)^2]
, Function[{x1, y1}, 1.5 Sin[x1 y1]] -> TraditionalForm[Sin[x y]]
, Function[{x1, y1}, 1/3 x1 E^(y1/4) + 1/2 Cos[x1 y1]] ->
TraditionalForm[1/3 x E^(y/4) + 1/2 Cos[x y]]
, Function[{x1, y1}, x1*Cos[y1]] -> TraditionalForm[x*Cos[y]]
, Function[{x1, y1}, (x1^2 - y1^2)/2] ->
TraditionalForm[(x^2 - y^2)/2]
},
PopupMenu},
Delimiter,
Row[{"(", Subscript[Style["x", Italic], 0], ", ",
Subscript[Style["y", Italic], 0], ") = "}],
{{point, {Mean[{.5 xmin, xmax}], Mean[{.6 ymin, ymax}]}, ""},
{xmin, ymin}, {xmax, ymax}, ControlType -> Slider2D},
TrackedSymbols :> {f, point},
AutorunSequencing -> {1, 2},
ControlPlacement -> Left
]