Variational principles applied in Physics look structurally different for reversible and irreversible processes, especially with respect to the time variable. This, in a sense, is one of the central problems of Non-equilibrium Thermodynamics. The formal difference is, however, not a mathematical necessity, there exists a common frame which we present here: It is shown that for any equation that can be composed by the application of a linear operator on a given function of the unknown function, there exists a method of construction of a Lagrangian and a potential function, so that the variational problem of this Lagrangian of this potential gives the original equation as the Euler-Lagrange equation (if the original unknown function is related to the potential in the given way). This construction of the Lagrangian-Potential pair (if it exists) contains an arbitrary function. The method is extended to the case when the equation can be constructed by the composition of linear operators and given functions in a finite number of steps. The method gives a common basis for approximation methods of Ritz and Galerkin type and also a modification of the latter which (not like the original method) provides natural boundary conditions to the problem. Examples of the Lagrangian are given for several equations of Physics. They include for the linear case: the damped linear oscillator and the equations of the wave approach of thermodynamics; for the nonlinear case we consider Maxwell's equations with Ohm's law and an arbitrary polarization function. Another example considered is a multicomponent diffusion system with second order chemical reactions. Examples of the construction method also are given for nonlinear cases: a nonlinear heat conduction equation, and equations of multicomponent diffusion with non-constant transport coefficients.