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 difficultsounding 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:





(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.”^{[1]}
Formulae
Univariate Kronecker delta
The univariate
Kronecker delta function returns
1 if
, otherwise returns
0, where we used the property of
powers of 0. (See:
A000007 The characteristic function of 0.)
^{[2]}
 ${\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,
.
Bivariate Kronecker delta
The bivariate
Kronecker delta$\textstyle {\delta _{i}^{j}\equiv \delta _{ij}=0^{\vert ij\vert }}$ function returns
1 if
,
0 otherwise.
This is the original
Kronecker delta function, returning
1 if
and
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}(ij))^{2}=(1+\operatorname {sgn}(ij))(1\operatorname {sgn}(ij))=1\vert \operatorname {sgn}(ij)\vert ,}\end{array}}$
where
is the
sign function (the
signum function) of
.
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 = δ ik + 1ik = 0 [  ik − ik + 1  ]. 
The two variable case of the multivariate
Kronecker delta gives the alternate notation
(or
if there is no ambiguity) for
.
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^{[3]}) 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;^{[4]} but in other implementations only False is specifically tied to 0 while True may be "any value other than zero."^{[5]} 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.^{[6]}
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.
^{[7]} In theoretical quantum optics, for example, the Kronecker delta is often used with square matrices
, with
referring to a specific cell in the matrix
by its row
and column
.
^{[8]}
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)} ^{[9]} or confusing.^{[10]} Furthermore, use of the Kronecker delta is prone to allowing mistakes with identity elements to go undetected.^{[11]}
See also
Notes
 ↑ “Die [positiven] ganzen Zahlen hat der liebe Gott gemacht, alles andere ist Menschenwerk”. Thomas Kesselring, Jean Piaget. Munich: C. H. Beck (1999): p. 124. This is usually translated as “God made the integers, all else is the work of man.”
 ↑ WARNING: Treatment of varies among programming languages, symbolic algebra systems, calculators, spreadsheet programs, ... (you may get 0 or undefined instead of 1!) See: The special case of zero to the zeroeth power.
 ↑ Weisstein, Eric W., XNOR, From MathWorldA Wolfram Web Resource.
 ↑ Paul M. Chirlian, Programming in C++. Merrill (1990): p. 67ff
 ↑ Herbert Schildt, C: The Complete Reference 3rd Ed. Osborne McGrawHill (1995) p. 43
 ↑ William T. Shaw & Jason Tigg, Applied Mathematica: Getting Started, Getting It Done. Reading, Mass: AddisonWesley Publishing Company (1994): 212—213
 ↑ G. Emanuel, Analytical Fluid Dynamics. Boca Raton, Florida: CRC Press (2001): p. 7, equation 1.12.
 ↑ Stephen M. Barnett & Paul M. Radmore, Methods in theoretical quantum optics. Oxford: Oxford University Press (2003): Appendix 1, p. 222 forward.
 ↑ To do: ADD A CITATION BACKING THIS UP.
 ↑ Peter Luschny, Notation Matters.
 ↑ Peter Luschny, Notation Matters: The perils of bad notation.
External links