Revision history [back]

Toward a related issue - how do I incorporate such a conditional in a 3d plot? Consider the following.

s,t=var('s,t') def f(x): if x<pi: return(arccos(-2="" (2+sin(x))))="" if="" x="">=pi: return(pi)

plot(f,(x,0,2*pi)) --- to check that the function is properly defined

X=parametric_plot3d([(2+sin(s))sin(t),cos(s),(2+sin(s))cos(t)],(s,0,2pi),(t,0,2pi)) --- to produce a torus X.show(aspect_ratio=[1,1,1])

Y=parametric_plot3d([(2+sin(s))sin(tf(s)),cos(s),(2+sin(s))cos(tf(s))],(s,0,2*pi),(t,-1,1)) --- to produce the part of the torus above the z=-2 plane Y.show(aspect_ratio=[1,1,1])

This fails. Any hints? 2 No.2 Revision

Toward a related issue - how do I incorporate such a conditional in a 3d plot? Consider the following.

s,t=var('s,t')
def f(x):
if x<pi: return(arccos(-2="" (2+sin(x))))="" if="" x="">=pi:
x<pi:
return(pi)

return(arccos(-2/(2+sin(x)))) if x>=pi: return(pi)

plot(f,(x,0,2*pi)) --- to check that the function is properly defined

defined

X=parametric_plot3d([(2+sin(s))sin(t),cos(s),(2+sin(s))cos(t)],(s,0,2pi),(t,0,2pi)) X=parametric_plot3d([(2+sin(s))*sin(t),cos(s),(2+sin(s))*cos(t)],(s,0,2*pi),(t,0,2*pi)) --- to produce a torus X.show(aspect_ratio=[1,1,1])

X.show(aspect_ratio=[1,1,1])

Y=parametric_plot3d([(2+sin(s))sin(tf(s)),cos(s),(2+sin(s))cos(tf(s))],(s,0,2*pi),(t,-1,1)) Y=parametric_plot3d([(2+sin(s))*sin(t*f(s)),cos(s),(2+sin(s))*cos(t*f(s))],(s,0,2*pi),(t,-1,1)) --- to produce the part of the torus above the z=-2 plane Y.show(aspect_ratio=[1,1,1])

Y.show(aspect_ratio=[1,1,1])

This fails. Any hints?