Clear[x, y]

f[x_, y_] := x^2  -  y^2

Plot3D[f[x, y], {x, -2, 2}, {y, -2, 2}]

g[x_, y_] := (x^2 +  2*y^2) Exp[-(x^2 + y^2)];

Plot3D[
      g[x, y], {x, -2, 2}, {y, -2, 
        2}, 
AxesLabel -> {"x", "y", "f(x,y)\
"}, 
ViewPoint -> {-2.5, 0.9, 2.5}]

Clear[x, y, f, g];

f[x_, y_] := (x - 1)^2  +  y^2;

g[x_, y_] := y^2  +  2 x  - 5;

L[x_, y_, lambda_] := f[x, y] + lambda g[x, y]

result = 
        Solve[{D[L[x, y, lambda], x] == 0, 
            D[L[x, y, lambda], y] == 0, 
            D[L[x, y, lambda], lambda] == 0}, {x, y, lambda}]

{{lambda -> -(3/2), x -> (5/2), 
          y -> 0}, {x -> 2, lambda -> -1, 
          y -> -1}, {x -> 2, lambda -> -1, 
          y -> 1}}

f[x, y] /. result

{(9/4), 2, 2}

Plot3D[f[x, y], {x, -2, 4}, {y, -3, 3}]

ContourPlot[f[x, y], {x, -2, 4}, {y, -3, 3}]

xtoy = Solve[g[x, y] == 0, x]

{{x -> (1/2) (5 - (y^2))}}

h[y_] := (f[x, y] /. xtoy)[[1]]

h[y]

(y^2) + (((-1 + (1/2) (5 - (y^2))))^2)

Plot[h[y], {y, -3, 3}]

Clear[x, y, g, f, h]

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

g[x_, y_] :=  p x  +  q y  -  m;

L[x_, y_, lambda_] := f[x, y] +  lambda g[x, y]

r1  =  
        Solve[{D[L[x, y, lambda], x] == 0, 
            D[L[x, y, lambda], y] == 0, 
            D[L[x, y, lambda], lambda] == 0}, {x, y, lambda}]

{{lambda -> ((-a - b)/m), 
          x -> ((a m)/((a + b) p)), 
          y -> ((b m)/((a + b) q))}}

h[p_, q_, m_] := f[x, y] /. r1

h[p, q, m]

{a Log[((a m)/((a + b) p))] + 
          b Log[((b m)/((a + b) q))]}

D[h[p, q, m], m]

{(a/m) + (b/m)}

Clear[x, y, g, f, h]

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

g[x_, y_] :=  p x  +  q y  -  m;

L[x_, y_, lambda_] := f[x, y] +  lambda g[x, y]

r1  =  
        Solve[{D[L[x, y, lambda], x] == 0, 
            D[L[x, y, lambda], y] == 0, 
            D[L[x, y, lambda], lambda] == 0}, {x, y, lambda}]

{{y -> ((b m - a q)/(b q)), 
          lambda -> -(b/q), x -> ((a q)/(b p))}}

h[p_, q_, m_] := f[x, y] /. r1

h[p, q, m]

{((b m - a q)/q) + a Log[((a q)/(b p))]}

D[h[p, q, m], m]

{(b/q)}