The Curl
1 Set-Up
Since we will be working with vectors, we will do our usual set-up routine. This time we will
also include the @ helper from the section on the gradient:
(%i10) |
load("vect")$ mag(u):=sqrt(u.u)$ hat(u):=u/mag(u)$ infix("##")$ u ## v := express(u~v)$ prefix("@")$ @E := ev(express(E),diff)$ i:[1,0,0]$ j:[0,1,0]$ k:[0,0,1]$ |
2 Intro to curl()
The "vect" library has a built-in curl() function that takes vector fields and applies the curl.
But just like the gradient, it returns a high-level symbolic object. Let's start by defining a vector
field:
(%i11) | F:[z^2,x^2,y^2]; |
Now we will attempt to take its curl:
(%i12) | curl(F); |
Alright, so we've hit the same road-block that we did when working with grad(). Let's try to express the above:
(%i13) | express(curl(F)); |
Yes! That's the curl alright! But it needs to be evaluated for the the derivatives. Let's do that too:
(%i14) | ev(express(curl(F)),diff); |
Aha! We got it! But again, we don't want to keep typing ev(express(curl(F)),diff) every time we want a curl!
That would get really messy. That's where our @ helper comes in!
(%i15) | @curl(F); |
So when we want our curl(F) we just prepend it with @ to do the heavy lifting under the hood!
3 Examples
(%i16) | kill(F); |
(%i18) |
F(x,y,z):=[exp(x+y+z),cos(x*z),sin(z)]; @curl(F(x,y,z)); |
Notice that since we defined F(x,y,z) to be a vector valued *function* we must write F(x,y,z) in curl()
to get the correct output. Otherwise:
(%i19) | @curl(F); |
(%i20) | kill(F); |
Let's catch the curl as a new vector field:
(%i22) |
F:[exp(x+y+z),sqrt(x-z),log(x)]; define(curlF(x,y,z),@curl(F)); |
Now we can work with curlF at our leisure. For example:
(%i24) | curlF(2,0,1);curlF(2*a,-3*a,a); |
(%i25) | kill(F); |
If we have defined i, j, and k (as we did in the set-up), then we can use them exactly as one would expect:
(%i28) | @curl(exp(x+y+z)*i+y^3*j); |
4 2D curl()
What happens if our vector field is in R^2? Let's see:
(%i26) | @curl([3*y^2,2*x^2]); |
Hmmm... the result is a scalar. Let's look more closely at that scalar:
(%i27) | express(curl([F[1],F[2]])); |
Aha! Just as in the case of cross product of two 2-vectors, the curl is yielding the coefficient of the k component
of the vector. To avoid this, we could either be careful to define 3D vectorfields with z-components 0 like so:
(%i29) | @curl([3*y^2,2*x^2,0]); |
Or we could use the i,j,k vectors that we defined in the set-up:
(%i30) | @curl(3*y^2*i+2*x^2*j); |
Or even still, we could simply throw the 2D curl onto the k vector:
(%i31) | @curl([3*y^2,2*x^2])*k; |
In any case, special care must be taken when curl-ing 2D vector fields.
(%i33) | kill(F); |
5 Intro to div()
Just like grad() and curl(), div() must be expressed and evaluated. So we will use @ to help with this.
Let's walk through the chain just to see what div() is doing:
(%i35) |
div([F[1],F[2],F[3]]); express(%); |
So we see that div() returns a high-level symbolic object which we then express. After expression
we must then evaluate the derivatives. Again: @ to the rescue:
(%i37) | @div([x^2,y^3,z^4]); |
Let's catch a divergence as a scalar function:
(%i41) |
F:[x^2,y^3,z^4]; define(f(x,y,z),@div(F)); |
(%i42) | kill(f,F); |
(%i47) |
F(x,y,z):=[cos(x),sin(x+y),tan(z)]; @div(F(x,y,z)); trigexpand(%); |
Let's see what div() does with 2D vector fields:
(%i48) | @div([x^2,y^3]); |
Looks like div() simply isn't defined for 2D vector fields. This makes some sense: think back to class,
when did we ever compute div() of a 2D vector field?
6 Other Variables?
What happens if we attempt a curl() or a div() on a field with variables other than x,y, or z?
(%i51) | @curl([s,t,u]);@div([s,t,u]); |
As in the case of grad(), s,t, and u don't mean anything to curl() and div() and so they are treated as constants.
We can get around this by swapping in x,y,z and then swapping back out like so:
(%i71) |
F:[t^2,s^2,0]; subst([s=x,t=y],F)$ @curl(%)$ subst([x=s,y=t],%); |
(%i72) | kill(F); |
(%i87) |
F:[s^3,t^4,u^5]; subst([s=x,t=y,u=z],F)$ @div(%)$ subst([x=s,y=t,z=u],%)$ define(divF(s,t,u),%); |