In this article, an engineering/physical dynamic system including losses is analyzed in relation to the stability from an engineer's/physicist's point of view. Firstly, conditions for a Hamiltonian to be an energy function, time independent or not, is explained herein. To analyze stability of engineering system, Lyapunov-like energy function, called residual energy function is used. The residual function may contain, apart from external energies, negative losses as well. This function includes the sum of potential and kinetic energies, which are special forms and ready-made (weak) Lyapunov functions, and loss of energies (positive and/or negative) of a system described in different forms using tensorial variables. As the Lypunov function, residual energy function is defined as Hamiltonian energy function plus loss of energies and then associated weak and strong stability are proved through the first time-derivative of residual energy function. It is demonstrated how the stability analysis can be performed using the residual energy functions in different formulations and in generalized motion space when available. This novel approach is applied to RLC circuit, AC equivalent circuit of Gunn diode oscillator for autonomous, and a coupled (electromechanical) example for nonautonomous case. In the nonautonomous case, the stability criteria can not be proven for one type of formulation, however, it can be proven in the other type formulation.