Partial Derivative of Square Root with Matrix Multiplication

128 Views Asked by At

for the scalar case $x\in \mathbb{R}$, the partial derivative of $f(x) = \sqrt{x^2 + \delta^2}$, where $\delta\in \mathbb{R}$ is a constant, is $f'(x) = x(x^2 + \delta^2)^{-1/2}$.

Now we assume that $x\in \mathbb{R}^n$, and $A\in \mathbb{R}^{n\times n}$. Define the function $f(x) = \sum_{i = 1}^n \sqrt{|Ax|_i^2 + \delta^2}$. Now we hope to find the partial derivative w.r.t. $x_i, i = 1,\dots, n$.

It seems that the partial derivative w.r.t. each element involves other locations. Could anyone give some hints about the derivative? Thanks in advance!

1

There are 1 best solutions below

0
On BEST ANSWER

$\def\B{\Big}\def\L{\left}\def\R{\right}\def\o{{\tt1}}\def\p#1#2{\frac{\partial #1}{\partial #2}}$Define the all-ones vector $\o$ and a vector $v$ such that $$\eqalign{ v\odot v &= Ax\odot Ax + \delta^2\o \\ 2\,v\odot dv &= 2\,Ax\odot A\,dx \\ dv &= Ax\odot A\,dx\oslash v \\ }$$ where $\odot$ denotes the elementwise/Hadamard product and $\oslash$ Hadamard division.
Note that $\{\o,v,x\}\in{\mathbb R}^{n}$.

Let's use a colon to denote the trace/Frobenius product, i.e. $$A:B = {\rm Tr}(A^TB)$$ which coincides with the usual dot product when $\{A,B\}$ are vectors.

Write the objective function in terms of the above notation.
Then calculate its differential and gradient. $$\eqalign{ f &= \o:v \\ df &= \o:dv \\ &= \o:(Ax\odot A\,dx\oslash v) \\ &= (Ax \oslash v):(A\,dx) \\ &= A^T(Ax\oslash v):dx \\ \p{f}{x} &= A^T\B(Ax\oslash v\B) \\ }$$


Many specialized formulas were used in the steps above. First, due to the properties of the underlying trace function, the terms in a Frobenius product can be rearranged in many different ways, e.g. $$\eqalign{ CA:B &= C:BA^T = A:C^TB \\ }$$ Second, the Frobenius and Hadamard products commute $$\eqalign{ A:B &= B:A \\ A\odot B &= B\odot A \\ C:(A\odot B) &= (C\odot A):B \\ }$$ Finally, the vector $\o$ is the identity element for Hadamard multiplication $$\eqalign{v &= \o\odot v}$$