f(x,y)=sin(x*y)
xlim = 5*pi/4
ylim = 5*pi/4
@interact
def demo(a = slider(-xlim,xlim,2*xlim/100,0), b = slider(-ylim,ylim,2*ylim/100,0)):
p=plot3d(f(x,y), (x, -xlim, xlim), (y, -ylim, ylim), opacity=0.8)
xslice=parametric_plot3d([x,b,f(x,b)],(x,-xlim,xlim),color='red', thickness=8)
yslice=parametric_plot3d([a,y,f(a,y)],(y,-ylim,ylim),color='green', thickness=8)
pnt=point((a,b,f(a,b)), color='black',size=10)
show('The surface defined by $z = f(x,y)$ with cross-sectional curves, from the base point $(a,b)=('+str(n(a,digits=3))+','+str(n(b,digits=3))+')$'+ ' in the $x$ and $y$ directions.')
show(p+xslice+yslice+pnt, spin=2.5)
fx=f.diff(x)
fy=f.diff(y)
p=plot(f(x,b),(x,-xlim,xlim),color='red', thickness=6, axes_labels=['$x$','$z$'])
q=plot(f(a,y),(y,-ylim,ylim),color='green', thickness=6, axes_labels=['$y$','$z$'])
show('The derivative $f_x(a,b)\\approx'+str(n(fx(a,b),digits=3))+'$.')
show(p+point((a,f(a,b)), color='black', size=150,zorder=5))
show('The derivative $f_y(a,b)\\approx'+str(n(fy(a,b),digits=3))+'$.')
show(q+point((b,f(a,b)), color='black', size=100,zorder=5))