In this paper we propose an optimal control design technique for a class of nonlinear and control non-affine equations. The dynamic equations of a flexible shaft supported by a pair of active magnetic bearings (AMBs) are used as the nonlinear control non-affine equations. The basic model of the system will be a Timoshenko beam supported at the ends by magnetic frictionless bearings. The effective control of such systems is extremely important for very high angular velocity shafts which are a feature of many modern machines. The control must be able to cope with unbalanced masses and hence be very robust.