In the notebook, the motion of an (inverted) pendulum mounted on a cart is modelled. First, the position of the cart and angle of the pendulum are plotted as a function of time when the system is subject to no external force but gravity. The Euler method is used to solve the involved differential equations, and plots are given both for large step size (leading to unrealistic global behavior of the system) and small step size. An animation and error analysis of the system is also given.
Next, the optimal control problem for the system is solved, i. e. external force is applied to the cart in order to keep the pendulum vertically balanced. Again, the dynamics of the system are plotted, and an animation and error analysis given.