Numerical Implementation of Functional Derivatives I am wondering if there is a way to numerically find the functional derivative of a functional with respect to a function. Currently, the function I have has been calculated numerically. Its dependence on the other function is analytically difficult to determine.
 A: Assume that $X \subseteq \mathbb R^n$ is a region and $F(f)$ a functional taking values in $\mathbb R$ for functions $f : X \to \mathbb R.$
For a numerical calculation of a functional and its derivative, we need to discretize our space $X$. We do this as in the Finite Element Method, i.e. we partition $X$ into small regions $R_k$ (e.g. triangles), set $f_k = f(x_k)$ and select basis functions $\psi_k$ on every $R_k$ such that $f \approx \sum_k f_k \psi_k$.
Then $F(f) \approx F(\sum_k f_k \psi_k) \equiv \hat F(f_1, \ldots, f_N)$. The functional derivative is given by taking some function $\phi \approx \sum_k \phi_k \psi_k$ and calculating
$$\begin{align}
\left\langle \frac{\delta}{\delta f} F(f), \phi \right\rangle
& := \left. \frac{d}{d\lambda} F(f+\lambda\phi) \right|_{\lambda=0} \\
& = \left. \frac{d}{d\lambda} F\big(\sum_k (f_k+\lambda\phi_k) \psi_k \big) \right|_{\lambda=0} \\
& = \left. \frac{d}{d\lambda} \hat F(f_1+\lambda\phi_1, \ldots, f_N+\lambda\phi_N)\right|_{\lambda=0} \\
& = \sum_k \frac{\partial}{\partial f_k} \hat F(f_1, \ldots, f_N) \, \phi_k
\end{align}$$
If $F(f) = \int L(x, f(x), f'(x)) \, dx$ then 
$$
\hat F(f_1, \ldots, f_N) = \int L\big(x, \sum_k f_k \psi_k(x), \sum_k f_k \psi'(x)\big) \, dx
\equiv \int \hat L(x; f_1, \ldots, f_N) \, dx
$$
so
$$\begin{align}
\sum_k \frac{\partial}{\partial f_k} \hat F(f_1, \ldots, f_N) \, \phi_k
& = \sum_k \int \frac{\partial}{\partial f_k} \hat L(x; f_1, \ldots, f_N) \, dx \\
& = \sum_k \int \left( \frac{\partial L}{\partial f} \psi_k(x) + \frac{\partial L}{\partial f'} \psi_k'(x) \right) \, dx \\
& = \sum_k \int \left( \frac{\partial L}{\partial f} - \frac{d}{dx} \frac{\partial L}{\partial f'} \right)  \psi_k(x) \, dx
\end{align}$$
