Compute $\frac{d}{dx} \left\{ u^H M^{-1}(x) \ A \ M^{-1}(x) \ u\right\} $, where $M(x) = \left(B + xA \right) ; \ M^H(x) = M(x)$ 
Problem:
Let $x \in \mathbb{R}$, $u \in \mathbb{C}^{n \times 1}$, $B \in \mathbb{C}^{n \times n}$, $A \in \mathbb{C}^{n \times n}$, and 
  $M(x) = \left(B + xA \right) ; \ M^H(x) = M(x)$.
Obtain
  \begin{align}
\frac{d}{dx} f(x) = \frac{d}{dx} \left\{ u^H M^{-1}(x) \ A \ M^{-1}(x) \ u\right\} \ .
\end{align}


 A: 
Answer: 
  \begin{align}
\frac{d}{dx} \left\{ u^H M^{-1}(x) \ A \ M^{-1}(x) \ u\right\}
&=  -2 \ u^H M^{-1}(x) \ A \ M^{-1}(x)  \ A \ M^{-1}(x) \ u  \ .
\end{align}

Solution:
Notation clarification: Complex conjugate of $u$ is denoted by $u^*$, and the conjugate transpose (or Hermitian) of $A$ is denoted by $A^H$.
I have utilized the following identities 


*

*Trace and Frobenius product relation $${\rm tr}(A^H B) = A^* : B$$ or $${\rm tr}(AB) = A^H : B = (A^*)^T : B$$

*Cyclic property of Trace/Frobenius product 
\begin{align}
 A : B C  
 &= AC^T : B   \\
 &=  B^T A :  C  \\
 &= {\text{etc.}} \cr
\end{align}


So, we compute the differential first, and then the gradient.
Firstly, we compute the differential of $M^{-1}(x)$, i.e., $dM^{-1}(x)$,
\begin{align}
& I = M(x) M^{-1}(x) \\
& \Rightarrow 0 = dM(x) M^{-1}(x) + M(x)dM^{-1}(x) \\
& \Leftrightarrow dM^{-1}(x) = -M^{-1}(x) \ \underbrace{dM(x)}_{= A dx} M^{-1}(x) = - M^{-1}(x) \ A \ M^{-1}(x) \ dx \ .
\end{align}
So, the differential of $f(x)$ reads
\begin{align}
df(x) 
&= d \left\{ u^H M^{-1}(x) \ A \ M^{-1}(x) \ u \right\} \\
&= d \left\{ u^* : M^{-1}(x) \ A \ M^{-1}(x) \ u \right\} \\
&= u^* : d \left\{M^{-1}(x) \ A \ M^{-1}(x) \ u \right\} \\
&= u^* : dM^{-1}(x) \ A \ M^{-1}(x) \ u + M^{-1}(x) \ A \ dM^{-1}(x) \ u \\
&= u^* : \left\{ \left[ - M^{-1}(x) \ A \ M^{-1}(x) \ dx \right] \ A \ M^{-1}(x)  u \ + \ M^{-1}(x) \ A \ \left[ - M^{-1}(x) \ A \ M^{-1}(x) \ dx \right] u \right\} \\
&= -u : \left\{ \left[M^{-1}(x) \ A \ M^{-1}(x)  \right] \ A \ M^{-1}(x)  u \ + \ M^{-1}(x) \ A \ \left[ M^{-1}(x) \ A \ M^{-1}(x)  \right] u \right\}^* \ dx \\
&= -\left\{ \left[M^{-1}(x) \ A \ M^{-1}(x)  \right] \ A \ M^{-1}(x)  u \ + \ M^{-1}(x) \ A \ \left[M^{-1}(x) \ A \ M^{-1}(x)  \right] u \right\}^H u : \ dx \\
&= -\left\{ u^H M^{-1}(x) \ A \ M^{-1}(x)  \ A \ M^{-1}(x)  u \ + u^H M^{-1}(x) \ A \ M^{-1}(x) \ A \ M^{-1}(x) u \right\} : dx \\
&= -2\left\{ u^H M^{-1}(x) \ A \ M^{-1}(x)  \ A \ M^{-1}(x) \ u \right\} : dx
\end{align}
The gradient is 
\begin{align}
\frac{d}{dx} f(x) 
&= \frac{d}{dx} \left\{ u^H M^{-1}(x) \ A \ M^{-1}(x) \ u\right\} \\
&= -2 \ u^H M^{-1}(x) \ A \ M^{-1}(x)  \ A \ M^{-1}(x) \ u \ .
\end{align}
