divergence

0th

Percentile

Numerical and Symbolic Divergence

Computes the divergence of functions, expressions and characters.

Usage
divergence(f, var, accuracy = 2, stepsize = NULL,
  coordinates = "cartesian")

f %divergence% var

Arguments
f

function, expression or character array.

var

character vector, giving the variable names with respect to which derivatives will be computed. If a named vector is provided, derivatives will be computed at that point.

accuracy

accuracy degree for numerical derivatives.

stepsize

finite differences stepsize for numerical derivatives. Auto-optimized by default.

coordinates

coordinate system to use. One of: cartesian, polar, spherical, cylindrical, parabolic, parabolic-cylindrical or a character vector of scale factors for each varibale.

Value

divergence array.

Functions

  • divergence: arbitrary coordinate system

  • %divergence%: cartesian coordinates

Aliases
  • divergence
  • %divergence%
Examples
# NOT RUN {
# divergence of a vector field
f <- c('x^2','y^3','z^4')
divergence(f, var = c('x','y','z'))
f %divergence% c('x','y','z')

# numerical divergence of a vector field
f <- c(function(x,y,z) x^2, function(x,y,z) y^3, function(x,y,z) z^4)
divergence(f, var = c('x'=1,'y'=1,'z'=1))
f %divergence% c('x'=1,'y'=1,'z'=1)

# divergence of array of vector fields
f1 <- c('x^2','y^3','z^4')
f2 <- c('x','y','z')
a <- matrix(c(f1,f2), nrow = 2, byrow = TRUE)
divergence(a, var = c('x','y','z'))
a %divergence% c('x','y','z')

# divergence in polar coordinates
f <- c('sqrt(r)/10','sqrt(r)')
divergence(f, var = c('r','phi'), coordinates = 'polar')

# }
Documentation reproduced from package calculus, version 0.1.0, License: GPL-3

Community examples

Looks like there are no examples yet.