# What's the derivative $\frac{dE[F]}{dF_i}$ of this function $E[F] = |\frac{dF}{dx}|^2$?

The function is

$E[F] = |\frac{dF}{dx}|^2$

where we take $\frac{dF}{dx}$ to be the discrete derivative defined by $F_{i+1} - F_i$.

Could someone walk through why $\frac{dE[F]}{dF_i} = -2F_{i+1}+4F_i-2F_{i-1}$

-

The notation leaves something to be desired. $\frac{dF}{dx}:=F_{i+1}-F_i$.
$$\frac{dE[F]}{dF_i}=\frac{d}{dF_i}|F_{i+1}-F_i|^2=\frac{d}{dF_i}\left(F_{i+1}^2-2F_{i+1}F_i+F_i^2\right)=2F_{i+1}+2F_i^2$$
This doesn't seem right, so perhaps the absolute value really means: take the norm of the vector $\frac{dF}{dx}$ whose $i$'th component is $F_{i+1}-F_i$. Then
$$\left|\frac{dF}{dx}\right|^2=\sum_{i=1}^{n-1}(F_{i+1}-F_i)^2$$
and the set of terms involving $F_i$ are $(F_{i}-F_{i-1})^2+(F_{i+1}-F_i)^2$. Now take derivatives in $F_i$, to get $2F_i-2F_{i-1}-(2F_{i+1}+2F_i)=4F_{i}-2F_{i-1}-2F_{i-1}$.