Showing $h(x)=\langle f(x),g(x)\rangle$ where $f,g:\Bbb R^n\to\Bbb R^m$ are differentiable, is also differentiable

I would like to prove $h:\Bbb R^n\to\Bbb R, h(x)=\langle f(x),g(x)\rangle,$ where $f,g:\Bbb R^n\to\Bbb R^m$ are differentiable functions, is also differentiable.

I've read this post, where the exercise is to compute $\frac{\partial h}{\partial v}(c)$ for an arbitrary $v\in\Bbb R^n.$ There, it is shown: $$\frac{\partial h}{\partial v}(c)=\left\langle\frac{\partial f}{\partial v}(c),g(c)\right\rangle+\left\langle f(c),\frac{\partial g}{\partial v}(c)\right\rangle.$$

I wanted to use the result and test the linear functional with the matrix

$\begin{aligned}L&=\begin{bmatrix} \left\langle\frac{\partial f}{\partial x_1}(c),g(c)\right\rangle+\left\langle f(c),\frac{\partial g}{\partial x_1}(c)\right\rangle&\ldots&\left\langle\frac{\partial f}{\partial x_n}(c),g(c)\right\rangle+\left\langle f(c),\frac{\partial g}{\partial x_n}(c)\right\rangle\end{bmatrix}\\&=\begin{bmatrix}\left\langle g(c),\frac{\partial f}{\partial x_1}(c)\right\rangle&\ldots&\left\langle g(c),\frac{\partial f}{\partial x_n}(c)\right\rangle\end{bmatrix}+\begin{bmatrix}\left\langle f(c),\frac{\partial g}{x_1}(c)\right\rangle&\ldots&\left\langle f(c),\frac{\partial g}{\partial x_n}(c)\right\rangle\end{bmatrix}\\&= g(c)^T Df(c)+f(c)^TDg(c).\end{aligned}$ as a candidate for the differential.

In order for $h$ to be differentiable, we need: $$\lim_{x\to c}\frac{\|\langle f(x),g(x)\rangle-\langle f(c),g(c)\rangle-(g(c)^TDf(c)+f(c)^TDg(c))(x-c)\|}{\|x-c\|}=0$$

We might write $(g(c)^TDf(c)+f(c)^TDg(c))(x-c)=\langle g(c)^TDf(c)+f(c)^TDg(c),x-c\rangle,$

but I got stuck. How should I proceed?


Solution 1:

Let $h:=x-c$. Let also $\varepsilon_1(h):=f(x)-f(c)-Df(c)h$, and $\varepsilon_2(h):=g(x)-g(c)-Dg(c)h$. Because $f$ and $g$ are differentiable at $c$, we have $\lim_{\|h\|\to0}\frac{\varepsilon_i(h)}{\|h\|}=0$ for $i=1,2$. Now, by bilinearity, \begin{align*} f(x)^Tg(x) &=\bigl(f(c)+ Df(c)h+\varepsilon_1(h)\bigr)^T\bigl(g(c)+ Dg(c)h+\varepsilon_2(h)\bigr)\\ &=f(c)^Tg(c)+\underbrace{\left(f(c)^TDg(c)+g(c)^TDf(c)\right)h}_{\ell(c)(h)} +\varepsilon_3(h), \end{align*} where $\varepsilon_3(h):=\varepsilon_1(h)^T\bigl(g(c)+Dg(c)h\bigr)+\varepsilon_2(h)^T\bigl(f(c)+Df(c)h\bigr)+\varepsilon_1(h)^T\varepsilon_2(h)$ is also such that $\lim_{\|h\|\to0}\frac{\varepsilon_3(h)}{\|h\|}=0$ by Cauchy-Schwarz inequality. Moreover, $\ell(c)$ is clearly a linear map, and it is also bounded (again, by Cauchy-Schwarz inequality). This shows that $x\mapsto f(x)^Tg(x)$ is differentiable at $c$ with differential $\ell(c)$.

Solution 2:

Don't confuse the differential with the gradient.

Using Leibniz we get for $h(p)=\langle f(p),g(p)\rangle$ the differential $$d_ph(v)=\langle d_pf(v),g(p)\rangle+ \langle f(p),d_pg(v)\rangle.$$ In terms of the Jacobian $J_f$ of $f$ and $J_g$ of $g$ we get $$ \begin{align} \langle J_f(p)v,g(p)\rangle+ \langle f(p),J_g(p)(v)\rangle&= \langle v,J^T_f(p)g(p)+\langle J^T_g(p)f(p),v\rangle\\ &=\langle J^T_f(p)g(p)+J^T_g(p)f(p),v \rangle, \end{align} $$ hence $$\nabla \langle f(p),g(p)\rangle =J^T_f(p)g(p)+J^T_g(p)f(p) $$