Topological methods for optimization Mechanical systems with constraints mathematics