$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?

Write $$f^{(n)}(x) = a_n(x)\cos x +b_n(x)\sin x$$
The proceed by induction to detrmine recurrences for polynomials $a_n(x), b_n(x)$.
Specifically, if:
$$f^{(n)}(x)=(A_nx^2+B_nx+C_n)\cos x + (D_nx^2+E_nx+F_n)\sin x$$
You get the recurrence:
$$\begin{pmatrix}A_{n+1}\\B_{n+1}\\C_{n+1}\\D_{n+1}\\E_{n+1}\\F_{n+1}\end{pmatrix} = \begin{pmatrix}0&0&0&1&0&0\\
2&0&0&0&1&0\\
0&1&0&0&0&1\\
-1&0&0&0&0&0\\
0&-1&0&2&0&0\\
0&0&-1&0&1&0
\end{pmatrix}
\begin{pmatrix}A_{n}\\B_{n}\\C_{n}\\D_{n}\\E_{n}\\F_{n}\end{pmatrix} $$
So, by induction:
$$\begin{pmatrix}A_{n}\\B_{n}\\C_{n}\\D_{n}\\E_{n}\\F_{n}\end{pmatrix}= \begin{pmatrix}0&0&0&1&0&0\\
2&0&0&0&1&0\\
0&1&0&0&0&1\\
-1&0&0&0&0&0\\
0&-1&0&2&0&0\\
0&0&-1&0&1&0
\end{pmatrix}^n\begin{pmatrix}1\\0\\0\\0\\0\\0\end{pmatrix}$$
So now you need to know how to do exponentiation of a matrix. Turns out, the characteristic polynomial of this matrix is a very simple $(1+x^2)^3$, so the roots are $i$ and $-i$ and that means we know we can write:
$$A_n = p_A(n)i^n + q_A(n)(-i)^n$$
where $p_A$ and $q_A$ are polynomials of degree $2$ or less. So we can solve for $p_A$ and $p_B$ by using the first six values of $A_n$.
Similarly, there are polynomials $p_B,q_B,p_C,q_C$, etc.
