@interact causes working program to err
The following code segment works well in sagenb.com until the @interact is put in to permit varying variables a and b. Then a long error is thrown, ending with
"self.loc = (float(center[0]), float(center[1]), float(center[2]))
TypeError: 'sage.symbolic.expression.Expression' object does not support
indexing"
The issue is the statement found near the end that says
G+=point((x,y), color='red',pointsize=4)
If that statement is commented out, then it runs again, although and of course the desired plot is not obtained. Why? What can i do about it?
Clearly you won't let me show you by uploading the file. I am posting what i can.
def Pxy(s,a,b):
x=var('q')
EQ1=s==(a*(sqrt(1+b^2))*e^(b*q))/b
theta=solve([EQ1],q)
x=a*cos(theta[0].rhs())*e^(b*theta[0].rhs())
y=a*sin(theta[0].rhs())*e^(b*theta[0].rhs())
return theta,x,y
def morestuff(a,b):
L=[]
t=var('t')
G=parametric_plot((a*cos(t)*e^(b*t),a*sin(t)*e^(b*t)),(t,0,3*pi),rgbcolor=hue(0.6),figsize=5,axes=True)
for i in range(1,20):
i=i/2
q,x,y=Pxy(7,a,b)
L.append([x.n(),y.n(),q[0].rhs().n()])
#create a list of x,y,q pairs.
G+=point((x,y), color='red',pointsize=4)
G.show(figsize=4)
@interact
def putvariables(a = slider(range(1,200), default = 97),b = slider(range(100), default = 38) ):
a=a/100
b=b/100
morestuff(a,b)