222 - Topic 19.5 - Conservative Vector Fields 2D

488 days ago by Professor222

# Drawing a conservative vector field by giving the potential function first. var('x,y') @interact def _(f = input_box(default=sin(x)*cos(y),label='Potential function $f(x)=$')): fx = derivative(f,x) fy = derivative(f,y) H = contour_plot(f, (x, -4, 4), (y, -4, 4),plot_points=200,cmap='cool') H += plot_vector_field((fx,fy), (x,-4,4), (y,-4,4),color='green') H.show() 
Potential function $f(x)=$ 

Click to the left again to hide and once more to show the dynamic interactive window