# How to differentiate with respect to a function

I have some complicated expression, let's call it $$X_n$$, for which I don't have a closed form, but I do have a recurrence relation. It is given in terms of some functions $$u(x,y),$$ $$v(x,y),$$ and derivatives.

What I want to do is find

$$\frac{\delta X_n}{\delta v},$$

given $$X_n,$$ for a good few values of $$n.$$ Is there a way to do this so that I can get Mathematica to think of $$u$$ and $$v$$ as 'variables' and then just differentiate with respect to them, even though they're technically functions?

So if I take an example, where $$X=\int uv_xdx,$$ so I set

expression[x_,y_]=u[x,y]D[v[x,y],x]


and I want to differentiate this w.r.t. $$v$$, so that I get the answer $$u_{xx}+2u^2v,$$ then what I want it to do is something like

D[Integrate[expression[x,y],x],v[x,y]]


which obviously doesn't make sense to Mathematica. I could try using the Euler-Lagrange equations, but this still requires me to actually differentiate with respect to a function, which is what I need to know.

I'm not exactly a computer-minded person, and only really require this code due to the large size of the expressions involved making them too tedious to do by hand, so I'd really appreciate assistance understandable to a beginner (i.e. the simpler the code I could implement, the better). Thanks.

• Have you seen this? – J. M. will be back soon Feb 25 '19 at 9:35
• How about VariationalMethodsVariationalD`? – Αλέξανδρος Ζεγγ Feb 25 '19 at 11:46
• It would be easier to respond if there was an explicit example, in Mathematica input form. – Daniel Lichtblau Feb 25 '19 at 15:35