How it works
Ordinary least squares minimizes squared vertical residuals. The slope uses centered covariance divided by centered x variance. R² is undefined when all y values are equal.
Try an example
x values: 1, 2, 3, 4; y values: 3, 5, 7, 9. The form starts with these values; change them to explore your own case.
Example result: y = 2x + 1
- Center x and y around their means.
- Slope = centered cross-product / centered x sum of squares.
- Intercept = mean(y) − slope·mean(x).
Learn more in Statistics and regression tools.
Results are calculated locally. Floating-point tools provide numerical approximations, not formal proof certificates.