Hermite polynomials are obtained by differentiation of the Gaussian kernel:
$$H_{\nu}(x,\Sigma) = exp \Bigl( \frac{1}{2} x_i \Sigma_{ij} x_j \Bigl) (- \partial_x )^\nu exp \Bigl( -\frac{1}{2} x_i \Sigma_{ij} x_j \Bigl)$$
where Σ is a d-dimensional square matrix and ν = (ν1…νd) is the vector representing the order of differentiation for each variable x = (x1…xd). In the case where Σ = 1 and x = x1 the formula reduces to the standard univariate Hermite polynomials:
$$ H_{\nu}(x) = e^{\frac{x^2}{2}}(-1)^\nu \frac{d^\nu}{dx^\nu}e^{-\frac{x^2}{2}} $$
The function hermite
generates recursively all the Hermite polynomials of degree ν′ where |ν′| ≤ |ν|. The output is a
list
of Hermite polynomials of degree ν′, where each polynomial is
described as a list
containing the character
representing the polynomial, the order of the polynomial, and a
data.frame
containing the variables, coefficients and
degrees of each term in the polynomial.
In the univariate case, for ν = 2:
hermite(order = 2)
#> $`0`
#> $`0`$f
#> [1] "(1) * 1"
#>
#> $`0`$order
#> [1] 0
#>
#> $`0`$terms
#> var coef degree
#> 0 1 1 0
#>
#>
#> $`1`
#> $`1`$f
#> [1] "(1) * x^1"
#>
#> $`1`$order
#> [1] 1
#>
#> $`1`$terms
#> var coef degree
#> 0 1 0 0
#> 1 x^1 1 1
#>
#>
#> $`2`
#> $`2`$f
#> [1] "(-1) * 1 + (1) * x^2"
#>
#> $`2`$order
#> [1] 2
#>
#> $`2`$terms
#> var coef degree
#> 0 1 -1 0
#> 1 x^1 0 1
#> 2 x^2 1 2
In the multivariate case, where for simplicity Σij = δij, x = (x1, x2), and |ν| = 2:
hermite(order = 2, sigma = diag(2), var = c("x1", "x2"))
#> $`0,0`
#> $`0,0`$f
#> [1] "(1) * 1"
#>
#> $`0,0`$order
#> [1] 0
#>
#> $`0,0`$terms
#> var coef degree
#> 0,0 1 1 0
#>
#>
#> $`0,1`
#> $`0,1`$f
#> [1] "(1) * x2^1"
#>
#> $`0,1`$order
#> [1] 1
#>
#> $`0,1`$terms
#> var coef degree
#> 0,0 1 0 0
#> 0,1 x2^1 1 1
#> 1,0 x1^1 0 1
#>
#>
#> $`1,0`
#> $`1,0`$f
#> [1] "(1) * x1^1"
#>
#> $`1,0`$order
#> [1] 1
#>
#> $`1,0`$terms
#> var coef degree
#> 0,0 1 0 0
#> 0,1 x2^1 0 1
#> 1,0 x1^1 1 1
#>
#>
#> $`0,2`
#> $`0,2`$f
#> [1] "(-1) * 1 + (1) * x2^2"
#>
#> $`0,2`$order
#> [1] 2
#>
#> $`0,2`$terms
#> var coef degree
#> 0,0 1 -1 0
#> 0,1 x2^1 0 1
#> 1,0 x1^1 0 1
#> 0,2 x2^2 1 2
#> 2,0 x1^2 0 2
#> 1,1 x1^1*x2^1 0 2
#>
#>
#> $`2,0`
#> $`2,0`$f
#> [1] "(-1) * 1 + (1) * x1^2"
#>
#> $`2,0`$order
#> [1] 2
#>
#> $`2,0`$terms
#> var coef degree
#> 0,0 1 -1 0
#> 0,1 x2^1 0 1
#> 1,0 x1^1 0 1
#> 0,2 x2^2 0 2
#> 2,0 x1^2 1 2
#> 1,1 x1^1*x2^1 0 2
#>
#>
#> $`1,1`
#> $`1,1`$f
#> [1] "(1) * x1^1*x2^1"
#>
#> $`1,1`$order
#> [1] 2
#>
#> $`1,1`$terms
#> var coef degree
#> 0,0 1 0 0
#> 0,1 x2^1 0 1
#> 1,0 x1^1 0 1
#> 0,2 x2^2 0 2
#> 2,0 x1^2 0 2
#> 1,1 x1^1*x2^1 1 2
If transform
is not NULL
, the variables
var
x are
replaced with transform
f(x) to compute the
polynomials Hν(f(x), Σ).
For example:
$$ f(x_1,x_2)= \begin{bmatrix} x_1+x_2,x_1-x_2 \end{bmatrix} $$
hermite(order = 2, sigma = diag(2), var = c("x1", "x2"), transform = c('x1+x2','x1-x2'))
#> $`0,0`
#> $`0,0`$f
#> [1] "(1) * 1"
#>
#> $`0,0`$order
#> [1] 0
#>
#> $`0,0`$terms
#> var coef degree
#> 0,0 1 1 0
#>
#>
#> $`0,1`
#> $`0,1`$f
#> [1] "(-1) * x2^1 + (1) * x1^1"
#>
#> $`0,1`$order
#> [1] 1
#>
#> $`0,1`$terms
#> var coef degree
#> 0,0 1 0 0
#> 0,1 x2^1 -1 1
#> 1,0 x1^1 1 1
#>
#>
#> $`1,0`
#> $`1,0`$f
#> [1] "(1) * x2^1 + (1) * x1^1"
#>
#> $`1,0`$order
#> [1] 1
#>
#> $`1,0`$terms
#> var coef degree
#> 0,0 1 0 0
#> 0,1 x2^1 1 1
#> 1,0 x1^1 1 1
#>
#>
#> $`0,2`
#> $`0,2`$f
#> [1] "(-1) * 1 + (1) * x2^2 + (1) * x1^2 + (-2) * x1^1*x2^1"
#>
#> $`0,2`$order
#> [1] 2
#>
#> $`0,2`$terms
#> var coef degree
#> 0,0 1 -1 0
#> 0,1 x2^1 0 1
#> 1,0 x1^1 0 1
#> 0,2 x2^2 1 2
#> 2,0 x1^2 1 2
#> 1,1 x1^1*x2^1 -2 2
#>
#>
#> $`2,0`
#> $`2,0`$f
#> [1] "(-1) * 1 + (1) * x2^2 + (1) * x1^2 + (2) * x1^1*x2^1"
#>
#> $`2,0`$order
#> [1] 2
#>
#> $`2,0`$terms
#> var coef degree
#> 0,0 1 -1 0
#> 0,1 x2^1 0 1
#> 1,0 x1^1 0 1
#> 0,2 x2^2 1 2
#> 2,0 x1^2 1 2
#> 1,1 x1^1*x2^1 2 2
#>
#>
#> $`1,1`
#> $`1,1`$f
#> [1] "(-1) * x2^2 + (1) * x1^2"
#>
#> $`1,1`$order
#> [1] 2
#>
#> $`1,1`$terms
#> var coef degree
#> 0,0 1 0 0
#> 0,1 x2^1 0 1
#> 1,0 x1^1 0 1
#> 0,2 x2^2 -1 2
#> 2,0 x1^2 1 2
#> 1,1 x1^1*x2^1 0 2
Guidotti E (2022). “calculus: High-Dimensional Numerical and Symbolic Calculus in R.” Journal of Statistical Software, 104(5), 1-37. doi:10.18637/jss.v104.i05
A BibTeX entry for LaTeX users is