# Symbolic derivative about functional and substitute function

I have trouble with symbolic functional derivatives and substitute , for example,

result1 =[D[f[x, y], x]]


$$result1 = \frac{\partial f[x,y]}{\partial x}$$

next, i want take $$f[x,y]=x+y$$ substitute into result1. This is very useful in symbolic computation, especially when substituting functions into expressions after complex computations.

I have try this answer with Inactivate  ,this is a very early version, and Inactivate  will deactivate all partial derivatives. It's very inconvenient, for example, When I only care about the properties of f,

result1 = Inactivate[D[f[x, y] Cos[x], x], D]


the output is $$\frac{\partial (\cos (x) f(x,y))}{\partial x}$$ , is there any better method can able to substitute f into the expression while computing known functions as much as possible?

As the follows example,

 result1 =[D[f[x, y] Cos[x], x]]
result2 = result1/.{f[x,y]=x+y}


I want output is $$result1 = \frac{\partial ( f(x,y))}{\partial x}\cos (x)-\sin (x) f(x,y), result2 = \cos (x)-(x+y) \sin (x)$$

• Maybe i can use result1 =[D[f[x, y] Cos[x], x]], result2 =Inactivate[[D[f[x, y] Cos[x], x]],D] , result3 = result2/.{f[x,y]=x+y}  and at last, result4 = Activate@ result3, but this looks clumsy, any advise very be much appreciate! Oct 16, 2022 at 15:26

Another way could be to simply define your replacement for $$f(x,y)$$ using Function notation as follows

ClearAll[f, x, y]
result1 = D[f[x, y] Cos[x], x]
myf = Function[{x, y}, x + y]
result2 = result1 /. f -> myf This is the same trick used to verify solution of an ode by plugging in the solution in Function form back into the ode which has derivatives in it.

• Thank you and Neumann, this answer solved my problem perfectly! Oct 16, 2022 at 15:34

result1 = D[f[x, y] Cos[x], x] (*-f[x, y] Sin[x] + Cos[x] Derivative[1, 0][f][x, y]*)