Given the function \begin{align*} f \colon \mathbb{R}^n &\to \mathbb{R}^n\\ v&\mapsto \dfrac{v}{\|v\|}, \end{align*} I would like to compute the derivative of $f$, that is $df(v)$. It is possible to derive it by hand, which leads to
$$df(v)=\dfrac{1}{\| v\|}\Big(I_n - \dfrac{v}{\|v\|}\otimes \dfrac{v}{\|v\|}\Big)$$
where $I_n$ is the identity second-order matrix.
I believe Mathematica cannot find that using simple built-in functions (without explicitly defining v = {v1, v2, v3}
if $n=3$ for instance). Some packages are dedicated to differential geometry (see Coordinate free differential forms package or Differential geometry add-ons for Mathematica) but I failed to achieve the above calculation. Any hint would be appreciated.
Edit For those of you who are interesting in how to find the above formula, you can define $g(t)=f(v(t))=\big(v(t)\cdot v(t)\big)^{1/2}v(t)$ and compute $g'(t)$ with the chain rule. $g'(t)$ is a linear function of $v'(t)$ because:
$$g'(t)=\dfrac{df}{dv}(v(t)) v'(t)$$
Taking the coefficient in front of $v'(t)$ gives the above expression.
Now, the naive implementation of this approach as follows fail because it does not capture the multi-dimensionality of the f
:
f[v_] = v/Norm[v]
h[t_] = D[f[v[t]], t]/v'[t] // Simplify
h[t] /. Norm'[v[t]] -> v[t]/Norm[v[t]] // Simplify
(* (Norm[v[t]]^2 - v[t]^2)/Norm[v[t]]^3 *)
IdentityMatrix[3]
$\endgroup$v
, here for instance, is dependent upont
, and presumablyv[t]
is an n-dimensional vector? It will be interesting to see what solutions come about from this, as I’d expect somehow to either have to give the dimensionality, or be able to determine it from the inputs. $\endgroup$v
does not necessarily depend ont
but that's a "trick" I used to derive the expression of $df(v)$ (the trick is to introduce artificiallyt
and remove it afterwards). But that's right,v[t]
would be a vector such as{v1[t], v2[t], ..., vn[t]}
. $\endgroup$