# Simulating electrons passing through a beam splitter for random number generation

I would like to write a program that would simulate the trajectory of an electron/photon passing through a 50-50% beam splitter and depending on which detector the particle is measured, it would return 0 or 1. The particle would be in a superposition state $$\vert{\psi}\rangle=\frac{\vert{0}\rangle+\vert{1}\rangle}{\sqrt{2}}$$ Is there some book that can help me with what i am trying to do? Also, I am a novice at programming in Mathematica, so I do not know how hard it would be.

• This isn't really a Mathematica question and should be moved to Physics. An electron or photon does not have a "trajectory" that you can simulate. In the Glauber formalism, all we get are detector events; no trajectory can be even spoken of because it wasn't measured. In this sense, the best you can get from modern quantum theory is RandomInteger[1] in this simplistic setup. A more advanced formalism could also describe spatial wavefunctions, particle losses, mixed states, and unbalanced beam splitters; but still no trajectories because they do not exist. Jul 15, 2021 at 18:01
• Assassinos, you end your question title with for random number generation, so what is it that you want to accomplish here? Do you want to make a random number generator or emulate a 50:50 BS? Jul 15, 2021 at 18:27
• I want to make a random number generator Jul 15, 2021 at 19:15
• all quantum mechanics will ever tell you is the probabilities at the end of the day. you can't simulate the actual "collapse of the wavefunction" because that choice between the two options is a truly random fundamental physical process (as far as we know)—and your computer is macro-scale and not made of quantum-mechanics-sensitive components, so only can do deterministic, classical computations. The best you can do on a classical computer is pseudorandom number generation, which is what's happening behind the scenes with RandomInteger[]. lmk if this makes sense :) Jul 15, 2021 at 20:38

Maybe you want a random number generator that uses RandomChoice to map probabilities to outcomes?

Ket[0] = {1, 0};
Ket[1] = {0, 1};

ψ = (Ket[0] + Ket[1])/Sqrt[2]
(*    {1/Sqrt[2], 1/Sqrt[2]}    *)

RandomChoice[Abs[ψ]^2 -> {0, 1}]
(*    0    *)

Table[RandomChoice[Abs[ψ]^2 -> {0, 1}], 10]
(*    {0, 0, 1, 1, 1, 1, 0, 0, 0, 0}    *)


For added generalizability you could go through the density matrix:

ρ = KroneckerProduct[Conjugate[ψ], ψ]
(*    {{1/2, 1/2}, {1/2, 1/2}}    *)

RandomChoice[Diagonal[ρ] -> {0, 1}]
(*    1    *)


For even more generalizability, I suggest you look into positive operator-valued measures:

Bra[0] = Conjugate[Ket[0]];
Bra[1] = Conjugate[Ket[1]];
zero = KroneckerProduct[Bra[0], Ket[0]];
one = KroneckerProduct[Bra[1], Ket[1]];

prob[0] = Tr[ρ . zero];
prob[1] = Tr[ρ . one];

RandomChoice[{prob[0], prob[1]} -> {0, 1}]
(*    1    *)


Of course all these formalisms give the same results in this simple example; but the latter ones can be extended to mixed states, asymmetric particle losses, etc. if desired.

Please remember that using a quantum-mechanical beam splitter to generate randomness is not different from using a classical mechanism (flipping a coin or using a Galton board). If you want true demonstrable quantum randomness, you need to look at two-particle correlations and go in the direction of Bell's inequality.