Astronomical Applications Department, U.S. Naval Observatory Sensitivity Integral Page 5
# terms, then restore the temporaries.
debug_print(procname,`simplifying...`,0);
tmp := mess:
Tlist := []:
for i from 1 to nops(arglist) do
tmp := subs( arglist[i]=T.i, tmp );
Tlist := [op(Tlist),T.i];
od;
tmp := collect(tmp,[sin,cos,op(Tlist)],factor);
for i from 1 to nops(arglist) do
tmp := subs( T.i=arglist[i], tmp );
od;
debug_print( procname, `error check:`, 0,
factor(expand(tmpmess)) );
# We're done.
tmp;
end:
Okay, here we go.
(
)
cleanup
,
indef x
cleanup[0]: number of unique sin/cos terms:
26
cleanup[0]: arg list:
 +
2 s
r
r g
 
2 s
r
r g
+ +
2 s
r
r g
+ 
2 s
r
r g

s
r g

2 s
2 r g
+
2 s
2 r g
 +
r
r g
+
r
r g
,
,
,
,
,
,
,
,
,
[
+
s
r g 2 r g

2 s
2 r

s
r
+
2 s
2 r
+
s
r r g 2 s 2 r r s
,
,
,
,
,
,
,
,
, , ]
cleanup[0]: simplifying...
cleanup[2]: error check:
=
0
0
;
(
)
cost
(
)
rhs %
(
)
cost
(
)
rhs indef
+
+
+
297 additions
26 functions
764 multiplications
80 divisions
+
+
+
437 additions
26 functions
959 multiplications
240 divisions
Our efforts have paid off.
:=
indef
%%%
Now we will create a Maple procedure out of this result. (A Maple procedure is needed in order
to generate a fortran subroutine.) We first substitute for the
a
i
since the subscript notation will
cause Maple problems in what comes next.
:=
tmp
(
)
subs
,
(
)
seq
,
=
a
i
.
a i
=
i
..
0
4
(
)
rhs indef
readlib(optimize):
sensitivity_expr :=
(
)
optimize/makeproc
,
[
]
(
)
optimize
,
tmp tryhard
=
parameters
[
]
,
, , ,
x
(
)
seq
,
.
a i
=
i
..
0
4
s r g
The cost of the optimized expression sequence is
Page 5