Because of the need of the operation rules of variational notation, I want to achieve the following effects:
Through[(f + s)'[x]]
Through[(f + s)''[x]]
I want to get the following results:
f'[x] + s'[x]
f''[x] + s''[x]
I need a general and easy way to achieve the above requirements. What should I do?
As mentioned below, LouisB's method can be used to solve the problem of single replacement, but how to realize the whole replacement for complex formula?
y[x0] + y[x] + y'[x] + x*y''[x]
I want to replace the function header y with y + εδy to get something like this:
y[x0] + ε*δ[y[x0]] +
y[x] + ε*δ[y[x]] +
y'[x] + ε*δ[y'[x]] +
x (y''[x] + ε*δ[y''[x]])
In addition, for the following cases:
replaceHead = # /.
h : (y |
Derivative[_][y]) :> (Times[ε, δ@
h[#]] &) &;
expr = (y[x0]^2) + Integrate[x y[x] + D[y[x], x]^2, {x, x0, x1}];
expr + replaceHead@expr
I need the results like this:
2 y[x0] δ[y[x0]] +
Integrate[(x δ[y[x]] +
2 Derivative[1][y][x] δ'[y[x]]), {x, x0, x1}]
But kglr's method can't combine integrals to get the form I want.



Through[Distribute[(f + s)'][x]]andThrough[Distribute[(f + s)''][x]]– LouisB Feb 21 '20 at 07:34x y[x]is should becomex (y[x] + ε*δ[y[x]]), you second says it should becomex δ[y[x]]. What happened toεbetween your first update and the second? – kglr Feb 23 '20 at 00:28this problemfinally. It's better to answer this question directly. – A little mouse on the pampas Feb 23 '20 at 00:37