Sage Examples in Text Format Day 1 Introduction to Sage Plotting Examples (examples of common plot types) %%%%%% SINGLE VARIABLE FUNCTION sage: x = var('x') sage: plot( (1 - cos(x)^2)/sin(x), x, -1, 5) %%%%%% MULTIVARIABLE FUNCTION sage: x, y = var('x, y') sage: plot3d( sin(x)^2*cos(y), (x,3,15), (y,5,17)) %%%%%% PARAMETRIC CURVE IN 2D sage: x = var('x') sage: parametric_plot((cos(x),sin(x)),(x,0,pi),color="red", aspect_ratio=1) %%%%%% PARAMETRIC CURVE IN 3D sage: u = var('u') sage: parametric_plot3d( (cos(u), sin(u), u^2), (u, 0, 200), plot_points=[1000]) %%%%%% PARAMETRIC SURFACE sage: u, v = var('u,v') sage: fx = u*v sage: fy = u sage: fz = v^2 sage: parametric_plot3d([fx, fy, fz], (u, -1, 1), (v, -1, 1), color="yellow") %%%%%% PARAMETRIC SURFACE sage: u, v = var('u,v') sage: fx = 2/3* (cos(u)* cos(2*v) + sqrt(2)* sin(u)* cos(v))* cos(u) / (sqrt(2) - sin(2*u)* sin(3*v)) sage: fy = 2/3* (cos(u)* sin(2*v) - sqrt(2)* sin(u)* sin(v))* cos(u) / (sqrt(2) - sin(2*u)* sin(3*v)) sage: fz = sqrt(2)* cos(u)* cos(u) / (sqrt(2) - sin(2*u)* sin(3*v)) sage: parametric_plot3d([fx, fy, fz], (u, -2*pi, 2*pi), (v, 0, pi), plot_points = [90,90], frame=False, color="purple") %%%%%% VECTOR FIELD IN 2D sage: x,y = var('x y') sage: plot_vector_field((sin(x), cos(y)), (x,-3,3), (y,-3,3)) %%%%%% VECTOR FIELD IN 3D sage: x,y,z=var('x y z') sage: plot_vector_field3d((x*cos(z),-y*cos(z),sin(z)), (x,0,pi), (y,0,pi), (z,0,pi),colors=['red','green','blue'],center_arrows=True) Day 2 More Plotting Examples %%%%% SOME MISC EXAMPLES OF PARAMETRIC CURVES sage: u = var('u') sage: parametric_plot( (sin(u), u^2), (u, 0, (pi/2)), aspect_ratio=1) sage: u = var('u') sage: parametric_plot3d( (u/sqrt(2), u/sqrt(2), sin(u)), (u, 0, 20), plot_points=[1000], aspect_ratio=1) sage: u = var('u') sage: parametric_plot3d( (u, u^2, sin(u)), (u, 0, 200), plot_points=[1000]) %%%%% THIS IS FROM THE INTERSECTION EXAMPLE IN CLASS sage: x,y,t = var('x, y, t') sage: P1 = plot3d(sqrt(x^2+y^2),(x,-10,10),(y,-10,10)) sage: P2 = plot3d(1+y,(x,-10,10),(y,-10,10), color="red") sage: P3 = parametric_plot3d([t,(t^2-1)/2,(t^2+1)/2],(t,-5,5), color="green", thickness=3) sage: show(P1+P2+P3, aspect_ratio=1)