[en] The nonlinear response of infinite periodic solids to homogenous electric fields and collective atomic displacements is discussed in the framework of density functional perturbation theory. The approach is based on the 2n+1 theorem applied to an electric-field-dependent energy functional. We report the expressions for the calculation of the nonlinear optical susceptibilities, Raman scattering efficiencies, and electro-optic (EO) coefficients. Different formulations of third-order energy derivatives are examined and their convergence with respect to the k-point sampling is discussed. We apply our method to a few simple cases and compare our results to those obtained with distinct techniques. Finally, we discuss the effect of a scissors correction on the EO coefficients and nonlinear optical susceptibilities.