gives a matrix that corresponds to an exponential kernel of radius r.


gives a matrix corresponding to an exponential kernel with radius r and region of support specified by σ.


gives a matrix formed from the n1^(th) derivative of the exponential with respect to rows and the n2^(th) derivative with respect to columns.


gives a matrix formed from the sums of the ni1 and ni2 derivatives.


gives an array corresponding to an exponential kernel with radius ri in the i^(th) index direction.

Details and Options

  • ShenCastanMatrix[{r,σ}] gives values proportional to  exp(-TemplateBox[{x}, Abs]/b) at x index positions from the center, where b is proportional to σ, so that a value of σ=r/2 gives approximately 95% of the total area under the exponential.
  • ShenCastanMatrix[r] uses .
  • By default, the elements of ShenCastanMatrix[r] sum to 1.
  • ShenCastanMatrix[,{n1,n2}] constructs derivatives as finite differences.
  • ShenCastanMatrix[{Automatic,σ,f},] constructs a matrix just large enough to include at least a fraction f of the discrete integral of an exponential in each direction.
  • Any of the r, σ, and f can be lists, specifying different values for different directions.
  • For integer r, ShenCastanMatrix[r,] yields a × matrix.
  • For noninteger r, the value of r is effectively rounded to an integer.
  • The following options can be specified:
  • Standardized Truewhether to rescale and shift the matrix to account for truncation
    WorkingPrecision Automaticthe precision with which to compute matrix elements
  • With Standardized->True, the elements of ShenCastanMatrix[r] will sum to 1. However, the elements of ShenCastanMatrix[r,{n1,n2,}] with at least one nonzero ni will sum to 0, and the sum of the elements, weighted in each direction by times the distance from the origin to the power of ni, will be 1.


open allclose all

Basic Examples  (3)

Exponential matrix of radius 20:

MatrixPlot of an exponential matrix:

1D exponential vector:

Scope  (3)

Derivative of the Exponential  (3)

First derivative of a 1D exponential vector:

First derivative of an exponential matrix in the vertical dimension:

First derivative of a 3D exponential array:

Options  (5)

Standardized  (3)

A normalized exponential matrix:

An unnormalized exponential matrix:

The total of the unnormalized matrix approaches 1 as the ratio of its size to its region of support increases:

Normalized exponential derivative vector will have a mean of 0:

Mean of an unnormalized exponential derivative vector:

A shifted exponential derivative is also normalized:

Unnormalized exponential derivative:

WorkingPrecision  (2)

Generate an exact symbolic exponential matrix:

A machine-precision exponential matrix:

A machine-precision exponential vector:

A high-precision exponential vector:

Properties & Relations  (1)

The derivative is computed using a finite difference:

Wolfram Research (2012), ShenCastanMatrix, Wolfram Language function, (updated 2015).


Wolfram Research (2012), ShenCastanMatrix, Wolfram Language function, (updated 2015).


Wolfram Language. 2012. "ShenCastanMatrix." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015.


Wolfram Language. (2012). ShenCastanMatrix. Wolfram Language & System Documentation Center. Retrieved from


@misc{reference.wolfram_2024_shencastanmatrix, author="Wolfram Research", title="{ShenCastanMatrix}", year="2015", howpublished="\url{}", note=[Accessed: 14-June-2024 ]}


@online{reference.wolfram_2024_shencastanmatrix, organization={Wolfram Research}, title={ShenCastanMatrix}, year={2015}, url={}, note=[Accessed: 14-June-2024 ]}