You are on page 1of 18

EGR 599

Advanced Engineering Math II

_____________________
LAST NAME, FIRST

Problem set #4
1. (P. 15.1 Chapra1) A company makes two types of products, A and B. These products are
produced during a 40-hour work week and then shipped out at the end of the week. They require
20 and 5 kg of raw material per kg of product, respectively, and the company has access to
10,000 kg of raw material per week. Only one product can be created at a time with a production
times for each of 0.05 and 0.15 hrs, respectively. The plant can only store 550 kg of total product
per week. Finally, the company makes profits of $45 and $30 on each unit of A and B,
respectively.
(a) Set up the linear programming problem to maximize profit.
(b) Solve the linear programming problem graphically.
(c) Solve the linear programming problem with the simplex method.
(d) Solve the linear programming problem with Matlab.
Solution
(a) Set up the linear programming problem to maximize profit.
Define xa = amount of product A produced, and xb = amount of product B produced. The
objective function is to maximize profit,
P = 45x a + 30 x b

Subject to the following constraints


20 x a + 5x b 10000
0.05x a + 015
. x b 40

x a + x b 550
x a , xb 0

{raw materials}
{production time}

{storage}
{positivity}

(b) To solve graphically, the constraints can be reformulated as the following straight lines
x b = 2000 4 x a
x b = 266.667 0.3333x a
x b = 550 x a

{raw materials}
{production time}
{storage}

The objective function can be reformulated as


1

Chapra and Canale, Numerical Methods for Engineers , Mc-Graw Hill, 4 th Edition, 2002

x b = (1 / 30) P 15
. xa

The constraint lines can be plotted on the xb-xa plane to define the feasible space. Then the
objective function line can be superimposed for various values of P until it reaches the
boundary. The result is P 23700 with xa 483 and xb 67. Notice also that material and
storage are the binding constraints and that there is some slack in the time constraint.

al
materi

0
237
P=
ge
ra

00
150

tim
e

P=

300

o
st

xb

200
optimum

P=
0
500

100

xa

0
0

200

400

600

(c) The simplex tableau for the problem can be set up and solved as
P
1
0
0
0

xa
-45
20
0.05
1

xb
-30
5
0.15
1

S1
0
1
0
0

S2
0
0
1
0

S3
0
0
0
1

Solution
0
10000
40
550

Intercept

material
time
storage

Basis
P
S1
S2
S3

P
1
0
0
0

xa
0
1
0
0

xb
-18.75
0.25
0.1375
0.75

S1
2.25
0.05
-0
-0.05

S2
0
0
1
0

S3
0
0
0
1

Solution
22500
500
15
50

Intercept

xa
time
storage

Basis
P
xa
S2
S3

P
1
0
0
0

xa
0
1
0
0

xb
0
0
0
1

S1
1
0.067
0.007
-0.07

S2
S3
0
25
0 -0.333
1 -0.183
0 1.333

Solution
23750
483.33333
5.8333333
66.666667

Intercept

xa
time
xb

Basis
P
xa
S2
xb

(d) Solve the linear programming problem with Matlab.


The problem is reformulated using slack variable S1, S2, and S3
Minimize y = 45xa 30xb
Subject to

500
800
550

2000
109.0909
66.66667

20xa + 5xb + S1 = 10000


0.05xa + 0.15xb + S2 = 40
xa + xb + S3 = 550
xa, xb, S1, S2, and S3 0
The arguments for the Matlab command X=LINPROG(f, A, b, Aeq, beq, LB, UB) are given as
45
30

0
, A = 0, b = 0, Aeq =
f=

0
0

20 5
.05 .15

1
1

0
0
0
0

1
0
0
0
0

0
1
0
0
0

0
0

1 , beq =

0
0

10000
40

550 , LB =

0
0

-------------------------------------------------------------------% Set 4, Problem 1


f=[-45;-30;0;0;0];
A=zeros(5,5);
b=zeros(5,1);
Aeq=[20 5 1 0 0 ;0.05 0.15 0 1 0;1 1 0 0 1;0 0 0 0 0;0 0 0 0 0];
beq=[10000;40;550;0;0];
LB=[0;0;0;0;0];UB=[inf;inf;inf;inf;inf];
x=linprog(f,A,b,Aeq,beq,LB,UB)
>> s4p1
Optimization terminated successfully.
x=
483.3333
66.6667
0.0000
5.8333
0.0000
-----------------------------------------------------The solution from the Matlab program is
xa = 483.3333
x2 = 66.6667
S1 = 0

0
0

0 , UB =

0
0

S2 = 5.8333
S3 = 0

2. (P. 15.2 Chapra)


A gas processing plant receives a fixed amount of raw gas each week. The raw gas is processed
into three grades of heating gas, regular, premium, and supreme quality. Their production
involves both time and on-site storage constraints. For example, only one of the grades can be
produced at a time, and the facility is open for only 80 hrs/week. There is limited on-site storage
for each of the products. All these factors are listed in Table 4-1 with a metric ton denoted tonne
equal to 1000 kg.
Table 4-1
Product
Resource
Raw gas
Production time
Storage
Profit

Regular
7 m3/tonne
10 hr/tonne
9 tonnes
150/tonne

Premium
11 m3/tonne
8 hr/tonne
6 tonnes
175/tonne

Supreme
15 m3/tonne
12 hr/tonne
5 tonnes
250/tonne

Availability
154 m3/week
80 hr/week

(a) Set up the linear programming problem to maximize profit.


(b) Solve the linear programming problem with the simplex method.
(c) Solve the linear programming problem with Matlab.
Solution
(a) Set up the linear programming problem to maximize profit.
The total LP formulation is given by
Maximize Z = 150 x1 + 175x 2 + 250 x 3

{Maximize profit}

subject to
7 x1 + 11x 2 + 15x 3 154

x2 6
x3 5

{Material constraint}
{Time constraint}
{Regular storage constraint}
{Premium storage constraint}
{Supreme storage constraint}

x1 , x 2 , x 3 0

{Positivity constraints}

10 x1 + 8 x 2 + 12 x 3 80
x1 9

(b) The simplex tableau for the problem can be set up and solved as
Basis
P
S1
S2

x1
1
0
0

x2
-150
7
10

x3
-175
11
8

S1
-250
15
12

S2
0
1
0

S3
0
0
1

S4
0
0
0

S5
0
0
0

0
0
0

Solution Intercept
0
154
10.2667
80
6.66667

S3
S4
S5

0
0
0

Basis
P
S1
S2
S3
S4
x3

Basis
P
S1
x2
S3
S4
x3

Basis
P
S1
x2
S3
S5
x3

1
0
0
x1

1
0
0
0
0
0

x2
-150
7
10
1
0
0

x1
1
0
0
0
0
0

1
0
0
0
0
0

0
1
0

0
0
1
x3

-175
11
8
0
1
0
x2

68.75
-6.75
1.25
1
-1.25
0
x1
x2
58.3333
-5.5
0
1
-0.8333
0.83333

0
0
0
S1

0
0
0
0
0
1
x3

0
0
1
0
0
0

S1

x3
0
0
1
0
0
0

S1
0
0
0
0
0
1

S2
0
1
0
0
0
0

0
0
0
0
0
1

0
0
0

1
0
0
S3

0
0
1
0
0
0

0
1
0
S4

0
0
0
1
0
0

0
0
1
S5

0
0
0
0
1
0

S2
S3
0 21.88
1 -1.375
0 0.125
0
0
0 -0.125
0
0

0
0
0
1
0
0

S4

S2
S3
0 20.83
1
-1.25
0
0
0
0
0 -0.083
0 0.083

S4
S5
0 8.33
0
-1
0
1
1
0
0 0.67
0 -0.67

250
-15
-12
0
0
1

9
6
5

S5
Solution Intercept
0 -12.5 1687.5
0
1.5
51.5
34.3333
0 -1.5
2.5 -1.66667

0
0
9
1
1.5
3.5
2.33333
0
1
5
5

0
0
0
0
1
0

Solution
1716.7
48
6
9
2.3333
2.6667

The problem is reformulated as


Minimize y = 150 x1 175 x 2 250 x3

x2 6
x3 5

{Material constraint}
{Time constraint}
{Regular storage constraint}
{Premium storage constraint}
{Supreme storage constraint}

x1 , x 2 , x 3 0

{Positivity constraints}

10 x1 + 8 x 2 + 12 x 3 80
x1 9

We use the Matlab command X=LINPROG(f, A, b, Aeq, beq, LB, UB)


The coefficient vector f for the objective function is

Solution Intercept
1250
79
7.18182
20
2.5

9
6
6

(c) Solve the linear programming problem with Matlab.

7 x1 + 11x 2 + 15x 3 154

150

f = 175
250
The matrix coefficient A for the inequality constraints is
7 11 15

A = 10 8 12
0 0 0
The right hand vector b for the inequality constraints is
154

b = 80
0
Since there are no equality constraints in this example, Aeq and beq are zeros.
Aeq = 0 and beq = 0
The lower and upper bounds vectors are given by
0

LB = 0 and UB =
0

9
6

5

The following Matlab statements are used to solve this linear programming problem.
Matlab Program ----------------------------------------------------% Set 4, Problem 2
f=[-150;-175;-250];
A=[7 11 15;10 8 12;0 0 0];
b=[154;80;0];
Aeq=zeros(3,3);
beq=zeros(3,1);
LB=[0;0;0];UB=[9;6;5];
x=linprog(f,A,b,Aeq,beq,LB,UB)
>> s4p2
Optimization terminated successfully.

x=
0.0000
6.0000
2.6667
------------------------------------------------------------------------------------------------------------The solution from the Matlab program is
x1 = 0
x2 = 6
x3 = 2.6667

3. (P. 15.3 Chapra)


Consider the linear programming problem:
5
x + y, subject to
3
x + 2.5y 15
x+y 7
2x + y 9
x 0 and y 0
(a) Solve the linear programming problem graphically.
(b) Solve the linear programming problem with the simplex method.
(c) Solve the linear programming problem with Matlab.
Solution

Maximize f(x, y) =

(a) Solve the linear programming problem graphically.


To solve graphically, the constraints can be reformulated as the following straight lines
y = 6 0.4x
y = 7 x
y = 9 2x

The objective function can be reformulated as


5
y = x +f(x, y)
3
The constraint lines can be plotted on the x-y plane to define the feasible space. Then the
objective function line can be superimposed for various values of f(x, y) until it reaches the
boundary. The result is f(x, y) 8.33 with x = 23 and y = 5.

0
y

C
y
y

(b) Solve the linear programming problem with the simplex method.
5
Maximize f(x, y) = x + y, subject to
3
x + 2.5y + S1 = 15
x + y + S2 = 7
2x + y + S3 = 9
x, y, S1, S2, S3 0
at A, x = 0
y=0
S1 = 15, S2 = 7, S3 = 9, and f(x, y) = 0
at B, y = 0
S3 = 0
x + S1 = 15
x + S2 = 7
2x = 9
x = 4.5, S1 = 10.5, S2 = 2.5, and f(x, y) = 7.5
at C, S3 = 0
S2 = 0
x + 2.5y + S1 = 15
x+y= 7
2x + y = 9
x = 2, y = 0, S1 = 0.5, and f(x, y) = 8.33

. 4

(c) Solve the linear programming problem with Matlab.


The problem is reformulated as
5
Minimize y = x y
3
x + 2.5y + S = 15
x+y 7
2x + y 9
x, y, and S 0
We use the Matlab command X=LINPROG(f, A, b, Aeq, beq, LB, UB).
The coefficient vector f for the objective function is
5 / 3

f = 1
0
The matrix coefficient A for the inequality constraints is
1 1 0

A = 2 1 0
0 0 0
The right hand vector b for the inequality constraints is
7

b = 9
0
The equality constraints Aeq and beq are given as
1 1 1

Aeq = 0 0 0 and beq =


0 0 0

15
0

0

The lower and upper bounds vectors are given by

0

LB = 0 and UB =
0

The following Matlab statements are used to solve this linear programming problem.
Matlab Program ----------------------------------------------------% Set 4, Problem 3
f=[-5/3;-1;0];
A=[1 1 0;2 1 0;0 0 0];
b=[7;9;0];
Aeq=[1 2.5 1; 0 0 0;0 0 0];
beq=[15;0;0];
LB=[0;0;0];UB=[inf;inf;inf];
x=linprog(f,A,b,Aeq,beq,LB,UB)
>> s4p3
Optimization terminated successfully.
x=
2.0000
5.0000
0.5000
------------------------------------------------------------------------------------------------------------The solution from the Matlab program is
x1 = 2
x2 = 5
S = 0.5

4. (P. 13.7 Chapra) Employ the following methods to find the maximum of
f(x) = 2x 1.75x2 + 1.1x3 0.25x4
a) Quadratic interpolation (x0 = 1.75, x1 = 2, x2 = 2.25, iterations = 5)
b) Newton method (x0 = 2.5, |xi+1 xi| < 0.01)
Solution

f(x) = 2x 1.75x2 + 1.1x3 0.25x4


f(x) = 2 3.5x + 3.3x2 x3
f(x) = 3.5 + 6.6x 3x2
% Set 4, problem 4
fx = '2*x - 1.75*x^2 + 1.1*x^3 - 0.25*x^4';
x0 = 1.75; x = x0; f0 = eval(fx);
x1 = 2; x = x1; f1 = eval(fx);
x2 = 2.25; x = x2; f2 = eval(fx);
f3save=f0;
disp('Quadratic interpolation')
for i=1:5
top = f0*(x1*x1-x2*x2)+f1*(x2*x2-x0*x0)+f2*(x0*x0-x1*x1);
bot = 2*f0*(x1-x2)+2*f1*(x2-x0)+2*f2*(x0-x1);
x3 = top/bot;
x = x3; f3 = eval(fx);
fprintf('x3 = %10.5f, f(x3) = %10.5f\n',x,f3)
% if abs(f3save-f3)<.00001, break, end
f3save=f3;
if x3<x0
x0=x3;x2=x1;x1=x0;
f0=f3;f2=f1;f1=f0;
elseif x3<x1
x2=x1;x1=x3;
f2=f1;f1=f3;
elseif x3<x2
x0=x1;x1=x3;
f0=f1;f1=f3;

else
x0=x1;x1=x2;x2=x3;
f0=f1;f1=f2;f2=f3;
end
end
disp('Newton method')
x = 2.5;
for i=1:10
fx = 2*x - 1.75*x^2 + 1.1*x^3 - 0.25*x^4;
fprintf('x = %8.5f, f(x) = %8.5f\n',x, fx)
dx = (2 - 3.5*x + 3.3*x^2 - x^3)/(- 3.5 + 6.6*x - 3*x^2 );
x= x - dx;
if abs(dx)<0.01, break, end
end
fx = 2*x - 1.75*x^2 + 1.1*x^3 - 0.25*x^4;
fprintf('x = %8.5f, f(x) = %8.5f\n',x, fx)
>> s4p4
Quadratic interpolation
x3 = 2.06166, f(x3) = 1.80775
x3 = 2.07412, f(x3) = 1.80813
x3 = 2.07807, f(x3) = 1.80817
x3 = 2.07898, f(x3) = 1.80817
x3 = 2.07926, f(x3) = 1.80817
Newton method
x = 2.50000, f(x) = 1.48438
x = 2.19565, f(x) = 1.78800
x = 2.09170, f(x) = 1.80796
x = 2.07951, f(x) = 1.80817
x = 2.07935, f(x) = 1.80817

5. (P. 13.9 Chapra) Employ the following methods to find the optimum of
f(x) = 6x + 7.5x2 + 3x3 + x4
a) Quadratic interpolation (x0 = 2, x1 = 1, x2 = 1, iterations = 5)
b) Newton method (x0 = 1, |xi+1 xi| < 0.01)
Solution

f(x) = 6x + 7.5x2 + 3x3 + x4


f(x) = 6 + 15x + 9x2 + 4x3
f(x) = 15 + 18x + 12x2
% Set 4, problem 5
fx = '6*x + 7.5*x^2 + 3*x^3 + x^4';
x0 = -2; x = x0; f0 = eval(fx);
x1 = -12; x = x1; f1 = eval(fx);
x2 = 1; x = x2; f2 = eval(fx);
f3save=f0;
disp('Quadratic interpolation')
for i=1:5
top = f0*(x1*x1-x2*x2)+f1*(x2*x2-x0*x0)+f2*(x0*x0-x1*x1);
bot = 2*f0*(x1-x2)+2*f1*(x2-x0)+2*f2*(x0-x1);
x3 = top/bot;
x = x3; f3 = eval(fx);
fprintf('x3 = %10.5f, f(x3) = %10.5f\n',x,f3)
% if abs(f3save-f3)<.00001, break, end
f3save=f3;
if x3<x0
x0=x3;x2=x1;x1=x0;
f0=f3;f2=f1;f1=f0;
elseif x3<x1
x2=x1;x1=x3;
f2=f1;f1=f3;
elseif x3<x2
x0=x1;x1=x3;
f0=f1;f1=f3;

else
x0=x1;x1=x2;x2=x3;
f0=f1;f1=f2;f2=f3;
end
end
disp('Newton method')
x = -1;
for i=1:10
fx = 6*x + 7.5*x^2 + 3*x^3 + x^4;
fprintf('x = %8.5f, f(x) = %8.5f\n',x, fx)
dx = (6 + 15*x + 9*x^2 + 4*x^3)/(15 + 18*x + 12*x^2);
x= x - dx;
if abs(dx)<0.01, break, end
end
fx = 6*x + 7.5*x^2 + 3*x^3 + x^4;
fprintf('x = %8.5f, f(x) = %8.5f\n',x, fx)
>> s4p5
Quadratic interpolation
x3 = -0.50980, f(x3) = -1.43952
x3 = 0.18902, f(x3) = 1.42358
x3 = -0.35706, f(x3) = -1.30649
x3 = -0.50715, f(x3) = -1.43906
x3 = -0.52720, f(x3) = -1.44099
Newton method
x = -1.00000, f(x) = -0.50000
x = -0.55556, f(x) = -1.43766
x = -0.52782, f(x) = -1.44099
x = -0.52803, f(x) = -1.44099

6. Minimize the function f(x, y) = 4x2 + y2 2xy, using Newton method with
x0 = [1 1]T.
Solution
x i+1 = x i Hi-1 f(x i)

(1)

8 x 2 y
f(x i) =

2 y 2 x
8 2
Hi =

2 2
Let x i = x i+1 x i, equation (1) becomes
Hix i = f(x i)
6
8 2 x
6
For i = 0, f(x i) =
=


0
0
2 2 y

x = 1, y = 1
x1 = x0 + x = 1 1 = 0
y1 = y0 + y = 1 1 = 0

f(x = 0, y = 0) = 0 is the solution


a company makes two products a and b with two processing departments and wishes to add one
new product line what must be product Cs unit profit in order to profitably add it to the product
line

You might also like