The summation over the eigenfrequencies is performed by making use of the argument principle (56), which yields the Casimir energy of two parallel gratings on a unit cell of a period Λ and unit length in the y direction: Here, as was defined in Sec. II, ϕ = 2 πx$_{0}$/ Λ and x$_{0}$ is a lateral displacement of the two gratings. This is an exact expression valid at zero temperature for two arbitrary parallel gratings with equal periods Λ separated by a vacuum gap. The Casimir free energy on a unit surface F C for the system of two gratings can be written as follows: This formula is valid for an arbitrary profile and an arbitrary dielectric permittivity of each grating. When one grating has a curvature of the sphere of the radius R ≫ Λ, the lateral Casimir force in this system F C lat can be obtained by combining the use of the PFA for a sphere-plate configuration and the exact formula for the free energy of the two gratings (64): For the sinusoidally corrugated sphere and plate used in our experiment L = a + A$_{1}$ + A$_{2}$ and the lateral Casimir force is given by Different methods were developed in grating theory starting with the pioneering work of Rayleigh [72]. For our case of sinusoidal gratings we used the so-called differential method [73]. The integration of the first-order ordinary differential equations (54) with the dielectric permittivity of the generalized plasma-like model (37) in the corrugation region of each grating was based on an explicit Runge-Kutta (4 , 5) formula, the Dormand-Prince pair, and was performed using the Matlab package. Then the reflection matrices R (1) bot and R (2) top were computed. The lateral Casimir force F C lat was computed using Eq. (66) for the experimental 32 F C $_{lat}$( a, ϕ ) = 4 k$_{B}$T R Λ ∫ ∞ a dz ′ ∞ ∑ l =0 ′ ∂ ∂ϕ ∫ ∞ 0 dk$_{y}$ ∫ π/ Λ 0 dk$_{x}$ × ln det [ I − R (1) $_{bot}$( k$_{⊥}$ , iξ$_{l}$ ) R (2) $_{top}$( k$_{⊥}$ , iξ$_{l}$, z ′ + A$_{1}$ + A$_{2}$, ϕ ) ] . (66) F C $_{lat}$( L, ϕ ) = 2 πR 2 π Λ ∫ ∞ L dz ′ ∂ F $^{C}$( z $^{′}$, ϕ ) ∂ϕ . (65) F $^{C}$( L, ϕ ) = k$_{B}$T π 2 ∞ ∑ l =0 ′ ∫ ∞ 0 dk$_{y}$ ∫ π/ Λ 0 dk$_{x}$ ln det [ I − R (1) $_{bot}$( k$_{⊥}$ , iξ$_{l}$ ) R (2) $_{top}$( k$_{⊥}$ , iξ$_{l}$, L, ϕ ) ] . (64) E $^{C}$( L, x$_{0}$ ) = ℏ c Λ (2 π ) 3 ∫ ∞ 0 dξ ∫ ∞ −∞ dk$_{y}$ ∫ 2 π/ Λ 0 dk$_{x}$ ln det [ I − R (1) $_{bot}$( k$_{⊥}$ , iξ ) R (2) $_{top}$( k$_{⊥}$ , iξ, L, x$_{0}$ ) ] . (63)