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.