Exercise 5.8: Solve the following diet problem:
                |  X1  X2  |  Min. Req.
        --------+----------+------------
          E1    |  10   4  |    40
          E2    |   7   7  |    49
          E3    |   5  10  |    50
        --------+----------+------------
	  Price |   5   7  |
We could have used the tableau method like in the last exercise, but we will show the alternative graphical method. The plot is made with MATLAB.
>> e1 = [-10/4 10]

e1 =

   -2.5000   10.0000

>> e2 = [-1 7]

e2 =

    -1     7

>> e3 = [-1/2 5]

e3 =

   -0.5000    5.0000

>> r = -0.1:0.1:4.2;   % plot range
>> y1 = polyval(e1,r);
>> y2 = polyval(e2,r);
>> y3 = polyval(e3,r);
>> figure
>> hold on
>> plot(r,y1,'b');
>> plot(r,y2,'r');
>> plot(r,y3,'g');
>> p6 = [-5/7 6];
>> yp6 = polyval(p6,r);
>> plot(r,yp6,'black');
>> p5 = [-5/7 5];
>> yp5 = polyval(p5,r);
>> plot(r,yp5,'black');
% Notice that the intersection of the first and third constraint
% will not satisfy the second constraint.  From the slope of the
% objective function, we can see that the optimal value occurs
% at the intersection of the second and third constraint:
>> a = [7 7; 5 10]

a =

     7     7
     5    10

>> b = [49; 50]

b =

    49
    50

>> x = a\b

x =

     4
     3

>> % computing the value of the objective function:
>> 5*x(1) + 7*x(2)

ans =

    41
Here is the plot: