Finding the law of oscillation of a prismatic rod during free damped longitudinal oscillations with a non-linear elastic characteristic is considered. \[ igma=E(1-a_3E^2e^2_x)e_x. \] In doing so, it is assumed that the nonlinearity is weak and that damping is achieved by viscous friction forces that are proportional to the first degree of speed. The task was solved in two ways, using Hamilton's and Vujanović's variational principles with non-commutative variations. Using both methods, the same results were obtained. The simplicity, efficiency and broad possibility of applying the variational principle with non-commutative variations are pointed out.