Okay, using what William said, I produced this an 'interact' example,
showing the linear and quadratic Taylor approximations to a certain
function in two variables.  Right now it's using a combo of the old
and new symbolic stuff, because that seems to be the best way to get
things done...

var('x y')
F = sin(x^2 + y^2) * cos(y) * exp(-0.5*(x^2+y^2))
plotF = plot3d(F, (x, 0.4, 2), (y, 0.4, 2), adaptive=True,
color='blue')
var('xx yy', ns=1)
G = sin(xx^2 + yy^2) * cos(yy) * exp(-0.5*(xx^2+yy^2))
@interact
def _(x0=(0.8,1.6), y0=(0.8, 1.6), show_plane=("Show linear
approximation", False), show_quad=("Show quadratic approximation",
False)):
    F0 = float(G.subs(xx=x0).subs(yy=y0))
    F1 = float(G.diff(xx).subs(xx=x0).subs(yy=y0))
    F2 = float(G.diff(yy).subs(xx=x0).subs(yy=y0))
    F11 = float(G.diff(xx, 2).subs(xx=x0).subs(yy=y0))
    F12 = float(G.diff(xx).diff(yy).subs(xx=x0).subs(yy=y0))
    F22 = float(G.diff(yy, 2).subs(xx=x0).subs(yy=y0))
    P = (x0, y0, F0)
    dot = point3d(P, size=15, color='red')
    plane = F0 + F1 * (x-x0) + F2 * (y-y0)
    quad = plane + 1/2 * (F11 * (x-x0)^2 + 2 * F12 * (x-x0) * (y-y0) +
F22 * (y-y0)^2)
    plane_string = 'z = %.2f + %.2f(x-x_0)+%.2f(y-y_0)'%(F0, F1, F2)
    quad_string = plane_string + '+ \\frac{1}{2} \\left((%.2f) (x-
x_0)^2 + 2(%.2f) (x-x_0)(y-y_0) + (%.2f)(y-y_0)^2\\right)'%(F11, F12,
F22)
    plot1 = plot3d(plane, (x, 0.4, 2), (y, 0.4, 2), color='green')
    plot2 = plot3d(quad, (x, max(0.4, x0-0.5), min(2.0, x0+0.5)),
         (y, max(0.4, y0-0.5), min(2.0, y0+0.5)), color='purple')
    plot = dot + plotF
    if show_plane: plot += plot1
    if show_quad: plot += plot2
    html('$F(x,y) = e^{-(x^2+y^2)/2} \\cos(y) \\sin(x^2+y^2)$')
    if show_plane: html('tangent plane: $%s$'%plane_string)
    if show_quad: html('quad approx: $%s$'%quad_string)
    show(plot)


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to