Astronomical Applications Department, U.S. Naval Observatory Linear Least Squares Page 12
end
Polynomial of degree 3
In this example, we will not show the solution, since it is a bit unwieldy.
leastsqrs
, , ,
=
Y
+
+
+
A B t
i
C t
i
2
D t
i
3
t i [
]
, , ,
A B C D
leastsqrs[0]: normal equations
=
-
+
+
+
+
2 S
0
2 A N 2 B T
1
2 C T
2
2 D T
3
0
=
-
+
+
+
+
2 S
1
2 A T
1
2 B T
2
2 C T
3
2 D T
4
0
=
-
+
+
+
+
2 S
2
2 A T
2
2 B T
3
2 C T
4
2 D T
5
0
=
-
+
+
+
+
2 S
3
2 A T
3
2 B T
4
2 C T
5
2 D T
6
0
leastsqrs[0]: Solving the normal equations...
leastsqrs[1]: substitution list
=
i 1
N
t
i
6
=
i 1
N
t
i
2 3
2
=
i 1
N
t
i
2 2
=
i 1
N
t
i
3
=
i 1
N
t
i
5
=
i 1
N
t
i
2 2
=
i 1
N
t
i
4 2
-
-
=
=
i 1
N
t
i
2
=
i 1
N
t
i
5 2
N
=
i 1
N
t
i
2
=
i 1
N
t
i
6
=
i 1
N
t
i
4
N
+
-
2
=
i 1
N
t
i
2
=
i 1
N
t
i
=
i 1
N
t
i
4
=
i 1
N
t
i
5
3
=
i 1
N
t
i
2
=
i 1
N
t
i
3 2
=
i 1
N
t
i
4
+
+
2
=
i 1
N
t
i
2
=
i 1
N
t
i
=
i 1
N
t
i
6
=
i 1
N
t
i
3
=
i 1
N
t
i
4 3
N
=
i 1
N
t
i
6
=
i 1
N
t
i
3 2
N
-
+
+
2
=
i 1
N
t
i
4
N
=
i 1
N
t
i
3
=
i 1
N
t
i
5
2
=
i 1
N
t
i
=
i 1
N
t
i
3
=
i 1
N
t
i
4 2
-
-
2
=
i 1
N
t
i
=
i 1
N
t
i
3 2
=
i 1
N
t
i
5
=
i 1
N
t
i
2
=
i 1
N
t
i
6
=
i 1
N
t
i
4
=
i 1
N
t
i
2
=
i 1
N
t
i
5 2
+
+
-
=
i 1
N
t
i
3 4
-
=
T
6
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