CHAPTER  8
CONSTRAINED OPTIMIZATION

The optimizing problems of business and economics are generally of a constrained nature.  This is because every economic unit faces constraints in optimizing objectives.  For example, every economy is constrained in production of goods and services (GDP) by the available economic resources or factors of production. Every consumer is constrained in buying goods and services by budget or income constraint, and every producer faces cost or input constraints.

Chapter 7 was concerned with the optimizing rules of functions with no constraints or restrictions on the variables. In such cases, the relative maximum or the relative minimum is the optimum solution. This chapter is concerned with the optimum solution of problems in which a function, called the objective function, is optimized subject to one or more constraints on variables.  With a constraint imposed on the variables, the solution of the constrained optimizing problem may differ from the unconstrained problem, even if the objective functions are the same.  

The problem of finding a constrained optimum in calculus assumes that the constraints hold with equality.  The more general problem of maximizing or minimizing an objective function subject to inequality constraints is called mathematical programming.  In both cases, however, the method of Lagrangian function can be used to solve constrained optimization problems.

TOOL BOX           
Mathematica Commands				Function
z = f(x, y)				       	 z is a function of x and y 
sol = Solve [{D[z,x]==0,D[z,y]==0},{x,y}]    	    For z = f(x, y), solves first order condition & sets it to sol.
(({{D[D[z, x], x], D[D[z, x, ], y]}, {D[D[z, y], x], D[D[z, y], y]}, {D[D[z, λ], x], D[D[z, λ], y]}}))/.{sol}		             Finds the Hessian of Z =  f(x, y) and evaluates it at sol.        
 ViewPoint ->{a, b, c}    		                Sets or changes the view point of a 3D graph.
ContourPlot[f(x, y), {x, a, b}, {y, c, d}] 	             Contourplots f(x,y) in the given x - y ranges.


I.   Lagrangian Function and Equality Constraints: The sol = Solve [{D[z,x]==0,D[z,y]==0},{x,y}] Command
Consider the following constrained maximization problem:
	Maximize:    U = U(X, Y)                  
	Subject to:    PxX + PyY = M               
where the first equation is the objective function in which U(X, Y) is the utility function, assumed to be differentiable, and PxX + PyY = M is the budget constraint. The problem is to maximize the utility subject to the budget constraint. To solve the constrained optimizing problem, we form the Lagrangian function.  

The Lagrangian function is formed by augmenting the constraint together with the Lagrange multiplier (λ) to the objective function.
     L = U(X, Y) + λ(M - PxX - PyY)             

 If the constraint is satisfied, no matter what value λ has, the second term in the right side of the Lagrangian equation will vanish and L = U(X, Y). That is, maximizing L with respect to X and Y is the same as maximizing U(X, Y). Therefore, the trick in solving a constrained optimizing problem is to incorporate the constraint into the problem and insure that the constraint is satisfied with 
equality.  This is done by treating λ as an additional variable and assuming L is a function of X, Y, and λ.  That is,
     L(X, Y, λ) = U(X, Y) + λ(M - PxX - PyY)    
this function may be maximized with respect to the three unknown variables X, Y, and λ. The first order conditions are:
     (Subscript[L, x]) = Ux - λPx = 0                         
     (Subscript[L, y]) = Uy - λPy = 0                          
     (Subscript[L, λ]) = M - PxX - PyY = 0                     

A point P(X*, Y*, λ*) that satisfies the three equations of the first-order condition is the extremum.  

The second order condition for L(X, Y, λ) to have a maximum at P is that (d^2)L to be negative definite at the extremum. To find (d^2)L, find total differential of dL
dL = UxdX + UydY + dλ(M - PxX - PyY) - PxλdX - PyλdY     
(d^2)L = Uxxd(X^2) + UxydXdY + UyxdXdY + Uyyd(Y^2) - 2PxdλdX - 2PydλdY     

Using the matrix notations,  (d^2) L can be expressed in a quadratic form as:
(({{dX, dY, dλ}}))(({{Uxx, Uxy, -Px}, {Uyx, Uyy, -py}, {-Px, -Py, 0}}))(({{dX}, {dY}, {dλ}}))
 
The matrix of the quadratic form is called a bordered Hessian matrix which consists of a simple Hessian and two borders corresponding  to the constraint. 

The quadratic form of the second-order condition is said to be negative definite if the bordered principal minors of the bordered Hessian,  H = (({{Uxx, Uxy, -Px}, {Uyx, Uyy, -Py}, {-Px, -Py, 0}})) alternate in sign, beginning with the first bordered principal minor negative. That is, the second-order condition for maximum utility at the point P* requires that Det(({{Uxx, -Px}, {-Px, 0}})) < 0 and Det(({{Uxx, Uxy, -Px}, {Uyx, Uyy, -Py}, {-Px, -Py, o}})) > 0.  

In general, for a n-variable function  y = f(x1, x2, ......, xn)  to be optimized subject to the constraint g(x1, x2, ......, xn) = c 
the Lagrangian function is L(x1, .., xn, λ) = f(x1, x2, .., xn) + λ(c - g(x1, x2, .., xn)) and the first-order conditions are:

     ∂(L/∂)x1 = (Subscript[f, x1]) - λ(Subscript[g, x1]) = 0
     ∂(L/∂)x2 = (Subscript[f, x2]) - λ(Subscript[g, x2]) = 0
         ................
         
     ∂(L/∂)xn = (Subscript[f, xn]) - λ(Subscript[g, xn]) = 0
     ∂(L/∂)λ  = c - g(x1, ..., xn) = 0

The first order condition yields n + 1 equations in n + 1 variables which can be solved simultaneously to determine the extremum P(\(TraditionalForm\`\(x\^*\)\_1\), \(TraditionalForm\`\(x\^*\)\_2\), ..., \(TraditionalForm\`\(x\^*\)\_n\), \(TraditionalForm\`\(λ\^*\)\)).  To test for the maximum or minimum, the second order condition yields the following bordered Hessian matrix, (Note that, (Subscript[f, 11]), (Subscript[f, 12]), and (Subscript[f, 1  n]) below are representing (Subscript[f, x1x1]), (Subscript[f, x1x2]), and (Subscript[f, x1xn]) respectively. For the clarity of exposition the xs are deleted.)   

H = (({{(Subscript[f, 11]), (Subscript[f, 12]), ., ., (Subscript[f, 1  n]), -(Subscript[g, 1])}, {(Subscript[f, 21]), (Subscript[f, 22]), ., ., (Subscript[f, 2  n]), -(Subscript[g, 2])}, {., ., ., ., ., .}, {., ., ., ., ., .}, {(Subscript[f, n1]), (Subscript[f, n2]), ., ., (Subscript[f, nn]), -(Subscript[g, n])}, {-(Subscript[g, 1]), -(Subscript[g, 2]), ., ., -(Subscript[g, n]), 0}}))

the extremum is a minimum if the bordered Hessian determinant and the corresponding matrix is positive definite. The bordered Hessian determinant is positive definite if the bordered principal minors, defined as follows and evaluated at the extremum, are all negative.  That is:

Det(({{(Subscript[f, 11]), -(Subscript[g, 1])}, {-(Subscript[g, 1]), 0}})) < 0,    Det(({{(Subscript[f, 11]), (Subscript[f, 12]), -(Subscript[g, 1])}, {(Subscript[f, 21]), (Subscript[f, 22]), -(Subscript[g, 2])}, {-(Subscript[g, 1]), -(Subscript[g, 2]), 0}})),   Det (({{(Subscript[f, 11]), (Subscript[f, 12]), (Subscript[f, 13]), -(Subscript[g, 1])}, {(Subscript[f, 21]), (Subscript[f, 22]), (Subscript[f, 23]), -(Subscript[g, 2])}, {(Subscript[f, 31]), (Subscript[f, 32]), (Subscript[f, 33]), -(Subscript[g, 3])}, {-(Subscript[g, 1]), -(Subscript[g, 2]), -(Subscript[g, 3]), 0}})) < 0 ,  . . . . . . . . . .  
The extremum is a maximum if the bordered Hessian determinant and the corresponding matrix is negative definite. The bordered Hessian determinant is negative definite if the bordered principal minors, defined as above and evaluated at the extremum, alternate in sign, beginning with the first bordered principal minor negative.  Note that, the principal minor rules for the positive definiteness and negative definiteness of the bordered-Hessian matrices are different from the rules for Hessians with no border (unconstrained optimization).

Example: Consumer Theory
A consumer has a utility function expressed as U(x, y) = lnxy,  where x and y are quantities of two goods X and Y consumed by the consumer.  The market price of X and Y are $2 and $3, respectively.  The consumer has a budget of $120 to spend on the two goods.  Solve the utility maximizing problem of the consumer and find the optimum quantities of x and y.
Solution:  The utility maximizing problem can be expressed as 
     Maximize:  U = lnxy
   Subject to:  2x + 3y = 120
The Lagrangian function is L(x, y, k) = lnxy + λ(120 - 2x - 3y) and the first order conditions are:

      ∂(L/∂)x = (1/x) - 2λ = 0,     	or    (1/x) = 2λ     
     ∂(L/∂)y = (1/y) - 3λ = 0,     	or    (1/y) = 3λ   
     ∂(L/∂)λ = 48 - 2x - 3y = 0                     
divide the first two equations of the first-order condition together to delete λ and to get x = (2/3)y.  Substitute for x in the third equation to get x = 12 and y = 8.  To test whether this point (x = 12, y = 8, and λ = (1/24)) is a minimum or maximum, the second-order conditions yields the Hessian, H = (({{((-1)/(x^2)), 0, -2}, {0, ((-1)/(y^2)), -3}, {-2, -3, 0}})),  the determinants of the bordered principal minors of which are Det(({{((-1)/(x^2)), -2}, {-2, 0}})) = -4 < 0 and Det (({{((-1)/(x^2)), 0, -2}, {0, ((-1)/(y^2)), -3}, {-2, -3, 0}})) = (9/(x^2)) + (4/(y^2))> 0.  Since the determinants of the bordered principal minors alternate in sign beginning with the first one negative, the Hessian is negative definite and the extremum is a maximum.  (  Note that the first bordered principal minor is always negative.)  The solution implies that for the consumer to be at utility maximizing equilibrium, the consumer should buy 12 units of X and 8 units of Y.
To solve the problem using  Mathematica,
\(Clear[L, \ U, \ x, \ y, \ λ, \ sol]

        \(L\  = \ Log[x\ y] + λ\ \((48 - 2  x - 3  y)\);\)

        sol = 
          Solve[{D[L, x] == 0, \ D[L, y] == 0, \ 
              D[L, λ] == 0}, \ {x, y, λ}]\)
{{(Null^2) (λ -> (1/24)), 
          (Null^2) (x -> 12), (Null^2) (y -> 8)}}
The bordered Hessian matrix of the second order condition is:
MatrixForm[(({{D[D[L, x], x], D[D[L, x], y], D[
                    D[L, x], λ]}, {D[D[L, y], x], D[D[L, y], y], D[
                    D[L, y], λ]}, {D[D[L, λ], x], D[D[L, λ], y], D[
                    D[L, λ], λ]}}))]
(({{-(1/(x^2)), 0, -2}, {0, -(1/(y^2)), -3}, {-2, -3, 0}}))
The determinant of the bordered principal minors evaluated at the solution point are,
N[Det[(({{D[D[L,  x],  x], D[
                        D[L,  x],  λ] }, {D[D[L,  λ],  x], D[
                        D[L,  λ],  λ]}}))]]/.{sol1}
-4.`
N[Det[(({{D[D[L,  x],  x], D[D[L,  x],  y], D[
                        D[L,  x],  λ]}, {D[D[l,  y],  x], D[D[L,  y],  y], D[
                        D[L,  y],  λ]}, {D[D[L,  λ],  x], D[D[L,  λ],  
                        y], D[D[L,  λ],  λ]}}))]]/.{sol}
{{0.125`}}
Since the determinants of the bordered principal minors alternate in sign beginning with the first determinant negative, the Hessian is negative definite and the extremum is a maximum. 

Mathematica provides a very useful tool to observe the solution of the problem by plotting the functions in 3-D.  As well, by using the command ContourPlot[U(x, y), {x, a, b}, {y, c, d}], the indifference curves of the utility function and the budget constraint can be graphed in x-y axis.  This allows us to find the solution to the consumer's utility maximizing problem at the tangency point of the highest feasible indifference curve and the budget constraint.  To see the solution point graphically in three dimensions, plot the objective function and the budget constraint together as follows
Clear[U,  x,  y]
U  =  Log[x y];
g1 =  Plot3D[U,  {x,  .5, 40},  {y,  .5, 40}]

⁃  SurfaceGraphics  ⁃
g2  =  
          Plot3D[2  x + 3  y - 48,  {x,  0, 40},  {y, 0, 40}]

⁃  SurfaceGraphics  ⁃
Show[g1, g2,  ViewPoint -> {1.2, 1.2, 1.5}]

⁃  Graphics3D  ⁃
Note:  you can always change the viewpoint in the "Show" command to have a better view of the solution point.  To Change the viewpoint use the ViewPoint command.
To see the solution point graphically in x-y space, plot the indifference curves and the budget constraint using the ContourPlot command as follows,
con1  =  
          ContourPlot[U,  {x,   .5,  40},  {y,   .5,  20},  
            ContourShading -> False]

⁃  ContourGraphics  ⁃
con2 = ContourPlot[2  x + 3  y - 48,  {x,  0,  40}, {y,  0,  20},  Contours -> {0}, ContourShading -> False]

⁃  ContourGraphics  ⁃
Show[con1,  con2]

⁃  Graphics  ⁃
Do More Practice:
1- Change the budget constraint from $120 to $360 and re-run the program.  Observe the changes in solution.
2- Change prices of x and y from $2 and $3 to $2 and $4, respectively.  Hold the budget constraint at $120.  Re-run the program and compare the results.

Example: Theory of Production
A single-product firm has the production function Q = ((La^(. 5)) + K\(TraditionalForm\`\^\(\(.\)\(\ \)\(5\)\)\))\(TraditionalForm\`\^2\)  where, La and K are labor and capital inputs, and Q is the output.  The firm is hiring the services of labor and capital at prices $12 and $8 per unit, respectively.  If the firm has a cost constraint of $600, solve the output maximizing problem of the firm subject to its cost constraint.  
Solution:  The problem can be formulated as,
     Maximize:  Q = \(TraditionalForm\`\((La\^\(\(.\)\(\ \)\(5\)\)\  + \ K\^\(\(.\)\(\ \)\(5\)\))\)\^2\)
   Subject to:  12La + 8K = 600
The Lagrangian function is L(La, K, λ) = \(TraditionalForm\`\((La\^\(\(\(.\)\(\ \)\(5\)\)\(\ \)\) + \ K\^\(\(.\)\(\ \)\(5\)\))\)\^2\) + λ(600 - 12La - 8K) and the first order conditions are:
      ∂(L/∂)La = \(TraditionalForm\`\(\(La\^\(-\(\(,\)\(\ \)\(5\)\)\)\)\((\)\(La\^\(\(,\)\(\ \)\(5\)\)\)\)\)+ (K^(, 5))) - 12λ = 0,	or   \(TraditionalForm\`\(\(La\^\(-\(\(,\)\(\ \)\(5\)\)\)\)\((\)\(La\^\(\(,\)\(\ \)\(5\)\)\)\)\)+ (K^(, 5))) = 12λ 
     ∂(L/∂)K = (K^(-, 5))((L^(. 5 )) +  
          (K^(. 5))) - 8λ = 0,	or   (K^(-, 5))((L^(. 5 )) +  
          (K^(. 5)))  =  8λ 
     ∂(L/∂)λ = 600 -12La -8K = 0                     
divide the first two equations of the first-order condition together to delete λ and to get \(TraditionalForm\`La\^\(-\(\(,\)\(\ \)\(5\)\)\)\/K\^\(-\(\(.\)\(\ \)\(5\)\)\)\) = (3/2) or K = (9/4)La.  Substitute for K in the third equation to get La = 20 and K = 45.  That is, to maximize its output, the firm should employ 20 units of labor and 45 units of capital.  This will produce 125 units of output (this number is arrived at by substituting La and K in production function Q).   To find λ, substitute for La and K in the first order condition to get λ = . 21. 
To test whether the extremum (La = 20, K= 45, and λ = .21 ) is a minimum or maximum, the second-order condition yields the Hessian, H = (({{\(\(\(-\(\(.\)\(\ \)\(5\)\)\) \((L\^\(\(\(.\)\(\ \)\(5\)\)\(\ \)\) + \ K\^\(\(.\)\(\ \)\(5\)\))\)\)\/La\^1.5 + \(\(.\)\(\ \)\(5\)\)\/La\),  .(5/((K^(. 5)) (La^(. 5)))), -12}, { .(5/((K^(. 5)) 
                      (La^(. 5)))), \(\(\(-\(\(.\)\(\ \)\(5\)\)\) \((L\^\(\(\(.\)\(\ \)\(5\)\)\(\ \)\) + \ K\^\(\(.\)\(\ \)\(5\)\))\)\)\/K\^1.5 + \(\(.\)\(\ \)\(5\)\)\/K\), -8}, {-12, -8, 0}})).  The determinants of the bordered principal minors evaluated at the critical point are Det(({{\(\(\(-\(\(.\)\(\ \)\(5\)\)\) \((L\^\(\(\(.\)\(\ \)\(5\)\)\(\ \)\) + \ K\^\(\(.\)\(\ \)\(5\)\))\)\)\/La\^1.5 + \(\(.\)\(\ \)\(5\)\)\/La\), -12}, {-12, 0}})) = -144 < 0 and Det[H] = 6.67 > 0, respectively.   Since the determinants of the bordered principal minors alternate in sign beginning with the first one negative, the Hessian is negative definite and the extremum is a maximum.  (Note that the first bordered principal minor is always negative.)
To solve the problem using Mathematica,
Clear[L,  La,  K,  λ,  sol]
L = (La^ .5  + K^ .5)^2 + λ (600 - 12  La - 
                    8  K);
sol =  
          Solve[{D[L,  La] == 0,  D[L, K] == 0,  
              D[L,  λ] == 0},  {La,  K,  λ}]
{{(Null^2) (La -> 20.`), (Null^2) (K -> 45.`), 
          (Null^2) (λ -> 0.20833333333333334`)}}
The first order condition implies that the firm will hire 20 units of labor and 45 units of capital.  To find Q, evaluate the production function at the optimal solution,
\(\(Q\  = \ \((La^ .5\  + \ K^ .5)\)^2;\)

        Q /. {sol}\)
{{125.00000000000001` Null}}
To test for the second order condition, the bordered Hessian is:
MatrixForm[(({{D[D[L, La], La], D[D[L, La], K], D[
                    D[L, La], λ]}, {D[D[L,  K],  La], D[D[L,  K],  K], D[
                    D[L, K],  λ]}, {D[D[L, λ],  La], D[D[L, λ],  
                    K], D[D[L, λ], λ]}}))]
(({{\(\(-\(\(0.5`\ \((K\^0.5` + La\^0.5`)\)\)\/La\^1.5`\)\) + 
                  0.5`\/La\^1.`\), \(0.5`\/\(K\^0.5`\ La\^0.5`\)\), -12}, {\(0.5`\/\(K\^0.5`\ La\^0.5`\)\), \(0.5`\/K\^1.` - \(0.5`\ \((K\^0.5` + La\^0.5`)\)\)\/K\^1.5`\), -8}, {-12, -8, 0}}))
The bordered principal minors evaluated at the extremum are:
Det[(({{D[D[L, La], La], D[D[L, La], λ]}, {D[D[L, λ],  La], D[
                      D[L, λ], λ]}}))]/.{sol}
{{-144}}
Det[(({{D[D[L, La], La], D[D[L, La], K], D[
                      D[L, La], λ]}, {D[D[L,  K],  La], D[D[L,  K],  K], D[
                      D[L, K],  λ]}, {D[D[L, λ],  La], D[D[L, λ],  
                      K], D[D[L, λ], λ]}}))]/.{sol}
{{6.666666666666666`}}
Since the determinants of the bordered principal minors alternate in sign beginning with the first one negative, the Hessian is negative definite and the extremum is a maximum. 
To see the solution point graphically in three dimensions, plot the objective function and the constraint using Mathematica and show them together,
Q = (La^ .5 + K^ .5)^ .5;

        graph1 = Plot3D[Q,  {La, 1, 30}, {K, 1, 50}]

⁃  SurfaceGraphics  ⁃
graph2 = 
          Plot3D[12  La + 8  K - 600,  {La, 1, 30}, {K, 1, 50}]

⁃  SurfaceGraphics  ⁃
Show[graph1, graph2,  ViewPoint -> {1.2, 1.2, 1.6}]

⁃  Graphics3D  ⁃
To see the solution point graphically in x-y space, plot the isoquants and the cost constraint using the "ContourPlot" command,
co1 = ContourPlot[Q,  {La,  1,  50},  {K,  1,  100},  
            ContourShading -> False]

⁃  ContourGraphics  ⁃
co2 = ContourPlot[
            12  La + 8  K - 600,  {La, 1,  50},  {K, 1,  100},  
            Contours -> {0},  ContourShading -> False]

⁃  ContourGraphics  ⁃
Show[co1 ,  co2]

⁃  Graphics  ⁃

Do More Practice:
1- Change the cost constraint to $1200.  What is the effect of doubling the cost budget on inputs and output?
2- Double the labor and capital costs and keep the total cost budget at $600.  How does the solution change?
3- Change the capital price from $8 to $12, what is the effect on labor input, capital input and the output?  
4- Change the production function to Q = ((La^2) + (K^2))\(TraditionalForm\`\^ .5\).  Re-run the program.  Is this a conventional utility function?  Why?

Example: Cost and Production
Suppose that the objective of a firm employing two variable inputs labor and capital is to minimize cost (C) subject to a given level of output ((Subscript[Q, o])).  Solve the constrained optimizing problem.
Solution: The constrained optimizing problem of the firm can be formulated as, 
     Minimize:  C = wLa + rK
     Subject to: Q(La, K) = (Subscript[Q, o])
where, La and K are labor and capital inputs used in production, and w and r are wages and rental cost of capital respectively.   The Lagrangian function is L(La, K, ) = wLa + rK + λ((Subscript[Q, o]) - Q(La, K)) and the first order condition is
     ∂(L/∂)La =   w - λQLa  = 0
     ∂(L/∂)K =   r -  λQK  = 0
     ∂(L/∂)λ  =   (Subscript[Q, o]) - Q(La, K) = 0
The second order condition requires that the bordered-Hessian, derived from the total differential of the first-order condition, to be positive definite. The total differential of the first-order condition yields H = (({{-λQLaLa, -λQLak, -QLa}, {-λQkLa, -λQkk, -Qk}, {-QLa, -Qk, 0}})).  The second order condition for a minimum is satisfied if  Det(({{-λQLaLa, -QLa}, {-QLa, 0}})) < 0  and  Det (({{-λQLaLa, -λQLak, -QLa}, {-λQkLa, -λQkk, -Qk}, {-QLa, -Qk, 0}})) < 0.

Example: Cost and Production 
A firm has a production function  Q = 10\(TraditionalForm\`x\^ .75\)\(TraditionalForm\`y\^ .25\) , where Q is the output, x is the labor input, and y is the capital input.  The firm has to produce 800 units to meet the market demand.  The market prices of labor input and capital input are $60 and $172, respectively.  Solve the cost minimizing problem of the firm and find the total cost. 
Solution: The constrained optimizing problem of the firm can be formulated as
Minimize:     C = 60x + 172y
Subject to:    10\(TraditionalForm\`\(x\^ .75\) y\^ .25\)= 800
the Lagrangian function can be formulated as L(x, y, λ) = 60x + 172y + λ(800 - 10\(TraditionalForm\`x\^ .75\)\(TraditionalForm\`y\^ .25\)).  The first order condition results in the following three equations:
∂(L/∂)x = (Subscript[L, x]) = 60 -7.5λ\(TraditionalForm\`y\^\(\(.\)\(\ \)\(25\)\)\/x\^\(\(.\)\(\ \)\(25\)\)\)= 0, 	or  60 = 7.5λ\(TraditionalForm\`y\^\(\(.\)\(\ \)\(25\)\)\/x\^\(\(.\)\(\ \)\(25\)\)\)

∂(L/∂)y = (Subscript[L, y]) = 172 - 2.5λ\(TraditionalForm\`x\^\(\(.\)\(\ \)\(75\)\)\/y\^\(\(.\)\(\ \)\(75\)\)\) = 0,	or 172 = 2.5λ\(TraditionalForm\`x\^\(\(.\)\(\ \)\(75\)\)\/y\^\(\(.\)\(\ \)\(75\)\)\)

∂(L/∂)λ =  (Subscript[L, λ]) = 800 - 10(x^(, 75))(y^(. 25)) = 0, 	or 800 = 10\(TraditionalForm\`x\^ .75\)\(TraditionalForm\`y\^ .25\)
Divide the first two equations of the first-order condition together to delete λ.  This gives y = ((5  x)/43).  By substituting for y in the third equation of the first-order condition we get x = 137, y = 16, and λ = 13.70.  
The first-order conditions of the constrained optimizing problem yields a solution with 1367 units of labor input and 16 units of capital input. To test for the second-order condition, form the bordered Hessian matrix and evaluate it at the critical point (x = 137, y = 16, λ = 13.70),
H = (({{(Subscript[L, xx]), (Subscript[L, xy]), (Subscript[L, x])λ}, {(Subscript[L, yx]), (Subscript[L, yy]), (Subscript[L, y])λ}, {(Subscript[L, λ])x, (Subscript[L, λ])y, (Subscript[L, λ])λ}})) = (({{((1.875` (y^0.25)` λ)/(x^1.25))`, \(-\(\(1.875`\ λ\)\/\(x\^0.25`\ y\^0.75`\)\)\), \(-\(\(7.5`\ y\^0.25`\)\/x\^0.25`\)\)}, {0, ((1.875` (x^0.75)` λ)/(y^1.75))`, -((2.5` (x^0.75)`)/(y^0.75))`}, {-((7.5` (y^0.25)`)/(x^0.25))`, \(-\(\(2.5`\ x\^0.75`\)\/y\^0.75`\)\), 0}}))= (({{0.11, -0.94, -4.38}, {0, 8.10, -12.55}, {-4.38, -12.55, 0}}))
The determinant of the bordered principal minors are -19.18 and -276.14, respectively.  Since the determinants of the bordered principal minors are both negative, the Hessian is positive definite and the extremum is a minimum point.  To find the total cost, substitute for x and y in the objective function to get C = 10972.
To solve the problem using Mathematica, formulate the Lagrangian function and use the "Solve" command as,
Clear[x, y, λ, sol, cont1, cont2]
L = 
            60  x + 172  y + λ (800 - 10  x^ .75 y^ .25);
sol = 
          Solve[{D[L , x] == 0, D[L , y] == 0, 
              D[L , λ] == 0}, {x, y, λ}]
{{x -> 136.9981175864378`, 
          y -> 15.930013672841602`, λ -> 
            13.699811758643778`}}
To test for the second-order condition, form the bordered Hessian matrix and evaluate it at the solution "sol", 
MatrixForm[(({{D[D[L,  x],  x], D[D[L,  x], y], D[
                      D[L,  x],  λ]}, {D[D[L,  K],  x], D[D[L,  y], y], D[
                      D[L,  y],  λ]}, {D[D[L,  λ],  x], D[D[L,  λ],  
                      y], D[D[L,  λ],   λ]}}))] /.sol
{(({{0.10949055552194634`, -0.9416187774887387`, -4.379622220877853`}, {0, 8.097921486403152`, -12.554917033183182`}, {-4.379622220877853`, -12.554917033183182`, 0}}))}
The determinants of the bordered principal minors of the Hessian evaluated at the solution point "sol" are,  
N[Det[(({{D[D[l,  x],  x], D[D[L,  x],  λ]}, {D[D[L,  λ],  x], D[
                        D[L,  λ],  λ]}}))]]/.sol
{-19.181090797607066`}
Det[(({{D[D[L,  x],  x], D[D[L,  x], y], D[
                      D[L,  x],  λ]}, {D[D[L,  y],  x], D[D[L,  y], y], D[
                      D[L,  y],  λ]}, {D[D[L,  λ],  x], D[D[L,  λ],  
                      y], D[D[L,  λ],   λ]}}))]/.sol
{-276.13683076016366`}
Since the determinants of the bordered principal minors are both negative, the Hessian is positive definite and the extremum is a minimum point.  To find the cost at the optimum solution, 
cost =  60  x  +  172  y;

        cost /. sol
{cost}
Therefore, the firm produces 800 units of output at a cost of $10959.80, using 136.6 units of labor input and 16 units of capital input. 
To see the solution point graphically, plot the iso-quants and the iso-cost together,
cont1 = ContourPlot[
            60  x + 172  y  - 10943.9,  {x,  0,  200},  {y,  0,  
              30},  Contours -> {0},  ContourShading -> False]

⁃  ContourGraphics  ⁃
cont2  =  
          ContourPlot[x^ .75 y^ .25,  {x,  0,  200},  {y,  0,  30},  
            ContourShading -> False]

⁃  ContourGraphics  ⁃
Show[cont1,  cont2]

⁃  Graphics  ⁃
the optimum solution is the point where the isoquant is tangent to the lowest feasible isocost.

Do More Practice:
1- Change the production function to Q = 10\(TraditionalForm\`x\^ .5\)\(TraditionalForm\`y\^ .5\), keeping other assumptions the same.  Re-run the program and observe changes in the solution.
2- Change the production function to Q = 10\(TraditionalForm\`x\^ .5\)\(TraditionalForm\`y\^ .5\) and the cost constraint to $2000.  Re-run the program and compare the results to those of practice 1 above. 
 
m-Constraint Case:  The Lagrangian multiplier technique may be generalized to cases in which a function is optimized subject to more than one constraint, provided that the constraints are consistent and the number of constraints is less than the number of variables.  (If the number of the constraints is equal to the number of the variables, locating the extremum will become a trivial matter of finding the intersection point of the constraints.)
   For the following n-variable m-constraint problem (m < n), a maximizing problem can be formulated as:
       Maximize:   y = f(x1, ....., xn)
     Subject to:   (g^1) (x1, ....., xn) = c1
                                    ..........
                         (g^i) (x1, ......, xn) = ci
                                  .............. 
                         (g^m)(x1, ....., xn) = cm
where the superscript " i " identifies the constraint i, i =1, ....., m. The Lagrangian function is,                       
     L = f(x1, ......, xn) + λ1(c1 - (g^1)(x1, ......, xn)) +  λ2(c2 - (g^2)(x1, ......, xn)) + ..................  + λm(cm - (g^m)(x1, ......, xn))                                   
and the first order condition is, ∂(L/∂)xj = (Subscript[f, j]) + (∑_(j = 1)^m) λ(Subscript[ig, j]^i) = 0  and ∂(L/∂)λi= ci - (g^i) = 0, where  (Subscript[f, j]) is the partial derivative of  f(x1, ....., xn) with respect to xj and (gj^i) is the partial derivative of (g^i)(x1, ....., xn) with respect to xj.  The first order condition yields n + m equations with n + m unknown variables (n independent variables and m Lagrangian multipliers) that can be solved to find the extremum.

To test whether the extremum is a relative maximum or a relative minimum, the second order condition 
yields the following bordered Hessian determinant, with m borders

  H = (({{f11, f12, ., ., (Subscript[f, 1  n]), -(Subscript[g, 1]^1), -(Subscript[g, 1]^2), ., ., -(Subscript[g, 1]^m)}, {f21, f22, ., ., (Subscript[f, 2  n]), -(Subscript[g, 2]^1), -(Subscript[g, 2]^2), ., ., -(Subscript[g, 2]^m)}, {., ., ., ., ., ., ., ., ., .}, {fn1, fn2, ., ., fnn, -(Subscript[g, n]^1), -(Subscript[g, n]^2), ., ., -(Subscript[g, n]^m)}, {-(Subscript[g, 1]^1), -(Subscript[g, 2]^1), ., ., -(Subscript[g, n]^1), 0, 0, ., ., 0}, {-(Subscript[g, 1]^2), -(Subscript[g, 2]^2), ., ., -(Subscript[g, n]^2), 0, 0, ., ., 0}, {., ., ., ., ., ., ., ., ., .}, {., ., ., ., ., ., ., ., ., .}, {-(Subscript[g, 1]^m), -(Subscript[g, 2]^m), ., ., -(Subscript[g, n]^m), 0, 0, ., ., 0}}))
    
As can be seen, the Hessian can be partitioned into four parts; a plain Hessian corresponding to objective function f, two border matrices corresponding to the constraints, and a null matrix.

For the extremum to be a maximum, the bordered Hessian determinant should be negative definite.  For Det[H] to be 
negative definite, the determinants of the bordered principal minors of H should alternate in sign, beginning with the 
first principal minor having the sign (((-1))^(m + 1)).  For the extremum to be a minimum, the bordered Hessian should be positive definite.  For H to be positive definite, the determinants of the bordered principal minors should all have the sign (((-1))^m).

Economic Interpretation of the Lagrangian Multiplier : The Lagrange multiplier can be thought of as the rate of change of the objective variable with respect to the constraint.  That is, it shows the marginal valuation, or the implicit price of the constraint.  For example,  in a utility maximizing problem subject to the budget constraint the objective variable is U and the constraint is M (Money or budget.)  Therefore,  λ = (dU/dM),  which is the marginal utility of money (marginal valuation of money) or the implicit price of money for the consumer.  

For a utility maximizing problem, the first order conditions  Ux =  λ Px, or (Ux/Px) = λ,  and  Uy =  λ Py, or (Uy/Py) = λ, imply that consumer is in  equilibrium if the marginal utility received from spending one dollar on X or Y is equal to the marginal utility of  that one dollar for the consumer.  If the budget constraint is binding, i.e., if the consumer spends all of her money on X and Y, then  λ is positive ( λ > 0), which implies that money has a positive marginal utility or implicit price for the consumer. In this case, the optimum solution  will be somewhere on the budget constraint. 

If the budget constraint is non-binding, i.e. the consumer's budget is not a factor in her buying decision, then λ = 0, which means that the consumer has so much money that the marginal valuation of money or the implicit price of 
money is zero for the consumer.  In this case, the solution will be the same as the unconstrained maximization. That is, the consumer buys those quantities of X and Y which satiates the consumer.

In general, if a resource is limited and its constraint is binding, that resource will have a positive implicit price, ( λ > 0).  On the contrary, if a resource is abundant and its constraint is non-binding, then the implicit price of the resource will be zero, ( λ = 0).

To prove that (dU/dM) =  λ,  totally differentiate the objective function U = U(x, y) and the constraint M = PxX + Py Y to get  dU = Uxdx + Uydy and dM = Pxdx + Pydy.  Divide both sides of the two equations together to get (dU/(dM )) = ((Uxdx  +  Uydy)/(PxX  +   PyY)).  Substitute for Ux and Uy from the  first order condition,  where Ux =  λPx  and  Uy =  λPy, to get (dU/(dM )) = \(TraditionalForm\`\(\(\ \)\(λPxdx\  + \ λPydy\)\)\/\(Pxdx\  + \ Pydy\)\) =  λ.

Example:
For a constrained cost minimizing problem prove that the Lagrangian multiplier  λ is the marginal cost of production.
Solution:  A cost minimizing problem can be formulated as Minimize C = wL + rK subject to Q(L, K) = (Subscript[Q, o]), where L and K are labor and capital inputs, w and r are wages and rental cost of capital and Q is the output.  Marginal cost is defined as cost of additional unit of output or (dC/dQ).  Totally differentiate the objective function and the constraint to get dC = wdL + rdK and dQ = QLdL + QKdK .  Divide the two equations together and substitute for w and r from the first order condition (w = λQL and r =  λQK),  (dC/dQ) = \(TraditionalForm\`\(λQLdL\  + \ \ λQKdK\)\/\(QLdL\  + \ QKdK\)\) =  λ.  Therefore, λ is the marginal cost of production (dC/dQ) =  λ.   

Problems:
1.   A consumer has a hypothetical  utility  function U = lnxy, where x and y are quantities of two goods sold at market prices of $2 and $3, respectively. Given that consumer has an income of $60:
a) Set up the mathematical programming problem of  maximizing consumer's utility subject to his budget constraint.
b) Find the optimum levels of x and y.
c) Test for the second order condition.
2.   Suppose that  the objective of  the  consumer in problem 1 is to minimize expenditures subject  to a fixed level of utility,  Uo= 150. Given  that  market prices are the same as in problem 1,
       a) 	set up the proper optimizing problem.
       b) 	find the optimum levels of x and y.
       c) 	test the second order conditions.
3.  A consumer has a hypothetical utility function U = ln xy + xy, where x and y are quantities of goods sold at market price of $2 and $1, respectively. Given that consumers has an income of $60:
       a)  Set up the mathematical programming problem of maximizing utility subject to the budget constraint.
       b) 	Find the optimum levels of x and y.
       c) 	Test for the second order condition.
4.  Solve the following problem of minimizing expenditure(E), subject to the given utility levels of  Uo = 25
	Minimize:  E  =  2x + 3y
	Subject to:  U   =  ( \(TraditionalForm\`x\^ .5\) + \(TraditionalForm\`y\^ .5\))\(TraditionalForm\`\^2\)	
5.  A firm operating in an environment of pure competition has the output function Q = f(L, K), where L and K stand for labor and capital, respectively. L and K are purchasable in competitive markets at prices w, r, respectively.
       a)Set up the  problem of minimizing cost  (C) subject to the given level of output Qo.
       b) Find  the necessary and sufficient conditions for the constrained minimizing problem.
       c) Write the expression for the second order condition.
6.  Suppose that the objective of the firm in problem 5 is to maximize output subject to the budget constraint C = Co.
       a)	Set up the  problem of maximizing output subject to given level of cost.
       b) 	Find the necessary  and sufficient conditions for the constrained maximizing problem.
       c) 	Write the expression for the second order condition.
7.   For the utility  maximizing problem:  Maximize U = lnxy, subject to 2x + 3y = 60, 
       a) 	Write an expression presenting the Lagrange multiplier.    
       b) 	What variable does the Lagrangian multiplier represent? 
       c) 	Find the  derivative of the Lagrange multiplier and show that it is negative.  
8.   For the expenditure-minimizing problem:  Minimize C = 2x + 3y subject to Uo = 150,  
       a) 	Write an expression presenting the Lagrange multiplier.   
       b) 	What variable does Lagrange multiplier represent?  What is the sign of the derivative of the Lagrangian 
               Multiplier?
9.   For the cost-minimizing problem:  Minimize C = wL + rK subject to Qo = f(L, K),  
       a) 	What variable in the problem  represents the  marginal cost?  
       b) 	Identify the  expression  for  the  rate  of change of marginal cost with respect to output.  
       c)	What can you infer about the sign of the rate of change of marginal cost?
10.   For the output-maximizing problem:  Maximize Q = f(L, K) subject to wL + rK = Co,
       a) 	What does Lagrangian multiplier represent?
       b) 	Find the derivative of the  Lagrange multiplier. What can you infer about the sign of this derivative?

II.  Parametric Programming  
In the previous section, computational techniques for a constrained optimization problem were introduced. It was assumed that certain parameters, such as market prices and the consumer's budget were fixed. But economic parameters do change, and much of  economic theory deals with the reaction of economic units or economic variables to changes in economic conditions. Using parametric programming techniques, variations of the optimum solutions in response to changing economic conditions can be studied.

The technique is to find  the total differential of the first order conditions not only with respect to the independent variables, but also with respect to those parameters which their change are to be studied.  For example, in the simple two-goods constrained utility maximizing problems of the previous section, the total differential of the first order condition with respect to the independent variables, prices, and the consumer's budget yields:

      Uxxdx + Uxydy - dλPx - λdPx = 0   
      Uyxdx + Uyydy - dλPy - λdPy = 0                     
      dM  - xdPx - dxPx - ydPy - dyPy = 0

Suppose that the price of X is changing, and we would like to find the effect of this price change on demand for X and Y. Assuming that price of Y and the consumer's budget are still  fixed, (dPy = dM = 0), we can write
(({{Uxx, Uxy, -Px}, {Uyx, Uyy, -Py}, {-Px, -Py, 0}}))(({{(dx/dPx)}, {(dy/dPx)}, {d(λ/dPx)}})) = (({{λ}, {0}, {x}})).  Using the Cramer's rule, (dx/dPx) can be derived as,

  (dx/dPx) = ((Det(({{λ, Uxy, -Px}, {0, Uyy, -Py}, {x, -Py, 0}})))/(Det(({{Uxx, Uxy, -Px}, {Uyx, Uyy, -Py}, {-Px, -Py, 0}})))) = ((λDet(({{Uyy, -Py}, {-Py, 0}})))/(Det(({{Uxx, Uxy, -Px}, {Uyx, Uyy, -Py}, {-Px, -Py, 0}})))) + ((x(({{Uxy, -Px}, {Uyy, -Py}})))/(Det(({{Uxx, Uxy, -Px}, {Uyx, Uyy, -Py}, {-Px, -Py, 0}}))))                

This equation is known as the Slutsky equation, and can be  written as, (Subscript[(((dx/dPx))), dM  =  0])=  (Subscript[(((dxc/dPx))), dU  =  0])- x (Subscript[(((dx/dM))), dPx  =  0]).

This equation expresses the full effect of a price change of good X on the slope of the demand  for X, ((dx/dPx)), in terms of the slope of the compensated demand  ((dxc/dPx)), and the income effect of a price change ((dx/dM)).

Economic theory predicts that, in general, the full effect of a price change on demand is negative.  But the full effect is the sum of the two terms.  The first term on the right side of the above equation,  (Subscript[(((dxc/dPx))), dU  =  0]), captures the pure substitution effect, which is always negative, (dxc/dPx) < 0.  It is the slope of the compensated demand curve, when utility and Py are held constant.  The negative definiteness of the bordered Hessian matrix guarantees a positive value for the determinants of the bordered Hessians in the above equations, while the numerator of the (dxc/dPx) is equal to -(Py^2) and is negative.  The second term is - x (Subscript[(((dx/dM))), dPx  =  0])which is the income effect of a price change. The sign of the income effect of price change is the opposite sign of the pure income effect, which is described below.

Suppose that prices are held constant and only income has changed.  From the total differentiation of the first-order condition we can write (({{Uxx, Uxy, -Px}, {Uyx, Uyy, -Py}, {-Px, -Py, 0}}))(({{(dx/dM)}, {(dy/dM)}, {d(λ/dM)}})) = (({{0}, {0}, {-1}})).   Using the Cramer's rule (dx/(dM )) = ((Det(({{0, Uxy, -Px}, {0, Uyy, -Py}, {-1, -Py, 0}})))/(Det(({{Uxx, Uxy, -Px}, {Uyx, Uyy, -Py}, {-Px, -Py, 0}})))).

(dx/(dM )) is called the pure income effect. The sign of the pure income effect depends on whether a good is a normal good or an inferior good. If X is a normal good, an increase in M increases consumption of X, and (dx/(dM )) will be positive. If X is an inferior good, then pure income effect will be negative.  Note that, the denominator of (dx/(dM )) is negative, based on the assumption of the negative definiteness of the bordered Hessian matrix. The numerator, however, is an off-diagonal determinant and there is no way to determine the sign of an off-diagonal matrix from the original matrix.

You may have noticed that there are two differences between the pure income effect and the income effect of price change. First, they have different signs; second, income effect of price change is multiplied by x. Hence, from the pure income effect, we can get information about the sign of the income effect of price change.  

If a good  is a  normal good, income effect of price change is negative, and the sign of the second term in (Subscript[(((dx/dPx))), dM  =  0])=  (Subscript[(((dxc/dPx))), dU  =  0])- x (Subscript[(((dx/dM))), dPx  =  0]) will be negative, resulting in negative slope for demand for X.  If a good is an inferior good, the income effect of price change is positive, and the sign of (dx/dPx) will depend on the magnitude of the substitution effect and income effect of price change. If the substitution effect outweighs the income effect of price change, then (dx/dPx) < 0 and demand for X will be a standard downward-sloping demand curve. If income effect of price change outweighs the substitution effect, then demand for X will have a positive slope. A good with a positively-sloped demand curve is called Giffen good.  Note that, for a good to be a Giffen good it should be an inferior good and the income effect of the price change should be so strong that it more than offsets the substitution effect.

Example: Consumer Theory
A consumer's utility function for X and Y is given as U(x, y) = \(TraditionalForm\`\((x\^5\  + \ \ y\^ .5)\)\^2\).  The consumer is spending $60.00 on the two goods which are sold at market prices of Px = $3.00 and Py = $1.00.  
a- Find the utility maximizing quantities of X and Y and test for the second order condition.
b- Find the total effect, substitution effect and the income effect of price change if Px changes from $3.00 to $3.50.
Solution:  The utility maximizing problem can be formulated as: 
Maximize:    U =  \(TraditionalForm\`\((x\^5\  + \ \ y\^ .5)\)\^2\) 
subject to:     3x + y = 60  
The lagrangian function is L(x, y, λ) = \(TraditionalForm\`\((x\^ .5 + \ y\^ .5)\)\^2\) + λ(60 - 3x - y) and the first order condition can be derived as:
  ∂(L/∂)x = (Subscript[L, x]) = (x^(- .5))\(TraditionalForm\`\((x\^5\  + \ \ y\^ .5)\)\) - 3λ = 0,	or    (x^(- .5))\(TraditionalForm\`\((x\^5\  + \ \ y\^ .5)\)\) = 3λ 	
 ∂(L/∂)y = (Subscript[L, y]) = (y^(- .5))\(TraditionalForm\`\((x\^5\  + \ \ y\^ .5)\)\) - λ = 0, 		or    (y^(- .5))\(TraditionalForm\`\((x\^5\  + \ \ y\^ .5)\)\) = λ
 ∂(L/∂)λ = (Subscript[L, λ]) = 60 - 3x -y = 0           
Divide the first two equations of the first-order conditions to delete λ.  This gives ((y^0.5)/(x^0.5)) = 3, or y = 9x.  Substitute for y in the third equation and use other equations to find x = 5, y = 45, and λ = 1.33.  This point is the extremum that has to be tested for maximum or minimum.  
To test for second-order condition, form the bordered Hessian matrix, H = (({{(Subscript[L, xx]), (Subscript[L, xy]), (Subscript[L, x])λ}, {(Subscript[L, yx]), (Subscript[L, yy]), (Subscript[L, y])λ}, {(Subscript[L, λ])x, (Subscript[L, λ])y, (Subscript[L, λ])λ}})) = (({{\(\( .5\ y\^ .5\)\/x\^1.5`\), \( .5\/\(x\^ .5\ y\^ .5\)\), -3}, {\( .5\/\(x\^ .5\ y\^ .5\)\), \(\(\(- .5\)\ x\^ .5\)\/y\^1.5`\), -1}, {-3, -1, 0}})).  Evaluated at the extremum, the bordered Hessian is H = (({{- .3, .033, -3}, {.033, - .0037, -1}, {-3, -1, 0}})).  The determinants of the bordered principal minors of H are Det(({{- .3, -3}, {-3, 0}})) = -9 and Det(({{- .3, .033, -3}, {.033, - .0037, -1}, {-3, -1, 0}}))= .53, respectively.  Since the determinants of the bordered principal minors alternate in sign beginning with a negative, the Hessian is negative definite and the solution is a maximum.  
To find the total effect of the change in Px find (dx/dPx) through the Slutsky equation above.  Note that, the denominators of the terms in the Slutsky equation are the determinant of the Hessian which is 0.533.  Therefore, the total effect can be calculated as (Subscript[(((dx/dPx))), dM = 0]) = (1/(Det[H]))Det(({{λ, (Subscript[L, xy]), -3}, {0, (Subscript[L, yy]), -1}, {x, -1, 0}})) =\(1\/ .533\)Det(({{1.33, .033, -3 }, {0, - .0037, -1}, {5, -1, 0}}))= -2.92.  Using the Slutsky equation, the substitution effect or the slope of the compensated demand can be calculated as (Subscript[(((dx/dPx))), dU = 0])= \(TraditionalForm\`1\/ .533\)λDet(({{(Subscript[L, yy]), -1}, {-1, 0}})) = \(TraditionalForm\`1.33\/ .533\)Det(({{- .007, -1}, {-1, 0}})) = -2.50.  Finally, using the Slutsky equation, the income effect of price change can be calculated as -x(Subscript[(((dx/dM))), dPx = 0])= \(TraditionalForm\`1\/ .533\)xDet(({{(Subscript[L, xx]), -3}, {(Subscript[L, yy]), -1}})) = \(TraditionalForm\`5\/ .533\)Det(({{.033, -3}, {- .0037, -1}})) = -.42
The final results can be summarized as,  (Subscript[(((dx/dPx))), dM  =  0])=  -2.91,  (Subscript[(((dxc/dPx))), dU  =  0])= -2.49,   and - x (Subscript[(((dx/dM))), dPx  =  0]) = -.42.  Since dPx = 3.50 - 3.00 = .50, the total effect of an increase in Px on quantity demanded of X is a decrease in quantity by dx = .50(-2.91) = -1.45 units.  From this quantity, -1.24 units is a reduction due to substitution effect, and -.21 units is due to income effect of price increase.
To solve the problem using Mathematica, formulate the Lagrangian as follows and find the solution to first-order conditions,
Clear[L,  U,  x,  y,  λ,  sol]
L = (x^ .5 + y^ .5)^2  +  λ (60 - 3  x - 
                    y);sol  =  
            Solve[{D[L,  x] == 0,  D[L,  y] == 0,  
                D[L,  λ] == 0}]
{{x -> 5.`, 
          y -> 45.`, λ -> 1.3333333333333333`}}
The first-order condition yields the solution x = 5, y = 45, and λ = 1.33.  To test for second-order condition, form the Hessian and find the determinants of the bordered Hessian
MatrixForm[(({{D[D[L,  x],  x], D[D[L,  x],  y], D[D[L,  x], λ]  }, {D[D[L,  y],  x], D[D[L, y],  y], D[D[L,  y], λ]}, {D[D[L, λ], x], D[D[L,  λ], y], D[D[L,  λ],  λ]}}))]/.sol
{(({{-0.30000000000000004`, 0.03333333333333333`, -3}, {0.03333333333333333`, -0.003703703703703704`, -1}, {-3, -1, 0}}))}
The determinant of the principal minors are,
Det[(({{D[D[L,  x],  x], D[D[L,  x], λ]}, {D[D[L, λ], x], D[D[L,  λ], λ]  }}))]/.sol
{-9}
Det[(({{D[D[L,  x],  x], D[D[L,  x],  y], D[D[L,  x], λ]  }, {D[D[L,  y],  x], D[D[L, y],  y], D[D[L,  y], λ]}, {D[D[L, λ], x], D[D[L,  λ], y], D[D[L,  λ],  λ]}}))]/.sol
{0.5333333333333333`}
Since the determinants of the bordered principal minors alternate in sign beginning with a negative, the Hessian is negative definite and the solution is a maximum.  
To find the total effect of the change in Px, find the (dx/dPx) through the Slutsky equation formulate the terms of the equations to Mathematica commands.  Note that, the denominators of the terms in the Slutsky equation are the determinant of the Hessian which is 0.533.  Therefore, the total effect can be calculated as,
(1/ .533)Det[(({{λ, D[D[L,  x],  y], -3  }, {0, D[D[L, y],  y], -1}, {x, -1, 0}}))]/.sol
{-2.918490723368772` Null}
using the Slutsky equation, the substitution effect or the slope of the compensated demand can be calculated as, 
(1/ .533)λ Det[(({{D[D[L, y],  y], -1}, {-1, 0}}))]/.sol
{-2.501563477173233`}
finally, using the Slutsky equation, the income effect of price change can be calculated as, 
(1/ .533)x Det[(({{D[D[L,  x],  y], -3}, {D[D[L, y],  y], -1}}))]/.sol
{-0.4169272461955389`}

The final results can be summarized as,  (Subscript[(((dx/dPx))), dM  =  0])=  -2.91,  (Subscript[(((dxc/dPx))), dU  =  0])= -2.49,   and - x (Subscript[(((dx/dM))), dPx  =  0]) = -.42.  Since dPx = 3.50 - 3.00 = .50, the total effect of an increase in Px on quantity demanded of X is a decrease in quantity by dx = .50(-2.91) = -1.45 units.  From this quantity, -1.24 units is a reduction due to substitution effect, and -.21 units is due to income effect of price increase.
Finally, the graphic capabilities of Mathematica allow us to see the solution visually.  To graph the utility function and the budget constraint in 3D, use the following commands:
Clear[x, y, U, p1, p2, con1, con2, con3]
U=(x^ .5 + y^ .5)^2;
p1 = 
          Plot3D[U, {x, 0, 10}, {y, 0, 50}, 
            AxesLabel -> {"X", "Y", "U"}]
p2 = 
          Plot3D[y + 3  x - 60, {x, 0, 10}, {y, 0, 50}, 
            AxesLabel -> {"X", "Y", "U"}]
Show[p1, p2]

⁃  SurfaceGraphics  ⁃

⁃  SurfaceGraphics  ⁃

⁃  Graphics3D  ⁃
To graph the indifference curves and the budget constraints use the following commands:
con1 = 
          ContourPlot[U, {x, 0, 10}, {y, 0, 80}, 
            ContourShading -> False]
con2=ContourPlot[3  x + y - 60,{x, 0, 10},{y, 0, 80},Contours -> {0},ContourShading -> False]
con3=ContourPlot[5  x + y - 60,{x, 0, 10},{y, 0, 80},Contours -> {0},ContourShading -> False]
Show[con1, con2, con3]


⁃  ContourGraphics  ⁃

⁃  ContourGraphics  ⁃

⁃  ContourGraphics  ⁃

⁃  Graphics  ⁃

Do More Practice:
1- Double the prices and the budget constraint.   Re-run the program and observe the changes in solution.
2-  Find the total effect, substitution effect and the income effect of price change if Px changes from $3.00 to $2.50 (keep all the other assumptions the same as in the text.).  Re-run the program and observe the changes in solution.  Is the effect of a 50 cents decrease in price of x symmetric to the effect of a 50cents increase in price of x? 

Problems
1.   For the utility  maximizing problem 1 of section I, 
       a) 	Derive the demand function for X. Analyze the sign of the slope of the demand curve.
       b)	If the  market price of X and Y are given as Px and Py respectively, find the elasticity of substitution of X for       
              Y.   (Hint: Elasticity of substitution of X for Y is defined as the ratio of percent change in (x/y) to percent      
               change in (Px/Py).    
2.  For the expenditure minimizing problem 2 of section I, 
       a) 	Derive the demand function for X. Analyze the sign of the slope of the demand curve. 
       b) 	What differences are there between the slopes of the demand curves in problems 1 and 2?

III. Constrained Optimization When Some Constraints Are Inequalities   
The more general problem of finding a maximum or minimum subject to equality and inequality constraints is called mathematical programming.  A general mathematical programming problem is one of finding (Subscript[x, 1]),........, (Subscript[x, n]) so as to

     Maximize:   f((Subscript[x, 1]), ......., (Subscript[x, n]))         
     Subject to : (g^i)((Subscript[x, 1]), ......, (Subscript[x, n])) < (Subscript[b, i])    for i = 1, .....,   r
                        (g^i)((Subscript[x, 1]), ......, (Subscript[x, n])) > (Subscript[b, i])    for i = r+1, ...,  s
                        (g^i)((Subscript[x, 1]), ......, (Subscript[x, n])) = (Subscript[b, i])    for i = s+1, ..., m
                               (Subscript[x, 1]), ......, (Subscript[x, n]) > 0

In 1951, Kuhn and Tucker developed a set of necessary and sufficient conditions for an optimal solution to the general programming problem.  The technique is to transform inequality constraints to equality, by adding slack or surplus variables, and using the Lagrangian multiplier technique of the previous section.     

A slack variable is a positive variable that can be added to an inequality constraint of "less than" form (<) to set it to equality.  A surplus variable is a positive variable that can be subtracted from an inequality constraint of "greater than" form (>) to set it to equality.    

In general, the solution to the mathematical programming problem can be summarized as:  If  f((Subscript[x, 1]), ...., (Subscript[x, n])) is a concave function and (g^i)((Subscript[x, 1]), ......, (Subscript[x, n])){< = >}(Subscript[b, i]), i = 1, .... , m, forms a convex set, the necessary and sufficient conditions for an extremum to the mathematical programming problem are as follows: (for a review of convex and concave functions, see appendix at the end of this chapter.)                          
I -   (Subscript[f, j])(.)   -  (∑_(i = 1)^m)(Subscript[λ, i])(g^i)(Subscript[x, j])(.)   > 0      i = 1, ..., m    j = 1, ..., n               
II-   (∑_(j = 1)^n) (Subscript[x, j])((Subscript[f, j])(.)   - (∑_(i = 1)^m)(Subscript[λ, i])(g^i)(Subscript[x, j])(.) ) = 0   
       (Subscript[b, i]) - (g^i)(.)  > 0    i = 1, ....., r
III-   (Subscript[b, i]) - (g^i)(.)   < 0    i = r + 1 ,...., s
         (Subscript[b, i]) - (g^i)(.)   = 0    i = s + 1, ...., m
IV-   (∑_(i = 1)^m)(Subscript[λ, i])(  (Subscript[b, i]) - (g^i)(.)  ) = 0
Where f(.) and g(.) are  f  and  g  functions, evaluated at the extremum. The point P((Subscript[x, 1])*, ...., (Subscript[x, n])*,  (Subscript[λ, 1])*, ...., (Subscript[λ, m])*) that satisfies the conditions I-IV guarantees a relative maximum for the mathematical programming problem as stated above.  

The necessary and sufficient conditions for a point to be an extremum also are necessary and sufficient conditions for the Lagrangian function L = f((Subscript[x, 1]), ......., (Subscript[x, n]))  +   (∑_(i = 1)^m)(Subscript[λ, i])((Subscript[b, i])  -  (g^i)((Subscript[x, 1]), ......, (Subscript[x, n]))) to have a saddle point at that point, provided that the concavity condition of the objective function and the convexity of the constraint set are satisfied.  A saddle point is a point is a point that L((Subscript[x, 1]), ......, (Subscript[x, n]), (Subscript[λ, 1]), ....., (Subscript[λ, m])) is a maximum with respect to ((Subscript[x, 1])*, ...., (Subscript[x, n])*) and is a minimum with respect to ((Subscript[λ, 1])*, ..., (Subscript[λ, m])*).

No attempt is made to prove the Kuhn-Tucker theorem here. Instead, using the interpretation of the Lagrangian Multiplier described in the previous section of this chapter and an economic example an attempt is made to facilitate the understanding of the theorem and economic interpretation of the Kuhn-Tucker conditions.   

Example: Consumer Theory
A consumer has a conventional twice differentiable utility function, U = U(x, y, z), where X and Y are purchased in the market at fixed prices and subject to the budget constraint.  Z, on the other hand, is the services of a durable consumer good, which is assumed to be fixed over the decision period.   Set up the proper mathematical programming problem and derive the necessary and sufficient conditions.

     Maximize:  U = U(x, y, z)
     Subject to:  xPx + yPy  < M
                        z < (Subscript[z, o])

The first step is to form the Lagrangian function and to find the first order conditions. The Lagrangian function is 

L(x, y, z, λ1, λ2) = U(x, y, z) + (Subscript[λ, 1])(M - xPx - yPy) + (Subscript[λ, 2])((Subscript[z, o]) - z) 

The first order condition is 

     ∂(L/∂)x  =  Ux - (Subscript[λ, 1])Px > 0,    	or    (Ux/Px) > (Subscript[λ, 1])      	
     ∂(L/∂)y  =  Uy - (Subscript[λ, 1])Py > 0,    	or    (Ux/Py) > (Subscript[λ, 1])
     ∂(L/∂)z  =  Uz - (Subscript[λ, 2])   > 0,    	or   Uz > (Subscript[λ, 2])    
     ∂(L/∂)λ1 =  M - xPx - yPy > 0                        
     ∂(L/∂)λ2  =  (Subscript[z, o])  - z > 0                              		

The first three equations above are maximizing L with respect to x, y, and z.  The last two equations above are minimizing L with respect to (Subscript[λ, 1]) and (Subscript[λ, 2]). Using the economic interpretation of the Lagrangian multiplier, described in the previous section, the Kuhn-Tucker condition can be interpreted as follows:

1- The first equation, which corresponds to condition I, states that, to maximize utility subject to the constraints, the consumer buys x as long as the marginal utility received from spending one dollar on x is greater or equal to the marginal valuation of that one dollar.  However, if (Ux/Px) < (Subscript[λ, 1]), then x = 0. The same is true for y in the second equation.

2- Condition II follows from condition I.  For this example it can be written as x(Ux - (Subscript[λ, 1])Px) + y(Uy - (Subscript[λ, 1])Py) + z(Uz - (Subscript[λ, 2])) = 0.  The three terms in this equation follow expressions in the first-order condition.  Either Ux - (Subscript[λ, 1])Px  = 0, that is, the consumer is buying positive amounts of x (x > 0), or Ux - λ1 Px < 0, where x = 0. The same is true for y and z in the second and third terms.

3- Condition III follows the inequality constraints in the optimizing problem, which should be satisfied.

4- Condition IV, which in this example can be written as (Subscript[λ, 1])(M - xPx - yPy) + (Subscript[λ, 2])((Subscript[z, o]) - z) = 0 states that, if the budget constraint is binding, i.e., if xPx + yPy = M, then marginal valuation of money is positive, (Subscript[λ, 1]) > 0.  If the budget constraint is not binding, xPx + yPy < M, then (Subscript[λ, 1]) = 0. The same  is true for the constraint on the services of durable good z.  Either the consumer uses all the services of durable good, (z = (Subscript[z, o])),  In which case, the implicit price of z will be positive, (Subscript[λ, 2]) > 0; or the consumer is not using all the services of z, (z < (Subscript[z, o])), and the  implicit price of z will be zero, (Subscript[λ, 2]) = 0.

If all these conditions are satisfied, then the first order condition will guarantee a global maximum.  If the sufficiency conditions of the Kuhn-Tucker theorem are not satisfied, it may be necessary to evaluate all the feasible solutions.  In this case, the computational effort may be enormous.

Example: Consumer Theory
A consumer has the utility function, U = U(x, y, z) = lnxyz, where X and Y are purchased at the market prices of $2 and $3 respectively, and are subject to a $120 budget constraint.  Z, on the other hand, is the services of a durable good, which consumer needs at least 8 units of it over the decision period.  Set up the proper mathematical programming  problem and derive the  necessary and sufficient conditions.

Solution:  The problem can be formulated as,
 Maximize:  U = lnxyz
 Subject to:  2x + 3y  < 120
                        z <  8
The Lagrangian function is L(x, y, z, (Subscript[λ, 1]), (Subscript[λ, 2])) = lnxyz + (Subscript[λ, 1])(120 - 2x - 3y) + (Subscript[λ, 2])(8 - z).  The first-order conditions are:

∂(L/∂)x = (1/x) - 2(Subscript[λ, 1]) = 0, 		or  (1/x) = 2(Subscript[λ, 1])
∂(L/∂)y = (1/y) -3(Subscript[λ, 1]) = 0, 		or   (1/y) = 3(Subscript[λ, 1])
∂(L/∂)z = (1/z) - (Subscript[λ, 2]) = 0, 		or   (1/z) = (Subscript[λ, 2])
∂(L/∂)λ1= 120 - 2x - 3y = 0
∂(L/∂)λ2= 8 - z = 0

Use the first two equations of the first-order conditions to delete (Subscript[λ, 1]).  This yields y =((2  x)/3).  Substitute y in the fourth equation to find x = 30 and y = 20.  Using the first equation, (Subscript[λ, 1])is found to be (Subscript[λ, 1]) = (1/60).  The third and fifth equations of the first-order conditions give z = 8 and (Subscript[λ, 2]) = (1/8).  

To test for the Kuhn-Tucker conditions, follow the requirements as follows:
Condition I is satisfied through the first order condition, which results in solution set (x = 30, y = 20, z = 8, (Subscript[λ, 1])= (1/60), (Subscript[λ, 2])= (1/8)).
Condition II can be tested for by evaluating x(Ux - 2(Subscript[λ, 1])) + y(Uy - 3(Subscript[λ, 1])) + z(Uz - (Subscript[λ, 2])) at the solution set (x = 30, y = 20, z = 8, (Subscript[λ, 1])= (1/60), (Subscript[λ, 2])= (1/8)).  Here, Ux = (1/x), Uy = (1/y), and Uz =(1/z) are marginal utilities of x, y, and z, respectively.  Evaluated at the solution set, x(Ux - 2(Subscript[λ, 1])) + y(Uy - 3(Subscript[λ, 1])) + z(Uz - (Subscript[λ, 2])) = 0 and satisfies the condition II.
Condition III follows the inequality constraints, which is satisfied in this problem.  
Condition IV can be tested for by evaluating the numerical value of (Subscript[λ, 1])(120 - 2x - 3y) + (Subscript[λ, 2])(8 - z) at the solution set.  Evaluated at the solution set (Subscript[λ, 1])(120 - 2x - 3y) + (Subscript[λ, 2])(8 - z) = 0 and the condition IV. 

To solve the problem using Mathematica, formulate Lagrangian function and proceed with the steps as follows,
Clear[L,  U,  x,  y,  z,  λ1,  λ2,  
          sol]
U  =  Log[x y z]; 
        L  =  Log[
              x y z]  +  λ1 (120  -  2  x  -  
                  3  y)  +  λ2 (8  -  z); 
        sol = Solve[{D[L,  x] == 0,  D[L,  y] == 0,  D[L,  z] == 0,  
              D[L,  λ1] == 0,  D[L,  λ2] == 0},  {x,  
              y,  z,  λ1,  λ2}]
{{λ2 -> (1/8), λ1 -> (1/60), x -> 30, 
          y -> 20, z -> 8}}

Condition I is satisfied through the first order condition, which is the solution above.  Condition II can be tested for through the following command. 
N[
            x (D[U,  x]  -  2  λ1 )  +  
              y (D[U,  y]  -  3  λ1 )  +  
              z (D[U,  z]  -  λ2)] /. sol
{0.`}

Condition III follows the inequality constraints, which is satisfied in this problem.  Condition IV can be test for as follows,
N[λ1 (120  -  2  x  - 
                    3  y)  +  λ2 (8  -  z)] /. sol
{0.`}

Do More Practice:
1- Change the utility function to U = (x^((1/3)))(y^((1/3)))(z^((1/3))).  Keep the other assumptions the same.  Re-run the program and compare the results.
2- Change the utility function to U = lnx + lny + lnz.  Keep the other assumptions the same.  Re-run the program and compare the results.

Problems:
1.    Solve the  following constrained maximizing problem and test for the Kuhn-Tucker conditions.
	Maximize: f(x, y) = x + y
        	Subject to: (x^2) + (y^2) < 4
              	     x > 0, y > 0   
2.   A single product firm with two processes, v and w, employs two fixed inputs, labor and capital.  In the short run, the firm is constrained to employing services of labor and capital of 150 and 850 units each, respectively. The technological relationship between output and the processes given as Q = (\(TraditionalForm\`v\^ .5\)+ \(TraditionalForm\`w\^ .5\))\(TraditionalForm\`\^2\).   Process v employs two units of labor and one unit of capital. Process w employs one unit of  labor and four units of capital.
       	a) Set up the mathematical programming problem of maximizing output subject to the constraints.
	b) Find the optimum levels of v and w.
       	c) Test for the Kuhn-Tucker conditions.
       	d) What economic variables do Lagrangian multipliers represent? 
       	
First Order Conditions and Derivation of Special Functions:  Once the optimum solution to a  mathematical programming problem is derived, the first order condition will yield itself to parametric programming, as described in the previous section.  At the optimum point, all the inequality relationships are dropped, and all the equations are held to derive the unknown variables.  This follows the conditions II and IV of the Kuhn-Tucker theorem that any constraint satisfied with inequality will have a zero Lagrange multiplier or implicit price.  Therefore, the system of equations in the first order conditions can be used to study behavior of variables, when other variables or parameters are changing. The procedure, however, is the same as described in the previous section.

First order conditions can also be used to derive certain functional relationships between variables.  For example, first order conditions of a utility maximization problem can be used to prove the existence of demand and to derive demand functions.  

To prove the existence of demand functions, and to derive them, we need to employ the Implicit Function Theorem.  The Implicit Function theorem states that a subset of variables can be expressed as explicit functions of the remaining variables, provided that the Jacobian determinant with respect to that subset of variables does not vanish.

The first step is to write the first order conditions as implicit functions, including all the variables and parameters.  For the utility maximizing example above, the first  order condition gives the following implicit functions:
     (F^1)(x, y, z, Px, Py, (Subscript[λ, 1]), (Subscript[λ, 2]), M, (Subscript[z, o])) = 0    
                  ...................              	
                  ...................
     (F^5)(x, y, z, Px, Py, (Subscript[λ, 1]), (Subscript[λ, 2]), M, (Subscript[z, o])) = 0   
The requirement for application of the Implicit Function Theorem is that all the functions have continuous first partial derivatives in the neighborhood of the optimal point. The total differential of the first order condition with respect to all variables can be summarized in Jacobian
                                        
J = ((d(F1  ...  .  F5))/(d(x,  y,  
              z,  px,  py,  λ1,  λ2,  M,  
              zo))) =  (({{Uxx, Uxy, Uxz, -Px, 0, -(Subscript[λ, 1]), 0, 0, 0}, {Uyx, Uyy, Uyz, -Py, 0, 0, -(Subscript[λ, 1]), 0, 0}, {Uzx, Uzy, Uzz, 0, -1, 0, 0, 0, 0}, {-Px, -Py, 0, 0, 0, -x, -y, 1, 0}, {0, 0, -1, 0, 0, 0, 0, 0, 1}}))
                              
If all the entries in the matrix are continuous, demand for x, y, and z can be expressed as explicit functions of prices, income, and (Subscript[z, o]).  That is, demand for x is x = X(Px, Py, M, (Subscript[z, o])), demand for y is y = Y(Px, Py, M, (Subscript[z, o])), and demand for z is z = Z(Px, Py, M, (Subscript[z, o])). 

Problems
1.  For the cost-minimizing problem of 3 of this chapter, give a precise, detailed derivation of total cost as a function of output.
2.   For the output-maximizing problem 4 of this chapter, 
       	a) Give a precise, detailed derivation  of  the  output function.
	b) What does the Lagrangian multiplier represent?
       	c) Write the first order condition as an implicit function. What special economic functions 
       	can be 	derived from the first order condition?
       	d) Give a precise, detailed derivation of the  total cost and output functions.
3.   In general, the consumer's behavior in the theory of consumption can be formulated either as:
         	Maximize:  U = U(x1, ...., xn)
       	Subject to :  p1x1 + .... + pnxn < M
              Or as:
         	Minimize:  E = p1x1 + .... + pnxn
       	Subject to:  U(x1, ...., Un) > Uo
       	Where x1, ...., xn are n commodities purchasable at market prices p1, ....., pn, U is utility,
       	and E stands for expenditure.  For a hypothetical two-commodity  model:
       	a)Find the necessary and sufficient conditions for the existence of an extremum in each case.
       	b) What do the Lagrangian multipliers  represent  in each case?
       	c) Write the first order conditions in implicit function form. Derive the demand for x in each case.  Analyze 
       	     the slope of the demand curve.
       	d) What differences are there between the two demand curves?       
4.    In general, the behavior of producers in the theory of the firm can be formulated as:
         	Maximize: Q = f(x1, ...., xn)
       	Subject to: c1x1 + ....+ cnxn < Co
       	Or as:
         	Minimize: C = c1x1 + .... + cnxn
       	Subject to: f(x1, ...., xn) > Qo
        	Where x1, ...., xn are n inputs bought in the market at prices c1, ......, cn, C stands 
        	for total cost, and Q is output. For a hypothetical case of a two-input firm:
       	a) Find the necessary  and sufficient conditions for the existence of an extremum in each case.
       	b) What do Lagrangian multipliers represent in each case? What can you say about the sign of
       	the first derivative of Lagrangian multipliers? 
       	c) Write the first order conditions in implicit function form. What special economic 
       	functions can be derived from the first order conditions in each case? Give a precise, 
       	detailed derivation of total cost and  output functions.

Appendix:   Concavity and Convexity of Functions
A function f(x) is said to be convex over the interval ((Subscript[x, 1]), (Subscript[x, 2])) if for the two points (Subscript[x, 1]) and (Subscript[x, 2]) and for all, 0 < α < 1, 
     f[α(Subscript[x, 2]) + (1- α)(Subscript[x, 1])] < [αf((Subscript[x, 2])) + (1- α)f((Subscript[x, 1]))]    
A function f(x) is said to be concave if -f(x) is convex.   A function f(x) is said to be strictly convex if  the equation above is a strict inequality.

Graphically, a function f(x) is convex if a line segment joining any two points [(Subscript[x, 1]), f((Subscript[x, 1]))], [(Subscript[x, 2]), f((Subscript[x, 2]))] of f(x) lies on or above the surface of f(x) (see the graph below.)

                                         

                          	                                   Convex Function
An easier way to show that a function is convex is to use the second order derivative of the function, if the function is twice differentiable. A univariate continuous function f(x) is convex in the neighborhood of (Subscript[x, o])if and only if f "((Subscript[x, o])) > 0.  A multivariable continuous function f((Subscript[x, 1]),......(Subscript[x, n])) is convex if and only if the Hessian determinant of  f  is positive definite.  

Example:   Prove that y = f(x) = 2(x^2) + x + 3 is a convex function.
Solution:  f '(x) = 4x + 1 and f "(x) = 4.  Since f "(x) > 0, the function is convex over the entire real number.  The graph of the function is shown below.



Example: Discuss the concavity or convexity of y = f(x) = (x^3) - 3(x^2) + x + 5.
Solution:  f '(x) = 3(x^2)-6x + 1 and f "(x) = 6x - 6.  f "(x) = -6 + 6x  is positive for all the values of x > 1 and is negative for all the values of x < 1.  Therefore, f(x) will be convex for x > 1 and concave for x < 1.  The graph of the function is shown below.



Example:  Discuss the convexity or concavity of the z = f(x, y) = 2  (x^2) + (y^2).
Solution:  The partial derivative of z with respect to x and y are ∂(z/∂)x= 4x and ∂(z/∂)y= 2y, respectively.  The second derivatives results in the quadratic form the Hessian matrix of which is H = (({{4, 0}, {0, 2}})).  Since the determinants of the principal minors of H are all positive, H is positive definite and f(x, y) is convex over the entire Euclidean E2 space.  The graph of the function is presented below.



To solve this problem using Mathematica, use the following commands.
Clear[x,  y,  z]
z  =  2  x^2  +  y^2;
H =MatrixForm[(({{D[D[z,  x],  x], D[D[z,  x],  y]}, {D[D[z,  y],  x], D[D[z,  y],  y]}}))]
Det[%]
(({{4, 0}, {0, 2}}))
8
To graph the function use the following command.
Plot3D[
          2  x^2  +  y^2,  {x,  -5,  5},  {y,  -5,  5},  
          AxesLabel -> {"X",  "Y",  "Z"}]

⁃  SurfaceGraphics  ⁃

Do More practice:
1- Change the z function to z = f(x, y) = -2  (x^2) - (y^(2  ))by changing the sign of the coefficients.  Re-run the program and analyze the results. 
2- Change the z function to z = f(x, y) = 2  (x^2) - (y^(2 )) by changing the sign of the coefficients.  Re-run the program and analyze the results.