# How to take the derivative with respect to a function with more than one variable?

I have a function that includes another function inside. I want to know the derivative at every point x. I have spent a lot of time trying to figure out how to do this, but I am very lost. I have searched on here without luck.

y = 70000.;
t = 350.;
f = 3000.;
ta = 250.;
fa = 1000.;
u = 3000.;
(* elasticity of income *)
\[Gamma] = 0.2;
(* price elasticity of housing *)
\[Epsilon] = -0.6;
(* constant in demand function *)
\[Omega] = 7.34074;

And the two functions:

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]


I need to know what the derivative of q is with respect to p on a graph of x.

I have tried these:

ND[q[x, y, t, ta, f, fa, u],p[x, y, t, ta, f, fa, u]];
ND[q[x, y, t, ta, f, fa, u],p];
D[q[x, y, t, ta, f, fa, u],p[x, y, t, ta, f, fa, u]];
D[q[x, y, t, ta, f, fa, u],p];
ND[q[1, y, t, ta, f, fa, u],p[1, y, t, ta, f, fa, u]];
ND[q[1, y, t, ta, f, fa, u],p];
D[q[1, y, t, ta, f, fa, u],p[1, y, t, ta, f, fa, u]];
D[q[1, y, t, ta, f, fa, u],p];


None of it gave any meaningful results. I only want to know if the result is negative at all given x'es.

• So you are trying to compute D[(1 - \[Gamma])^(\[Gamma]/(1 - \[Gamma]))*E^\[Omega]*p^(\[Epsilon] + 1)*((E^\[Omega]*p )), p]? If so, you can do that and then substitute for p.
– Alan
Jun 1, 2022 at 13:35
• @Alan When I do that, I get an equation rather than a number. I would like to see if the result is positive or negative. Jun 2, 2022 at 14:40
• After you substitute for p[x,params] you also need to substitute forparams; this will produce an express in x.
– Alan
Jun 2, 2022 at 21:12
• I created an answer to show what I mean in more detail.
– Alan
Jun 3, 2022 at 15:18

ClearAll[x, y, t, ta, f, fa, u]
params = {y -> 70000., t -> 350., ta -> 250., f -> 3000., fa -> 1000.,u -> 3000.};
(* constants: *)
\[Gamma] = 0.2(*elasticity of income*);
\[Epsilon] = -0.6(*price elasticity of housing*);
\[Omega] = 7.34074(*constant in demand function*);

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 = (1 - \[Gamma])^(\[Gamma]/(1 - \[Gamma]))*E^\[Omega]*p^(\[Epsilon] + 1)*(E^\[Omega]*p);
D[q, p] // Simplify   (* as requested *)
fx = % /. {p -> p[x, y, t, ta, f, fa, u]} /. params // PowerExpand
Plot[fx, {x, 0, 200}]


• exactly what I was looking for. Thank you so much. Jun 7, 2022 at 12:01

I understand that you want to calculate dp/dq. That is the ratio of the change of p to the change of q if x is changed an infinite small amount.

To make it simpler I insert the constants and define:

p[x_] = 9.446200643449517*^6 (-3000. +
1.25 (-1000. - f - (250. + t) x + y)^0.8)^2.5;
q[x_] = 1.3098400921578258*^16 ((-3000. +
1.25 (-1000. - f - (250. + t) x + y)^0.8)^2.5)^1.4;


The differential quotient dp/dq is then:

p[x] / q'[x]


and dq/dp:

• It's actually the opposite. I want to take dq/dp. Preferably I would like to get a number so I can see if it's positive or negative. I actually just want to know what happens to q as we increase p by 1. Does it increase or decrease? Jun 2, 2022 at 14:39
• dq/dp is simply the inverse of dp/dq. I added this to the answer. Jun 2, 2022 at 16:11