Ask Your Question

Revision history [back]

The def line following @interact needs to contain the variables being changed, not the function of the variables. Here's a modified version of your code that produces the expected output:

@interact
def myplot(c_repulsion=(0.1,1), epsilon=(.1,1)):
    var('d')
    f = (c_repulsion / (epsilon + abs(d))^2) * (d / abs(d))
    show(plot(f, (d,-10, 10), ymin=-2, ymax=2, detect_poles=true))

I've added ymin and ymax to prevent the area around the origin from controlling the appearance of the plot too much, and detect_poles to remove the blue line on the y-axis.

Here's a live example of the code.