  We investigate upper-division student difficulties with direct integration in
multiple contexts involving the calculation of a potential from a continuous
distribution (e.g., mass, charge, or current). Integration is a tool that has
been historically studied at several different points in the curriculum
including introductory and upper-division levels. We build off of these prior
studies and contribute additional data around student difficulties with
multi-variable integration at two new points in the curriculum: middle-division
classical mechanics, and upper-division magnetostatics. To facilitate
comparisons across prior studies as well as the current work, we utilize an
analytical framework that focuses on how students activate, construct, execute,
and reflect on mathematical tools during physics problem solving (i.e., the
ACER framework). Using a mixed-methods approach involving coded exam solutions
and student problem-solving interviews, we identify and compare students'
difficulties in these two different context and relate them to what has been
found previously in other levels and contexts. We find that some of the
observed student difficulties were persistent accross all three contexts (e.g.,
identifying integration as the appropriate tool, and expressing the difference
vector), while other difficulties seemed to fade as students advanced through
the curriculum (e.g., expressing differential line, area, and volume elements).
We also identified new difficulties that appear in different contexts (e.g.,
interpreting and expressing the current density).
