## Abstract

We report on prime number decomposition by use of the Talbot effect, a well-known phenomenon in classical near field optics whose description is closely related to Gauss sums. The latter are a mathematical tool from number theory used to analyze the properties of prime numbers as well as to decompose composite numbers into their prime factors. We employ the well-established connection between the Talbot effect and Gauss sums to implement prime number decompositions with a novel approach, making use of the longitudinal intensity profile of the Talbot carpet. The new algorithm is experimentally verified and the limits of the approach are discussed.

© 2018 Optical Society of America under the terms of the OSA Open Access Publishing Agreement

## 1. Introduction

Diffraction is one of the most fundamental aspects of optics occurring when physical objects are described by waves. The corresponding interferences may lead to surprising phenomena such as a self-imaging of periodic structures as discovered by Talbot [1] and theoretically derived by Rayleigh [2]. The optical Talbot effect was later on studied theoretically in much detail, either by formulations in real space [3,4] or phase space [5,6], and experimentally observed with x-rays [7], electron beams [8], atomic matter waves [9,10] and surface plasmons [11,12]. Although the Talbot effect has been proven to be useful for various applications, we focus on a particular application, namely to decompose composite numbers into their prime factors. Since self-imaging is a general property of diffraction in the near field, the Talbot effect extends prime number decomposition to the field of classical optics, representing an alternative to factorizing algorithms known from quantum computation [13], albeit by purely classical means. This alternative approach was initially developed by Clauser and Dowling [14] and later linked to generalized Gauss sums [15], which constitute a practical tool to perform prime number decompositions [16]. This ability of Gauss sums was already proven in many experiments e.g. by using the temporal Talbot effect [17], different interferometers [18–21], Bose-Einstein condensates [22] or NMR techniques [23–25]. However, up to now there appears to be no experimental realization of the optical Talbot effect with the aim of performing prime number decomposition. This circumstance becomes less surprising when noticing that complete measurements of the two-dimensional intensity profile using coherent illumination, so called Talbot carpets [26], were not recorded until recently [27]. The goal of this paper is to connect the two dots.

## 2. Prime number decomposition using Gauss sums

Our technique to implement prime number decompositions is based on the properties of Gauss sums, which exist in many different forms [16, 28, 29]. The discrete Gauss sum, showing the characteristic property of a quadratically occurring summation index, is defined as

with*l*,

*N*∈ ℕ and weight factors

*w*, where the latter is supposed to be a slowly varying function of

_{m}*m*[16]. In view of the upcoming discussion, we assume the weight factor to be of the form

*w*=

_{m}*a*sinc(

*ma*) with

*a*∈ ℝ

^{+}. Inserting this weight factor, exploiting the periodicity of the exponential function in

*m*with period

*N*and applying the Poisson summation formula, allows us finding the convenient expression

*G*(

*l*,

*N*) represents the so called complete Gauss sum (normalized by

*N*), if the condition $a<\raisebox{1ex}{$2$}\!\left/ \!\raisebox{-1ex}{$N$}\right.$ holds. Employing the properties of the complete Gauss sum

*G*(

*l*,

*N*) we can perform prime number decomposition [16]. To this aim, we assume that the number

*N*to be factorized is odd and

*l*a test factor. If

*l*is no factor of

*N*, we obtain from Eq. (2) ${\left|{S}_{N}(l)\right|}^{2}=\raisebox{1ex}{$1$}\!\left/ \!\raisebox{-1ex}{$N$}\right.$, whereas if

*l*is a prime factor

*p*of

*N*or a multiple

*kp*of a prime factor, we find ${\left|{S}_{N}(kp)\right|}^{2}=\raisebox{1ex}{$p$}\!\left/ \!\raisebox{-1ex}{$N$}\right.$. Hence, all prime factors of an odd number

*N*can be uniquely identified by evaluating |

*S*(

_{N}*l*)|

^{2}for all test factors

*l*and comparing with the “line of factors

*p*”, given by $f(p)=\raisebox{1ex}{$p$}\!\left/ \!\raisebox{-1ex}{$N$}\right.$ (see Fig. 1).

## 3. The Talbot effect

The Talbot effect is a diffraction phenomenon taking place in the near field behind a grating upon illumination with a plane wave. To derive the Talbot diffraction pattern, we assume an infinite periodic one-dimensional grating with slit width *w* and period *d*. The corresponding transmission function reads

*E*(

*ξ*,

*z*= 0) =

*E*

_{0}to the detection plane (

*x*,

*z*> 0) via

*λ*the wavelength and

*k*the wave number. Since there are infinitely many slits,

*T*(

*ξ*) is a periodic function and can be decomposed into a Fourier series

*E*(

*x*, 0) =

*E*(

*x*,

*nL*) for

_{T}*n*∈ ℕ. The intensity at the grating is found by calculating the modulus square of the electric field amplitude leading to

## 4. Prime number decomposition using the Talbot effect

In 2009, a precise measurement of a Talbot carpet [27] showed that the intensity distribution along the x-axis at the fractional distances $\raisebox{1ex}{${z}_{l}$}\!\left/ \!\raisebox{-1ex}{${z}_{T}$}\right.\approx \raisebox{1ex}{$l$}\!\left/ \!\raisebox{-1ex}{$N$}\right.$ contains features of a Gauss sum. This allows to perform prime number decomposition by counting the intensity maxima parallel to the grating at the distinct distances *z _{l}* [27]. The properties of the lateral intensity distribution of the Talbot carpet lies also at the heart of [14]. Upon relaxing the assumption of infinitesimal slits to finite slits, it can be shown that the maximal number that can be factored with both methods is given by ${N}_{\text{max}}<\raisebox{1ex}{$d$}\!\left/ \!\raisebox{-1ex}{$w$}\right.$. In this paper, however, we propose a different algorithm for prime number decomposition, based on another appearance of a Gauss sum within the Talbot carpet. Considering the intensity distribution of Eq. (7) at a fixed lateral position

*x*=

*qd*,

*q*∈ ℕ, and studying the intensity distribution along the

*z*-axis, we obtain after a change of the summation index

*n*= −

*m*and exploiting the symmetry of the Fourier coefficients

*A*=

_{m}*A*

_{−m}

*S*(

_{N}*l*). With Fourier coefficients ${A}_{n}=\left(\raisebox{1ex}{$w$}\!\left/ \!\raisebox{-1ex}{$d$}\right.\right)\cdot \text{sinc}\left[m\left(\raisebox{1ex}{$w$}\!\left/ \!\raisebox{-1ex}{$d$}\right.\right)\right]$ it turns into a complete Gauss sum

*G*(

*l*,

*N*), normalized by

*N*, if the condition $N<\raisebox{1ex}{$2d$}\!\left/ \!\raisebox{-1ex}{$w$}\right.$ holds. This can be seen by identifying $\raisebox{1ex}{$w$}\!\left/ \!\raisebox{-1ex}{$d$}\right.$ with

*a*in Sec. (2). Note that this condition limits the numbers we can factorize via the dimensions of the used grating. Using this expression we can rewrite Eq. (8) as

- Record the intensity profile of the Talbot carpet along the
*z*-axis from any Talbot distance*sL*to the next Talbot distance (_{T}*s*+ 1)*L*with sufficiently small steps Δ_{T}*z*at some fixed slit position*x*=*qd*with*s*,*q*∈ ℕ. This requires $\raisebox{1ex}{${L}_{T}$}\!\left/ \!\raisebox{-1ex}{$\mathrm{\Delta}z$}\right.$ measurements. - Locate the fractional Talbot distances ${z}_{l,N}=s{L}_{T}+\raisebox{1ex}{${L}_{T}$}\!\left/ \!\raisebox{-1ex}{$N$}\right.\cdot l$,
*l*= 1, . . .,*N*by dividing the measured Talbot length equidistantly into*N*parts. - Draw the line of factors for arbitrary $N<\raisebox{1ex}{$2d$}\!\left/ \!\raisebox{-1ex}{$w$}\right.$ from [1,
*I*(*z*_{1,N})] to [*N*,*I*(*z*_{N,N})] and locate the intensities*I*(*z*_{l,N}) on or above this line to find the prime factors*l*of this*N*.

## 5. Experimental realization of the Talbot effect with focus on prime number decomposition

To prove the above proposed algorithm for prime number decomposition, we designed the experimental setup shown in Fig. 2. Placing the grating in the focus of the Gaussian beam leads to the following expression for the lateral electric field distribution at the position of the grating

with the Gaussian beam waist*σ*. In this case the Fresnel diffraction integral is not calculated using a plane wave as input but a Gaussian distribution, such that the intensity behind the grating reads

*d*= 200 μm and a slit width of

*w*= 10 μm, the measurement was automated to record with a CMOS camera images between

*L*= 150.4 mm and 2

_{T}*L*= 300.8 mm in steps of Δ

_{T}*z*= 50 μm. From the collected data the Talbot carpet was reconstructed by stacking the measured intensity for each step, whereby each image was averaged over all rows along the

*y*-axis (since the intensity does not depend on

*y*). The resulting Talbot carpet is shown in Fig. 3(a). Besides the experimental data (green line) Fig. 3(b) displays also the theoretical prediction (black dashed line) obtained by numerical evaluation of Eq. (11), demonstrating an excellent agreement between theory and experiment. As an example, Fig. 3(

**c**) shows the decomposition of the number

*N*= 27 using our new algorithm. As can be seen, the prime factors 3 and 9 lie above the line of factors connecting

*I*(

*z*

_{1,27}) and

*I*(

*z*

_{27,27}) and not as before on this line. The reason for this is due to the reduced intensity at

*z*= 2

*L*compared to

_{T}*z*=

*L*, stemming from the Fresnel diffraction of the Gaussian beam. Hence

_{T}*I*(

*z*

_{27,27}= 2

*L*) lies lower than

_{T}*I*(

*z*=

*L*) (see Fig. 3(b)) causing the slope of the line of factors to be smaller than in the ideal case. This effect is small, but becomes more prominent for Gaussian beams compared to plane waves. This also leads to a slight decrease of the limit up to which numbers can be factorized, theoretically given by $N<\raisebox{1ex}{$2d$}\!\left/ \!\raisebox{-1ex}{$w$}\right.$. For the particular grating used, this means that we can decompose only numbers up to

_{T}*N*= 29 and not as theoretically predicted up to

*N*= 40. Nevertheless, the application of the discrete Gauss sum |

*S*(

_{N}*l*)|

^{2}appearing in the Talbot carpet along the

*z*-direction allows us to decompose numbers within the theoretical limit of the approach into their correct prime factors. Our approach reduces also the amount of required experimental data to the measurement of a single Talbot carpet. The latter contains the information for all possible numbers since encoding the number to be factorized is done by merely rescaling the

*z*axis through

*z*

_{l,N}[16,19,30,31].

## 6. Conclusion

We theoretically discussed the capabilities of the Talbot effect to perform prime number decomposition based on its mathematical analogy to a Gauss sum. We envisaged at first a diffraction grating with infinitely many slits illuminated by a plane wave. We then found that the properties of the ideal case are still valid for the realistic case of a diffraction grating with finite number of slits illuminated by a Gaussian beam. The theoretical investigations result in the first realization of the discrete Gauss sum |*S _{N}*(

*l*)|

^{2}using the longitudinal intensity profile of the Talbot effect. Our novel approach improves the amount of possible numbers that can be experimentally decomposed compared to existing factorization schemes based on the fractional Talbot effect. Nevertheless, we note that the Fourier coefficients of the grating transmission function yield a criterion that, depending on the geometry of the diffraction grating, limits the maximal number

*N*that can be decomposed to rather low values. However, other interference phenomena that can be described by the discrete Gauss sum |

*S*(

_{N}*l*)|

^{2}might yield less restrictive conditions and therefore enhance the possibility to implement prime number decompositions within a physical realization.

## Funding

Erlangen Graduate School in Advanced Optical Technologies (SAOT) by the German Research Foundation (DFG) in the framework of the German excellence initiative, Staedtler Foundation, Universitätsbund Erlangen-Nürnberg e.V.

## References and links

**1. **H. F. Talbot, “Facts relating to optical science,” Philos. Mag. **9**, 401–407 (1836).

**2. **L. Rayleigh, “On copying diffraction–gratings, and some phenomena connected therewith,” Philos. Mag. **11**, 196–205 (1881). [CrossRef]

**3. **W. D. Montgomery, “Self-imaging Objects of Infinite Aperture,” J. Opt. Soc. Am. **57**, 772–775 (1967). [CrossRef]

**4. **L. Liu, “Talbot and Lau effects on incident beams of arbitrary wavefront, and their use,” Appl. Opt. **28**, 4668–4678 (1989). [CrossRef] [PubMed]

**5. **K. Banaszek, K. Wódkiewicz, and W. P. Schleich, “Fractional Talbot effect in phase space: A compact summation formula,” Opt. Express **2**, 169–172 (1998). [CrossRef] [PubMed]

**6. **O. Friesch, I. Marzoli, and W. P. Schleich, “Quantum carpets woven by Wigner functions,” New J. Phys. **2**, 4 (2000). [CrossRef]

**7. **P. Cloetens, J. P. Guigay, C. De Martino, J. Baruchel, and M. Schlenker, “Fractional Talbot imaging of phase gratings with hard x rays,” Opt. Lett. **22**, 1059–1061 (1997). [CrossRef] [PubMed]

**8. **B. J. McMorran and A. D. Cronin, “An electron Talbot interferometer,” New J. Phys. **11**, 033021 (2009). [CrossRef]

**9. **M. S. Chapman, C. R. Ekstrom, T. D. Hammond, J. Schmiedmayer, B. E. Tannian, S. Wehinger, and D. E. Pritchard, “Near–field imaging of atom diffraction gratings: The atomic Talbot effect,” Phys. Rev. A **51**, R14–R17 (1995). [CrossRef]

**10. **S. Nowak, C. Kurtsiefer, T. Pfau, and C. David, “High-order Talbot fringes for atomic matter waves,” Opt. Lett. **22**, 1430–1432 (1997). [CrossRef]

**11. **M. R. Dennis, N. I. Zheludev, and F. J. G. de Abajo, “The plasmon Talbot effect,” Opt. Express **15**, 9692–9700 (2007). [CrossRef] [PubMed]

**12. **S. Cherukulappurath, D. Heinis, J. Cesario, N. F. van Hulst, S. Enoch, and R. Quidant, “Local observation of plasmon focusing in Talbot carpets,” Opt. Express **17**, 23772–23784 (2009). [CrossRef]

**13. **P. W. Shor, “Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a Quantum Computer,” SIAM Journal on Computing **26**, 1484–1509 (1997). [CrossRef]

**14. **J. F. Clauser and J. P. Dowling, “Factoring integers with Young’s N-slit interferometer,” Phys. Rev. A **53**, 4587–4590 (1996). [CrossRef] [PubMed]

**15. **M. V. Berry and S. Klein, “Integer, fractional and fractal Talbot effects,” J. Mod. Opt. **43**, 2139–2164 (1996). [CrossRef]

**16. **S. Wölk, W. Merkel, W. P. Schleich, I. Sh. Averbukh, and B. Girard, “Factorization of numbers with Gauss sums: I. Mathematical background,” New J. Phys. **13**, 103007 (2011). [CrossRef]

**17. **D. Bigourd, B. Chatel, W. P. Schleich, and B. Girard, “Factorization of Numbers with the Temporal Talbot Effect: Optical Implementation by a Sequence of Shaped Ultrashort Pulses,” Phys. Rev. Lett. **100**, 030202 (2008). [CrossRef] [PubMed]

**18. **V. Tamma, H. Zhang, X. He, A. Garuccio, and Y. Shih, “Factorization of integers with multi-path optical interference,” Int. J. Quantum Inf. **9**, 423–430 (2011). [CrossRef]

**19. **V. Tamma, H. Zhang, X. He, A. Garuccio, W. P. Schleich, and Y. Shih, “Factoring numbers with a single interferogram,” Phys. Rev. A **83**, 020304 (2011). [CrossRef]

**20. **V. Tamma, C. O. Alley, W. P. Schleich, and Y. H. Shih, “Prime Number Decomposition, the Hyperbolic Function and Multi-Path Michelson Interferometers,” Found. Phys. **42**, 111–121 (2012). [CrossRef]

**21. **M. Gilowski, T. Wendrich, T. Müller, Ch. Jentsch, W. Ertmer, E. M. Rasel, and W. P. Schleich, “Gauss Sum Factorization with Cold Atoms,” Phys. Rev. Lett. **100**, 030201 (2008). [CrossRef] [PubMed]

**22. **M. Sadgrove, S. Kumar, and K. Nakagawa, “Enhanced Factoring with a Bose-Einstein Condensate,” Phys. Rev. Lett. **101**, 180502 (2008). [CrossRef] [PubMed]

**23. **M. Mehring, K. Müller, I. Sh. Averbukh, W. Merkel, and W. P. Schleich, “NMR Experiment Factors Numbers with Gauss Sums,” Phys. Rev. Lett. **98**, 120502 (2007). [CrossRef] [PubMed]

**24. **T. S. Mahesh, N. Rajendran, X. Peng, and D. Suter, “Factorizing numbers with the Gauss sum technique: NMR implementations,” Phys. Rev. A **75**, 062303 (2007). [CrossRef]

**25. **X. Peng and D. Suter, “NMR implementation of factoring large numbers with Gauß sums: Suppression of ghost factors,” Europhys. Lett. **84**, 40006 (2008). [CrossRef]

**26. **M. Berry, I. Marzoli, and W. P. Schleich, “Quantum carpets, carpets of light,” Phys. World **14**, 39 (2001). [CrossRef]

**27. **W. B. Case, M. Tomandl, S. Deachapunya, and M. Arndt, “Realization of optical carpets in the Talbot and Talbot-Lau configurations,” Opt. Express **17**, 20966–20974 (2009). [CrossRef] [PubMed]

**28. **M. Štefaňák, W. Merkel, W. P. Schleich, D. Haase, and H. Maier, “Factorization with Gauss sums: scaling properties of ghost factors,” New J. Phys. **9**, 370 (2007). [CrossRef]

**29. **M. Štefaňák, D. Haase, W. Merkel, M. S. Zubairy, and W. P. Schleich, “Factorization with exponential sums,” J. Phys. A **41**, 304024 (2008). [CrossRef]

**30. **V. Tamma, H. Zhang, X. He, A. Garuccio, and Y. Shih, “New factorization algorithm based on a continuous representation of truncated Gauss sums,” J. Mod. Opt. **56**, 2125–2132 (2009). [CrossRef]

**31. **W. Merkel, S. Wölk, W. P. Schleich, I. Sh. Averbukh, B. Girard, and G. G. Paulus, “Factorization of numbers with Gauss sums: II. Suggestions for implementation with chirped laser pulses,” New J. Phys. **13**, 103008 (2011). [CrossRef]