# How to calculate weight for least squares if both values error is known?

Usually minimizing $$\chi^2 = \sum_i w_i (y_i - f(a_0, a_1, \dots, a_n, x_i))^2$$ where $$a_k$$ are parameters is done by taking $$w_i = 1/\sigma_i^2$$ where $$\sigma_i$$ is a observation error of $$y_i$$ while value of $$x_i$$ assumed to be exact. In this case errors of $$a_k$$ are calculated correctly in linear and non-linear cases (e.g. in GSL package).

However what should I take as $$w_i$$ in case when errors of both $$x_i$$ and $$y_i$$ are known? Something like $$w_i = 1/(\sigma_{x,i}^2+\sigma_{y,i}^2)$$? Is there any way to make e.g. GSL to calculate $$\sigma_{a_i}$$ at least approximately in this case?

All errors assumed to be uncorrelated and Gaussian.