Ask Your Question
0

My error with @interact

asked 2020-05-22 16:26:55 +0100

Cyrille gravatar image

updated 2020-05-23 08:01:14 +0100

FrédéricC gravatar image

I suppose it's not the custom to reuse a question, but the precedent was not a problem with Sagemath but with my computer

Here is a true question due to my incompetence. The following code leads onlys to the slider not the display of the function.

p, D, w_0, x, I = var('p, D, w_0, x, I')
β = var('beta')
π = var('pi') 
w00=8 
D1=6
p1=0.5

A = matrix(SR, 2, 2, [[w_0, 1],[w_0-π,1]])
y = vector([w_0-D, w_0-D-π+I])
sol=A.solve_right(y)
sola=sol[0].full_simplify().function(D, π, w_0)
solb=sol[1].full_simplify().function(D, π, I, w_0)
f=(sola*x + solb).function(x, D, π, I, w_0)
g=f(x, D, β*I*(1-p), I, w_0).factor().collect(x).simplify().function(x, D, β, p, w_0)
show(g(x,D1,β,p1,w00))
@interact
def _(β=slider(1,5, step_size=1)):
    s1sol=solve(g(x,D1,β,p1,w00)==x, x)
    intersect2=s1sol[0].rhs()
    glou=plot(g(x,D1,β,p1,w00),(x, intersect2,w00))
    glou+=circle((intersect2,intersect2), .075, fill=True, edgecolor='red', facecolor='red')
    glou+=arc((w00,w00-D1),1.75,1.75,0,(3.14/2+3.14/4,3.14), linestyle="--", color="green")
    glou

What do I do wrong ?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2020-05-22 18:35:53 +0100

tmonteil gravatar image

You should ask the function to actually do something, so replace glou+plccp with show(glou+plccp). By the way, plccp is not defined in your code.

edit flag offensive delete link more

Comments

Yes of course. I will erase plccp since it add nothing to the question. Thanks

Cyrille gravatar imageCyrille ( 2020-05-22 19:01:24 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-05-22 16:26:55 +0100

Seen: 399 times

Last updated: May 23 '20