We combined an inverse engineering technique based on Lagrange mechanics and optimal control theory to design an optimal trajectory that can transport a cartpole in a fast and stable way. For classical control. we used the relative displacement between the ball and the trolley as the controller to study the anharmonic effect of the cartpole. Under this constraint. https://macorners.shop/product-category/wine-tumbler-friend-card/