Addressing discontinuous root-finding for subsequent differentiability in machine learning, inverse problems, and control