In the theory of periodic gratings, there is no methodto make up a numerical solution that satisfies thereciprocity so far. On the basis of the shadow theory, however, this paper proposes a new method to obtain a numerical solution that satisfies the reciprocity. The shadow thoery states that, bythe reciprocity, the mth order scattering factor is an even function with respect to a symmetricalaxis depending on the order m of diffraction. However, a scattering factor obtained numerically becomesan even function only approximately, but not accurately.It can be decomposed to even and odd components,where an odd component represents an error with respect to the reciprocity and can be removed by the average filter. Using even components, a numerical solution that satisfies the reciprocity is obtained. Numerical examples are givenfor the diffraction of a transverse magnetic (TM) plane wave by a very rough periodic surface with perfect conductivity. It is then found that, by use ofthe average filter, the energy error is much reduced in some case.