# Untitled

## 1118 days ago by pub

Here we give 2 examples of 2D vector fields that are NOT the gradient field of some function.

1. $\vec F_1= \, <-y,x>$

2. $\vec F_2= \, <sin(y),cos(x)>$

Notice that both fields "show" rotation (curl). At the bottom, we show that the $curl(\vec F) \ne 0$

var ('x y') F1=vector([-y,x]) view(F1)
V1=plot_vector_field(F1,(x,-2,2),(y,-2,2), color='red') show(V1,aspect_ratio=1,figsize=4)
var ('x y') F2=vector([sin(y),cos(x)]) view(F2)
V2=plot_vector_field(F2,(x,-2*pi,2*pi),(y,-2*pi,2*pi), color='blue') show(V2,aspect_ratio=1,figsize=4)

We define the divergence and curl operators. Because we have 2D vector fields, we just set the z-component = 0 to get 3D vector fields. Credit

var ('x y z') def divergence(F): assert(len(F) == 3) return diff(F[0],x) + diff(F[1],y) + diff(F[2],z) def curl(F): assert(len(F) == 3) return vector([diff(F[2],y)-diff(F[1],z), diff(F[0],z)-diff(F[2],x), diff(F[1],x)-diff(F[0],y)])
F1=vector([-y,x,0]) curl(F1)
 (0, 0, 2) (0, 0, 2)
F2=vector([sin(y),cos(x),0]) curl(F2)
 (0, 0, -sin(x) - cos(y)) (0, 0, -sin(x) - cos(y))

Notice that the curl in the $\vec k$ -direction is non-zero in both cases.