Inverse optimal design for bilinear systems is considered. The main result is that a nonlinear optimal feedback control law which minimizes a new quadratic cost function with nonlinear weight is obtained based on an inverse optimal control problem for bilinear systems. This inverse optimal control design is applied to the problem of the stabilization of the inverted pendulum on the cart which moves not only in the horizontal direction but also in the vertical direction. This inverted pendulum system can be transformed into a bilinear system by using input transformation and coordinate transformation forcused on the center of percussion of the pendulum. It is theoretically shown that the proposed nonlinear optimal feedback controller has higher control performance than a conventional linear optimal controller for the linear approximation system. Furthermore, it is shown by numerical simulations that the control performance of the pendulum is improved by utilizing the vertical movement of the pendulum.