The article describes methods and computational algorithms for estimating the temperature distribution law in the body of a rectangular parallelepiped shape under the influence of heat flow and the presence of heat exchange. It is believed that one of the faces is amenable to heat flow, and the other faces are insulated or are under the influence of the environment. To use the variational approach, the total energy functional is calculated, taking into account the boundary conditions. Minimizing the functional and equating it to zero, we obtain a system of linear equations, the solution of which gives the temperature of a rectangular parallelepiped at the nodal points. Further, substituting these nodal temperature values into the approximating function, we obtain the law of temperature distribution in the body in the form of a rectangular parallelepiped. The temperature distribution law is obtained by dividing a rectangular parallelepiped into one, two and three elements. To speed up the process of calculating the temperature distribution law, an algorithm has been developed that allows you to create a program code that increases the calculation efficiency by an order of magnitude. This is achieved by the fact that the created code contains only a system of linear equations, unlike the main program, which forms a general functional of full energies, calculates derivatives of this functional and obtains a system of equations.