Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168703
Image: ubuntu2004
# Sage will ignore every line that begins with a # (like this one) # First, tell Sage that we're going to use three variables var('x,y,z')
(x, y, z)
# Now, define a function f(x,y) of two variables... f(x,y) = (x^3-y^3+4*x*y)/(x^2+y^2) # ... and its graph (in the "viewing window" 0 <= x <= 4, -1 <= y <= 3) ... SurfacePlot = plot3d(f, (x,0,4), (y,-1,3)) # ... and a point on the surface: PointPlot = point3d((2,1,3),color="lightgreen",size=15)
# Display the graph of f(x,y) and the point on it # (try spinning the surface around to get a better look at it from all angles) SurfacePlot + PointPlot
# Slice the surface with the plane y=1. The partial function (not the same thing # as the partial derivative!) has its graph where the plane meets the surface. Yfixed = implicit_plot3d(y==1, (x,0,4), (y,-1,3), (z,0,6), color="orange") SurfacePlot + PointPlot + Yfixed
# Here's the function f_x(x,y) (you can confirm this with the quotient rule). diff(f,x)(x,y)
(3*x^2 + 4*y)/(x^2 + y^2) - 2*(x^3 - y^3 + 4*x*y)*x/(x^2 + y^2)^2
# Evaluating at x=2, y=1 tells us the slope of the tangent line to the curve diff(f,x)(2,1)
4/5
# Now we can do the same thing switching the roles of x and y -- # slice the surface with the plane x=2 Xfixed = implicit_plot3d(x==2, (x,0,4), (y,-1,3), (z,0,6), color="red") SurfacePlot + PointPlot + Xfixed
# The two slicing planes at the same time (so you can see both partial functions) SurfacePlot + PointPlot + Xfixed + Yfixed
# The tangent plane (calculated using the general formula) T(x,y) = diff(f,x)(2,1) * (x-2) + diff(f,y)(2,1) * (y-1) + f(2,1) TanPlot = plot3d(T, (x,0,4), (y,-1,3), color="yellow") TanPlot + SurfacePlot + PointPlot
# Here you can see how the tangent plane contains the tangent lines to both partial functions TanPlot + SurfacePlot + PointPlot + Xfixed + Yfixed