This site is supported by donations to The OEIS Foundation.

# Kronecker delta

The Kronecker delta function compares (usually discrete) values and returns 1 if they are all the same, otherwise it returns 0. Put another way, if all the differences of the arguments are 0, then the function returns 1.

Despite the Greek letter and all the difficult-sounding talk of tensors, vectors and identity matrices that often surrounds the Kronecker delta, it is really just an equality test, as the following examples will hopefully make clear:

 δ  4747  =  1
 δ  172947  =  0
 δ  e i  π−1  =  1
δ7,  2 3 − 1,
 21 3
=  1
 δ  sin (2017  5√  2 )−1  =  0

(Though the last example requires greater precision than is available on most calculators to resolve correctly).

Note however that some mathematicians and physicists consider the function’s arguments to be limited to rational integers, which makes sense given Leopold Kronecker’s famous remark that “The whole numbers dear God made, all else is man’s work.”

## Formulae

### Univariate Kronecker delta

The univariate Kronecker delta
 δn   ≡   0 | n |
function returns 1 if
 n = 0
, otherwise returns 0, where we used the property of powers of 0. (See: A000007 The characteristic function of 0.)
${\begin{array}{l}\displaystyle {0^{x}={\begin{cases}1&{\text{if }}x=0,\\0&{\text{if }}x>0.\end{cases}}}\end{array}}$ Under this definition, then,
 δx = 0  x
.

### Bivariate Kronecker delta

The bivariate Kronecker delta$\textstyle {\delta _{i}^{j}\equiv \delta _{i-j}=0^{\vert i-j\vert }}$ function returns 1 if
 i  −  j = 0
, 0 otherwise. This is the original Kronecker delta function, returning 1 if
 i
and
 j
are equal or 0 if they are different (hence delta).

The formula can also be given as

${\begin{array}{l}\displaystyle {\delta _{i}^{j}=1-(\operatorname {sgn}(i-j))^{2}=(1+\operatorname {sgn}(i-j))(1-\operatorname {sgn}(i-j))=1-\vert \operatorname {sgn}(i-j)\vert ,}\end{array}}$ where
 sgn (x)
is the sign function (the signum function) of
 x
.

### Multivariate Kronecker delta

The multivariate Kronecker delta$\textstyle {\delta _{i_{0},\,\ldots ,\,i_{n}}}$ function returns 1 if all the value differences are 0, otherwise returns 0.

It may be expressed using the following formula:

δi0 ,  ..., in  =
 n − 1 ∏ k  = 0

δik  + 1ik  =  0[
 n − 1

 k  = 0
|  ik  −  ik  + 1 |
]
.
The two variable case of the multivariate Kronecker delta gives the alternate notation
 δi, j
(or
 δi j
if there is no ambiguity) for
 δ    ji
.

## Implementations

If we map the binary integers {0, 1} to the Boolean binary logic values {False, True} respectively, then the Kronecker delta function applied to the binary integers is isomorphic to the equivalence operation (accomplished with an XNOR gate) applied to the Boolean binary logic values. In some implementations of C or C++, it may be possible to implement the Kronecker delta by the simple act of "casting" the result of an equality comparison to an integer or any numeric data type; but in other implementations only False is specifically tied to 0 while True may be "any value other than zero." Therefore the following is not guaranteed to work correctly:

bool kroneckerDelta(int x, int y) {
return (x == y);
}


In Mathematica, KroneckerDelta[i, j] is essentially the same as Boole[i == j] (the former was added in Version 4, the latter in 5.1). Still, there may be some pedagogical value in having students program their own version of the function: Shaw and Tigg, for example, use it to illustrate how Mathematica stores rules. In the following example, these instructions

kDelta[x_, x_] := 1;
kDelta[x_, y_] := 0;


need to be given in this precise order (or forced to this order); if not the function will always return 0 even with both arguments being exactly the same, since the x_, y_ rule "shadows" the x_, x_ rule.

### Issues

Using the Kronecker delta function with nondiscrete (e.g. floating point) values leads to precision limitation issues (Cf. Discussion.) For example, look under "Possible Issues" for Mathematica 7.

## Applications

In the OEIS, the function has been used in connection to matrices (see A132440 and A132710) and ternary words (see A120987).

The Kronecker delta function has applications in many branches of mathematics, such as calculus and analysis, as well as in physics, such as the study of fluid dynamics. In theoretical quantum optics, for example, the Kronecker delta is often used with square matrices
 M
, with
 Mi  j
referring to a specific cell in the matrix
 M
by its row
 i
and column
 j
.

The function can even be used in number theory, making the definitions of some number theoretic functions rather compact, such as the Möbius function:

 μ (n)  =  δ  Ω (n)ω (n) (−1) ω (n).

But depending on your viewpoint, the result is either concise (ADD A CITATION BACKING THIS UP) or confusing. Furthermore, use of the Kronecker delta is prone to allowing mistakes with identity elements to go undetected.