Integrability and Nonintegrability in Geometry and Mechanics