# Multivariable derivative of matrix valued function

Determine the derviative of \begin{align*} \mathbf{A}(\mathbf{x})\colon \mathbb{R}^{n} \to \mathbb{R}^{n, n} , \quad \mathbf{A}(\mathbf{x}) = \begin{bmatrix} \alpha(\mathbf{x}) & 1 & 0& 0 & \cdots & 0 \\ 1 & \alpha(\mathbf{x}) & 1 & 0 & \cdots & 0 \\ 0 & 1 & \alpha(\mathbf{x}) & 1 & \cdots & 0 \\ \vdots & \cdots & \ddots & \ddots & \ddots & \vdots \\ 0 & 0 & 0 & 1 & \alpha(\mathbf{x})& 1 \\ 0 & 0 & 0 & 0 & 1 & \alpha(\mathbf{x}) \end{bmatrix} \end{align*} whereby $$\alpha(\mathbf{x})\colon \mathbb{R}^{n} \to \mathbb{R}$$ is some function.

My attempt: I tried to determine the derivative using the chain rule, i.e. \begin{align*} \mathbf{A}(\mathbf{x}) = \left \{x \mapsto \begin{bmatrix} x & 1 & 0& 0 & \cdots & 0 \\ 1 & x & 1 & 0 & \cdots & 0 \\ 0 & 1 &x & 1 & \cdots & 0 \\ \vdots & \cdots & \ddots & \ddots & \ddots & \vdots \\ 0 & 0 & 0 & 1 &x& 1 \\ 0 & 0 & 0 & 0 & 1 &x \end{bmatrix}\right\} \circ \alpha(\mathbf{x}) \end{align*} so that \begin{align*} \mathrm{D}\mathbf{A}(\mathbf{x})h = \mathbf{I}_{n} \cdot \mathrm{D}\alpha(\mathbf{x})h .\end{align*} However, this would suggest that \begin{align*} \mathrm{D}\mathbf{A}(\mathbf{x}) = \mathbf{I}_{n} \cdot \mathrm{D}\alpha(\mathbf{x}) \end{align*} which makes little sense to me since $$\mathrm{D}\alpha(\mathbf{x})$$ is a row vector (for some fixed $$\mathbf{x}$$), making it not compatible with $$\mathbf{I}_{n}$$ (the $$n \times n$$ identity matrix). Where is my mistake?

Edit: For the first map, call it $$f(x)$$, I calculated: \begin{align*} f(x + h) &= \begin{bmatrix} x + h & 1 & 0& 0 & \cdots & 0 \\ 1 & x + h& 1 & 0 & \cdots & 0 \\ 0 & 1 &x + h & 1 & \cdots & 0 \\ \vdots & \cdots & \ddots & \ddots & \ddots & \vdots \\ 0 & 0 & 0 & 1 &x + h& 1 \\ 0 & 0 & 0 & 0 & 1 &x + h \end{bmatrix} \\ &= \underbrace{\begin{bmatrix} x & 1 & 0& 0 & \cdots & 0 \\ 1 & x & 1 & 0 & \cdots & 0 \\ 0 & 1 &x & 1 & \cdots & 0 \\ \vdots & \cdots & \ddots & \ddots & \ddots & \vdots \\ 0 & 0 & 0 & 1 &x& 1 \\ 0 & 0 & 0 & 0 & 1 &x \end{bmatrix}}_{f(x)} + \underbrace{ \begin{bmatrix} h & 0 & 0& 0 & \cdots & 0 \\ 0 & h & 0 & 0 & \cdots & 0 \\ 0 & 0 &h & 0 & \cdots & 0 \\ \vdots & \cdots & \ddots & \ddots & \ddots & \vdots \\ 0 & 0 & 0 & 0 &h& 0 \\ 0 & 0 & 0 & 0 & 0 &h \end{bmatrix}}_{\mathbf{I}_{n}h} \end{align*} so when plugging this into the definition of the derivative I get \begin{align*} \lim_{h \to 0} \frac{\left\|f(x + h) - f(x) - \mathrm{D}f(x)h\right\|_{2} }{h}= \lim_{h\to 0} \frac{\left\|\mathbf{I}_{n}h - \mathrm{D}f(x)h\right\|_{2} }{h} \stackrel{!}{=} 0 \end{align*} from which I concluded $$\mathrm{D}f(x) = \mathbf{I}_{n}$$

• Note that the derivative at $x$ will be a linear function from $\mathbf{R}^n$ to $\mathbf{R}^{n,n} = \mathbf{Mat}(n \times n),$ this is quite the expression (I believe this will be an $n \times n \times n$ "matrix"). You can, however, "identify" $A(x)$ with the sum of a constant matrix plus the diagonal matrix with entries $\alpha(x)$ (you already did this). The evaluation should be relatively obvious $A'(x) \cdot h$ will be the diagonal matrix with entries $\alpha'(x) \cdot h.$ Feb 4, 2022 at 17:18
• While I have never work this way myself, I also believe that when you can "identify" $A(x) = M(x) \circ \alpha(x)$ then $A'(x) = M'(\alpha(x)) \otimes \alpha'(x)$ (where $\otimes$ is the tensor product of matrices). Try Neudecker and Magnus' Matrix Differential Calculus. Feb 4, 2022 at 17:20
• @Mason could you please point out my mistake? Feb 4, 2022 at 21:40
• Why not just write $A(x) =\alpha(x) I_n + const$?
– Laz
Feb 4, 2022 at 21:45
• @Laz yes, don't know why I didn't do that... Feb 4, 2022 at 21:48

Your work is correct. $$Df(x)$$ is the map that sends $$h \in \mathbb{R}$$ to $$hI_n$$. So for $$y \in \mathbb{R}^n$$, $$DA(x)y = (D\alpha(x)y) I_n$$.
• but the composition is $f(\alpha(\mathbf{x}))$ so shouldn't it be the other way around, i.e. $(\mathrm{D}f)(\alpha(\mathbf{x})) \cdot \mathrm{D}\alpha(\mathbf{x})\cdot h$? Feb 7, 2022 at 10:23
• @Richard there is no conflict. $DA(x) : \mathbb{R}^n \to M(n, \mathbb{R})$ just as $A$ does. Feb 8, 2022 at 2:45