The Mach–Zehnder interferometer was originally conceived as a device to measure the refractive index of an object placed in one of the arms of the interferometer .
A light beam along the line labeled
is split in two by a half-silvered mirror, represented by the left-most purple block. The two resulting beams are each reflected by a mirror (thick black line).
Changing the time delay
) in the upper (lower) arm of the interferometer changes the phase
) of the lightbeam in this arm, according to
) (dimensionless units). According to Maxwell's classical theory of electrodynamics, the beams interfere in the second half-silvered mirror and the resulting signals registered by the two detectors at the end of the lines labeled
show interference patterns,
, respectively .
Generally, it is accepted that interference is a typical wave phenomenon. On the other hand, it is an experimental fact that when the experiment is carried out one photon at a time, the number of photons recorded at each detector agrees with the prediction of Maxwell's theory . However, at any time there is only one photon traveling from the source to the detector and it has been shown experimentally that each individual photon travels along one path only . Quantum physics "solves" this dilemma by introducing the concept of particle-wave duality.
This Demonstration shows that classical, event-based processes that satisfy Einstein's criterion of local causality  can provide an alternative interpretation of results conventionally attributed to quantum effects. In the simulation, the photons are regarded as messengers that travel from the source to a detector. The message carried by a messenger may change as the messenger encounters another object, such as a beam splitter. In this Demonstration, only the beam splitters update the messages. The key point of the update algorithm is that it defines a classical, dynamical system that has a primitive learning capability. In this Demonstration, the user can control the speed or accuracy of the learning process in each beam splitter.
 M. Born and E. Wolf, Principles of Optics
, Cambridge: Cambridge Univ. Press, 2005.
 T. L. Dimitrova and A. Weis, "The wave-particle duality of light: A demonstration experiment," American Journal of Physics 76
 P. Grangier, G. Roger, and A. Aspect, Europhys. Lett. 1
 H. De Raedt, K. De Raedt, and K. Michielsen, "Event-Based Simulation of Single-Photon Beam Splitters and Mach-Zehnder Interferometers," Europhys. Lett., 69
, 2005 pp. 861–867.