- An optimisation problem asks for the largest or smallest value of something (cost, profit, area, time) when you are free to choose one quantity.
- Write the target as a function of one variable, using the constraint to remove any second variable, and state the domain.
- Differentiate, set the derivative equal to zero and solve. Then prove it is a maximum or minimum with the second derivative test or a sign change.
- On a closed interval, always compare the stationary values with the endpoints: the best answer is sometimes at the edge.
- Finish by answering the question in words and units, not just with a value of \( x \).
The case: fencing a school garden for the least money
A school is building a rectangular vegetable garden with an area of 250 m². The side that faces the street must use a decorative steel railing, which costs $16 per metre. The other three sides can use plain wire mesh at $4 per metre. The headteacher wants to know what shape of rectangle makes the fencing as cheap as possible, and what that cheapest bill is. (The prices are illustrative, but they are in the range a school would see.)
A first guess might be a square, with sides of about 15.8 m and a fence costing around $443. Can we do better? The railing is four times as expensive as the mesh, so it makes sense to shorten the street side. Shorten it too much, though, and the garden becomes a thin strip with a huge amount of mesh. Somewhere in between is a best shape, and calculus finds it exactly.
The concept: the top of the hill, the bottom of the valley
Picture the cost as a graph against the length of the street side. As you start shortening a wide garden, the cost falls. As you keep going, it starts to rise again. At the exact turning point, the graph is flat for an instant: its gradient is zero. That flat spot is the cheapest point. The same idea finds the highest point of a profit curve or the largest volume a box can hold. Wherever a smooth quantity reaches a peak or a trough inside its range, its derivative is zero there.
Two details complete the story. A flat point could be a peak, a trough or neither, so you must check which. And real variables have limits (a length cannot be negative, a plot cannot be wider than the land), so the best value might sit at an edge, where the graph is not flat at all.
The formula
For an objective function \( f(x) \) that you can differentiate twice, a stationary point \( x^* \) satisfies
and the second derivative test tells you what kind of point it is:
Here \( x \) is the quantity you choose (the decision variable), \( f(x) \) is what you want to make best (cost, profit, area), \( f'(x) \) is its rate of change and \( f”(x) \) measures how that rate is changing, which tells you whether the curve bends upwards (a valley) or downwards (a hill). If \( f”(x^*) = 0 \) the test gives no answer, and you check the sign of \( f'(x) \) on either side instead.
On a closed interval \( a \le x \le b \), the candidates test (also called the closed interval method) says the absolute maximum and minimum are among the values \( f(a) \), \( f(b) \) and \( f(x^*) \) at every stationary point inside the interval[1].
Why this formula fits the case
The fencing bill changes smoothly as the street side changes: there are no jumps, because metres of fence can be any length. A smooth curve that falls and then rises must flatten out at its lowest point, so solving \( C'(x) = 0 \) is exactly the right way to find it. The second derivative then confirms that the flat point is the bottom of a valley and not the top of a hill.
It is not the right tool every time. If the variable can only take whole values (number of buses, number of staff), calculus gives a guide value, and you then test the whole numbers on either side. If there are two or more free variables with a constraint that you cannot easily solve for one of them, you need methods such as Lagrange multipliers. If everything is linear, the best point is always at a corner of the feasible region, and linear programming does the job. And if the domain has edges, the derivative alone can miss the answer, which is why the endpoint check matters.
Setting it up
Let the street side be \( x \) metres and the other pair of sides be \( y \) metres. The garden has four sides: one street side of railing, one back side of mesh, and two side runs of mesh.
- Objective: total cost \( C = 16x + 4x + 4y + 4y = 20x + 8y \) dollars.
- Constraint: area \( xy = 250 \), so \( y = \dfrac{250}{x} \).
- One variable: substitute to get \( C(x) = 20x + \dfrac{2000}{x} \).
- Domain: \( x > 0 \). (There is no upper limit yet; we add one in Worked example 3.)
Notice what the two terms mean. \( 20x \) is the cost that grows with the street side; \( 2000/x \) is the cost of the side runs, which shrinks as the street side grows. The optimum balances the two.
Solving it
Find the dimensions that minimise \( C(x) = 20x + \dfrac{2000}{x} \) for \( x > 0 \), and the minimum cost.
The cheapest garden is 10 m along the street and 25 m deep, and the fencing costs $400, compared with about $443 for the square.
The second case moves from geometry to business, and the variable is a price rather than a length.
A local gym finds that if it charges \( p \) dollars a month, it keeps \( N = 1200-20p \) members. Each member costs $10 a month to serve, and fixed costs (rent, staff) are $8,000 a month. Prices are allowed from $10 to $60. Find the price that maximises monthly profit. (Illustrative figures.)
The gym should charge $35 a month. It keeps 500 members and earns $4,500 profit, far better than either endpoint.
Back at the school, the street side sits between two existing buildings, so it can be at most 8 m long. Find the cheapest garden now.
With an 8 m frontage the best garden is 8 m by 31.25 m and costs $410. Setting \( C'(x) = 0 \) alone would have given an answer the school cannot build.
What the answer tells us
In the garden, the minimum came where the two parts of the bill were equal: $200 on railing and back fence, $200 on side runs. That is no accident. For any cost of the form \( ax + \dfrac{b}{x} \), the minimum is at \( ax = \dfrac{b}{x} \), so the two parts balance, and the minimum cost is \( 2\sqrt{ab} \). Here \( 2\sqrt{20 \times 2000} = 2\sqrt{40000} = 400 \). If you shorten the street side past 10 m, every metre saved on railing costs more than a metre’s worth of extra mesh.
Check that the answer is sensible. The units work: metres for lengths, dollars for cost. The shape is long and narrow, as we predicted, because the expensive side should be short. And the saving over the square, about $43 or roughly 10%, is worth having on a school budget.
Sensitivity is worth a moment too. If the railing went up to $25 a metre, the cost would become \( 29x + 2000/x \), and the best street side would shrink to \( \sqrt{2000/29} \approx 8.30 \) m, at a cost of about $482. In the gym, the best price is \( p = 30 + c/2 \) for a cost per member \( c \). If that cost rose from $10 to $14, the best price would rise only from $35 to $37: the gym should pass on half of the increase, not all of it. Patterns like this are what economists call comparative statics, and they come straight from the derivative[2].
The Mathematics Made Simple textbook builds this method up in Chapter 12, and the Mathematics Made Simple practice questions book adds two full mock papers for timed practice.
Practice questions
EasyQ1. A rectangle has a perimeter of 36 cm. Find the largest area it can have. Show worked answer
\( A = x(18-x) = 18x-x^2 \), so \( A’ = 18-2x \).
\( A’ = 0 \) gives \( x = 9 \), and \( A” = -2 < 0 \), so it is a maximum.
The rectangle is a 9 cm by 9 cm square, with area \( 81 \) cm².
EasyQ2. A firm’s profit is \( \pi(Q) = 120Q-3Q^2-500 \) dollars. Find the output that maximises profit, and the maximum profit. Show worked answer
\( \pi”(Q) = -6 < 0 \), so it is a maximum.
\( \pi(20) = 2400-1200-500 = 700 \) dollars.
MediumQ3. A closed box has a square base of side \( x \) cm and a volume of 324 cm³. The base and lid cost 3 cents per cm², and the four sides cost 2 cents per cm². Find the dimensions that minimise the cost, and the minimum cost. Show worked answer
Cost \( C = 3(2x^2) + 2(4xh) = 6x^2 + \dfrac{2592}{x} \) cents.
\( C'(x) = 12x-\dfrac{2592}{x^2} = 0 \) gives \( x^3 = 216 \), so \( x = 6 \) cm and \( h = 324/36 = 9 \) cm.
\( C”(x) = 12 + \dfrac{5184}{x^3} \), so \( C”(6) = 36 > 0 \): a minimum.
\( C(6) = 216 + 432 = 648 \) cents, which is $6.48.
MediumQ4. The volume of water in a tank, in hundreds of litres, is \( V(t) = t^3-9t^2 + 24t + 10 \) for \( 0 \le t \le 6 \) hours. Find the greatest and least volumes over this period. Show worked answer
Candidates: \( V(0) = 10 \), \( V(2) = 30 \), \( V(4) = 26 \), \( V(6) = 46 \).
Greatest volume 4,600 litres at \( t = 6 \) (an endpoint); least volume 1,000 litres at \( t = 0 \) (also an endpoint). The local maximum at \( t = 2 \) is not the absolute maximum.
ExamQ5. A power cable runs from a station \( A \) on one bank of a straight river 300 m wide to a point \( B \) on the opposite bank, 1,000 m downstream. The cable goes underwater from \( A \) to a point \( P \) on the far bank, \( x \) m downstream, and then along the bank to \( B \). Underwater cable costs $50 per metre; cable on land costs $30 per metre. (a) Show that the cost is \( C(x) = 50\sqrt{90000 + x^2} + 30(1000-x) \). [2] (b) Find the value of \( x \) that minimises the cost. [4] (c) Find the minimum cost and show it is less than both endpoint costs. [3] Show worked answer
(b) \( C'(x) = \dfrac{50x}{\sqrt{90000 + x^2}}-30 \) [1]. Setting it to zero: \( 50x = 30\sqrt{90000 + x^2} \) [1], so \( 25x^2 = 9(90000 + x^2) \) and \( 16x^2 = 810000 \) [1]. So \( x^2 = 50625 \) and \( x = 225 \) m [1].
(c) \( \sqrt{90000 + 50625} = \sqrt{140625} = 375 \), so \( C(225) = 50(375) + 30(775) \), which is \( 18750 + 23250 = 42000 \) dollars [1]. \( C(0) = 15000 + 30000 = 45000 \) [1]; \( C(1000) = 50\sqrt{1090000} \approx 52202 \) [1]. The minimum is $42,000.
Frequently asked questions
Do I always need the second derivative test?
No. Any valid justification works: the second derivative, a sign change in the first derivative, or the candidates test on a closed interval. The second derivative is quickest when it is easy to compute; the sign change is safer when \( f”(x^*) = 0 \).
What is the difference between a local and an absolute maximum?
A local maximum is higher than the points just around it. The absolute maximum is the highest value over the whole domain. In Q4 above, \( t = 2 \) is a local maximum, but the absolute maximum is at the endpoint \( t = 6 \).
What if there is no stationary point in the domain?
Then the function is rising or falling throughout, and the optimum (if there is one) is at an endpoint, as in Worked example 3. On an open domain with no stationary point, there may be no maximum or minimum at all.
References
- Strang, G. and Herman, E. (2016) Calculus Volume 1, Section 4.7 “Applied Optimization Problems”. Houston, TX: OpenStax. https://openstax.org/details/books/calculus-volume-1
- Chiang, A.C. and Wainwright, K. (2005) Fundamental Methods of Mathematical Economics, 4th edn. New York: McGraw-Hill.
- College Board (2020) AP Calculus AB and AP Calculus BC Course and Exam Description, Unit 5, topics 5.10–5.11. New York: College Board.
- Cambridge International (2024) Cambridge International AS & A Level Mathematics 9709: Syllabus for examination in 2026 and 2027, Pure Mathematics 1, topic 1.7 Differentiation. Cambridge: Cambridge University Press & Assessment.
- International Baccalaureate Organization (2019) Mathematics: analysis and approaches guide (first assessment 2021), SL 5.8. Cardiff: IBO.

