f[x_, y_]  =  
      x^2  +  y^2  -  Cos[Pi x - 2]
Plot3D[f[x, y], {x, -5, 5}, {y, -5, 5}, 
      AxesLabel -> {x, y, z}]
Plot3D[f[x, y], {x, -5, 5}, {y, -5, 5}, 
      AxesLabel -> {x, y, z}, 
      PlotPoints -> 35]
Plot3D[f[x, y], {x, -5, 5}, {y, -5, 5}, 
      AxesLabel -> {x, y, z}, PlotPoints -> 35, 
      ColorFunction -> Hue]

ContourPlot[f[x, y], {x, -5, 5}, {y, -5, 5}, 
      Contours -> 20, PlotPoints -> 40, FrameLabel -> {x, y}, 
      ColorFunction -> Hue]
DensityPlot[f[x, y], {x, -5, 5}, {y, -5, 5}, 
      PlotPoints -> 40, FrameLabel -> {x, y}, 
      ColorFunction -> Hue, Mesh -> False]

f[x_, 
        y_]  =  (x + y - 1/4) Exp[-x^2 - 
            y^2]
Plot3D[f[x, y], {x, -2, 2}, {y, -3, 3}, 
      AxesLabel -> {x, y, z}, PlotPoints -> 35, 
      ColorFunction -> Hue, 
      PlotRange -> {-1/2, 1/2}]
ContourPlot[f[x, y], {x, -2, 2}, {y, -3, 3}, 
      Contours -> 20, PlotPoints -> 40, 
      FrameLabel -> {x, y}]
DensityPlot[f[x, y], {x, -2, 2}, {y, -3, 3}, 
      PlotPoints -> 40, FrameLabel -> {x, y}, 
      Mesh -> True]
Solve[{D[f[x, y], y] == 0, D[f[x, y], x] == 0}, {x, 
        y}]
N[%]

Clear[x, y]
f[x_, 
        y_]  =  (x +  a y - 1/4) Exp[- x^2 - 
            y^2]
sol  =  
      Solve[{D[f[x, y], y] == 0, D[f[x, y], x] == 0}, {x, 
          y}]
x  =  x /. x -> Part[sol, 1, 1, 2]
y  =  y /. y -> Part[sol, 1, 2, 2]
ParametricPlot[{x, y}, {a, -4, 4}, Frame -> True, 
      FrameLabel -> {"Optimal x", "Optimal y"}, 
      GridLines -> {{-0.441}, {-0.441}}]

Plot[f[x, y], {a, -4, 4}, Frame -> True, 
      FrameLabel -> {"a", "Minimum of f"}, 
      GridLines -> {{1}, {-0.767}}, Axes -> False]

s1[a_]  =  Simplify[D[x, a] a/x]
TeXForm[%]

s2[a_]  =  Simplify[D[y, a] a/y]
TeXForm[%]

s3[a_]  =  
      Simplify[D[f[x, y], a] a/f[x, y]]
TeXForm[%]

Plot[s1[a], {a, -4, 4}, Frame -> True, 
      FrameLabel -> {"a", "S(Optimal x, a)"}, 
      Axes -> False]
Plot[s2[a], {a, -4, 4}, Frame -> True, 
      FrameLabel -> {"a", "S(Optimal y, a)"}, 
      Axes -> False]
Plot[s3[a], {a, -4, 4}, Frame -> True, 
      FrameLabel -> {"a", "S(Minimum f, a)"}, 
      Axes -> False]

N[s2[1]]