Computes the numerical curl of functions
or the symbolic curl of characters
in arbitrary orthogonal coordinate systems.
curl( f, var, params = list(), coordinates = "cartesian", accuracy = 4, stepsize = NULL, drop = TRUE ) f %curl% var
f  array of 

var  vector giving the variable names with respect to which the derivatives are to be computed and/or the point where the derivatives are to be evaluated. See 
params 

coordinates  coordinate system to use. One of: 
accuracy  degree of accuracy for numerical derivatives. 
stepsize  finite differences stepsize for numerical derivatives. It is based on the precision of the machine by default. 
drop  if 
Vector for vectorvalued functions when drop=TRUE
, array
otherwise.
The curl of a vectorvalued function \(F_i\) at a point is represented by a
vector whose length and direction denote the magnitude and axis of the maximum
circulation.
In 2 dimensions, the curl
is computed in arbitrary orthogonal coordinate
systems using the scale factors \(h_i\) and the LeviCivita symbol epsilon
:
$$\nabla \times F = \frac{1}{h_1h_2}\sum_{ij}\epsilon_{ij}\partial_i\Bigl(h_jF_j\Bigl)= \frac{1}{h_1h_2}\Biggl(\partial_1\Bigl(h_2F_2\Bigl)\partial_2\Bigl(h_1F_1\Bigl)\Biggl)$$
In 3 dimensions:
$$(\nabla \times F)_k = \frac{h_k}{J}\sum_{ij}\epsilon_{ijk}\partial_i\Bigl(h_jF_j\Bigl)$$
where \(J=\prod_i h_i\). In \(m+2\) dimensions, the curl
is implemented in such
a way that the formula reduces correctly to the previous cases for \(m=0\) and \(m=1\):
$$(\nabla \times F)_{k_1\dots k_m} = \frac{h_{k_1}\cdots h_{k_m}}{J}\sum_{ij}\epsilon_{ijk_1\dots k_m}\partial_i\Bigl(h_jF_j\Bigl)$$
When \(F\) is an array
of vectorvalued functions \(F_{d_1,\dots,d_n,j}\) the curl
is computed for each vector:
$$(\nabla \times F)_{d_1\dots d_n,k_1\dots k_m} = \frac{h_{k_1}\cdots h_{k_m}}{J}\sum_{ij}\epsilon_{ijk_1\dots k_m}\partial_i\Bigl(h_jF_{d_1\dots d_n,j}\Bigl)$$
%curl%
: binary operator with default parameters.
Guidotti, E. (2020). "calculus: High dimensional numerical and symbolic calculus in R". https://arxiv.org/abs/2101.00086
Other differential operators:
derivative()
,
divergence()
,
gradient()
,
hessian()
,
jacobian()
,
laplacian()
#> [1] "(1) * 1 + (x^3 * (2 * y)) * 1"### numerical curl of a 2d vector field in (x=1, y=1) f < function(x,y) c(x^3*y^2, x) curl(f, var = c(x=1, y=1))#> [1] 1### numerical curl of a 3d vector field in (x=1, y=1, z=1) f < function(x,y,z) c(x^3*y^2, x, z) curl(f, var = c(x=1, y=1, z=1))#> [1] 0 0 1#> [1] 0 0 1### symbolic array of vectorvalued 3d functions f < array(c("x*y","x","y*z","y","x*z","z"), dim = c(2,3)) curl(f, var = c("x","y","z"))#> [,1] [,2] [,3] #> [1,] "(y) * 1" "(z) * 1" "(x) * 1" #> [2,] "0" "0" "0"### numeric array of vectorvalued 3d functions in (x=1, y=1, z=1) f < function(x,y,z) array(c(x*y,x,y*z,y,x*z,z), dim = c(2,3)) curl(f, var = c(x=1, y=1, z=1))#> [,1] [,2] [,3] #> [1,] 1 1 1 #> [2,] 0 0 0#> [1] "(y) * 1" "(z) * 1" "(x) * 1"