Solution (source code)

= Solution

Let $M(t_1,\ldots,t_n)=\operatorname{diag}(t_1,\ldots,t_n)-A$. Expanding the <determinant> along row $i$ shows that
$$
\frac{\partial p}{\partial t_i}=C_{ii}(M),
$$
where $C_{ii}$ is the corresponding cofactor. Since a diagonal entry of the <adjugate matrix> is that same cofactor, the multivariable <chain rule> along the diagonal $t_1=\cdots=t_n=t$ yields
$$
\frac d{dt}\det(tI-A)
=\sum_{i=1}^n\left.\frac{\partial p}{\partial t_i}\right|_{(t,\ldots,t)}
=\sum_{i=1}^n[\operatorname{adj}(tI-A)]_{ii}.
$$
Therefore
$$
\boxed{\frac d{dt}\det(tI-A)=\operatorname{Tr}(\operatorname{adj}(tI-A))}.
$$