116 CHAPTER 3. CLASSICAL MULTISCALE ALGORITHMS
This lemma allows us to convert multi-p ole expansions into local expansions. Note
that contrary to the multi-pole expansions which are centered at the centers of the boxes
where the sources lie in, the local expansions are centered at the centers of the boxes
where the targets lie in.
Once we have the local expansions for all the boxes, the final step is to distribute
the contributions of the sources in each box to the targets in its interaction list. For
this purpose, we need t o translate a local expansion with respect to one center to a lo cal
expansion with respect to a different center, i.e. we need to convert an expansion of the
form
P
p
k=0
a
k
(z −z
0
)
k
to a form
P
p
k=0
b
k
z
k
. This can be done using the standard Horner
algorithm.
We are ready to describe the main steps in FMM.
1. Initialization : Build log
4
(N/s) levels of boxes so that there are, on average, s
particles per box at the finest level.
2. Upward Pass: Beginning at the finest level, create the multi-pole expansions of the
potential for each box due to the sources in this box. The expansions for all boxes
at coarser levels are then formed by the merging procedure described in Lemma 3.
The cost is O(Np + p
2
N/s).
3. Downward Pass: Beginning at the coarsest level, convert the multi-pole expansion
of each box to a local expansion about the centers of the boxes in its interaction
list. These local expansions are shifted to their children’s level, using the Horner
algorithm described above. Therefore at each level, the local expansion for each
box receives contributions from two sources: The contribution inherited from the
parent box, and the contributions from sources in its interaction list.
At t he finest level, we have local expansions for each finest scale box, which ac-
count for contributions from charges that lie outside the nearest n eighors of each
box. These local expansions are then evaluated at each target. Contributions from
neighboring finest level boxes are computed directly.
The cost for pre-computing the local expansions is O(p
2
N/s). The cost for evaluating
the local expansions at the targets is O(pN/s). Thus the total cost in this step is
O(Np
2
/s). The cost for the direct summation over the nearest neighbors at the finest