Composition with Second Derivative of Dirac Distribution Here's a nasty question that came up on an old qualifying exam that I'm helping students study.  

Let $T = \delta^{\prime\prime}(\cos(x))$ and let $\varphi = e^{-x^2}$.
  Evaluate $\langle T,\varphi\rangle$.

We all initially thought the question was trivial - just move the derivatives over using integration by parts to obtain (incorrectly) 
$$
\langle \delta^{\prime\prime}(\cos(x)),\varphi(x)\rangle = \langle \delta(\cos(x)),\varphi^{\prime\prime}(x)\rangle
$$
then apply the formula for a composition of $\delta$ with a function.
$$
\langle\delta(f(x)),\varphi\rangle = \sum_{i:f(x_i)=0}\frac{1}{\vert f^\prime(x_i)\vert}\varphi(x-x_i)\tag{$\star$}
$$
Of course, this is wrong!  One must first make a substitution of the form $u = \cos(x)$, then we really have
$$
\langle \delta^{\prime\prime}(\cos(x)),\varphi(x)\rangle = -\left\langle \delta^{\prime\prime}(u),\frac{\varphi(\arccos(u))}{\sqrt{1-u^2}}\right\rangle
$$  Now we can move the derivatives over and use the formula $(\star)$.  This seems absolutely horrible.  Is there an easier way, perhaps an analogous formula to $(\star)$ for more general singular distributions?
 A: In your formula, $\arccos u$ is not necessarily the principal branch; there's summation over all $x_0$ such that $\cos(x_0)=0$, so when considering each such term, we use $\arccos(0)=x_0$.
Your (correct) approach is what should be done, and the remaining computation of second derivative is not hard: you only need it at $u=0$. Claim:
$$\frac{d^2}{du^2}\bigg|_{u=0}\frac{\varphi(\arccos(u))}{\sqrt{1-u^2}} = \varphi''(x_0)+\varphi(x_0)\tag{0}$$
for any smooth $\varphi$. Indeed,  arccosine is essentially linear at $0$ (second derivative is zero), so composition with it doesn't change much. And the denominator has zero derivative of first order, so the interaction between the numerator and denominator is simple.
Here are the details. 
If $\cos(x_0)=0$, then $\cos(x) = - \sin(x_0)(x-x_0) + O((x-x_0)^3)$ as $x\to x_0$, since the second derivative vanishes. Hence,
$$\arccos(u) =x_0 - \sin(x_0)u + O(u^3)\tag1$$
(recall  $\arccos $ means the branch such that $\arccos(0)=x_0$, not necessarily the principal one). Plug this into the Taylor expansion of $\varphi$ to get
$$\varphi(\arccos(u)) =\varphi(x_0 - \sin(x_0)u) + O(u^3) 
 \\= \varphi(x_0)- \varphi'(x_0)\sin(x_0) u + \frac12 \varphi''(x_0) u^2 + O(u^3)\tag2$$   (using $\sin^2(x_0)=1$).
Multiply (2) by 
$$
(1-u^2)^{-1/2} = 1 + \frac12 u^2 + O(u^3)
\tag3$$
to obtain 
$$\frac{\varphi(\arccos(u))}{\sqrt{1-u^2}} = \varphi(x_0)- \varphi'(x_0)\sin(x_0) u + \frac12 (\varphi''(x_0) + \varphi(x_0)) u^2 + O(u^3) $$ proving the claim. 
