(* We find the global extrema of x^2-y^2  on the region [-2,1]x[-1,2] *)

f=x^2-y^2
Plot3D[f,{x,-2,1},{y,-1,2}]
ContourPlot[f,{x,-2,1},{y,-1,2}]

Gf=Grad[f,{x,y}]
VectorPlot[Gf,{x,-2,1},{y,-1,2}]

(* Critical points *)
crits=Solve[Gf=={0,0},{x,y}]

H=D[Gf,{{x,y}}] /. crits[[1]];
MatrixForm[H]
Det[H]
(* The only critical point inside the region is a saddle point. The global extrema cannot be there. *)

(* Boundary *)
west=f/.{x->-2,y->t}
Plot[west,{t,-1,2}]
wcrits=Solve[D[west,t]==0,t]
west /. t->-1
west /. wcrits[[1]]
west /. t->2

east=f/.{x->1,y->t}
Plot[east,{t,-1,2}]
ecrits=Solve[D[east,t]==0,t]
east /. t->-1
east /. ecrits[[1]]
east /. t->2

south=f/.{x->t,y->-1}
Plot[south,{t,-2,1}]
scrits=Solve[D[south,t]==0,t]
south /. t->-2
south /. scrits[[1]]
south /. t->1

north=f/.{x->t,y->2}
Plot[north,{t,-2,1}]
ncrits=Solve[D[north,t]==0,t]
north /. t->-2
north /. ncrits[[1]]
north /. t->1

(* Global maximum of 4 at (-2,0).
Global minimum of -4 at (0,2) *)