Variable projection for nonlinear least squares problems