Consumer's choice

u[x_, y_] :=  a Log[x]  +  b Log[y];

lag[x_, y_, l_] := 
      u[x, y] + l (m  -  p x  -  q y)

D[lag[x, y, l], x]

D[lag[x, y, l], y]

optimal = 
      Solve[{-l p + (a/x) == 0, -l q + (b/y) == 0, 
          m  -  p x  -  q y == 0}, {x, y, l}]

v[x_, y_] :=  a Log[x]  +  b y;

lag[x_, y_, l_] := 
      v[x, y] + l (m  -  p x  -  q y)

D[lag[x, y, l], x]

D[lag[x, y, l], y]

Solve[{D[lag[x, y, l], x] == 0, 
        D[lag[x, y, l], y] == 
          0, 
m  -  p x  -  q y == 0}, {x, y, 
        l}]

iv[p_, q_, m_] := v[x, y] /. optimal[[1]]

iv[p, q, m]

D[iv[p, q, m], m]

D[iv[p, q, m], p]

Producer's choice

a = 2/3;  b  =  1/3;

f[x1_, x2_] :=  x1^a x2^b;

lag[x1_, x2_, l_] := -q1 x1  -  q2 x2  +  
            l (y - f[x1, x2]);

eq1 = D[lag[x1, x2, l], x1] == 0;

eq2 = D[lag[x1, x2, l], x2] == 0;

eq3  =  y  -  f[x1, x2] ==  0;

sols = Solve[{eq1, eq2, eq3}, {x1, x2, l}] // Simplify

sol = sols[[2]]

{x1 -> (((2^(1/3)) (q2^(1/3)) y)/(q1^(1/3))), 
        x2 -> (((q1^(2/3)) y)/((2^(2/3)) (q2^(2/3)))), 
        l -> -((3 (q1^(2/3)) (q2^(1/3)))/(2^(2/3)))}

D[q1 x1  +  q2 x2 /. sol, y] // Simplify

((3 (q1^(2/3)) (q2^(1/3)))/(2^(2/3)))

Pareto optima

Clear[u1, u2]

u1[x11_, x12_] =  a1 Log[x11]  +  b1 Log[x12];

u2[x21_, x22_] =  a2 Log[x21]  +  b2 Log[x22];

lag[x11_, x12_, x21_, x22_, l1_, l2_] := 
          c1 u1[x11, x12] + c2 u2[x21, x22]  +  
            l1 (w1  -  x11  -  x21)  +  
            l2 (w2  -  x12  -  x22);

eq11 = D[lag[x11, x12, x21, x22, l1, l2], x11] == 0

eq12 = D[lag[x11, x12, x21, x22, l1, l2], x12] == 0

eq21 = D[lag[x11, x12, x21, x22, l1, l2], x21] == 0

eq22 = D[lag[x11, x12, x21, x22, l1, l2], x22] == 0

eqw1  =  
        w1  -  x11  -  x21  ==  0;

eqw2  =  w2  -  x12  -  x22  ==  0;

paretosol = 
      Solve[{eq11, eq12, eq21, eq22, eqw1, eqw2}, {x11, x12, x21, x22, l1, 
          l2}]

{{l1 -> ((a1 c1 + a2 c2)/w1), 
          l2 -> ((b1 c1 + b2 c2)/w2), 
          x12 -> ((b1 c1 w2)/(b1 c1 + b2 c2)), 
          x22 -> ((b2 c2 w2)/(b1 c1 + b2 c2)), 
          x11 -> ((a1 c1 w1)/(a1 c1 + a2 c2)), 
          x21 -> ((a2 c2 w1)/(a1 c1 + a2 c2))}}

paretosol /. {c1 -> γ, c2 -> (1 - γ)} // 
      Simplify

{{l1 -> ((a2 + a1 γ - a2 γ)/w1), 
          l2 -> ((b2 + b1 γ - b2 γ)/w2), 
          x12 -> ((b1 w2 γ)/(b2 + b1 γ - b2 γ)), 
          x22 -> ((b2 w2 (-1 + γ))/(b2 (-1 + γ) - b1 γ)), 
          x11 -> ((a1 w1 γ)/(a2 + a1 γ - a2 γ)), 
          x21 -> ((a2 w1 (-1 + γ))/(a2 (-1 + γ) - a1 γ))}}

welfare[w1_, w2_] := 
        c1 u1[x11, x12] + c2 u2[x21, x22] /. paretosol

D[welfare[w1, w2], w1]

{((a1 c1)/w1) + ((a2 c2)/w1)}

D[welfare[w1, w2], w2]

{((b1 c1)/w2) + ((b2 c2)/w2)}

mrs1[x11_, x12_] := -D[u1[x11, x12], x12]/
          D[u1[x11, x12], x11]

mrs2[x21_, x22_] := -D[u2[x21, x22], x22]/
          D[u2[x21, x22], x21]

mrs1[x11, x12] /. paretosol // Simplify

{-(((b1 c1 + b2 c2) w1)/((a1 c1 + 
                    a2 c2) w2))}

mrs2[x21, x22] /. paretosol // Simplify

{-(((b1 c1 + b2 c2) w1)/((a1 c1 + 
                    a2 c2) w2))}