Vector fields are used to represent force fields such as electromagnetic fields, and are used to visualize the solutions of differential equations. Sage has a special plotting function to visualize vector fields.
var('x, y') a = plot_vector_field((x, y), (x, -3, 3), (y, -3, 3), color='blue') b = plot_vector_field((y, -x), (x, -3, 3), (y, -3, 3), color='red') show(a + b, aspect_ratio=1, figsize=(4, 4))
You should get the following image:
The p
lot_vector_field
function uses the following syntax:
plot_vector_field((x_function,y_function), (x,x_min,x_max), (y,y_min,y_max))
The keyword argument color
specifies the color of the vectors.