Aug 31, 2016

$y = - 0.489421 x + 25.3113$

#### Explanation:

Given a list of values $\left\{{x}_{k} , {y}_{k}\right\} , k = 1 , 2 , \cdots , n$

a line can be adjusted such that the accumulated deviation error is minimum.

Let the line be given by

$y = a x + b$

then the error at point ${x}_{k}$ is ${e}_{k} = {y}_{k} - \left(a {x}_{k} + b\right)$

The accumulated quadratic error will be given by

$E \left(a , b\right) = {\sum}_{k = 1}^{n} {e}_{k}^{2} = {\sum}_{k = 1}^{n} {\left({y}_{k} - \left(a {x}_{k} + b\right)\right)}^{2}$

$E \left(a , b\right)$ have a minimum for ${a}_{0} , {b}_{0}$ such that

$\frac{\partial E}{\partial a} \left({a}_{0} , {b}_{0}\right) = 0 \to {b}_{0} \sum {x}_{k} + {a}_{0} \sum {x}_{k}^{2} = \sum {x}_{k} {y}_{k}$
$\frac{\partial E}{\partial b} \left({a}_{0} , {b}_{0}\right) = 0 \to n {b}_{0} + {a}_{0} \sum {x}_{k} = \sum {y}_{k}$

solving for ${a}_{0} , {b}_{0}$

${a}_{0} = \frac{\left(\sum {x}_{k}\right) \left(\sum {y}_{k}\right) - n \sum {x}_{k} {y}_{k}}{{\left(\sum {x}_{k}\right)}^{2} - n \sum {x}_{k}^{2}}$
b_0 = ((sum x_k)(sum x_ky_k)-(sum x_k^2)(sum y_k))/((sum x_k)^2-nsum x_k^2

appliying it to the table

$\left\{\left\{10 , 15\right\} , \left\{10 , 25\right\} , \left\{15 , 17\right\} , \left\{17 , 20\right\} , \left\{25 , 11.5\right\} , \left\{30 , 11\right\} , \left\{35 , 5\right\} , \left\{35 , 10\right\}\right\}$

we obtain:

${a}_{0} = - 0.489421 , {b}_{0} = 25.3113$

$y = - 0.489421 x + 25.3113$