Astronomical Applications Department, U.S. Naval Observatory Linear Least Squares Page 2
Next, we calculate the partial derivatives of
2
with respect to the model parameters, setting these
derivatives to zero and thus forming the normal equations.
=
A
( )
rhs %
0
=
B
(
)
rhs %%
0
=
C
(
)
rhs %%%
0
=
=
i 1
N
-
+
+
+
2 y
i
2 A 2 B t
i
2 C t
i
2
0
=
=
i 1
N
-
2
- -
-
y
i
A B t
i
C t
i
2
t
i
0
=
=
i 1
N
-
2
- -
-
y
i
A B t
i
C t
i
2
t
i
2
0
:=
NormalEqs
{
}
,
,
% %% %%%
Finally, we solve the normal equations for the parameter values. These values are the linear least
squares solution.
:=
sols
(
)
sortsols
,
(
)
solve
,
(
)
value NormalEqs {
}
, ,
A B C
[
]
, ,
A B C
for in
do
od
p
sols
( )
print p
A
=
i 1
N
y
i
=
i 1
N
t
i
3 2
=
i 1
N
y
i
=
i 1
N
t
i
4
=
i 1
N
t
i
2
=
i 1
N
t
i
=
i 1
N
t
i
y
i
=
i 1
N
t
i
4
-
+
=
=
i 1
N
t
i
=
i 1
N
t
i
3
=
i 1
N
t
i
2
y
i
=
i 1
N
t
i
2
=
i 1
N
t
i
3
=
i 1
N
t
i
y
i
-
-
=
i 1
N
t
i
2 2
=
i 1
N
t
i
2
y
i
+
2
=
i 1
N
t
i
=
i 1
N
t
i
2
=
i 1
N
t
i
3
N
=
i 1
N
t
i
3 2
-
+
=
i 1
N
t
i
2 3
=
i 1
N
t
i
4
=
i 1
N
t
i
2
=
i 1
N
t
i
4
N
=
i 1
N
t
i
2
+
+
-
B
=
i 1
N
t
i
4
=
i 1
N
y
i
=
i 1
N
t
i
=
i 1
N
t
i
=
i 1
N
t
i
2
y
i
=
i 1
N
t
i
2
-
=
=
i 1
N
t
i
y
i
N
=
i 1
N
t
i
4
=
i 1
N
y
i
=
i 1
N
t
i
2
=
i 1
N
t
i
3
N
=
i 1
N
t
i
3
=
i 1
N
t
i
2
y
i
-
-
+
Page 2