%mathpiper,def="Curl"

Rulebase("Curl", {aFunc, aBasis});

Rule("Curl", 2, 1, Length(aBasis)=Length(aFunc))
	{
		Apply("Differentiate",{aBasis[2],aFunc[3]})-Apply("Differentiate",{aBasis[3],aFunc[2]}),
		Apply("Differentiate",{aBasis[3],aFunc[1]})-Apply("Differentiate",{aBasis[1],aFunc[3]}),
		Apply("Differentiate",{aBasis[1],aFunc[2]})-Apply("Differentiate",{aBasis[2],aFunc[1]})
	};

%/mathpiper



%mathpiper_docs,name="Curl",categories="User Functions;Calculus Related (Symbolic)"
*CMD Curl --- curl of a vector field
*STD
*CALL
	Curl(vector, basis)

*PARMS

{vector} -- vector field to take the curl of

{basis} -- list of variables forming the basis

*DESC

This function takes the curl of the vector field "vector" with
respect to the variables "basis". The curl is defined in the usual way,

	Curl(f,x) = {
	    Differentiate(x[2]) f[3] - Differentiate(x[3]) f[2],
	    Differentiate(x[3]) f[1] - Differentiate(x[1]) f[3],
	    Differentiate(x[1]) f[2] - Differentiate(x[2]) f[1]
	}
Both "vector" and "basis" should be lists of length 3.

*E.G.

In> Curl({x*y,x*y,x*y},{x,y,z})
Result: {x,-y,y-x};

*SEE D, Diverge
%/mathpiper_docs