To form an objective function, write the quantity you want to maximise or minimise, then use the constraint to replace one variable so only one is left. Only then can you differentiate.
This is the core skill of stationary points and optimisation. It builds on finding stationary points and classifying them.
The three-line set-up
Every optimisation problem can be started with three lines.
- Objective: write a formula for what you are optimising, such as A = xy.
- Constraint: write the fixed condition as an equation, such as 2x + y = 60.
- Substitute: rearrange the constraint for one variable and put it into the objective, giving a function of one variable.
If you can write these three lines neatly, the rest is the same differentiate, solve and classify routine from the earlier lessons.
Worked example
A rectangle has a perimeter of 36 cm. Find the dimensions that give the largest area.
Step 1, variables: let the sides be x cm and y cm.
Step 2, constraint: perimeter gives 2x + 2y = 36, so x + y = 18 and y = 18 − x.
Step 3, objective function: A = xy = x(18 − x) = 18x − x².
Step 4, differentiate: dA/dx = 18 − 2x. Setting this to zero gives x = 9, then y = 18 − 9 = 9.
Step 5, classify: d²A/dx² = −2, which is negative, so this is a maximum.
Step 6, answer: the largest area is 9 × 9 = 81 cm², when the rectangle is a 9 cm by 9 cm square.
Another example with a wall
A farmer uses 60 m of fencing on three sides of a pen, with the fourth side against a wall. With sides x m (two of them) and y m (parallel to the wall), the constraint is 2x + y = 60. So y = 60 − 2x and A = 60x − 2x², which has a maximum at x = 15 and A = 450 m².
Notice that the constraint does not always look like “perimeter is fixed”. Reading which sides need fencing is part of the skill.
The mistake to watch for
A common slip is to write the constraint incorrectly, or to try to differentiate before eliminating.
Mistaken working: A = xy, so dA/dx = y.
The student treated y as a constant, but y changes as x changes.
The correction is that y depends on x through the constraint, so replace it first.
For the wall problem, using y = 60 − x (wrong, since two sides have length x) would give A = 60x − x², a maximum at x = 30 and the wrong answer. Always check the constraint against a labelled sketch.
Check yourself
Try these without a calculator, then open each answer.
1. Two numbers add to 12. Find the largest possible product.
Show answer
Let the numbers be x and 12 − x. P = x(12 − x) = 12x − x². dP/dx = 12 − 2x = 0 gives x = 6. d²P/dx² = −2 < 0, so it is a maximum.
Largest product = 6 × 6 = 36
2. Two numbers add to 10. Find the least possible value of the sum of their squares.
Show answer
S = x² + (10 − x)² = 2x² − 20x + 100. dS/dx = 4x − 20 = 0 gives x = 5. d²S/dx² = 4 > 0, so it is a minimum.
Least sum of squares = 25 + 25 = 50
3. A rectangle has perimeter 50 cm. Write its area as a function of one variable and find the greatest area.
Show answer
x + y = 25, so y = 25 − x and A = 25x − x². dA/dx = 25 − 2x = 0 gives x = 12.5, so y = 12.5. d²A/dx² = −2 < 0, a maximum.
Greatest area = 12.5 × 12.5 = 156.25 cm²
Where this leads next
The next lesson asks what happens when the allowed range of x is restricted: check endpoints as well as stationary values. The function composition and inverse explorer may help if you want more practice substituting one expression into another.
Teachers in online one-to-one Additional Mathematics tuition often start with exactly this skill, because a clean set-up makes the rest of the problem much shorter.