# How to take a derivative of a function with respect to another function inside the function?

I have these two equations:

p[x_, y_, t_, ta_, f_, fa_, u_] := (E^\[Omega]*(\[Epsilon] + 1)*((y - (f + fa) - (t + ta)*x)^(1 - \[Gamma])/(1 - \[Gamma]) - u))^(1/(\[Epsilon] + 1));
q[x_, y_, t_, ta_, f_, fa_, u_] := (1 - \[Gamma])^(\[Gamma]/(1 - \[Gamma]))*E^\[Omega]*p[x, y, t, ta, f, fa, u]^(\[Epsilon] + 1)*((E^\[Omega]*p[x, y, t, ta, f, fa, u]^(\[Epsilon] + 1))/(\[Epsilon] + 1) + u)^(\[Gamma]/(1 - \[Gamma]));


I need to make a test with the Slutsky equation:

dq/dp + q*dq/dy < 0


What I have tried so far:

Slutsky[x_, y_, t_, ta_, f_, fa_, u_] := D[q[p], p] + q[x]*D[q[y], y] #doesn't recognise q[p] or q[y] - I already knew this wasn't going to work

Slutsky[x_, y_, t_, ta_, f_, fa_, u_] := D[q[x, y, t, ta, f, fa, u], p] + q[x, y, t, ta, f, fa, u]*D[q[x, y, t, ta, f, fa, u], y] #problem is that p is not a parameter in the function so I also knew this wasn't going to work


Question is what would work? Do I have to make p into a parameter?

PS. I have parameter numerical values for y, t, ta, f, fa.

x follows a gradient from 0 to xbar.

u is calculated in model, but I could set it arbitrarily for this test.

• I’m pretty sure this has been asked before on this site. You might try searching May 24 at 21:26
• I tried that for a while, but there were not really any answers. I might not have used the right terminology in my search, but maybe I don’t know it. May 24 at 21:31
• Note that dp/dq is ill defined. This only makes sense for functions of 1 variable. If there are more than 1 variable, the derivative may depend on the direction of the change. Therefore you have to define the direction. May 26 at 10:17