Guides · 7 min read

Optimization Problems: A Complete Walkthrough

Optimization problems ask you to find the largest or smallest possible value of some quantity — the biggest area, the least material, the shortest time — given a constraint that links its variables together. The calculus itself, once you have a single-variable function to differentiate, is just critical points and a test. Almost all of the difficulty is in the setup: translating a word problem into that one function.

This guide walks through a repeatable procedure for the setup, then applies it to a worked example so you can see each step earn its place.

Step One: Identify the Quantity to Optimize

Read the problem and name, in words, exactly what you are maximizing or minimizing: an area, a volume, a distance, a cost, a time. Give it a variable name, commonly tied to its meaning, such as A for area or C for cost. This becomes your objective — the function you will eventually differentiate.

At this stage you are not yet writing a function of one variable. You are just being precise about the target so that every later step is aimed at the right thing. A surprising number of setup errors come from optimizing the wrong quantity, such as minimizing a side length when the problem actually asked for minimal material cost.

Step Two: Write the Objective Function and the Constraint

Express your objective quantity in terms of the variables the problem gives you, using whatever geometric or physical formulas apply — area formulas, volume formulas, distance formulas. This objective function will typically have more than one variable at this stage, which is expected.

Then find the constraint: a separate equation, usually reflecting a fixed total such as a fixed perimeter, a fixed amount of material, or a fixed sum, that links those same variables together. The constraint is what lets you eliminate all but one variable in the next step.

A=xy,2x+2y=P    y=P2xA = xy, \quad 2x + 2y = P \;\Rightarrow\; y = \frac{P}{2} - x

A fixed-perimeter constraint solved for one variable, ready to substitute into the objective.

Step Three: Reduce to a Single Variable

Solve the constraint equation for one variable and substitute it into the objective function. This is the step that turns a two-variable formula into the single-variable function you actually know how to differentiate. Simplify the result before moving on; a cleaner expression means a cleaner derivative.

Pin down the domain at the same time. Physical quantities like lengths and areas cannot be negative, so use the constraint and the context of the problem to determine the interval of valid values for your one remaining variable. You will need that domain later to confirm the extremum is not just a local one but the actual answer to the problem.

Step Four: Differentiate, Find Critical Points, and Test

Differentiate the single-variable objective function and set the derivative equal to zero to find critical points, also checking for points where the derivative is undefined. These critical points, together with the endpoints of your domain if the domain is a closed interval, are the only candidates for the maximum or minimum.

Confirm which candidate is the actual extremum. On a closed interval, evaluate the objective function at every critical point and both endpoints, then compare the values directly — the largest is the maximum, the smallest is the minimum. On an open or infinite interval, use the first or second derivative test to classify the critical point, and reason about the function's behavior at the boundaries of the domain to confirm it is a global extremum, not just a local one.

  • Closed interval: compare the objective function's value at every critical point and both endpoints.
  • Open interval: use the first or second derivative test, then check behavior at the domain's edges.
  • Points where the derivative is undefined count as critical points too — do not skip them.

A Worked Example: Maximum-Area Rectangle

A farmer has 200 meters of fencing and wants to enclose the largest possible rectangular area against an existing straight wall, so fencing is needed on only three sides. Let x be the length of the two sides perpendicular to the wall and y the side parallel to it. The constraint is 2x plus y equals 200, and the objective is area A equals xy.

Solve the constraint for y: y equals 200 minus 2x. Substitute into the objective: A equals x times the quantity 200 minus 2x, which is 200x minus 2x squared, a single-variable function on the domain 0 to 100. Differentiate: A prime equals 200 minus 4x. Setting this to zero gives x equals 50, and A double prime equals negative 4, which is negative, confirming a maximum. The dimensions are x equals 50 meters and y equals 100 meters, for a maximum area of 5,000 square meters.

Common Setup Mistakes

Nearly every wrong answer traces back to the setup rather than the differentiation.

  • Optimizing the wrong quantity because the objective was never stated precisely in words first.
  • Forgetting to reduce to one variable, then differentiating a function that still has two.
  • Skipping the domain, so a mathematically valid critical point turns out to be physically impossible.
  • Confirming a critical point is a local extremum but never checking that it is the global one the problem asked for.
  • Forgetting to substitute back to find the second variable and report both dimensions, not just x.

Frequently asked questions

Do I always need both an objective function and a constraint?

Yes. The objective function is the quantity you are optimizing; the constraint is the extra relationship, usually a fixed total, that lets you reduce that objective to a single variable before differentiating.

How do I know whether to check endpoints or use a derivative test?

If your domain is a closed interval, the extremum could occur at an endpoint, so compare the objective function's value at the endpoints and every critical point directly. If the domain is open or unbounded, use the first or second derivative test on the critical point instead.

What if the second derivative test is inconclusive?

If the second derivative is also zero at the critical point, fall back on the first derivative test, checking the sign of the first derivative just before and after the critical point.

Why does the problem always give me a fixed total, like fencing or material?

Because that fixed total is the constraint equation. Without some fixed relationship linking the variables, there would be no way to reduce the objective function to one variable, and no finite optimum to find.

Keep going

CalcRef is an educational reference. Verify formulas for exams, engineering work, or professional use.