Ask Your Question

MathLynx's profile - activity

2012-01-29 18:58:41 +0200 answered a question plot issue with a self-defined piecewise function

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,2*pi),(t,0,2*pi))  --- to produce a torus
X.show(aspect_ratio=[1,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])

This fails. Any hints?