To test the VariationalMethods` toolbox, I tried to compute $\frac{\delta I[y]}{\delta y(x)}$ for the following functional, assuming $w(x)$ is some well-behaved function:

$\qquad I[y(x)]=\int y(x) g\left(\int w(t) y(t-x)dt\right)dx$

The exact answer is:

$\qquad \frac{\delta I[y]}{\delta y(x)}= g\left(\int w(t) y(t-x)dt\right) + \int w(x)y(x)g'\left(\int w(t) y(t-x)dt\right)dx$,

where $g'(x)$ is the derivative of $g(x)$.

Mathematica did not find the above result.

These are the commands I run:

<< VariationalMethods`
VariationalD[y[x]*g[Integrate[w[t]*y[t - x], t]], y[x], x]

The the above code gives only the first term of the exact answer. What am I doing wrong? Is it even possible to compute such variations with Mathematica?

  • $\begingroup$ Please note that the answer below (after resolving Dirac Deltas), which in my eyes is correct, differs from yours, posted above. Concerning the toolbox you have mentioned, it seems that it is restricted to local functionals, i.e., whose integrand involves function values and their derivatives at the same point, thus my assumption would be that due to the fact you variate y[x] the value of y[t-x] is not variated. Anyway, I am also disappointed with the capabilities of the package you mentioned. $\endgroup$
    – MK.
    Mar 4, 2019 at 17:30

1 Answer 1


You could use FunctionalD from my answer to Non-trivial functional derivatives, which I repeat here:

FunctionalD[expr_, v:(f_[_]|{f_[_],_Integer}) .., OptionsPattern[]] := Internal`InheritedBlock[{f},
    f /: D[f[x_], f[y_], NonConstants->{f}] := DiracDelta[x-y];
    f /: D[f, f[y_], NonConstants->{f}] := DiracDelta[#-y]&;

    D[expr, v, NonConstants->{f}]

Then, for your example, we have:

    (s|x) ∈ Reals,
        Integrate[y[x] g[Integrate[w[t] y[t-x], {t, -∞, ∞}]], {x, -∞, ∞}],
] //TeXForm

$\int_{-\infty }^{\infty } \left(\delta (x-s) g\left(\int_{-\infty }^{\infty } w(t) y(t-x) \, dt\right)+y(x) w(s+x) g'\left(\int_{-\infty }^{\infty } w(t) y(t-x) \, dt\right)\right) \, dx$

You still need to distribute integrand, and resolve the Dirac delta function, but both terms are there.


Not the answer you're looking for? Browse other questions tagged or ask your own question.