This site is supported by donations to The OEIS Foundation.

Kronecker delta

From OeisWiki
(Redirected from Kronecker delta function)
Jump to: navigation, search

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
δ  ei  π−1  =  1
δ7,  2 3 − 1, 
 =  1
δ  sin (2017  
5  2
 =  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.”[1]


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.)[2]
Under this definition, then,
δx = 0  x

Bivariate Kronecker delta

The bivariate Kronecker delta function returns 1 if
i  −  j = 0
, 0 otherwise. This is the original Kronecker delta function, returning 1 if
are equal or 0 if they are different (hence delta).

The formula can also be given as

sgn (x)
is the sign function (the signum function) of

Multivariate Kronecker delta

The multivariate Kronecker delta 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
if there is no ambiguity) for
δ    ji


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]


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.


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
Mi  j
referring to a specific cell in the matrix
by its row
and column

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


  1. “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.”
  2. WARNING: Treatment of
    0 0
    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.
  3. Weisstein, Eric W., XNOR, From MathWorld--A Wolfram Web Resource.
  4. Paul M. Chirlian, Programming in C++. Merrill (1990): p. 67ff
  5. Herbert Schildt, C: The Complete Reference 3rd Ed. Osborne McGraw-Hill (1995) p. 43
  6. William T. Shaw & Jason Tigg, Applied Mathematica: Getting Started, Getting It Done. Reading, Mass: Addison-Wesley Publishing Company (1994): 212—213
  7. G. Emanuel, Analytical Fluid Dynamics. Boca Raton, Florida: CRC Press (2001): p. 7, equation 1.12.
  8. Stephen M. Barnett & Paul M. Radmore, Methods in theoretical quantum optics. Oxford: Oxford University Press (2003): Appendix 1, p. 222 forward.
  10. Peter Luschny, Notation Matters.
  11. Peter Luschny, Notation Matters: The perils of bad notation.

External links