The color difference, or ΔE, between a sample color L_{2}a_{2}b_{2} and a reference color L_{1}a_{1}b_{1} is:

where

**Implementation Notes:**

- In the calculation of ΔH, the value inside the radical is, in theory, always greater than or equal to zero. However in an actual implementation, it may become a very slightly negative value, due to limited arithmetic precision. Should this occur, the square root will fail. Be sure to account for this possibility (see following note for a solution).
- The value for ΔH is not actually needed. Rather, ΔH
^{2}is needed instead. So an optimization might be to avoid the square root altogether.