$n^{th}$ derivative of $y=x^2\cos x$ I am stuck with Leibniz formula
$$D^{n}y = \sum_{k=0}^{n} \binom{n}{k} \, x^{(2k)}\cos^{(n-k)}x$$
Could someone show how to do it?

The Leibniz formula only has a few terms. This is seen by the following.
\begin{align}
D^{n} y &= D^{n}\{ x^{2} \, \cos(ax)\} = \sum_{k=0}^{n} \binom{n}{k} \, D^{k}\{x^{2}\} \, D^{n-k}\{\cos(ax)\} 
\end{align} 
Since $D(x^{2}) = 2 x$, $D^{2}(x^{2}) = 2$, and $D^{3+m}(x^{2}) = 0$ for $m \geq 0$, then
\begin{align}
D^{n} y &= \binom{n}{0} \, D^{0}(x^{2}) \, D^{n}(\cos(ax)) + \binom{n}{1} \, D^{1}(x^{2}) \, D^{n-1}(\cos(ax)) + \binom{n}{2} \, D^{2}(x^{2}) \, D^{n-2}(\cos(ax)) \\
&= x^{2} \, D^{n}(\cos(ax)) + 2 n x \, D^{n-1}(\cos(ax)) + n(n-1) \, D^{n-2}(\cos(ax))
\end{align} 
For the case of $n$ being even then
\begin{align}
D^{2n} y &= (-1)^{n} \, a^{2n-2} \, \left[(a^{2} \, x^{2} - 2n(2n-1)) \, \cos(ax) + 4 a n x \, \sin(ax) \right]
\end{align} 
and for $n$ being odd
\begin{align}
D^{2n+1} y &= (-1)^{n+1} \, a^{2n-1} \, \left[ (a^{2} x^{2} + 2n(2n+1)) \, \sin(ax) - 2(2n+1) a x \cos(ax) \right]
\end{align}
