The inverted pendulum on a cart is a classic control theory problem for demonstrating control of an inherently unstable system. Left to its own devices, an inverted pendulum will always fall away from the centre. The cart is controllable however and can move either left or right in order to stabilise the motion of the…