N single photons enter N distinct input modes of an M-mode linear-optical network built from the beamsplitters you configure above. The network implements an M×M unitary matrix U, built by literally multiplying together each beamsplitter's own 2×2 unitary (embedded in the M×M identity) in sequence. For an output pattern with occupation numbers (t₁,…,t_M), the exact quantum probability is:
P_quantum(t) = |Per(U_ST)|² / (t1!·t2!·…·tM!)
where U_ST is the N×N submatrix formed by the N input columns and the output rows (repeated per occupation number), and Per(·) is the matrix permanent — computed here from scratch via Ryser's inclusion–exclusion formula, exact for these small matrices. It is the same formula as a determinant but with every term added instead of alternating in sign.
If the particles were classical and distinguishable instead of identical bosons, the same formula holds with the permanent taken over |U_ST|² (probabilities, no interference):
P_classical(t) = Per(|U_ST|²) / (t1!·t2!·…·tM!)
- Drag any beamsplitter's reflectivity slider and every bar in the chart recomputes instantly from a freshly multiplied unitary — nothing here is precomputed or looked up.
- The permanent has no efficient known classical algorithm (it is #P-hard) — this gap is exactly why sampling from P_quantum is believed to be classically intractable for large N, M, the basis of the original "quantum supremacy" boson-sampling proposal.
- Total variation distance between the quantum and classical distributions measures how much genuine multi-photon interference reshapes the output — the multi-photon generalization of the Hong-Ou-Mandel dip.
- The green "prob. sum" readout in the top-right of the canvas is a live sanity check: both the quantum and classical distributions must each sum to 1.000 over all output patterns, every time the network changes.
Real-world relevance: this is the same computational model behind photonic quantum-advantage demonstrations (e.g. Jiuzhang, Borealis) — one of the hardware platforms national and corporate quantum strategies fund alongside superconducting and trapped-ion qubits.