Let's take an example from Chapter 8 and make it interactive. Run the following code in a worksheet:
var('x,y') @interact def _(c1 = slider(vmin=0, vmax=3, default=2, label='c1:'), c2 = slider(vmin=-3, vmax=3, default=1, label='c2:'), c3 = slider(vmin=-3, vmax=3, default=1, label='c3:'), c4 = slider(vmin=0, vmax=3, default=2, label='c4:')): c=vector(RDF,[-4,-5]) G=matrix(RDF,[[c1,c2],[c3,c4],[-1,0],[0,-1]]) h=vector(RDF,[3,3,0,0]) sol=linear_program(c,G,h) print "Minimum:" + str(sol['x']) print "Slack variables: " + str(sol['s']) c1_plot = implicit_plot(c1*x + c2*y ==3, (x,0,6), (y,0,6)) c2_plot = implicit_plot(c3*x + c4*y == 3, (x,0,6), (y,0,6)) c3_plot = implicit_plot(x == 0, (x,0,6), (y,0,6)) c4_plot = implicit_plot(y == 0, (x,0,6), (y,0,6)) min_plot = point(sol['x'], color='red', size=50) rp = region_plot([c1*x + c2*y <= 3, c3*x + c4*y <...