The linear optimal control problem is considered. Duration of the controlled process is fixed. It is necessary to minimize the functional, that characterizes the energy consumption. A method of constructing an approximate solution based on the Galerkin method is proposed. Examples of numerical solutions of the problem are given.