In this paper, using the example of a two-mass calculation scheme, which can be used to describe the dynamic properties of many mechatronic systems with elastic elements, we present the results of research on finding control actions that provide compensation of dynamic errors based on solving the inverse dynamic problems according to a given law of change of the force in an elastic element. It is shown that the found control actions in the form of time dependences make it possible not to impose any restrictions on the methods of their technical implementation and thereby provide a comprehensive solution the problem of compensating for dynamic errors caused by elastic deformations of mechanical elements.