Inverted pendulum is an example of naturally unstable system. In order to stabilize an inverted pendulum, a proper controller should be used. One of the famous controllers is PID 1). PID controller…