The double derangements problem is discussed in the 1934 paper "Théorie des substitutions. Sur un problème de permutations" by Jacques Touchard. I've also seen references to a 1953 paper by Touchard,
Permutations discordant with two given permutations, Scripta Math., 19 (1953), 108-119,
but I don't have a copy, and so can't comment on it. I'll try to describe some of the results of the first paper.
Touchard starts by mentioning a problem of Cayley, Muir, Laisant, and Moreau, which actually goes back to Tait. The problem is to enumerate permutations of $\{0, 1,\ldots, n-1\}$ that differ from both the permutation $i\mapsto i$ and the permutation $i\mapsto i+1\pmod{n}$ at every position, that is, at every $i$ in the set. (As an aside, the solution to the ménage problem is $2\cdot n!$ multiplied by the number of such permutations.) He also mentions the problem of Netto of enumerating permutations that differ from both the permutation $i\mapsto i$ and the permutation $i\mapsto n-1-i\pmod{n}$ at every position.
Touchard's aim is to solve the more general problem of enumerating permutations of $\{0, 1, \ldots, h+n-1\}$ whose values differ from those of two given permutations $\sigma$ and $\tau$ at every $i$. He identifies as a key special case the one where the permutation $\sigma\circ\tau^{-1}$ has $h$ $1$-cycles and a single $n$-cycle, with $n\ge2$. Restricting attention to this special case, let $\varphi(h;n)$ denote the number of permutations that differ from both $\sigma$ and $\tau$ at every $i$. The solution to the general problem can be expressed in terms of $\varphi(h;n)$.
Touchard paper is short on proofs. He first states a formula for the number of permutations $\pi$ of $\{0, 1, \ldots, h+n-1\}$ such that $\pi(i)\ne i$ for all $i$ in a set of $h$ specified elements,
$$
\nu(h,h+n)=\sum_{k=0}^h(-1)^k\binom{h}{k}(n+h-k)!.
$$
This can be derived by means of the standard inclusion-exclusion argument used to compute the number of derangements. Importantly, it applies equally to the situation where $\pi$ represents any one-to-one map from a set $A$ of cardinality $n+h$ to a set $B$ of the same cardinality, where there is a fixed one-to-one map $\rho$ from a subset $H$ of $A$ of cardinality $h$ to a subset $K$ of $B$, also of cardinality $h$, and where the problem is to enumerate all maps $\pi$ such that $\pi(j)\ne\rho(j)$ for all $j\in H$.
Touchard gives the formula
$$
\varphi(h; n)=\sum_{k=0}^n(-1)^k\frac{2n}{2n-k}\binom{2n-k}{k}\nu(h,h+n-k).
$$
He does not comment on the derivation of this formula, but likely he had in mind something like the following. Let the cycle decomposition of $\sigma\circ\tau^{-1}$ be $(d_1)(d_2)\ldots(d_h)(c_0c_1\ldots c_{n-1})$, which means that $\sigma\circ\tau^{-1}(d_j)=d_j$ for all $j\in\{1,2,\ldots,h\}$ and $\sigma\circ\tau^{-1}(c_j)=c_{j+1}$ for all $j\in\{0,1,\ldots,n-1\}$, where $j+1$ is computed $\mod n$. Define $H=\{b_1,b_2,\ldots,b_h\}$ to be the set of elements of $\{0,1,\ldots,h+n-1\}$ that map to the $d_j$ under $\sigma$ and $\tau$, that is, let $\tau(b_j)=\sigma(b_j)=d_j$. Similarly define $N=\{a_0,a_1,\ldots,a_{n-1}\}$ to be the set of elements that map to the $c_j$ under $\sigma$ and $\tau$, that is, let $\tau(a_j)=\sigma(a_{j-1})=c_j$, where $j-1$ is computed $\mod n$. The goal is to enumerate permutations $\pi$ of $\{0,1,\ldots,h_n-1\}$ that satisfy the two sets of conditions,
- $\pi(b_j)\ne d_j$ for all $j\in\{1,2,\ldots,h\}$,
- $\pi(a_j)\notin\{c_j,c_{j+1}\}$ for all $j\in\{0,1,\ldots,n-1\}$, where $j+1$ is computed $\mod n$.
Touchard's formula is obtained by using the principle of inclusion-exclusion to remove permutations that violate the second set of conditions from the set of permutations that satisfy the first set of conditions. The second set contains $2n$ conditions, but at most $n$ of them might be violated by any single permutation. To visualize which members of the second set of conditions are compatible with each other, form a graph of $2n$ vertices labelled by pairs $(a_j,c_j)$, representing the violations $\pi(a_j)=c_j$, and pairs $(a_j,c_{j+1})$, representing the violations $\pi(a_j)=c_{j+1}$. Place an edge between two violations when they cannot occur simultaneously. There will be an edge between $(a_j,c_j)$ and $(a_j,c_{j+1})$ since it is not possible for $\pi(a_j)$ to equal both $c_j$ and $c_{j+1}$. There will also be an edge between $(a_j,c_{j+1})$ and $(a_{j+1},c_{j+1})$ since it is not possible for both $\pi(a_j)$ and $\pi(a_{j+1})$ to equal $c_{j+1}$. The result is a cycle of length $2n$.
The factor $\frac{2n}{2n-k}\binom{2n-k}{k}$ in Touchard's formula is the number of ways of choosing $k$ compatible violations of the second set of conditions, or equivalently, the number of ways of choosing $k$ non-consecutive vertices from a cycle of length $2n$. (See here or here.) Making such a choice fixes the value of the permutation $\pi$ for $k$ of the elements of $N$. To specify $\pi$ completely, it remains to fix its value for the remaining $n-k$ elements of $N$ and for the $h$ elements of $H$. For the latter, the first set of conditions are required to hold. As noted above, the number of ways of assigning these values of $\pi$ is $\nu(h,h+n-k)$, which establishes the formula.
Touchard points out that the solution to the problem of Tait, Cayley, Muir, Laisant, and Moreau, which is related to the ménage problem, follows by setting $h=0$ in his formula. Observe that $\nu(0,n-k)$ in this formula is simply $(n-k)!$.
While Touchard's formula for $\varphi(h;n)$ has been derived under the assumption $n\ge2$, the formula for general permutations, discussed below, requires that $n$ sometimes equal $1$, $0$, or a negative number. Touchard asks us to extend the definition by setting $\varphi(h;-n)=\varphi(h;n)$. For $n=1$, we simply apply Touchard's formula to get
$$
\varphi(h;1)=\nu(h,h+1)-2\nu(h,h).
$$
I was surprised to find that when $h=0$ this equals $-1$. For $n=0$, Touchard's formula is undefined, and Touchard asks us instead to use
$$
\varphi(h;0)=2\nu(h,h).
$$
The definitions for $n=1$, $0$ are natural given the connection of Touchard's formula with Chebyshev polynomials, explained in the next section, and the definition for negative $n$ stems from the use of a formula for products of Chebyshev polynomials in the derivation of the general formula in the section following that.
Recurrence for $\varphi(h;n)$: The following recurrence holds for all nonnegative $h$ and all $n$:
$$
\varphi(h+1;n)=\varphi(h;n-1)+\varphi(h;n)+\varphi(h;n+1).
$$
The proof makes use of a property of $\nu(h,h+n)$, namely that
$$
\nu(h+1,h+1+n)=\nu(h,h+n+1)-\nu(h,h+n),
$$
or, in other words, that $\nu(h+1,h+1+n)$ is the forward difference of $\nu(h,h+n)$, regarded as a function of $n$. It follows that $\nu(h,h+n)$ is the $h^\text{th}$ forward difference of $\nu(0,n)=n!$. The proof also uses a the connection of the factor $(-1)^k\frac{2n}{2n-k}\binom{2n-k}{k}$ in Touchard's formula with Chebyshev polynomials of the first kind. An explicit formula for the Chebyshev polynomials of the first kind, for $N>0$ is
$$
T_N(x)=\frac{1}{2}\sum_{k\ge0}(-1)^k\frac{N}{N-k}\binom{N-k}{k}(2x)^{N-2k},
$$
from which we conclude that the above mentioned factor is the coefficient of $x^{n-k}$ in $2T_{2n}(x^{1/2}/2)$, which we will denote $P_n(x)$. The defining recurrence for $T_N(x)$ is $T_{N+1}(x)=2xT_N(x)-T_{N-1}(x)$. Applying the recurrence to the first term on the right gives $T_{N+1}(x)=2x(2xT_{N-1}(x)-T_{N-2}(x))-T_{N-1}(x)$. Applying the recurrence one more time to the $T_{n-2}(x)$ term gives $T_{N+1}(x)=4x^2T_{N-1}(x)-(T_{n-1}(x)+T_{N-3}(x))-T_{N-1}(x)$, or
$$
T_{N+1}(x)=(4x^2-2)T_{N-1}(x)-T_{N-3}(x).
$$
Letting $N+1=2n+2$ and replacing $x$ with $x^{1/2}/2$ yields
$$
P_{n+1}(x)=(x-2)P_n(x)-P_{n-1}(x).
$$
Letting $a(n,k)=(-1)^k\frac{2n}{2n-k}\binom{2n-k}{k}$ be the expression in Touchard's formula, so that
$$
P_n(x)=\sum_{k\ge0}a(n,k)x^{n-k},
$$
we find that
$$
a(n+1,k)=-2a(n,k)+a(n,k-1)-a(n-1,k),
$$
or, rearranging terms,
$$
a(n+1,k)+a(n,k)+a(n-1,k)=a(n,k-1)-a(n,k).
$$
This can be used to generate all the coefficients, with the initial conditions $a(0,0)=2$ and $a(0,k)=0$ for $k\ne0$. Note that this definition of $P_n$ is compatible with Touchard's definition of $\varphi(h;0)$.
Now to prove the recurrence, evaluate
$$
\begin{aligned}
\varphi(h+1; n)=&\sum_{k=0}^na(n,k)\nu(h+1,h+1+n-k)\\
=&\sum_{k=0}^na(n,k)(\nu(h,h+n+1-k)-\nu(h,h+n-k))\\
=&\sum_{k=0}^{n+1}(a(n,k-1)-a(n,k))\nu(h,h+n-k)\\
=&\sum_{k=0}^{n+1}(a(n+1,k)+a(n,k)+a(n-1,k))\nu(h,h+n-k)\\
=&\varphi(h;n+1)+\varphi(h;n)+\varphi(h;n-1),
\end{aligned}
$$
where Touchard's formula has been used in line 1, the forward-difference property of $\nu$ has been used in line 2, the first term in the summation has been reindexed in line 3, and the recurrence for $a$ has been used in line 4. This establishes the recurrence for all positive $n$. It is easy to check that it also holds for $n\le0$ under Touchard's definition $\varphi(h;-n)=\varphi(h;n)$.
Here is a table of values of $\varphi(h;n)$ for some small $n$ and $h$.
$$
\begin{array}{r|rrrrrrr}
h/n & 0 & 1 & 2 & 3 & 4 & 5 & 6\\
\hline
0 & 2 & -1 & 0 & 1 & 2 & 13 & 80\\
1 & 0 & 1 & 0 & 3 & 16 & 95 & 672\\
2 & 2 & 1 & 4 & 19 & 114 & 783 & 6164\\
3 & 4 & 7 & 24 & 137 & 916 & 7061 & 61720\\
4 & 18 & 35 & 168 & 1077 & 8114 & 69697 & 671736\\
5 & 88 & 221 & 1280 & 9359 & 78888 & 749547 & 7913440\\
6 & 530 & 1589 & 10860 & 89527 & 837794 & 8741875 & 100478588
\end{array}
$$
One can check that the recurrence holds. The first row contains the
ménage numbers; the first column contains twice the numbers of derangements; the second column contains the forward differences of the numbers of derangements.
Formula for general permutations: With $\varphi(h;n)$ known, a formula for the general case can be written. Let $\sigma\circ\tau^{-1}$ have $h$ cycles of length $1$ and $s$ cycles of lengths $p_1,\ p_2,\ \ldots,\ p_s$, all greater than or equal to $2$. Touchard's expression for the number of permutations $\pi$ that differ from both $\sigma$ and $\tau$ at every $i\in\{0,1,\ldots,h+n-1\}$ is
$$
\sum\varphi(h;p_1\pm p_2\pm\ldots\pm p_s),
$$
where the sum is over all $2^{s-1}$ choices of sign. Note that second argument of $\varphi$ may equal $1$, $0$, or a negative value in the sum, in which case we use Touchard's definitions for these cases, described above.
I have checked that the formula works in a few special cases, namely $s=2$, $p_2=2$ and $p_1=2,\ 3,\ 4,\ 5$. This has a ménage-like interpretation where $p_1+2$ male-female couples are to be seated at two round tables, the first with $2p_1$ seats, the second with $4$ seats, such that women and men alternate seats and no one sits adjacent to their partner. For a given seating of the women, the problem is to enumerate possible seatings of the men. Clearly the partners of the women at table $2$ must sit at table $1$, and it is not too much work to compute the number of possibilities by hand for small values of $p_1$. The values one gets for $p_1=2,\ 3,\ 4,\ 5$ are $4,\ 12,\ 80, 580$, which are also what Touchard's formula gives.
To prove the general formula, we can consider the case $s=2$ (meaning $\sigma\circ\tau^{-1}$ has two cycles of lengths $p_1,p_2\ge2$), and then proceed by induction on $s$. When $s=2$, the second set of conditions on the permutation $\pi$ that appeared in the proof of the $s=1$ formula now applies separately to both cycles. The factor $a(n,k)=(-1)\frac{2n}{2n-k}\binom{2n-k}{k}$ in the inclusion-exclusion argument that accounted for the number of ways of choosing $k$ violated conditions from the second set gets replaced with a sum over all ways of apportioning the violations between the two cycles,
$$
\begin{aligned}
&\sum_{r=0}^k(-1)^r\frac{2p_1}{2p_1-r}\binom{2p_1-r}{r}(-1)^{k-r}\frac{2p_2}{2p_2-(k-r)}\binom{2p_2-(k-r)}{k-r}\\
&\quad=\sum_{r=0}^ka(p_1,r)a(p_2,k-r),
\end{aligned}
$$
which is the coefficient of $x^{p_1+p+2-k}$ when the product $P_{p_1}(x)P_{p_2}(x)$ is expanded. We can therefore apply an identity for products of Chebyshev polynomials of the first kind,
$$
2T_a(x)T_b(x)=T_{a+b}(x)+T_{\lvert a-b\rvert}(x),
$$
which implies
$$
P_a(x)P_b(x)=P_{a+b}(x)+P_{\lvert a-b\rvert}(x),
$$
to see the the needed coefficient is
$$
\sum_{r=0}^ka(p_1,r)a(p_2,k-r)=a(p_1+p_2,k)+a(\lvert p_1-p_2\rvert,k).
$$
Touchard's formula for $s=2$, and by induction, his formula for all $s$, then follows.
Alternative formula of Wyman and Moser: For completeness, I should mention that Wyman and Moser gave a slightly different formula for $\varphi(h;n)$ in the case related to the ménage problem ($h=0$) (equation 5.7 in the linked paper), and that their formula can be extended to general $h$.
Due to the connection of the expression $\frac{2n}{2n-k}\binom{2n-k}{k}$ with Chebyshev polynomials of the first kind, identities relating to Chebyshev polynomials can be used to find alternative expressions. Closely connected with the trigonometric identity, $\cos2\theta=2\cos^2\theta-1$ is the identity, $T_{2n}(x)=T_n(2x^2-1)$. We saw that $(-1)^k\frac{2n}{2n-k}\binom{2n-k}{k}$ is the coefficient of $x^{n-k}$ in $2T_{2n}(\sqrt{x}/2)$, which we called $P_n(x)$. So replacing $x$ with $\sqrt{x}/2$ and multiplying both sides of the identity by $2$ gives
$$
\begin{aligned}
P_n(x)&=\sum_{k\ge0}(-1)^k\frac{2n}{2n-k}\binom{2n-k}{k}x^{n-k}\\
&=\sum_{i\ge0}(-1)^i\frac{n}{n-i}\binom{n-i}{i}(x-2)^{n-2i}\\
&=\sum_{i\ge0}(-1)^i\frac{n}{n-i}\binom{n-i}{i}\sum_{j\ge0}\binom{n-2i}{j}(-2)^jx^{n-2i-j}\\
&=\sum_{k\ge0}(-1)^kx^{n-k}\sum_{i\ge0}(-1)^i\frac{n}{n-i}\binom{n-i}{i}\binom{n-2i}{k-2i}2^{k-2i},
\end{aligned}
$$
from which we conclude
$$
\begin{aligned}
\frac{2n}{2n-k}\binom{2n-k}{k}&=\sum_{i\ge0}(-1)^i\frac{n}{n-i}\binom{n-i}{i}\binom{n-2i}{k-2i}2^{k-2i}\\
&=\sum_{i\ge0}(-1)^i\frac{n}{n-i}\frac{(n-i)!}{i!\,(k-2i)!\,(n-k)!}2^{k-2i}.
\end{aligned}
$$
We note in passing that this identity can be understood combinatorially. We already mentioned that the left side is the number of ways of selecting $k$ non-adjacent vertices from a $(2n)$-cycle. This is equivalent to the number of matchings, that is, the number of ways of placing non-overlapping dominoes on a $(2n)$-cycle, where a domino covers two adjacent vertices. The right side counts the same thing. To see this, first consider the $i=0$ term, which reduces to $\binom{n}{k}2^k$. The binomial coefficient is the number of ways of coloring $k$ of the vertices of an $n$-cycle green, with the rest colored red. Create a $(2n)$-cycle by inserting a white vertex between each of the original vertices. The factor $2^k$ is the number of ways of placing $k$ possibly overlapping dominoes on this graph, each covering a green vertex and one of the adjacent white vertices. It remains to exclude the placements that contain overlaps. When two green vertices are adjacent in the original $n$-cycle and it comes to placing dominoes on the corresponding vertices in the $(2n)$-cycle, there are three legal placements and one illegal one. It is fine to place both dominoes so that they cover the white vertices in the forward (say clockwise) direction relative to the green vertex. It is also permissible to have both dominoes cover the white vertices in the backward direction, or to have the front domino covering in the forward direction and the back domino covering in the backward direction. What is not allowed is to have the front domino covering backward and the back domino covering forward, as this produces an overlap of the dominoes. The sum on the right consists of the inclusion-exclusion terms needed to exclude these illegal placements. The factor $\frac{n}{n-i}\frac{(n-i)!}{i!\,(k-2i)!\,(n-k)!}$ is the number of ways of placing $i$ green dominoes, $k-2i$ green checkers, and $n-k$ red checkers on the vertices of an $n$-cycle. (Checkers each cover only one vertex.) Add the $n$ extra white vertices as before. In the $i$ positions where a green domino covers two adjacent vertices in the $n$-cycle, place two dominoes in the illegal overlapping configuration at the corresponding positions in the $(2n)$-cycle. Then add $k-i$ dominoes in all $2^{k-i}$ possible ways at the vertices of the $(2n)$-cycle corresponding to vertices covered by green checkers in the $n$-cycle. In this way, we account for and remove all illegal placements.
Returning to the task at hand, we convert this alternative counting formula for domino placements into an alternative formula for $\varphi(h;n)$. Touchard's formula arises when the factor $x^{n-k}$ in $P_n(x)$ is replaced with $\nu(h,h+n-k)$. So make the same replacement in our alternative formula for $P_n(x)$, which gives
$$\begin{aligned}
&\varphi(h;n)\\
&\quad=\sum_{k\ge0}(-1)^k\nu(h;h+n-k)\sum_{i\ge0}(-1)^i\frac{n}{n-i}\binom{n-i}{i}\binom{n-2i}{k-2i}2^{k-2i}\\
&\quad=\sum_{i\ge0}(-1)^i\frac{n}{n-i}\binom{n-i}{i}\sum_{k\ge2i}(-1)^k\nu(h;h+n-k)\binom{n-2i}{k-2i}2^{k-2i}\\
&\quad=\sum_{i\ge0}(-1)^i\frac{n}{n-i}\binom{n-i}{i}\sum_{k\ge0}(-1)^k\nu(h;h+n-2i-k)\binom{n-2i}{k}2^k.
\end{aligned}
$$
Our final aim is to simplify the inner sum. Writing $r$ for $n-2i$, we evaluate,
$$
\begin{aligned}
&\sum_{k=0}^r(-1)^k\nu(h;h+r-k)\binom{r}{k}2^{k}\\
&\quad=\sum_{k=0}^r(-1)^k\binom{r}{k}2^k\sum_{j=0}^h(-1)^j\binom{h}{j}(r-k+h-j)!\\
&\quad=\sum_{j=0}^h(-1)^j\binom{h}{j}\sum_{k=0}^r\binom{r}{k}(-2)^k(r-k+h-j)!.
\end{aligned}
$$
A straightforward way to simplify this last expression is to recognize that it is the $x=-2$, $y=1$ case of the identity in this answer. Using this identity to replace the inner sum yields
$$
\varphi(h;n)=\sum_{i\ge0}(-1)^i\frac{n}{n-i}\binom{n-i}{i}\sum_{j=0}^h\binom{h}{j}k_{n-2i+j},
$$
where, as defined by Wyman and Moser,
$$
k_r=r!\sum_{i=0}^r\frac{(-2)^i}{i!}.
$$
This formula for $\varphi(h;n)$ generalizes Wyman and Moser's formula for the ménage problem to all $h\ge0$.
My own original, more cumbersome method for simplifying the inner sum, which I leave for reference but which you should feel free to skip, was to recognize it as the $x=-2$ case of the sum
$$
\begin{aligned}
&\sum_{j=0}^h(x+1)^j\binom{h}{j}\sum_{k=0}^r\binom{r}{k}x^k(r-k+h-j)!\\
&\quad=\sum_{j=0}^h\sum_{i=0}^j\binom{j}{i}x^i\frac{h!}{j!}\sum_{k=0}^r\binom{r}{k}\frac{(r-k+h-j)!}{(h-j)!}x^k\\
&\quad=\sum_{i=0}^h\sum_{j=i}^h\frac{h!}{i!\,(j-i)!}\sum_{k=0}^r\binom{r}{k}\frac{(r-k+h-i-(j-i))!}{(h-i-(j-i))!}x^{i+k}\\
&\quad=\sum_{i=0}^h\sum_{j=i}^h\frac{h!}{i!\,(h-j)!}\sum_{k=0}^r\binom{r}{k}\frac{(r-k+h-i-(h-j))!}{(h-i-(h-j))!}x^{i+k},
\end{aligned}
$$
where in the next-to-last line we have written the summand so that $j$ always occurs in the combination $j-i$, and in the last line we have used the rule
$$
\sum_{j=i}^hf(j-i)=\sum_{j=i}^hf(h-j).
$$
Simplifying, swapping the outer two summations back again, and then swapping the inner two summations gives
$$
\begin{aligned}
&\sum_{j=0}^h\frac{h!}{(h-j)!}\sum_{k=0}^r\sum_{i=0}^j\binom{r}{k}\frac{(r-k+j-i)!}{(j-i)!}\frac{x^{i+k}}{i!}\\
&\quad=\sum_{j=0}^h\frac{h!}{(h-j)!}\sum_{k=0}^r\sum_{i=k}^{j+k}\binom{r}{k}\frac{(r+j-i)!}{(k+j-i)!}\frac{x^i}{(i-k)!}\\
&\quad=\sum_{j=0}^h\frac{h!}{(h-j)!}\sum_{k=0}^r\sum_{i=k}^{j+k}r!\binom{r+j-i}{r-k}\binom{i}{k}\frac{x^i}{i!}.
\end{aligned}
$$
The presence of the two binomial coefficients means we can eliminate the $k$-dependence of the limits of the innermost summation by changing the lower limit to $0$ and the upper limit to $j+r$. We may then swap back the two inner summations to get
$$
\begin{aligned}
&\sum_{j=0}^h\frac{h!}{(h-j)!}r!\sum_{i=0}^{j+r}\frac{x^i}{i!}\sum_{k=0}^r\binom{r+j-i}{r-k}\binom{i}{k}\\
&\quad=\sum_{j=0}^h\frac{h!}{(h-j)!}r!\sum_{i=0}^{j+r}\frac{x^i}{i!}\binom{r+j}{r}\\
&\quad=\sum_{j=0}^h\binom{h}{j}(r+j)!\sum_{i=0}^{j+r}\frac{x^i}{i!},
\end{aligned}
$$
where Vandermonde's identity has been used in the second line. We have therefore proved the identity
$$
\begin{aligned}
&\sum_{j=0}^h(x+1)^j\binom{h}{j}\sum_{k=0}^r\binom{r}{k}x^k(r-k+h-j)!\\
&\quad=\sum_{j=0}^h\binom{h}{j}(r+j)!\sum_{i=0}^{j+r}\frac{x^i}{i!}.
\end{aligned}
$$
We now set $x=-2$ in this identity and use it to replace the inner sum in our expression for $\varphi(h;n)$.