Optimal Swing-up Control of an Inverted Pendulum