Tutorials › AP Calculus › Turning Constraints into Objective Functions

Optimization and L'Hôpital's Rule · Tutorial 395 of 999

Turning Constraints into Objective Functions

Learn to identify what can vary, what must be optimized, and which equations every allowable design must satisfy.

Advanced 9 min read

What You'll Learn

  • Distinguish decision variables, fixed parameters, objective functions, and constraints
  • Translate a fixed-perimeter rectangle into an area objective and a perimeter equation
  • Model a triangular enclosure using its area and perimeter
  • Build a cost function from separate material, printing, and setup charges
  • Check a model by substituting a concrete design and verifying its units
  • Recognize common errors that confuse an objective with a constraint

From a Story to a Mathematical Model

Many optimization problems begin with a practical question: Which design gives the greatest area? Which plan costs the least? The calculus comes later. First, the situation must be translated into mathematics without changing what the question asks.

A useful model separates three things. Decision variables describe the quantities that a designer may choose. The objective function gives the quantity to maximize or minimize. Constraints state the equations or inequalities that the choices must satisfy.

Definition: An optimization model consists of decision variables, an objective function to maximize or minimize, and constraints that restrict which choices are allowed. A choice satisfying all the constraints is a feasible design.

For example, if a rectangle’s side lengths can vary but its perimeter is fixed, the side lengths are decision variables. Its area is the objective if the goal is to make the rectangle as large as possible. The fixed perimeter is a constraint. These roles are different: the objective measures what is being optimized, while the constraint describes a requirement that every allowed design must meet.

A Reliable Translation Process

Before writing formulas, identify the goal and the fixed information. Then assign variables to the quantities that can change. Give each variable a clear meaning and unit. Write the objective from its definition, and write each constraint from the corresponding fixed total, geometric relationship, or resource limit.

1
Identify the choice.
Name the quantities the design can vary, and attach units to them.
2
State the goal.
Decide whether the problem asks to maximize or minimize a specific quantity.
3
Write the objective.
Use a definition or a sum of contributions to express the quantity being optimized.
4
Write the constraints.
Translate fixed dimensions, totals, budgets, and geometric relationships into equations or inequalities.
5
Check the model.
Substitute a possible design and verify the relationships, arithmetic, and units.

The variables and fixed numbers should not be confused. A fixed perimeter of \(40\) meters is a parameter supplied by the situation; the side lengths \(x\) and \(y\) are choices. A formula involving those choices is not automatically the objective: it could instead express a constraint. The wording of the problem determines its role.

Worked Example: Area of a Rectangle with Fixed Perimeter

Worked Example: Area of a Rectangle with Fixed Perimeter

A rectangular garden must use exactly \(40\) meters of edging. Choose variables and formulate the objective and constraint if the goal is to maximize the garden’s area.

Let \(x\) be the garden’s length in meters and \(y\) its width in meters. Both are decision variables. The goal is to maximize area, so the objective function is the rectangle’s area:

$$ A(x,y)=xy. $$

The edging covers all four sides. There are two sides of length \(x\) and two of length \(y\), so the total edging requirement gives the constraint

$$ 2x+2y=40. $$

Thus the model is to maximize \(A(x,y)=xy\) subject to \(2x+2y=40\), with \(x>0\) and \(y>0\). The positivity conditions express that the garden has nonzero side lengths; they do not replace the perimeter equation.

Check the formulas with the possible design \(x=8\) meters and \(y=12\) meters. Its perimeter is

$$ 2(8)+2(12)=16+24=40\text{ meters}, $$

so it satisfies the constraint. Its area is

$$ A(8,12)=(8)(12)=96\text{ square meters}. $$

The units agree: meters times meters gives square meters. This substitution checks that the model correctly measures the perimeter and area. It does not establish that this design has the greatest possible area.

Worked Example: Area of a Triangular Enclosure

Worked Example: Area of a Triangular Enclosure

A right-triangular enclosure has a fixed perimeter of \(24\) meters. Formulate a model for maximizing its area.

Let \(x\) and \(y\) be the lengths, in meters, of the two perpendicular sides. These are the decision variables. By the Pythagorean theorem, the third side has length \(\sqrt{x^2+y^2}\) meters. The area of a right triangle is half the product of its perpendicular sides, so the objective is

$$ A(x,y)=\frac{1}{2}xy. $$

The fixed perimeter includes all three sides. Therefore the constraint is

$$ x+y+\sqrt{x^2+y^2}=24. $$

The model is to maximize \(A(x,y)=\frac12xy\) subject to this perimeter equation, with \(x>0\) and \(y>0\).

Check the equations using \(x=6\) meters and \(y=8\) meters. The third side is

$$ \sqrt{6^2+8^2}=\sqrt{36+64}=\sqrt{100}=10\text{ meters}. $$

The perimeter is \(6+8+10=24\) meters, as required. The area is

$$ A(6,8)=\frac12(6)(8)=\frac12(48)=24\text{ square meters}. $$

The perimeter equation uses lengths, while the objective uses square meters. This is an important check: adding lengths gives a perimeter, but multiplying two lengths gives an area.

Worked Example: Modeling Total Production Cost

Worked Example: Modeling Total Production Cost

A sign must have a printed area of \(24\) square feet. Its width is \(x\) feet and its height is \(y\) feet. Printing costs \(\$2\) per square foot, horizontal border material costs \(\$3\) per foot, vertical border material costs \(\$5\) per foot, and setup costs \(\$40\). Formulate the cost-minimization model.

The decision variables are the sign’s width \(x\) and height \(y\), measured in feet. The fixed printed area gives the constraint

$$ xy=24. $$

The objective is total cost. The printing charge is \(\$2\) for each of \(xy\) square feet, so it is \(2xy\) dollars. The two horizontal edges have a combined length of \(2x\) feet, so their border cost is \(3(2x)=6x\) dollars. The two vertical edges have a combined length of \(2y\) feet, giving a cost of \(5(2y)=10y\) dollars. Adding the fixed setup charge gives

$$ C(x,y)=2xy+6x+10y+40. $$

The model is to minimize \(C(x,y)\) subject to \(xy=24\), with \(x>0\) and \(y>0\). Each term in the cost function has units of dollars: for instance, \((\$2/\text{ft}^2)(xy\text{ ft}^2)\) is a dollar amount.

Check the model at \(x=4\) feet and \(y=6\) feet. The area is \((4)(6)=24\) square feet, so the constraint holds. The printing costs \((\$2/\text{ft}^2)(24\text{ ft}^2)=\$48\). The horizontal border costs \((\$3/\text{ft})(2\cdot4\text{ ft})=\$24\), and the vertical border costs \((\$5/\text{ft})(2\cdot6\text{ ft})=\$60\). Including setup, the total is \(\$48+\$24+\$60+\$40=\$172\). Substitution in the formula confirms this: \(C(4,6)=2(24)+6(4)+10(6)+40=48+24+60+40=172\).

Why the Model Represents the Problem

A model is useful only if its formulas preserve the meaning of the story. This can be justified directly. Each allowable design determines values for its decision variables. Applying the stated geometric definitions or cost rates to those values gives the actual quantity of interest. The objective function is constructed to equal that quantity, and the constraints are constructed to hold precisely when the design meets the stated requirements.

For the rectangular garden, a design with side lengths \(x\) and \(y\) has area \(xy\) by the definition of rectangle area, and edging length \(2x+2y\) by adding the lengths of its four sides. Therefore designs using exactly \(40\) meters of edging are represented by \(2x+2y=40\), and for every such design, \(A(x,y)=xy\) is its actual area. Consequently, maximizing the modeled area over designs satisfying the constraint is exactly the original goal of maximizing garden area. The same reasoning applies to the triangle and sign: their objectives calculate the requested area or cost, while their constraints encode the fixed requirements.

Key takeaway: A correct optimization model has a faithful objective and faithful constraints. The objective answers “what quantity is being optimized?” The constraints answer “what must every permitted design satisfy?”

Common Modeling Pitfall

A frequent error is to put the constrained quantity in the objective. For the garden, someone might write “maximize \(2x+2y\) subject to \(2x+2y=40\).” This does not model the request to maximize area. The proposed objective is the perimeter, and the constraint fixes that same perimeter at \(40\). Every feasible design would have the same objective value, \(40\), regardless of its area.

The correction is to distinguish the two roles: \(2x+2y=40\) is the perimeter constraint, while \(xy\) is the area objective. Another common error is to omit a contribution from a cost objective. In the sign example, counting only the printing charge would leave out border and setup costs, so the resulting function would not represent total production cost. Listing each cost source before adding the terms helps prevent this mistake.

Check Your Understanding

For each question, identify the variables, objective, and constraint before considering how an optimum might be found.

  1. A rectangle has a fixed perimeter of \(30\) meters. If its area is to be maximized, what are suitable decision variables, objective function, and perimeter constraint?
  2. A right triangle has perpendicular sides \(a\) and \(b\), and its perimeter is \(18\) centimeters. Write its area objective and perimeter constraint.
  3. A rectangular surface has width \(x\) feet and length \(y\) feet, with a fixed area of \(50\) square feet. If the goal is to minimize a stated total installation cost, which relationship is the area constraint?
  4. Why is a setup charge included in total cost even if it does not vary with the dimensions?
  5. In a model, what question does the objective answer, and what question do the constraints answer?

Test yourself: AP Calculus practice exams

Ready to check what you know? Work an AP-style practice exam, then open the full solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers all of AP Calculus AB & BC: full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon