# Solution verification post : Problem $12.2$, Mathematical Analysis, Apostol

As a continuation of this post, I'm posting my solutions (or attempts) to the exercise problems of Chapter 12 (Multivariable Differential Calculus), Mathematical Analysis by Apostol. Since I'm essentially self-studying, I'd really appreciate if anyone checks the solutions and let me know if there is any gap in my arguments or if there exists any cleverer solutions. Thank you.

Problem $12.2.$ Calculate all first order partial derivatives and the directional derivative $f'(x;u)$ for each of the real-valued functions defined on $\mathbb{R}^n$ as follows : \begin{align*} &(a)\,\, f(x)=a \boldsymbol{\cdot} x\\ &(b)\,\, f(x)=\left\Vert x \right\Vert^4\\ &(c)\,\, f(x)=x \boldsymbol{\cdot} L(x), \text{ where } L:\mathbb{R}^n \to \mathbb{R}^n \text{ is a linear function.}\\ &(d)\,\, f(x)=\sum_{i=1}^n \sum_{j=1}^n a_{ij}x_ix_j, \text{ where } a_{ij}=a_{ji}. \end{align*}

Solution. $(a)$ Let $a=(a_1,\dots,a_n)$, $x=(x_1,\dots,x_n)$. Thus, $$f(x)=a \boldsymbol{\cdot} x=a_1x_1+\dots+a_nx_n \tag1$$ Then we have, $$D_kf(x)=\frac{\partial f}{\partial x_k}(x)=a_k=a \boldsymbol{\cdot} e_k; \,\,k=1,\dots,n \tag2$$ $D_kf(x)$ is constant for all $k$ $\Rightarrow$ $D_kf(x)$ is continuous for all $k$. We recall the following :

Theorem. Assume that one of the partial derivatives $D_1f,\dots,D_nf$ exists at $c$ and that the remaining $n−1$ partial derivatives exists in some $\delta$-ball $B_{\delta}(c)$, and are continuous at $c$. Then $f$ is differentiable at $c$.

Using the theorem, we conclude that $f$ is differentiable and hence directional derivative at any direction exists. Then,

\begin{align*} f'(x;u)&=\lim_{h \to 0} \frac{f(x+hu)-f(x)}{h}\\ &=\lim_{h \to 0} \frac{a \boldsymbol{\cdot} (x+hu)-a \boldsymbol{\cdot} x}{h}\\ &=\lim_{h \to 0} \frac{a \boldsymbol{\cdot} (hu)}{h}\\ &=\lim_{h \to 0} \frac{h \sum_{i=1}^n a_iu_i}{h}\\ &=\sum_{i=1}^n a_iu_i=a \boldsymbol{\cdot} u \tag3 \end{align*}

Solution. $(b)$ \begin{align*} f(x)&=\left\Vert x \right\Vert^4=\left(\sum_{i=1}^n x_i^2\right)^2=\sum_{i=1}^n x_i^4+\sum_{i \neq j} x_i^2x_j^2\\ &=x_k^4+\sum_{i \neq k} x_i^4+x_k^2\left(\sum_{i \neq k} x_i^2\right)+\left(\sum_{i \neq k} x_i^2\right)x_k^2+\sum_{i \neq k,\,j \neq k,\,i \neq j} x_i^2x_j^2\\ &=x_k^4+\sum_{i \neq k} x_i^4+2x_k^2\left(\sum_{i \neq k} x_i^2\right)+\sum_{i \neq k,\,j \neq k,\,i \neq j} x_i^2x_j^2 \tag4 \end{align*}

Let $k \in \{1,\dots,n\}$. Then, $$D_kf(x)=4x_k^3+4x_k\left(\sum_{i \neq k}x_i^2\right)=4x_k\left(\sum_{i=1}^nx_i^2\right)=4x_k\left\Vert x \right\Vert^2 \tag5$$ Thus, $D_kf(x)$ exists and is continuous for all $k \in \{1,\dots,n\}$. By the statement stated above, $f$ is differentiable, and hence directional derivative exists in all directions. Let $u=(u_1,\dots,u_n)=u_1e_1+\dots+u_ne_n$. Now, \begin{align*} f'(x;u)&=f'(x)(u)=f'(x)(u_1e_1+\dots+u_ne_n)=\sum_{k=1}^n u_kf'(x)(e_k)=\sum_{k=1}^n u_kf'(x;e_k)\\ &=\sum_{k=1}^n u_k\frac{\partial f}{\partial x_k}(x)=\sum_{k=1}^n u_k\left(4x_k\left\Vert x \right\Vert^2\right)=4\left\Vert x \right\Vert^2\sum_{k=1}^n x_ku_k=4\left\Vert x \right\Vert^2 \left(x \boldsymbol{\cdot} u\right) \tag6 \end{align*}

$(c)$ \begin{align*} D_kf_(x)&=\lim_{h \to 0} \frac{f(x+he_k)-f(x)}{h}\\ &=\lim_{h \to 0} \frac{(x+he_k) \boldsymbol{\cdot} L(x+he_k)-x \boldsymbol{\cdot} L(x)}{h}\\ &=\lim_{h \to 0} \frac{(x+he_k) \boldsymbol{\cdot} \left(L(x)+L(he_k)\right)-x \boldsymbol{\cdot} L(x)}{h}\\ &=\lim_{h \to 0} \frac{x \boldsymbol{\cdot} L(x)+x \boldsymbol{\cdot} L(he_k)+he_k \boldsymbol{\cdot} L(x)+he_k \boldsymbol{\cdot} L(he_k)-x \boldsymbol{\cdot} L(x)}{h}\\ &=\lim_{h \to 0} \frac{x \boldsymbol{\cdot} L(he_k)+he_k \boldsymbol{\cdot} L(x)+he_k \boldsymbol{\cdot} L(he_k)}{h}\\ &=\lim_{h \to 0} \frac{x \boldsymbol{\cdot} hL(e_k)+he_k \boldsymbol{\cdot} L(x)+he_k \boldsymbol{\cdot} hL(e_k)}{h}\\ &=\lim_{h \to 0} \frac{hx \boldsymbol{\cdot} L(e_k)+he_k \boldsymbol{\cdot} L(x)+h^2e_k \boldsymbol{\cdot} L(e_k)}{h}\\ &=\lim_{h \to 0} \frac{h\left(x \boldsymbol{\cdot} L(e_k)+e_k \boldsymbol{\cdot} L(x)+he_k \boldsymbol{\cdot} L(e_k)\right)}{h}\\ &=\lim_{h \to 0} x \boldsymbol{\cdot} L(e_k)+e_k \boldsymbol{\cdot} L(x)+he_k \boldsymbol{\cdot} L(e_k)\\ &=x \boldsymbol{\cdot} L(e_k)+e_k \boldsymbol{\cdot} L(x) \tag7 \end{align*}

By continuity of $x$ and $L(x)$, we conclude that $D_kf_(x)$ is continuous for all $k \in \{1,\dots,n\}$. Thus, by the theorem stated above, $f$ is differentiable and hence, directional derivative of $f$ exists in all directions. Let $u=(u_1,\dots,u_n)$. Then,

\begin{align*} f'(x;u)&=\sum_{k=1}^n u_kD_kf_(x)\\ &=\sum_{k=1}^n u_k\left(x \boldsymbol{\cdot} L(e_k)+e_k \boldsymbol{\cdot} L(x)\right)\\ &=\sum_{k=1}^n \left(x \boldsymbol{\cdot} u_kL(e_k)+u_ke_k \boldsymbol{\cdot} L(x)\right)\\ &=\sum_{k=1}^n \left(x \boldsymbol{\cdot} L(u_ke_k)+u_ke_k \boldsymbol{\cdot} L(x)\right)\\ &=x \boldsymbol{\cdot} \sum_{k=1}^nL(u_ke_k)+\sum_{k=1}^n\left(u_ke_k\right) \boldsymbol{\cdot} L(x)\\ &=x \boldsymbol{\cdot} L(\sum_{k=1}^n u_ke_k)+\sum_{k=1}^n\left(u_ke_k\right) \boldsymbol{\cdot} L(x)\\ &=x \boldsymbol{\cdot} L(u)+u \boldsymbol{\cdot} L(x) \tag8 \end{align*}

$(d)$ \begin{align*} f(x)&=\sum_{i=1}^n\sum_{j=1}^n a_{ij}x_ix_j\\ &=a_{kk}x_k^2+\sum{i \neq k}a_{ik}x_ix_k+\sum{i \neq k}a_{ki}x_kx_i+\sum_{i \neq k,\,j \neq k,\,i \neq j} a_{ij}x_ix_j \tag9 \end{align*}

Then we have, \begin{align*} D_kf(x)&=2a_{kk}x_k+\sum_{i \neq k} a_{ik}x_i+\sum_{i \neq k} a_{ki}x_i\\ &=2a_{kk}x_k+2\sum_{i \neq k} a_{ik}x_i \,\left(\text{since } a_{ik}=a_{ki}\right)\\ &=2\sum_{i=1}^n a_{ik}x_i \tag{10} \end{align*}

Thus, $D_kf(x)$ exists and is continuous. Hence, $f$ is differnetiable and thus, it has directional derivative in every direction. Then, $$f'(x;u)=\sum_{k=1}^n u_k \frac{\partial f}{\partial x_k}(x)=2\sum_{i=1}^n u_k\left(\sum_{i=1}^n a_{ik}x_i\right)=2\sum_{i=1}^n\sum_{i=1}^n a_{ik}x_iu_k=2x^TAu, \tag{11}$$ where $A={(a_{ij})_{i=1}^n}_{j=1}^n$.