I have this code to produce an interactive visualization of a tangent plane to a function:
Clear[f]
f[x_, y_] := x^3 + 2*y^3
Manipulate[
Show[
Plot3D[f[x, y], {x, -1, 1}, {y, -1, 1}, PlotStyle -> Opacity[0.8]],
Plot3D[f[point[[1]], point[[2]]] +
Limit[(f[point[[1]] + h, point[[2]]] - f[point[[1]], point[[2]]])/
h, h -> 0]*(x - point[[1]]) +
Limit[(f[point[[1]], point[[2]] + h] - f[point[[1]], point[[2]]])/
h, h -> 0]*(y - point[[2]]), {x, -1, 1}, {y, -1, 1},
PlotStyle -> Opacity[0.8], MeshStyle -> Gray]],
{{point, {0, 0}}, {-1, -1}, {1, 1}},
SaveDefinitions -> True]
It is, however, extremely slow. I suspect that the reason is that I unnecessarily compute the partial derivatives over and over again inside the second Plot3D, so my question is: how to change it?
Note: I am using the above code also for other functions as discussed here, and that is the reason for the Limit in computation of partial derivatives.
fx[x_,y_]? – mbork Sep 29 '12 at 19:36Doperator or theLimitdefinition, as you indicated that you might need to. – Mark McClure Sep 29 '12 at 19:40Limitone is chosen if theDdoesn't work (e.g., when the function is given by a separate rule for one point). And thanks for the nicety - the large point! (I did it using a one-element list inListPointPlot3D, definitely less elegant.) – mbork Sep 29 '12 at 19:42Points using Epilog – Simon Sep 30 '12 at 02:07Epilogis really for 2D graphics. From the documentation: "In three-dimensional graphics, two-dimensional graphics primitives can be specified by the Epilog option. The graphics primitives are rendered in a 0,1 coordinate system." - Hence, theShow[{Plot3D[__], Graphics3D[__]}]construct. – Mark McClure Sep 30 '12 at 02:38