The inverted pendulum is a classical control problem, which is an absolutely unstable system with the characteristics of higher-order, unstable, multivariable, nonlinear and strong coupling. There can be varieties of methods to be applied to control inverted pendulum system, such as PID control, optimal control, robust control, sliding mode control, fuzzy control, neural network control, human-imitating intelligent control. In this paper, firstly by using the principle of Newtonian mechanics, the mathematical model of the inverted pendulum system was established and the differential equations and state space representation were derived. Secondly, a controller was designed by using the Linear Quadratic Regulator (LQR) cost equation. Thirdly, the PID controller was designed in which the tuning of the PID parameters was focused. Finally, the simulation results show the inverted pendulum could be balanced with the both controllers.