# Straight line equation that accounts for known error in X&Y?

Tags:
1. Apr 15, 2015

### AlanKirby

I'm looking for how to mathematically relate X and Y, in such a way that the Chi-Squared per degree of freedom is minimised. However I can't understand how this would work, given that I'm trying to use known X,Y dX and dY (errors) values, to get the related gradient and intercept for the line of best fit.

nb: I'm currently trying to program a straight line in java that accounts for known errors in both X and Y, however everything I find either obtains errors, or is way over complicated.

Alternatively, write down the equation for $\chi^2$ yourself, calculate the derivatives and see how the expression can get minimized. I'm not sure if that gives a single nice formula.