Change of coordinates for coends I recall that there was a theorem mimicking the change of variables' integral formula. Surprisingly, I can't find it on the Fosco Loregian book. The change of variables formula states that, if $f: E \to B$ is a measurable mapping between measurable spaces and $\mu$ is a measure on $E$, then for all $g: B \to \mathbb{R}$
$$ \int_E f(g(x)) d \mu(x) = \int_B g(x) d f_* \mu(x) $$
Analogously, I want to understand how to reduce the coend over a big category if the bifunctor depends on a smaller category.
In other words, let $p: E \to B$ be a functor of categories and a bifunctor $\alpha: B \times B^{op} \to D$. Define $p^*F: E\times E^{op} \to D$ as the composition $F(p \times p^{op})$. In case $p$ has set-fibers and is a surjection, I think one should have
$$ \int^{y \in E} (p^*F) (y,y) \simeq \int^{x \in B} E_{x} \cdot F(x,x )$$
where $\cdot$ is the copower and $E_x$ is the fiber of $E \to B$ in $x$.

Is there a general formula for $$ \int^{y \in E} (p^*F) (y,y) $$ and what is a reference to the proof?

 A: $\require{AMScd}$First of all, I suspect that "$p$ has set fibers and it is surjective" means that it is a discrete fibration. In that case, $p$ corresponds to a functor $G_p : C \to Set$ (covariant if $p$ is an opfibration, contravariant if it's a fibration) defined precisely as $Gx = E_x$. So, a better way to rephrase your question would be the following

Conjecture. Let $F : C^{op}\times C \to D$ a functor with codomain a cocomplete category; let $P : C^{op}\to Set$ be a presheaf. Then
$$\int^X PX^-\cdot F(X^-,X^+)\cong \int^{W\in Elts(P)} F(\Sigma_PW,\Sigma_PW) \tag{$\heartsuit$}$$ where

*

*the "sign rule" is a convention on dummy variables that says that all $X^-$ vary simultaneouly, and contravariantly, and all $X^+$ vary
simultaneously, and covariantly;

*$Elts(P)$ denotes the category of elements of $P$ and $\Sigma_P$ is the associated forgetful functor, which is a discrete fibration.

Without loss of generality, all discrete fibrations are of this form.
Dually, if $Q : C\to Set$ is a copresheaf, $$\int^X QX^+\cdot
F(X^-,X^+)\cong \int^{W\in Elts(P)} F(\Sigma_PW,\Sigma_PW) $$

But coends have nothing special against ends, and by properly dualising the statement, we get that for a presheaf $P$ and copresheaf $Q$,
$$\begin{gather*}
\int_X PX^+\pitchfork F(X^-,X^+)\cong \int_{W\in Elts(P)} F(\Sigma_PW,\Sigma_PW) \\ \int_X QX^-\pitchfork F(X^-,X^+)\cong \int_{W\in Elts(P)} F(\Sigma_PW,\Sigma_PW)
\end{gather*}$$ (or probably the opposite of $Elts(P)$?)
This is meant to address the problem that the integral $\int^X PX\cdot F(X,X)$ depends on three variables, and what exactly is the coend you're performing?
The precise sense of the conjecture is that for every fibration $p : E\to C$ there is a coequalizer diagram
$$
\sum_{x\to y} E_y \cdot F(y,x) \rightrightarrows \sum_{x\in X} E_x\cdot F(x,x) \to \textstyle\int p^*F
$$
or more precisely that $\int p^*F$ is the coend of the functor
$$\begin{CD}
C^{op}\times C \\
@V\Delta\times C VV\\
C^{op}\times C^{op} \times C\\
@VG_p\times C^{op}\times C VV\\
Set \times C^{op} \times C\\
@VSet\times FVV\\
Set\times D\\
@V\_\cdot\_VV\\
D
\end{CD}$$
In "stupid" examples, this works:

*

*If $P$ is constant, say $PX\equiv A$ for a set $A$, then $$\int^X PX\cdot F(X,X) \cong A\cdot \int^X F(X,X)$$ which, since $Tw(C\times A)=Tw(C)\times A$ when $A$ is discrete, seems to be precisely the RHS of $(\heartsuit)$.

*If $P$ is representable and $F$ is mute, it reduces to a "Yoneda-like" argument and actually this is enough to say that the conjecture is true for any $P$ and $F$ mute, because $\_\cdot\_$ is separately cocontinuous in both variables; alternatively, one can argue that the conjecture reduces to the fact that the colimit of $F$ weighted by $P$ is the coend $\int^X PX\cdot FX$. Incidentally, this suggests that if you want to state a similar conjecture in an enriched setting, it will only work for the bases of enrichment that have a meaningful Grothendieck construction, e.g. for the class of categories of this paper.

Remark. By the abovementioned cocontinuity of $\_\cdot\_$ it might be sufficient to prove $(\heartsuit)$ in the case where $P$ is representable. But one must then find a way to circumvent the following problem: let's compute with the LHS of $(\heartsuit)$, and get
$$\begin{align*}
\int^X PX\cdot F(X,X) &= \int^X \big(\text{colim}_\alpha C(X,A_\alpha)\big)\cdot F(X,X) \\ 
&= \text{colim}_\alpha\int^X C(X,A_\alpha) \cdot F(X,X) \\ 
&=\text{colim}_\alpha\int^{(X,u) \in C/A_\alpha} F(\Sigma (X,u),\Sigma (X,u))
\end{align*}$$ from which it is "evident" (?!) that the sense in which this is just $\int^{W \in Elts(P)} F(\Sigma W, \Sigma W)$ is the same sense in which $Elts(P)\cong \int^X C/X\times PX$. Yet, I don't see a formal manipulation ensuring that this is true, and I find a direct, hands-on proof pretty daunting.
Probably it's a good point to stop and find counterexamples, so that at least we have a clear idea of when the conjecture is false. We're in the same ballpark of this question I asked years ago, so I suspect that a similar condition as the one stated in the comments, to "compute colimits fiberwise" is needed.
A different path that one might take is more belligerent: find a cowedge $F(\Sigma_P(X,a), \Sigma_P(X,a)) \to \int^X PX\cdot F(X,X)$ and prove that it is initial. But I don't trust the back-of-the-envelope computation that seems to say $(\heartsuit)$ is true in general.

PS: join the ItaCa gang!
A: Here is my attempt at a partial answer:
First, a recollection about colimits along coCartesian fibrations: Let $p: X\to Y$ be a coCartesian fibration, and $f: X\to D$ a functor to a cocomplete category.
For each $y\in Y$, we can consider the colimit of the restriction of to the fiber $X_y$ of $p$ at $y$ : $\mathrm{colim}_{X_y} f$. $p$ being a coCartesian fibration means that $X_y$ is (pseudo)functorial in $y$, so these colimits are functorial and assemble into a functor $Y\to D$, whose colimit $\newcommand{\colim}{\mathrm{colim}} \colim_{y\in Y}\colim_{X_y}f$ is isomorphic to $\colim_X f$.
I'm going to apply this here to $Tw(p) : Tw(E)\to Tw(B)$, where $Tw$ is the twisted arrow category. Recall indeed that $\int^C F = \colim_{Tw(C)}F\circ q$, where $q: Tw(C)\to C\times C^{op}$ is the canonical projection.
In particular, I need $Tw(p)$ to be a coCartesian fibration. A sufficient condition for this is (if I haven't made a mistake) that $p$ be a bicartesian fibration, that is, it is a coCartesian fibration and a cartesian fibration. Equivalently, it's a cocartesian fibration and for any $b_0\to b_1$ in $B$, the induced functor $E_{b_0}\to E_{b_1}$ has a right adjoint.
In this case, we can compute $\int^E p^*F = \colim_{Tw(E)} p^*F \circ q_E= \colim_{f\in Tw(B)}\colim_{Tw(E)_f} (p^*F\circ q_E)_{\mid Tw(E)_f}$.
Let us see what this says. $p^*F : E\times E^{op}\to D$ is simply $F\circ (p\times p^{op})$ and clearly $(p\times p^{op})\circ q_E= q_B\circ Tw(p)$ so that $(p^*F\circ q_E)_{\mid Tw(E)_f}$ is a constant functor with value $F\circ q_B(f) = F(b_0,b_1)$ if $f: b_0\to b_1$.
So the colimit simplifies to $\colim_{(b_0\xrightarrow{f}b_1)\in Tw(B)} |Tw(E)_f|\times F(b_0,b_1)$ where : $|C|$, for a category $C$, is the "classifying set" of $C$, i.e. the set of path components of the undirected graph spanned by $C$; and for a set $P$ and an element $d\in D$, $P\times d$ means a $P$-indexed coproduct of $d$.
Now we're getting closer to a $B$-indexed co-end, because the $F(b_0,b_1)$ factor has the form $F\circ q_B$, but the term $|Tw(E)_f|$ doesn't seem to be so nice. We obtain:

If $p: E\to B$ is a bicartesian fibration, $\int^E p^*F \cong \colim_{f\in Tw(B)}(|Tw(E)_f|\times (F\circ q_B))$


If $p: E\to B$ is a bicartesian fibration, and if the functor $Tw(B)\to Set$, $f\mapsto |Tw(E)_f|$ is of the form $T\circ q_B$ for some functor $T: B\times B^{op}\to Set$, then for any $F$, $\int^E p^*F \cong \int^B T\times F$.

Note that this assumption on $Tw(E)_f$ is "universal" and doesn't depend on the functor $F$. This is somehow because there is a universal coend.
Indeed, if you think about the case where $F: B\times B^{op}\to Set$ is constant with value $*$, then you'll find that $\int^E p^*F$ is going to be exactly the colimit over $Tw(B)$ of $Tw(E)_f$, so if you want a general co-end formula, it better specialize to one in this case.
So when is this hypothesis satisfied ? I'm not sure. Certainly, $f\mapsto Tw(E)_f$ actually depends on $f$ and not just $b_0\to b_1$. In terms of objects, letting $f_!$ denote the pushforward along $f$, an object of $Tw(E)_f$ is classified by some $e_0\in E_{b_0}$, some $e_1\in E_{b_1}$ and some $f_!e_0\to e_1$ in $E_{b_1}$.
Naively, it looks like $Tw(E)_f \simeq E_{b_0}\times_{E_{b_1}}Tw(E_{b_1})$ which looks like it doesn't depend on $f$, but $E_{b_0}\to E_{b_1}$ in this pullback is precisely $f_!$. Maybe in certain situations you can prove that it doesn't depend on $f$, but this would be specific to certain $p$'s. For example if $B$ is a preorder then there is at most one $f$ per $b_0, b_1$, so that $Tw(B) \to B\times B^{op}$ is a fully faithful inclusion, so there exists a factorization through $q_B$ (say by left Kan extension). Therefore, a special case is :

If $E\to B$ is a bicartesian fibration, and $B$ is a preorder, then $\int^E p^*F \cong \int^B T\times F$, where, if $b_0\leq b_1$,  $T(b_0,b_1)\cong \colim_{(x,y)\in E_{b_0}^{op}\times E_{b_1}}\hom_E(x,y)$.

Let me also finish with a remark: I said bicartesian fibration to have that $Tw(p)$ was a coCartesian fibration and have this nice formula with $Tw(E)_f$, but the recollection I gave at the very start works for an arbitrary functor $p: X\to Y$ if one replaces $X_y$ with $X_{/y} := X\times_Y Y_{/y}$. In our story we then get the same thing with $\colim_{f\in Tw(B)}\colim_{Tw(E)_{/f}} F\circ q_B\circ Tw(p)$ except that now the latter isn't even constant on $Tw(E)_{/f}$. If you assume on top of everything that it is, then you can again do something similar etc. But this is going to be even rarer.
