Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
29 views
#you can call your variables anything you like; here I've named them to mostly match the traditional names rho,theta,phi = var('rho,theta,phi')
#plotting 1: if you have rho as a function of theta and phi, i.e., rho = stuff in theta and phi, you can use the command #spherical_plot3d(your function,(theta,theta min, theta max),(phi, phi min, phi max)) #for example, the sphere of radius 3, rho = 3, theta from 0 to 2pi, phi from 0 to pi: spherical_plot3d(3,(theta,0,2/3*pi),(phi,0,pi))
3D rendering not yet implemented
#or a teardrop spherical_plot3d(exp(-phi),(theta,0,2*pi),(phi,0,pi))
3D rendering not yet implemented
# or anything else of the form rho = stuff in phi, theta; I think this one looks like a seashell spherical_plot3d(phi * theta, (theta, 0, 2*pi), (phi, 0, pi))
3D rendering not yet implemented
︠85872ed7-ce4c-45bd-bf70-54ea27e104e2︠ #if you want to plot something other than rho as a function of theta and phi, we have to define the spherical transformation to match this case #the normal setup is # T = Spherical ('dependent variable', ['independent variable', 'independent variable']) ︠d950ab49-e682-45ca-bb39-182289cc8c4ds︠ # for instance, if we want to plot the cone in spherical coordinates, we want phi constant, and rho and theta as independent variables # We use the transformation T1 = Spherical('inclination',['radius','azimuth']) # and apply the transformation T1.transform(radius=rho, azimuth=theta, inclination=phi) #Sage uses radius for rho, azimuth for theta, and inclination for phi, and we must list use the variables in this order when plotting
(rho*cos(theta)*sin(phi), rho*sin(phi)*sin(theta), rho*cos(phi))
#for example, we plot the cone, using the plot3d command, with the transformation: plot3d(pi/2,(rho,0,1),(theta,0,2*pi),transformation=T1)
3D rendering not yet implemented
#You can do the same thing for theta = stuff in rho and phi (or theta constant) by using a transformation of the form T2= Spherical('azimuth', ['radius', 'inclination']) T2.transform(radius=rho, azimuth=theta, inclination=phi) # and a wedge of constant theta: plot3d(pi/3,(rho,0,1),(phi,pi/4,3*pi/4),transformation = T2)
(rho*cos(theta)*sin(phi), rho*sin(phi)*sin(theta), rho*cos(phi))
3D rendering not yet implemented
# equivalent to spherical_plot3d, we could use plot3d with the transformation #T = Spherical('radius', ['azimuth', 'inclination']) #T.transform(radius=rho, azimuth=theta, inclination=phi) #plot3d(your function of rho,(theta,theta min, theta max),(phi, phi min, phi max),transformation = T) ︠bc25cf83-5a6d-4139-92cc-829533841a06︠ #setting up plots in cylindrical coordinates is similar, but we use #T = Cylindrical('height', ['radius', 'azimuth']) #instead ︠eadce050-6cda-4d38-9523-e8a87adc02e0︠ # Integration in Spherical Coordinates #no special transformations required for integration #just remember that in spherical coordinates we have an extra rho^2 * sin(phi) factor #and you can name your variables r,t,and p if you like ︠bc47ace3-f26c-49b2-add3-22d027eb6e87︠ #example: integrating over the unit sphere: r,t,p = var('r,t,p') integrate(integrate(integrate(1*r^2*sin(p),r,0,1),t,0,2*pi),p,0,pi)
4/3*pi
#or you can write out the traditional variable names: integrate(integrate(integrate(rho^2*sin(phi),rho,0,1),theta,0,2*pi),phi,0,pi)
4/3*pi
︠ba91c01a-feb2-4e0b-b481-75057c34fa77︠ ︠da40c870-1997-4e53-9dcf-c3d05cad03d0︠ ︠6d6d9343-05c1-46d5-ba09-6cf78c72a903︠ ︠c124cf93-0af7-47fd-984e-cebfe07ceb01︠ ︠4211f1ed-b577-46a9-8999-6a6f9aca2fe5︠ ︠8099d834-5d10-439b-b42c-16f841c07941︠ ︠468a9dcd-1a5b-4774-a15a-da33671f7684︠ ︠ffb6d9a6-a3a3-450b-a0f5-7ad73daeb166︠