On the inversion of the Lagrange-Dirichlet theorem in a case of nonhomogeneous potential