Ask Your Question

Revision history [back]

using @interact

I have this code which works just fine and produces an image: var('u') center(x) =sqrt(x) spin(x) = 2- 1/4 * x^2 r(x) = abs(spin(x) - center(x)) parametric_plot3d((x, r(x)sin(u)+center(x), r(x)cos(u)), (u, 0, 2*pi), (x, 0, 2), mesh=True)

However, I would like to use a @interact to be able to change the functions named center and spin. I tried this (and a few variations) @interact def _(center =6 -x^2, spin = x): var('u') var('t')
r(x) = abs(spin(x) - center(x)) parametric_plot3d((t, r(t)sin(u)+center(x=t), r(t)cos(u)), (u, 0, 2*pi), (t, 0, 2), mesh=True)

and while I don't get an error, I also don't get a picture for some reason. Any suggestions?

click to hide/show revision 2
No.2 Revision

using @interact

I have this code which works just fine and produces an image: image:

var('u') 
center(x) =sqrt(x) 
spin(x) = 2- 1/4 * x^2 
r(x) = abs(spin(x) - center(x)) 
parametric_plot3d((x, r(x)sin(u)+center(x), r(x)cos(u)), r(x)*sin(u)+center(x), r(x)*cos(u)), (u, 0, 2*pi), (x, 0, 2), mesh=True)

mesh=True)

However, I would like to use a @interact to be able to change the functions named center and spin. I tried this (and a few variations) variations)

@interact
def _(center =6 -x^2, spin = x):
  var('u')
  var('t') 
r(x) = abs(spin(x) - center(x)) parametric_plot3d((t, r(t)sin(u)+center(x=t), r(t)cos(u)), r(t)*sin(u)+center(x=t), r(t)*cos(u)), (u, 0, 2*pi), (t, 0, 2), mesh=True)

mesh=True)

and while I don't get an error, I also don't get a picture for some reason. Any suggestions?