When the Jacobian of the problem is singular, compute a solution to the least squares problem instead of crashing. Closes #1889