Ask Your Question

Revision history [back]

When you pass g(x) as an argument, since g is a Python function, it tries to evaluate the function. It then can't tell whether x<0, so it returns 1. You could instead change the call to plot_vector_field to use the lambda x,y: g(x) construction. Since plot_vector_field expects two functions as input, let's use the same function twice, once with x and once with y:

plot_vector_field((lambda x, y: g(x), lambda x,y: g(y)), (x,-1,1),(y,-1,1))