Astronomical Applications Department, U.S. Naval Observatory Linear Least Squares Page 19
:=
t1
(
)
sum
,
[ ]
Y i
=
i
..
1 N ;
:=
t2
(
)
sum
,
^
(
)
ln [ ]
t i
2
=
i
..
1 N ;
:=
t4
(
)
sum
,
(
)
ln [ ]
t i
=
i
..
1 N ;
:=
t5
(
)
sum
,
(
)
ln [ ]
t i
[ ]
Y i
=
i
..
1 N ;
:=
t8
^
t4 2;
:=
t11
/
(
)
1
- +
t8
t2 N ;
:=
[ ]
tmp 1
(
)
-
t2 t1
t4 t5 t11;
:=
[ ]
tmp 2
(
)
-
t5 N
t1 t4 t11;
tmp
end
Exponential
leastsqrs
, , ,
=
Y
+
A B e
t
i
t i [
]
,
A B
leastsqrs[0]: normal equations
=
-
+
+
2 S
0
2 A N 2 B T
0
0
=
-
+
+
2 S
1
2 A T
0
2 B T
1
0
leastsqrs[0]: Solving the normal equations...
leastsqrs[0]: substitution list
=
-
+
=
i 1
N
e
t
i
2
=
i 1
N
e
t
i
2
N
=
S
0
=
i 1
N
Y
i
=
T
0
=
i 1
N
e
t
i
=
S
1
=
i 1
N
e
t
i
Y
i
,
,
,
,
=
T
1
=
i 1
N
e
t
i
2
leastsqrs[0]: Verifying the solution...
,
=
A
-
S
0
T
1
T
0
S
1
=
B
-
S
1
N T
0
S
0
(
)
eval
,
% _subslist
=
A
-
=
i 1
N
Y
i
=
i 1
N
e
t
i
2
=
i 1
N
e
t
i
=
i 1
N
e
t
i
Y
i
-
+
=
i 1
N
e
t
i
2
=
i 1
N
e
t
i
2
N
,
Page 19