Computes univariate and multivariate Hermite polynomials.

hermite(order, sigma = 1, var = "x", transform = NULL)

Arguments

order

the order of the Hermite polynomial.

sigma

the covariance matrix of the Gaussian kernel.

var

character vector giving the variables of the polynomial.

transform

character vector representing a change of variables. See details.

Value

list of Hermite polynomials with components:

f

the Hermite polynomial.

order

the order of the Hermite polynomial.

terms

data.frame containing the variables, coefficients and degrees of each term in the Hermite polynomial.

Details

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 \(\Sigma\) is a \(d\)-dimensional square matrix and \(\nu=(\nu_1 \dots \nu_d)\) is the vector representing the order of differentiation for each variable \(x = (x_1\dots x_d)\). In the case where \(\Sigma=1\) and \(x=x_1\) 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}}$$

If transform is not NULL, the variables var \(x\) are replaced with transform \(f(x)\) to compute the polynomials \(H_{\nu}(f(x),\Sigma)\)

References

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

See also

Other polynomials: taylor()

Examples

### univariate Hermite polynomials up to order 3
hermite(3)
#> $`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
#> 
#> 
#> $`3`
#> $`3`$f
#> [1] "(-3) * x^1 + (1) * x^3"
#> 
#> $`3`$order
#> [1] 3
#> 
#> $`3`$terms
#>   var coef degree
#> 0   1    0      0
#> 1 x^1   -3      1
#> 2 x^2    0      2
#> 3 x^3    1      3
#> 
#> 

### multivariate Hermite polynomials up to order 2
hermite(order = 2, 
        sigma = matrix(c(1,0,0,1), nrow = 2), 
        var = c('z1', 'z2'))
#> $`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) * z2^1"
#> 
#> $`0,1`$order
#> [1] 1
#> 
#> $`0,1`$terms
#>      var coef degree
#> 0,0    1    0      0
#> 0,1 z2^1    1      1
#> 1,0 z1^1    0      1
#> 
#> 
#> $`1,0`
#> $`1,0`$f
#> [1] "(1) * z1^1"
#> 
#> $`1,0`$order
#> [1] 1
#> 
#> $`1,0`$terms
#>      var coef degree
#> 0,0    1    0      0
#> 0,1 z2^1    0      1
#> 1,0 z1^1    1      1
#> 
#> 
#> $`0,2`
#> $`0,2`$f
#> [1] "(-1) * 1 + (1) * z2^2"
#> 
#> $`0,2`$order
#> [1] 2
#> 
#> $`0,2`$terms
#>           var coef degree
#> 0,0         1   -1      0
#> 0,1      z2^1    0      1
#> 1,0      z1^1    0      1
#> 0,2      z2^2    1      2
#> 2,0      z1^2    0      2
#> 1,1 z1^1*z2^1    0      2
#> 
#> 
#> $`2,0`
#> $`2,0`$f
#> [1] "(-1) * 1 + (1) * z1^2"
#> 
#> $`2,0`$order
#> [1] 2
#> 
#> $`2,0`$terms
#>           var coef degree
#> 0,0         1   -1      0
#> 0,1      z2^1    0      1
#> 1,0      z1^1    0      1
#> 0,2      z2^2    0      2
#> 2,0      z1^2    1      2
#> 1,1 z1^1*z2^1    0      2
#> 
#> 
#> $`1,1`
#> $`1,1`$f
#> [1] "(1) * z1^1*z2^1"
#> 
#> $`1,1`$order
#> [1] 2
#> 
#> $`1,1`$terms
#>           var coef degree
#> 0,0         1    0      0
#> 0,1      z2^1    0      1
#> 1,0      z1^1    0      1
#> 0,2      z2^2    0      2
#> 2,0      z1^2    0      2
#> 1,1 z1^1*z2^1    1      2
#> 
#> 
        
### multivariate Hermite polynomials with transformation of variables
hermite(order = 2, 
        sigma = matrix(c(1,0,0,1), nrow = 2), 
        var = c('z1', 'z2'),
        transform = c('z1+z2','z1-z2'))
#> $`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) * z2^1 + (1) * z1^1"
#> 
#> $`0,1`$order
#> [1] 1
#> 
#> $`0,1`$terms
#>      var coef degree
#> 0,0    1    0      0
#> 0,1 z2^1   -1      1
#> 1,0 z1^1    1      1
#> 
#> 
#> $`1,0`
#> $`1,0`$f
#> [1] "(1) * z2^1 + (1) * z1^1"
#> 
#> $`1,0`$order
#> [1] 1
#> 
#> $`1,0`$terms
#>      var coef degree
#> 0,0    1    0      0
#> 0,1 z2^1    1      1
#> 1,0 z1^1    1      1
#> 
#> 
#> $`0,2`
#> $`0,2`$f
#> [1] "(-1) * 1 + (1) * z2^2 + (1) * z1^2 + (-2) * z1^1*z2^1"
#> 
#> $`0,2`$order
#> [1] 2
#> 
#> $`0,2`$terms
#>           var coef degree
#> 0,0         1   -1      0
#> 0,1      z2^1    0      1
#> 1,0      z1^1    0      1
#> 0,2      z2^2    1      2
#> 2,0      z1^2    1      2
#> 1,1 z1^1*z2^1   -2      2
#> 
#> 
#> $`2,0`
#> $`2,0`$f
#> [1] "(-1) * 1 + (1) * z2^2 + (1) * z1^2 + (2) * z1^1*z2^1"
#> 
#> $`2,0`$order
#> [1] 2
#> 
#> $`2,0`$terms
#>           var coef degree
#> 0,0         1   -1      0
#> 0,1      z2^1    0      1
#> 1,0      z1^1    0      1
#> 0,2      z2^2    1      2
#> 2,0      z1^2    1      2
#> 1,1 z1^1*z2^1    2      2
#> 
#> 
#> $`1,1`
#> $`1,1`$f
#> [1] "(-1) * z2^2 + (1) * z1^2"
#> 
#> $`1,1`$order
#> [1] 2
#> 
#> $`1,1`$terms
#>           var coef degree
#> 0,0         1    0      0
#> 0,1      z2^1    0      1
#> 1,0      z1^1    0      1
#> 0,2      z2^2   -1      2
#> 2,0      z1^2    1      2
#> 1,1 z1^1*z2^1    0      2
#> 
#>