1. Formula & Examples
Formula
The equation is `y = a + bx + cx^2 + dx^3` and the normal equations are
|
1. `sum y = an + b sum x + c sum x^2 + d sum x^3`
|
2. `sum xy = a sum x + b sum x^2 + c sum x^3 + d sum x^4`
|
3. `sum x^2y = a sum x^2 + b sum x^3 + c sum x^4 + d sum x^5`
|
4. `sum x^3y = a sum x^3 + b sum x^4 + c sum x^5 + d sum x^6`
|
Examples
1. Calculate Fitting cubic equation - Curve fitting using Least square method
X | Y | 1996 | 40 | 1997 | 50 | 1998 | 62 | 1999 | 58 | 2000 | 60 |
Solution: The equation is `y = a + bx + cx^2 + dx^3` and the normal equations are
`sum y = an + b sum x + c sum x^2 + d sum x^3`
`sum xy = a sum x + b sum x^2 + c sum x^3 + d sum x^4`
`sum x^2y = a sum x^2 + b sum x^3 + c sum x^4 + d sum x^5`
`sum x^3y = a sum x^3 + b sum x^4 + c sum x^5 + d sum x^6`
`X` | `y` | `x = X - 1998` | `x^2` | `x^3` | `x^4` | `x^5` | `x^6` | `x*y` | `x^2*y` | `x^3*y` | 1996 | 40 | -2 | 4 | -8 | 16 | -32 | 64 | -80 | 160 | -320 | 1997 | 50 | -1 | 1 | -1 | 1 | -1 | 1 | -50 | 50 | -50 | 1998 | 62 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1999 | 58 | 1 | 1 | 1 | 1 | 1 | 1 | 58 | 58 | 58 | 2000 | 60 | 2 | 4 | 8 | 16 | 32 | 64 | 120 | 240 | 480 | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | 9990 | 270 | 0 | 10 | 0 | 34 | 0 | 130 | 48 | 508 | 168 |
Substituting these values in the normal equations `270=5a+0b+10c+0d`
`48=0a+10b+0c+34d`
`508=10a+0b+34c+0d`
`168=0a+34b+0c+130d`
Solving these 4 equations using inverse matrix method, Here `5a+10c=270` `10b+34d=48` `10a+34c=508` `34b+130d=168`
Now converting given equations into matrix form `[[5,0,10,0],[0,10,0,34],[10,0,34,0],[0,34,0,130]] [[a],[b],[c],[d]]=[[270],[48],[508],[168]]`
Now, A = `[[5,0,10,0],[0,10,0,34],[10,0,34,0],[0,34,0,130]]`, X = `[[a],[b],[c],[d]]` and B = `[[270],[48],[508],[168]]`
`:. AX = B`
`:. X = A^-1 B`
`|A|` | = | | `5` | `0` | `10` | `0` | | | `0` | `10` | `0` | `34` | | | `10` | `0` | `34` | `0` | | | `0` | `34` | `0` | `130` | |
|
= | | `5` | | × | | | `10` | `0` | `34` | | | `0` | `34` | `0` | | | `34` | `0` | `130` | |
|
| | `+0` | | × | | | `0` | `0` | `34` | | | `10` | `34` | `0` | | | `0` | `0` | `130` | |
|
| | `+10` | | × | | | `0` | `10` | `34` | | | `10` | `0` | `0` | | | `0` | `34` | `130` | |
|
| | `+0` | | × | | | `0` | `10` | `0` | | | `10` | `0` | `34` | | | `0` | `34` | `0` | |
|
|
`=5 × (4896)+0 × (0)+10 × (-1440)+0 × (0)`
`=24480+0-14400+0`
`=10080`
`"Here, " |A| = 10080 != 0`
`:. A^(-1) " is possible."`
`Adj(A)` | = | Adj | | `5` | `0` | `10` | `0` | | | `0` | `10` | `0` | `34` | | | `10` | `0` | `34` | `0` | | | `0` | `34` | `0` | `130` | |
|
|
= | | + | | `10` | `0` | `34` | | | `0` | `34` | `0` | | | `34` | `0` | `130` | |
|
| - | | `0` | `0` | `34` | | | `10` | `34` | `0` | | | `0` | `0` | `130` | |
|
| + | | `0` | `10` | `34` | | | `10` | `0` | `0` | | | `0` | `34` | `130` | |
|
| - | | `0` | `10` | `0` | | | `10` | `0` | `34` | | | `0` | `34` | `0` | |
|
| | | - | | `0` | `10` | `0` | | | `0` | `34` | `0` | | | `34` | `0` | `130` | |
|
| + | | `5` | `10` | `0` | | | `10` | `34` | `0` | | | `0` | `0` | `130` | |
|
| - | | `5` | `0` | `0` | | | `10` | `0` | `0` | | | `0` | `34` | `130` | |
|
| + | | `5` | `0` | `10` | | | `10` | `0` | `34` | | | `0` | `34` | `0` | |
|
| | | + | | `0` | `10` | `0` | | | `10` | `0` | `34` | | | `34` | `0` | `130` | |
|
| - | | `5` | `10` | `0` | | | `0` | `0` | `34` | | | `0` | `0` | `130` | |
|
| + | | `5` | `0` | `0` | | | `0` | `10` | `34` | | | `0` | `34` | `130` | |
|
| - | | `5` | `0` | `10` | | | `0` | `10` | `0` | | | `0` | `34` | `0` | |
|
| | | - | | `0` | `10` | `0` | | | `10` | `0` | `34` | | | `0` | `34` | `0` | |
|
| + | | `5` | `10` | `0` | | | `0` | `0` | `34` | | | `10` | `34` | `0` | |
|
| - | | `5` | `0` | `0` | | | `0` | `10` | `34` | | | `10` | `0` | `0` | |
|
| + | | `5` | `0` | `10` | | | `0` | `10` | `0` | | | `10` | `0` | `34` | |
|
| |
| T |
|
= | | `+(10 xx (34 × 130 - 0 × 0) +0 xx (0 × 130 - 0 × 34) +34 xx (0 × 0 - 34 × 34))` | `-(0 xx (34 × 130 - 0 × 0) +0 xx (10 × 130 - 0 × 0) +34 xx (10 × 0 - 34 × 0))` | `+(0 xx (0 × 130 - 0 × 34) -10 xx (10 × 130 - 0 × 0) +34 xx (10 × 34 - 0 × 0))` | `-(0 xx (0 × 0 - 34 × 34) -10 xx (10 × 0 - 34 × 0) +0 xx (10 × 34 - 0 × 0))` | | | `-(0 xx (34 × 130 - 0 × 0) -10 xx (0 × 130 - 0 × 34) +0 xx (0 × 0 - 34 × 34))` | `+(5 xx (34 × 130 - 0 × 0) -10 xx (10 × 130 - 0 × 0) +0 xx (10 × 0 - 34 × 0))` | `-(5 xx (0 × 130 - 0 × 34) +0 xx (10 × 130 - 0 × 0) +0 xx (10 × 34 - 0 × 0))` | `+(5 xx (0 × 0 - 34 × 34) +0 xx (10 × 0 - 34 × 0) +10 xx (10 × 34 - 0 × 0))` | | | `+(0 xx (0 × 130 - 34 × 0) -10 xx (10 × 130 - 34 × 34) +0 xx (10 × 0 - 0 × 34))` | `-(5 xx (0 × 130 - 34 × 0) -10 xx (0 × 130 - 34 × 0) +0 xx (0 × 0 - 0 × 0))` | `+(5 xx (10 × 130 - 34 × 34) +0 xx (0 × 130 - 34 × 0) +0 xx (0 × 34 - 10 × 0))` | `-(5 xx (10 × 0 - 0 × 34) +0 xx (0 × 0 - 0 × 0) +10 xx (0 × 34 - 10 × 0))` | | | `-(0 xx (0 × 0 - 34 × 34) -10 xx (10 × 0 - 34 × 0) +0 xx (10 × 34 - 0 × 0))` | `+(5 xx (0 × 0 - 34 × 34) -10 xx (0 × 0 - 34 × 10) +0 xx (0 × 34 - 0 × 10))` | `-(5 xx (10 × 0 - 34 × 0) +0 xx (0 × 0 - 34 × 10) +0 xx (0 × 0 - 10 × 10))` | `+(5 xx (10 × 34 - 0 × 0) +0 xx (0 × 34 - 0 × 10) +10 xx (0 × 0 - 10 × 10))` | |
| T |
|
= | | `+(10 xx (4420 +0) +0 xx (0 +0) +34 xx (0 -1156))` | `-(0 xx (4420 +0) +0 xx (1300 +0) +34 xx (0 +0))` | `+(0 xx (0 +0) -10 xx (1300 +0) +34 xx (340 +0))` | `-(0 xx (0 -1156) -10 xx (0 +0) +0 xx (340 +0))` | | | `-(0 xx (4420 +0) -10 xx (0 +0) +0 xx (0 -1156))` | `+(5 xx (4420 +0) -10 xx (1300 +0) +0 xx (0 +0))` | `-(5 xx (0 +0) +0 xx (1300 +0) +0 xx (340 +0))` | `+(5 xx (0 -1156) +0 xx (0 +0) +10 xx (340 +0))` | | | `+(0 xx (0 +0) -10 xx (1300 -1156) +0 xx (0 +0))` | `-(5 xx (0 +0) -10 xx (0 +0) +0 xx (0 +0))` | `+(5 xx (1300 -1156) +0 xx (0 +0) +0 xx (0 +0))` | `-(5 xx (0 +0) +0 xx (0 +0) +10 xx (0 +0))` | | | `-(0 xx (0 -1156) -10 xx (0 +0) +0 xx (340 +0))` | `+(5 xx (0 -1156) -10 xx (0 -340) +0 xx (0 +0))` | `-(5 xx (0 +0) +0 xx (0 -340) +0 xx (0 -100))` | `+(5 xx (340 +0) +0 xx (0 +0) +10 xx (0 -100))` | |
| T |
|
= | | `4896` | `0` | `-1440` | `0` | | | `0` | `9100` | `0` | `-2380` | | | `-1440` | `0` | `720` | `0` | | | `0` | `-2380` | `0` | `700` | |
| T |
|
= | | `4896` | `0` | `-1440` | `0` | | | `0` | `9100` | `0` | `-2380` | | | `-1440` | `0` | `720` | `0` | | | `0` | `-2380` | `0` | `700` | |
|
`"Now, "A^(-1)=1/|A| × Adj(A)`
`"Here, "X = A^(-1) × B`
`:. X = 1/|A| × Adj(A) × B`
= | `1/(10080)` × | | `4896` | `0` | `-1440` | `0` | | | `0` | `9100` | `0` | `-2380` | | | `-1440` | `0` | `720` | `0` | | | `0` | `-2380` | `0` | `700` | |
| × | |
= | `1/(10080)` × | | `4896×270+0×48-1440×508+0×168` | | | `0×270+9100×48+0×508-2380×168` | | | `-1440×270+0×48+720×508+0×168` | | | `0×270-2380×48+0×508+700×168` | |
|
= | `1/(10080)` × | | `590400` | | | `36960` | | | `-23040` | | | `3360` | |
|
= | | `410/7` | | | `11/3` | | | `-16/7` | | | `1/3` | |
|
`:.[[a],[b],[c],[d]]=[[410/7],[11/3],[-16/7],[1/3]]`
`:. a=410/7, b=11/3, c=-16/7, d=1/3`
Now substituting this values in the equation is `y = a + bx + cx^2 + dx^3`, we get
`y = 410/7 +11/3x-16/7x^2+1/3x^3`
`y = 410/7 +11/3(X-1998)-16/7(X-1998)^2+1/3(X-1998)^3`
This material is intended as a summary. Use your textbook for detail explanation. Any bug, improvement, feedback then
|