This slider never stops on the optimal vertex of the feasible region

asked 2020-09-23 01:05:31 -0500

Cyrille gravatar image

updated 2020-09-24 00:13:07 -0500

I changed the question. This slider seems to work perfectly to the point that it theline doesnt change its aspect in z1. I wonder why? It' borring since I would like to add some dash lines and commentary (labels, values..) in the cas where it is exactly at this value.

  var('x') # ne pas oublier de définir une variable avant de l'utiliser.
f(x) = (3/2) - (1/2)*x
g(x) = (11/2) - 2*x
h(x) = -1 + x
gr = plot(f(x), (x, 0, 3),thickness=1.5, color="#4b59ea",legend_label='$f(x)=\\frac{3}{2} - \\frac{1}{2}x$')
gr+= plot(g(x), (x, 0, 3),thickness=1.5, color="#e52411",legend_label='$g(x)=\\frac{11}{2} - 2x$')
gr+= plot(h(x), (x, 0, 3),thickness=1.5, color="#2ea012",legend_label='$h(x)=-1 + x$')
fs1=solve(f(x) == h(x), x)
fs2=solve(f(x) == g(x), x)
fs3=solve(f(x) == 0, x)
gs1=solve(g(x) == h(x), x)
gs2=solve(g(x) == f(x), x)
gs3=solve(g(x) == 0, x)
hs1=solve(h(x) == 0,x)
c=[circle(x, .05,fill=true,edgecolor='#ff9933', facecolor='#ff9933') for x in pint]
z1=solve(f(gs2[0].rhs())==z - (0.3333) *gs2[0].rhs(),z)[0].rhs()
def _(z=slider(z1-(5*0.1),z1+(5*0.1),step_size=0.333333)):
    if z!=z1:
        zplot=plot(z - (0.3333) *x, (x, 0,5),color="#4b26ea",linestyle='-.')
    elif z==z1:
        zplot=plot(z - (0.3333) *x, (x, 0,5),color="#4b26ea",linestyle='--')    
edit retag flag offensive close merge delete