Question:
How does one determine the optimal function f that either maximize or minimizes:
$$\int_{x_1}^{x_2} L\left(x, f, D_{h,x}[f ]\right) dx$$
Whereas:
$$ D_{h,x}[f] = \frac{f(x + h) - f(x)}{h} $$
And in the limit that $h \rightarrow 0$
$$ D_{0,x}[f] = \frac{df}{dx} $$
Work
We Derive from Scratch:
Find a function f that maxmimizes
$$\int_{x_1}^{x_2} L\left(x, f, D_{h,x}f \right) dx $$
The derivation of this solution is to consider the optimal solution $\phi(x)$ and state that any function $f$ can be expressed as $\phi(x) + eB(x)$ for some error function $B(x)$ that accounts for the difference between $\phi(x)$ and $f$. Additionally $B(x_1) = B(x_2) = 0$ can be stipulated IF we have some initial constraints on F.
Thus we write:
$$R(e) = \int_{x_1}^{x_2} L\left(x, f, D_{h,x}f \right) dx = \int_{x_1}^{x_2} L\left(x, \phi(x) + eB(x), D_{h,x} [\phi(x) + eB(x)] \right) = $$
$$\int_{x_1}^{x_2} L\left(x, \phi(x) + eB(x), D_{h,x} [\phi(x)] + eD_{h,x}[B(x)] \right) $$
Notice that an optimal value for R occurs at $e = 0$ and therefore
$$\frac{dR}{de}[0] = 0$$
This yields us
$$ \frac{dR}{de} = \int_{x_1}^{x_2} \left( \frac{\partial L}{\partial f} \frac{df}{de} + \frac{\partial L}{\partial D_{h,x}f} \frac{dD_{h,x}f}{de} \right) dx $$
Generating
$$\frac{dR}{de} = \int_{x_1}^{x_2} \left( \frac{\partial L}{\partial f} \frac{\phi(x) + e B(x)}{de} + \frac{\partial L}{\partial D_{h,x}f} \frac{D_{h,x} [\phi(x)] + e D_{h,x}[B(x)]f}{de} \right) dx $$
And that simplifies to:
$$\frac{dR}{de} = \int_{x_1}^{x_2} \left( \frac{\partial L}{\partial f}B(x) + \frac{\partial L}{\partial D_{h,x}f}D_{h,x}[B(x)] \right) dx $$
And evaluated at e = 0 Note that (e itself isn't present) gives us:
$$\int_{x_1}^{x_2} \left( \frac{\partial L}{\partial f}B(x) + \frac{\partial L}{\partial D_{h,x}f}D_{h,x}[B(x)] \right) dx = 0 $$
Unfortunately the standard integration by parts trick no longer works unless h = 0. So how do I progress further and get an expression independent of B?
Idea 1: Maybe the piece inside the Integrand must be totally 0
We query if it is ever possible that:
$$ \left( \frac{\partial L}{\partial f}B(x) + \frac{\partial L}{\partial D_{h,x}f}D_{h,x}[B(x)] \right) \ne 0 \ \forall B(x) $$
And yet:
$$\int_{x_1}^{x_2} \left( \frac{\partial L}{\partial f}B(x) + \frac{\partial L}{\partial D_{h,x}f}D_{h,x}[B(x)] \right) dx = 0 $$
If the scenario I gave is not possible then we can conclude:
$$\left( \frac{\partial L}{\partial f}B(x) + \frac{\partial L}{\partial D_{h,x}f}D_{h,x}[B(x)] \right) = 0$$
From here it is pretty trivial to proceed. We take the inverse difference $D_{h,x}^{-1}[f]$ on both sides:
$$D_{h,x}^{-1} \left[ \frac{\partial L}{\partial f}B(x) + \frac{\partial L}{\partial D_{h,x}f}D_{h,x}[B(x)] \right ] = D_{h,x}^{-1}[0]$$
This yields:
$$D_{h,x}^{-1} \left[ \frac{\partial L}{\partial f}B(x) + \frac{\partial L}{\partial D_{h,x}f}D_{h,x}[B(x)] \right ] = C$$
Now we can apply generalized integration by parts: That is given:
$$D_{h,x}[fg] = D_{h,x}[f]g + fD_{h,x}[g] + hD_{h,x}[f]D_{h,x}[g] $$
It follows that
$$D_{h,x}[fg] -D_{h,x}[f]g - hD_{h,x}[f]D_{h,x}[g] = fD_{h,x}[g] $$
Therefore
$$ D_{h,x}[fg] - D_{h,x}[f](g + hg) = fD_{h,x}[g] $$
Thus:
$$ fg - D_{h,x}^{-1} [D_{h,x}[f](g + hg)] = D_{h,x}^{-1}[ fD_{h,x}[g] ] $$
This when applied to the original equation yields:
$$D_{h,x}^{-1} \left[ \frac{\partial L}{\partial f}B(x) + \frac{\partial L}{\partial D_{h,x}f}D_{h,x}[B(x)] \right ] = C \rightarrow$$
$$D_{h,x}^{-1} \left[ \frac{\partial L}{\partial f}B(x) - D_{h,x}\left[\frac{\partial L}{\partial D_{h,x}f}\right](1+h)B(x) \right ] + \frac{\partial L}{\partial D_{h,x}f}B(x) = C$$
We can re-difference the equation (dropping the right hand in a very unrigorous fashion by declaring "the integration boudns make this 0 at both ends):
$$ \frac{\partial L}{\partial f}B(x) - D_{h,x}\left[\frac{\partial L}{\partial D_{h,x}f}\right](1+h)B(x) = 0 $$
Now we divide through by $B(x)$ and find:
$$ \frac{\partial L}{\partial f} - D_{h,x}\left[\frac{\partial L}{\partial D_{h,x}f}\right](1+h) = 0$$ And just to check we haven't shot ourselves, indeed as $h \rightarrow 0 $ we still recover the standard euler-lagrange equations