Let $A$ be a real, symmetric, invertible $k \times k$ matrix and let $B$ be a real $k \times (n-k)$ matrix. How can I compute the derivative of the function
$$ F:[A, B] \mapsto B^T A^{-1} B $$
I'm using this to compute the tangent space of the set of symmetric $n \times n$ matrices with rank $k$.
$DF_{A,B}:(H,K)\in S_{k,k}\times M_{k,n-k}\rightarrow (-B^TA^{-1}HA^{-1}B,K^TA^{-1}B+B^TA^{-1}K^T)$.