Calculate Fitting straight line - Curve fitting using Least square method
Solution:Method-1 of solution :Straight line equation is `y = a + bx`.
The normal equations are
`sum y = an + b sum x`
`sum xy = a sum x + b sum x^2`
The values are calculated using the following table
`x` | `y` | `x^2` | `x*y` |
3 | 2.3 | 9 | 6.9 |
5 | 2.6 | 25 | 13 |
7 | 2.8 | 49 | 19.6 |
9 | 3.2 | 81 | 28.8 |
11 | 3.5 | 121 | 38.5 |
--- | --- | --- | --- |
`sum x=35` | `sum y=14.4` | `sum x^2=285` | `sum x*y=106.8` |
Substituting these values in the normal equations
`5a+35b=14.4`
`35a+285b=106.8`
Solving these two equations using Elimination method,
`5a+35b=14.4`
and `35a+285b=106.8`
`5a+35b=14.4 ->(1)`
`35a+285b=106.8 ->(2)`
equation`(1) xx 7 =>35a+245b=100.8`
equation`(2) xx 1 =>35a+285b=106.8`
Substracting `=>-40b=-6`
`=>40b=6`
`=>b=6/40`
`=>b=3/20`
`=>b=0.15`
Putting `b=0.15` in equation `(1)`, we have
`5a+35(0.15)=14.4`
`=>5a=14.4-5.25`
`=>5a=9.15`
`=>a=9.15/5`
`=>a=1.83`
`:.a=1.83" and "b=0.15`
Now substituting this values in the equation is `y = a + bx`, we get
`y = 1.83 +0.15x`
Method-2 of solution :
Equation of straight line is `y=mx+b`, where Slope is m and Intercept is b
`m=(n sum xy - sum x sum y) / (n sum(x^2) - (sum x)^2)`
`b=(sum y - m sum x)/n`
The values are calculated using the following table
`x` | `y` | `x^2` | `x*y` |
3 | 2.3 | 9 | 6.9 |
5 | 2.6 | 25 | 13 |
7 | 2.8 | 49 | 19.6 |
9 | 3.2 | 81 | 28.8 |
11 | 3.5 | 121 | 38.5 |
--- | --- | --- | --- |
`sum x=35` | `sum y=14.4` | `sum x^2=285` | `sum x*y=106.8` |
Find the value of Slope `m`
`m=(n sum xy - sum x sum y) / (n sum(x^2) - (sum x)^2)`
`:.m=(5 * 106.8 - 35*14.4) / (5* 285 - (35)^2)`
`:.m=(534 - 504) / (1425 - 1225)`
`:.m=(30) / (200)`
`:.m=0.15`
Find the value of Intercept `b`
`b=(sum y - m sum x)/n`
`:.b=(14.4 - 0.15 * 35)/5`
`:.b=(14.4 -5.25)/5`
`:.b=(9.15)/5`
`:.b=1.83`
So the required equation is `y=mx+b`
`y=0.15x+1.83`
The (x,y) points and line `y = 1.83 +0.15x` on a graph

This material is intended as a summary. Use your textbook for detail explanation.
Any bug, improvement, feedback then