# Symbolic differentiation on a function of matrices and vectors

Let $I_t$, $I$, $V$, $Z$ be vectors and $R$, $B$, $P$, $A$, $\mathcal{K}$, $\mathcal{P}$ be some matrices such that

$$\begin{eqnarray} S&=&-(R I+B^\top V)^\top \mathcal{R}(R I+B^\top V) \\&&-(I_t+B I- P V+A Z)^\top \mathcal{P}(I_t+B I- P V+A Z) \\&&+(I_t+B I- P V)^\top \mathcal{K}(I_t+B I- P V) \end{eqnarray}$$

is a scalar quantity. Is there a way to use mathematica's symbolic computation to rewrite it as \begin{eqnarray} S&=&-\begin{bmatrix} I_t & I & V & Z \end{bmatrix} \underbrace{\begin{bmatrix} \star & \star & \star & \star\\ \star & \star & \star & \star\\ \star & \star & \star & \star\\ \star & \star & \star & \star \end{bmatrix}}_{\textbf M} \begin{bmatrix} I_t \\I\\V\\Z \end{bmatrix} \end{eqnarray}.

PS: I am trying to check if the $S\leq 0$ for all $I_t$, $I$, $V$ and $Z$.

• Try m = 1/2 D[-s, {{it, i, v, z}, 2}]. Note that I, like several other capital letters` is the built-in symbol, so that I had to decapitalized all symbols. – Henrik Schumacher Aug 28 '18 at 20:59
• Sorry for the caps. I tried it earlier, it did not work as they are all vectors and Matrices. Mathematica is not considering them to be vectors (Matrices) variables. – kosa Aug 28 '18 at 21:02