Astronomical Applications Department, U.S. Naval Observatory Sensitivity Integral Page 16
[0] cost before simplification:
+
+
+
+
87 additions
258 multiplications
32 divisions
26 functions
37 subscripts
[0] cost after simplification:
+
+
+
+
69 additions
185 multiplications
16 divisions
26 functions
29 subscripts
[0] error check:
0
Unfortunately, this simplification does not lead to more efficient results for parts[0..3].
Finally, combine the five parts of the integral.
:=
defint
collect
,
,
+
=
' '
k
0
3
parts
' '
k
tmp4 [
]
,
,
,
sin cos
1
2
factor
(
)
cost defint
+
+
+
+
1155 additions
3970 multiplications
320 divisions
64 functions
1080 subscripts
Surely we can do better than this. Employ the cleanup routine that we wrote near the end of
section 2
.
(
)
cleanup
,
,
defint
1
2
cleanup[0]: number of unique sin/cos terms:
64
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 r (
)
- +
1
g
r (
)
+
1
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[9]: error check:
0
(
)
cost %
+
+
+
+
885 additions
2287 multiplications
160 divisions
64 functions
1039 subscripts
:=
defint
=
(
)
S , , , ,
,
r s g T
1
2
%%
This is much better, though still somewhat bulky. Let's determine the cost of an optimized
expression sequence that would constitute the body of a fortran subroutine if we were to construct
one now.
(
)
cost
(
)
optimize
(
)
rhs defint
+
+
+
+
+
409 additions
632 multiplications
87 divisions
64 functions
148 subscripts
346 assignments
Compare this with the equivalent for the indefinite integration result (remember to multiply by
two).
2
(
)
cost
(
)
optimize
(
)
rhs indef
Page 16