Astronomical Applications Department, U.S. Naval Observatory Linear Least Squares Page 20
=
B
-
=
i 1
N
e
t
i
Y
i
N
=
i 1
N
e
t
i
=
i 1
N
Y
i
-
+
=
i 1
N
e
t
i
2
=
i 1
N
e
t
i
2
N
:=
tmp
(
)
array
(
)
map
,
x
( )
rhs x
(
)
eval
,
%% _subslist
(
)
optimize
(
)
makeproc
,
tmp
=
parameters [
]
, ,
N Y t
, ,
N Y t
proc
(
)
local
;
,
, , ,
, ,
t5 t11 t1 t2 tmp t4 t8
:=
tmp
(
)
array ..
1 2 ;
:=
t1
(
)
sum
,
[ ]
Y i
=
i
..
1 N ;
:=
t2
(
)
sum
,
^
(
)
exp [ ]
t i
2
=
i
..
1 N ;
:=
t4
(
)
sum
,
(
)
exp [ ]
t i
=
i
..
1 N ;
:=
t5
(
)
sum
,
(
)
exp [ ]
t i
[ ]
Y i
=
i
..
1 N ;
:=
t8
^
t4 2;
:=
t11
/
(
)
1
- +
t8
t2 N ;
:=
[ ]
tmp 1
(
)
-
t1 t2
t4 t5 t11;
:=
[ ]
tmp 2
(
)
-
t5 N
t4 t1 t11;
tmp
end
Exponentially Decaying Sinusoid
The substitution list for this case is quite long, so its output will be suppressed.
:=
printlevel
1
leastsqrs
, , ,
=
Y
+
A e
(
)
-
t
i
(
)
+
B
(
)
cos 2
t
i
C
(
)
sin 2
t
i
t i [
]
, ,
A B C
leastsqrs[0]: normal equations
=
+
-
+
2 A N (
)
-
4 T
0
2 T
2
B 2 S
0
4 C T
3
0
=
+
+
-
+
(
)
-
4 T
0
2 T
2
A (
)
-
+
8 T
4
8 T
6
2 T
5
B (
)
-
+
4 T
8
8 T
7
C 4 S
1
2 S
2
0
=
+
-
+
4 A T
3
(
)
-
+
4 T
8
8 T
7
B 4 S
3
8 C T
1
0
leastsqrs[0]: Solving the normal equations...
leastsqrs[2]: Verifying the solution...
:=
soln
%
for in
do
od
p
soln
( )
print p
Page 20