Constrained optimization exploratory activity

Solving constrained optimization problems with Lagrange multipliers:

Part 3: CAS Computation

Introduction:

This portion of the activity guides you through the solution of the constrained optimization problem boxed below using MATLAB®. Similar procedures can be used in other computer algebra systems.

Code

(*) Find the maximum value of

subject to the pair of constraints

.

Guide:

(1) Open MATLAB® and prime the Symbolic Toolbox with a symbol declaration.

>> syms x y z lambda mu

(2) Define the objective function, and the functions appearing in the constraint equations.

>> f =
>> g =
>> h =

(3) Define the Lagrangian for our example problem.

>> lagrangian = f - lambda*g - mu*h

(4) Encode the necessary condition for constrained extrema as a single vector equation. (Don't confuse the double equal sign == [equality] with the single equal sign = [assignment].)

>> eqn = ( gradient(lagrangian, [x y z lambda mu]) == [0; 0; 0; 0; 0] )

(5) Solve the system.

>> candidates = solve( eqn, [x y z lambda mu] )

(6) Extract the spacial coordinates from the solutions (and peek at numerical approximations).

>> [ candidates.x candidates.y candidates.z ]
>> vpa( ans )

(7) Evaluate at the candidate points.

>> subs( f, [x y z], [candidates.x(1) candidates.y(1) candidates.z(1)] )
>> vpa( ans )
>> subs( f, [x y z], [candidates.x(2) candidates.y(2) candidates.z(2)] )
>> vpa( ans )

(8) Where is the constrained maximum of achieved and what is its value? (Is your answer here consistent with your answer to question (10) from Part 2?)

Notes to grader

Notes from grader

Team member names *

Team contact information

Score