The modern controller design is increasingly based on data-driven control methods. PID controllers are still used primarily in the industry because they are proportional-integral-derivative (PID). The Linear Quadratic Regulator (LQR) provides an efficient way to tune the parameters of a PID controller. The LQR has the disadvantage of requiring accurate models of the system, as well as reducing a high–order system to a second-order model. Firstly, the authors explore the new horizons of control theory in the form of the state-space model for high nonlinear systems. Secondly, the Lagrangian method establishes the new mathematical model of the linear two–stage inverted pendulum system. In addition, real–time LQR parameters are calculated under the variable load. This method has been demonstrated to be highly applicable and accurate through simulations and experiments using the Double Inverted Pendulum model.