Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168730
Image: ubuntu2004

Math 2500

Niles Johnson, University of Georgia



A function f:R2Rf: \mathbb{R}^2 \to \mathbb{R} and its graph:

var('x,y') f(x,y) = x^2 -y^2 fgraph = plot3d(f, (x,-3,3), (y,-3,3)) fgraph.show()

Slices of ff along x=x0x = x_0 and y=y0y=y_0:

x0 = 1 y0 = 0 xslice=parametric_plot((x0,y,f(x=x0)), (x,-3,3), (y,-3,3),color='red', thickness=4) yslice=parametric_plot((x,y0,f(y=y0)), (x,-3,3), (y,-3,3),color='red', thickness=4) fgraph+xslice+yslice

Contours of ff:

contour_plot(f(x,y), (x,-3,3), (y,-3,3),colorbar=True,cmap=colormaps.Spectral)
c0 = 1 c1 = 2.5 c2 = 4 contour_plot(f(x,y), (x,-3,3), (y,-3,3),contours=[c0,c1,c2],fill=False,labels=True,cmap='flag')

Functions R3R\mathbb{R}^3 \to \mathbb{R}

Level surfaces:

f(x,y,z) = z - x^2 - y^2 contours=[-1, 0, 1, 2] fc=fast_callable(f,domain=float)

Alternate functions:

f(x,y,z)=sin(x)*cos(y)*z^2 contours = [1, 2, 4] f(x,y,z) = sin(x) - y*cos(z) contours = [0,1,3] fc=fast_callable(f,domain=float)
p=point([0,0,0]) for c in contours: H = contours.index(c)*1.0/len(contours) p+=implicit_plot3d(fc, (x,-3,3), (y,-3,3), (z,-3,3), contour=c, color=hue(H), opacity=0.7) p.show()

Slice y=0y=0: we plot the points (x,z,f(x,0,z))(x,\, z,\, f(x,0,z)) as a parametric surface.

z0 = 1 parametric_plot((x,z,f(y=0)), (x,-2,2), (z,-2,2),color='red') + \ parametric_plot((x,z0,f(y=0, z=z0)), (x,-2,2),color='cyan', thickness=5)

Slice z=0z=0: we plot the points (x,y,f(x,y,0))(x,\, y,\, f(x,y,0)) as a parametric surface.



y0 = 0 parametric_plot((x,y,f(z=0)), (x,-1,1), (y,-1,1),color='red') + \ parametric_plot((x,y0,f(y=y0,z=0)), (x,-1,1),color='cyan', thickness=5)