We will searching for stationary points, qualifying then as local maxima/minima.

First we will transform the maxima/minima with inequality restrictions into an equivalent maxima/minima problem but now with equality restrictions.

To do that we will introduce the so called slack variables #s_1# and #s_2# such that the problem will read.

Maximize/minimize #f(x,y) = x^2 + 3 x y + 9 y^2#

constrained to

#{
(g_1(x,y,s_1)=x + 3 y - s_1^2=0),
(g_2(x,y,s_2)=x + 3 y + s_2^2 - 2=0)
:}#

The lagrangian is given by

#L(x,y,s_1,s_2,lambda_1,lambda_2) = f(x,y)+lambda_1 g_1(x,y,s_1)+lambda_2g_2(x,y,s_2)#

The condition for stationary points is

#grad L(x,y,s_1,s_2,lambda_1,lambda_2)=vec 0#

so we get the conditions

#{
(lambda_1 + lambda_2 + 2 x + 3 y = 0),
(3 lambda_1 + 3 lambda_2 + 3 x + 18 y = 0),
( -s_1^2 + x + 3 y = 0),
( -2 lambda_1 s_1 = 0),
(-2 + s_2^2 + x + 3 y = 0),
(2 lambda_2 s_2 = 0)
:}#

Solving for #{x,y,s_1,s_2,lambda_1,lambda_2}# we have

#{(x = 0., y = 0., lambda_1 = 0., s_1 = 0., lambda_2 = 0.,
s_2 = 1.41421), (x = 1., y = 0.333333, lambda_1 = 0., s_1 = -1.41421,
lambda_2 = -3., s_2 = 0.)
:}#

so we have two points #p_1={0,0}# and #p_2 = {1,0.333333}#

Point #p_2# activates restriction #g_1(x,y,0)=0,{lambda_1 ne 0, s_1 = 0}#

#p_1# is qualified with #f(x,y)#

and

#p_2# is qualified with #f_{g_2}(x) =x(x-2)+4#

Computing

#grad f(0,0) = 0#

and

#"Eigenvalues"(grad^2 f(0,0))={18.544, 1.456}#

we conclude that #p_1# local minimum point.

Analogously for #p_2#

#d/(dx)(f_{g_2}(0)) = 0#

and

#d^2/(dx^2)(f_{g_2}(0)) = 2#

so #p_1,p_2# are local minima points