Activity 5.6.1. Derivative identities for least squares (U3-LO3).
Compute the following derivatives.
-
For a fixed vector \(\mathbf d\text{,}\) let\begin{equation*} g(\mathbf x)=\mathbf d\cdot\mathbf x. \end{equation*}Compute \(\nabla g(\mathbf x)\text{.}\)
-
\begin{equation*} q(\mathbf x)=\mathbf x^TA\mathbf x. \end{equation*}Compute \(\nabla q(\mathbf x)\text{.}\)
-
\begin{equation*} F(\mathbf x)=C\mathbf x. \end{equation*}Compute \(J_F(\mathbf x)\text{.}\)
Solution.
Expanding the first function gives
\begin{equation*}
g(\mathbf x)=d_1x_1+\cdots+d_nx_n.
\end{equation*}
Therefore
\begin{equation*}
\frac{\partial g}{\partial x_i}=d_i,
\qquad
\nabla g(\mathbf x)=\mathbf d.
\end{equation*}
For the quadratic function,
\begin{equation*}
q(\mathbf x)
=
\sum_{i=1}^n\sum_{j=1}^n A_{ij}x_ix_j.
\end{equation*}
For \(1\leq k\leq n\text{,}\)
\begin{equation*}
\frac{\partial q}{\partial x_k}
=
\sum_{j=1}^n A_{kj}x_j
+
\sum_{i=1}^n A_{ik}x_i.
\end{equation*}
This is the \(k\)-th entry of
\begin{equation*}
(A+A^T)\mathbf x.
\end{equation*}
Hence
\begin{equation*}
\nabla q(\mathbf x)=(A+A^T)\mathbf x.
\end{equation*}
In particular, if \(A\) is symmetric, then
\begin{equation*}
\nabla q(\mathbf x)=2A\mathbf x.
\end{equation*}
Finally, the \(i\)-th component of \(F\) is
\begin{equation*}
F_i(\mathbf x)=C_{i1}x_1+\cdots+C_{in}x_n.
\end{equation*}
Thus
\begin{equation*}
\frac{\partial F_i}{\partial x_j}=C_{ij},
\end{equation*}
and therefore
\begin{equation*}
J_F(\mathbf x)=C.
\end{equation*}
