Derivative of a matrix times a vector within an exponential function

72 Views Asked by At

Let us consider $\beta:=(\beta_1,...,\beta_p)^T$ and $X$ a matrix of dimension ($n\times p$). I would like to calculate the following derivative $$\frac{\partial}{\partial \beta}\exp(X\beta) $$

Is it possible?

2

There are 2 best solutions below

0
On

In my general, the derivative of an $n$-dimensonal function $\boldsymbol f(\boldsymbol x)$ with $p$ variables is a $(p\times n)$ matrix $[\frac{\partial \boldsymbol f}{\partial \boldsymbol x}]_{i,j}=\frac{\partial f_j}{\partial x_i}$. Then $\frac{\partial}{\partial \beta}\exp(X\beta) $ can be calculated to be $X^T diag(\exp(X\beta)$.

0
On

$ \def\LR#1{\left(#1\right)} \def\op#1{\operatorname{#1}} \def\diag#1{\op{diag}\LR{#1}} \def\Diag#1{\op{Diag}\LR{#1}} \def\qiq{\quad\implies\quad} \def\p{\partial} \def\grad#1#2{\frac{\p #1}{\p #2}} \def\c#1{\color{red}{#1}} \def\CLR#1{\c{\LR{#1}}} $Let's use a convention wherein an uppercase Latin letter denotes a matrix, lowercase Latin a vector, and Greek a scalar. Then define the following vector variables $$\eqalign{ w &= Xb &\qiq dw = X\,db \\ f &= \exp(w) &\qiq F = \Diag f \\ }$$ Calculate the differential and gradient of the elementwise exp() function $$\eqalign{ df &= f\odot dw \;=\; F\: dw \;=\; FX\,db \\ \grad fb &= FX \\ }$$ In the above, $(\odot)$ denotes the elementwise/Hadamard product. Conveniently, Hadamard multiplication by a vector can be replaced by matrix multiplication with a diagonal matrix.