A solution to the singularity problem of a non-redundant robot is proposed by reformulating the inverse kinematic problem as a constraint optimization problem. The main idea is to allow a cartesian error in a certain subspace in the vicinity of a singularity and to minimize this error subject to operational constraints such as maximum motor speeds. As a result, in every sampling instant a series of linear least squares problems with linear equality and inequality constraints have to be solved. This task can be carried out on a Pentium processor within a few milliseconds. The new method is demonstrated at hand to some experiments with an industrial robot