Optimisation with calculus: the biggest box
What this lesson covers
- An optimisation problem is solved by writing the quantity as a function of one variable and finding its turning point.
- The answer must be shown to be a maximum or minimum, and must make sense in context.
Optimisation: the best value
- Biggest volume, least material, most profit.
- The best value is at a turning point.
- So form a function and differentiate it.
A box from a 24 cm square card
- Cut a square of side x from each corner.
- Fold up the sides: the height is x.
- Each base side is 24 − 2x.

Try it: the open box
Write the volume in one variable
- Volume = base² × height.
- Square the bracket first.
- Then multiply by x.
- height x, base 24 − 2xx off each end
- V = x(24 − 2x)²height × base²
- (24 − 2x)² = (24 − 2x)(24 − 2x)
- = 576 − 48x − 48x + 4x²expand
- = 576 − 96x + 4x²collect the x terms
- V = x(576 − 96x + 4x²)
- = 4x³ − 96x² + 576x
Differentiate and solve
- Take out 12 first.
- x = 12 leaves no base.
- V = 4x³ − 96x² + 576x
- V′ = 12x² − 192x + 576differentiate
- 12x² − 192x + 576 = 0stationary
- 12(x² − 16x + 48) = 0take out 12
- 12(x − 4)(x − 12) = 0factorise
- x = 4 or x = 12
- x = 12: base 24 − 24 = 0no box
- x = 4: V = 4(24 − 8)²
- = 4 × 256 = 1024 cm³
Check the answer makes sense
- x must be more than 0 and less than 12.
- An answer outside that is not a box.
- Say why you reject it.
Prove it is a maximum
- V″ negative: a maximum.
- Or V′ goes + then −.
- V′ = 12x² − 192x + 576
- V″ = 24x − 192differentiate again
- V″(4) = 24 × 4 − 192
- = 96 − 192 = −96 < 0a maximum
- V′(3) = 108 − 576 + 576
- = 108 > 0rising
- V′(5) = 300 − 960 + 576
- = −84 < 0falling
- x = 4 gives the maximum
Try it: a maximum where f′ = 0
Answer the question asked
- Cut 4 cm squares from each corner.
- The box is 16 cm by 16 cm by 4 cm.
- Maximum volume: 1024 cm³.

Try it: the box, step by step
Another: 60 m of fence against a wall
- The wall is the fourth side.
- Two widths, one length.
- width = x
- x + x + length = 60three sides fenced
- length = 60 − 2x
- A = x(60 − 2x)width × length
- = 60x − 2x²expand
Differentiate and solve
- Set the derivative to zero.
- Check: a maximum.
- A = 60x − 2x²
- A′ = 60 − 4xdifferentiate
- 60 − 4x = 0stationary
- 4x = 60, so x = 15
- A″ = −4 < 0a maximum
- length = 60 − 30 = 30
- A = 15 × 30 = 450 m²
Five steps for any optimisation
- Most marks are lost at step 2 and step 4.
- One variable only, before differentiating.
- Reject what the context rules out.
| Step | |
|---|---|
| 1 | draw it, name the variable |
| 2 | write the quantity in one variable |
| 3 | differentiate, set to zero, solve |
| 4 | reject answers outside the context |
| 5 | prove max or min, answer with units |
Where the marks are
- Achieved: differentiate the given function.
- Merit: find the optimum with working.
- Excellence: form it yourself, justify, check in context.
What to take away
- Form it, solve it, reject what cannot be, prove it.
| Form | one quantity, one variable |
| Solve | derivative equals zero |
| Domain | reject impossible answers |
| Prove | second derivative or gradient test |
| Answer | the question asked, with units |
Common mistakes
- Box from a 24 cm card: V = x(24 − x)²A square of side x comes off both ends of each side, so the base is 24 − 2x and V = x(24 − 2x)².
- (24 − 2x)² = 576 + 4x²Square a bracket by writing it out: (24 − 2x)(24 − 2x) = 576 − 96x + 4x².
- V′ = 0 at x = 4 or x = 12, so there are two best boxes.Reject x = 12 and say why: the base would be 24 − 24 = 0, so there is no box. Use x = 4.
- x = 4 gives V = 1024 cm³, so that is the maximum.Prove it is a maximum: V″ = 24x − 192, and V″(4) = −96 < 0. Then answer with the box's size and units.
Your turn: eight questions
- Question 3 has an answer to reject.
- Give units.
A = x(40 − 2x) m². Find the maximum area.
Profit P = −x² + 50x − 400. Find the maximum profit.
12 cm card, corners x cut: V = x(12 − 2x)². Best x?
Prove your answer to question 3 is a maximum.
A box is made from a 30 cm square card by cutting a square of side x cm from each corner. Which values of x make sense?
A rectangular garden has a perimeter of 36 m and a width of x m. Which gives its area in one variable?
A Tauranga courier's cost per trip is C = 0.02v² − 3v + 200 dollars at speed v km/h. Find the speed for the least cost, and that cost.
Two positive numbers x and y add to 12. Find them so that x²y is as large as possible.
Show answer
1. A′ = 40 − 4x = 0 at x = 10: A = 10 × 20 = 200 m². 2. P′ = −2x + 50 = 0 at x = 25: P = 225. 3. V′ = (12 − 2x)(12 − 6x) is zero at x = 2 or 6; x = 6 leaves no base, so x = 2 cm and V = 128 cm³. 4. V = 4x³ − 48x² + 144x, V″ = 24x − 96, V″(2) = −48 < 0, so a maximum. 5. 0 < x < 15. The base side is 30 − 2x, which must be more than 0, and x must be more than 0. 6. A = x(18 − x). Width plus length is half of 36, so the length is 18 − x. 7. v = 75 km/h, cost $87.50. C′ = 0.04v − 3 = 0 at v = 75, C(75) = 112.5 − 225 + 200 = 87.50, and C″ = 0.04 > 0, so a minimum. 8. x = 8, y = 4, product 256. P = x²(12 − x) = 12x² − x³, P′ = 24x − 3x² = 0 at x = 0 or 8; reject x = 0, and P″(8) = −24 < 0, so a maximum of 64 × 4 = 256.
The answers: questions 1 and 2
- 1. A = x(40 − 2x) = 40x − 2x²expand
- A′ = 40 − 4x = 0, so x = 10stationary
- A = 10(40 − 20) = 10 × 20
- = 200 m²
- 2. P′ = −2x + 50differentiate
- −2x + 50 = 0, so x = 25stationary
- P = −625 + 1250 − 400substitute x = 25
- = 225
The answers: question 3
- 3. V = x(12 − 2x)²base 12 − 2x
- (12 − 2x)² = 144 − 48x + 4x²square the bracket
- V = 4x³ − 48x² + 144xmultiply by x
- V′ = 12x² − 96x + 144differentiate
- = 12(x² − 8x + 12)take out 12
- = 12(x − 2)(x − 6) = 0factorise
- x = 6: base 12 − 12 = 0no box
- x = 2: V = 2(12 − 4)² = 2 × 64
- = 128 cm³
The answers: question 4
- V′ = 12x² − 96x + 144
- 4. V″ = 24x − 96differentiate again
- V″(2) = 24 × 2 − 96
- = 48 − 96 = −48
- −48 < 0, so x = 2 is a maximum
Sample question: Achieved
A farmer has 40 m of fencing to make a rectangular pen against a long wall, so fencing is only needed on three sides. The two sides at right angles to the wall are each x m long. Find the value of x that gives the largest area, and the largest area.
Hint
The side parallel to the wall is 40 − 2x. Write the area in terms of x, differentiate and set the derivative to zero.
Answer
x = 10 m, giving a largest area of 200 m² (the pen is 10 m by 20 m)
Step by step
- The fence makes two sides of length x and one side along the wall. So the side parallel to the wall is 40 − 2x.
- Area = length × width: A = x(40 − 2x) = 40x − 2x².
- At the largest area the gradient is zero, so differentiate: dAdx = 40 − 4x.
- Set it to zero: 40 − 4x = 0, so x = 10 m.
- Show it is a maximum: d²Adx² = −4, which is negative, so the turning point is a maximum.
- Largest area: A = 10 × (40 − 20) = 10 × 20 = 200 m².
- Classic mistake: stopping at x = 10. The question also asks for the largest area, so finish by putting x back into A.
- Check: x = 9 gives 9 × 22 = 198 and x = 11 gives 11 × 18 = 198, both less than 200.
Full working
- A = x(40 − 2x) = 40x − 2x²the side along the wall is 40 − 2x
- dAdx = 40 − 4x = 0, so x = 10
- d²Adx² = −4 < 0maximum
- A = 10 × 20 = 200 m²
- x = 10 m, largest area 200 m²
Sample questions: Merit
An open box is made from a rectangular sheet of card 30 cm by 16 cm by cutting a square of side x cm from each corner and folding up the sides. Find the value of x that gives the greatest volume, prove it is a maximum, and find the greatest volume.
Hint
The base is (30 − 2x) by (16 − 2x) and the height is x. Expand V, differentiate, and solve dVdx = 0. One solution will not fit the card.
Answer
x = 103 cm, giving a greatest volume of 1960027 ≈ 725.9 cm³
Step by step
- Cutting x from both ends of each side leaves a base of (30 − 2x) by (16 − 2x). The folded sides give a height of x.
- V = x(30 − 2x)(16 − 2x). Expand: (30 − 2x)(16 − 2x) = 480 − 92x + 4x², so V = 4x³ − 92x² + 480x.
- Sensible values: the 16 cm side must stay positive, so 16 − 2x > 0 and 0 < x < 8.
- Differentiate: dVdx = 12x² − 184x + 480. Set it to zero and divide by 4: 3x² − 46x + 120 = 0.
- Formula: x = 46 ± √(2116 − 1440)6 = 46 ± √6766 = 46 ± 266. So x = 12 or x = 103.
- x = 12 is outside 0 < x < 8; you cannot cut 12 cm squares from a 16 cm side. Reject it.
- Classic mistake: keeping x = 12 and getting a 'volume' from negative lengths. Always check the answer fits the context.
- Prove it is a maximum: d²Vdx² = 24x − 184. At x = 103 this is 80 − 184 = −104, negative, so a maximum.
- Greatest volume: V = 103 × (30 − 203) × (16 − 203) = 103 × 703 × 283 = 1960027 ≈ 725.9 cm³.
- Check: x = 3 gives 3 × 24 × 10 = 720 and x = 4 gives 4 × 22 × 8 = 704, both a little less than 725.9.
Full working
- V = x(30 − 2x)(16 − 2x) = 4x³ − 92x² + 480x0 < x < 8
- dVdx = 12x² − 184x + 480 = 0, so 3x² − 46x + 120 = 0
- x = 46 ± 266 = 12 or 103reject 12: more than 8
- d²Vdx² = 24x − 184 = −104 < 0 at x = 103maximum
- V = 103 × 703 × 283 = 1960027
- x = 103 cm, V ≈ 725.9 cm³
Two positive numbers add to 12. Find the numbers that make the product of the square of one number and the other number as large as possible, and prove your answer gives a maximum.
Hint
Call the squared number x, so the other is 12 − x. Write P = x²(12 − x), differentiate and set it to zero.
Answer
8 and 4 (8² × 4 = 256 is the largest product)
Step by step
- Two unknowns, but they are linked: if one is x, the other is 12 − x. That gets the problem into one variable.
- Let x be the number that is squared. The product is P = x²(12 − x) = 12x² − x³.
- Both numbers must be positive, so 0 < x < 12.
- Differentiate: dPdx = 24x − 3x². Set it to zero: 3x(8 − x) = 0, so x = 0 or x = 8.
- x = 0 is not allowed (the numbers are positive), and it would give P = 0 anyway. So x = 8.
- Prove it is a maximum: d²Pdx² = 24 − 6x. At x = 8 this is −24, negative, so x = 8 gives a maximum.
- The other number is 12 − 8 = 4, and the product is 8² × 4 = 256.
- Classic mistake: answering 6 and 6, which makes the plain product x(12 − x) largest. Squaring one of the numbers changes the best split.
- Check: 6² × 6 = 216 and 9² × 3 = 243, both less than 256.
Full working
- P = x²(12 − x) = 12x² − x³the other number is 12 − x
- dPdx = 24x − 3x² = 3x(8 − x) = 0
- x = 8 (x = 0 is not positive)
- d²Pdx² = 24 − 48 = −24 < 0maximum
- 8 and 4, product 256
Sample questions: Excellence
A rectangular window is fitted inside an arch whose shape is y = 12 − x², with x and y in metres and the ground along y = 0. The bottom of the window sits on the ground and its top corners touch the arch. Find the dimensions of the window with the greatest area, justify that it is a maximum, and state the greatest area.
Hint
Put the top right corner at (x, 12 − x²). The window is symmetric, so its width is 2x. Write the area in terms of x only.
Answer
4 m wide and 8 m high, with a greatest area of 32 m²
Step by step
- The arch is symmetric about the y-axis, so the window is too. Let its top right corner be at (x, 12 − x²) on the arch.
- Then the width is 2x (from −x to x) and the height is 12 − x².
- Area: A = 2x(12 − x²) = 24x − 2x³.
- Sensible values: the width and height must be positive, so x > 0 and 12 − x² > 0. That gives 0 < x < √12 ≈ 3.46.
- Differentiate: dAdx = 24 − 6x². Set it to zero: x² = 4, so x = 2 (x = −2 is not in range).
- Justify a maximum: d²Adx² = −12x, which is −24 at x = 2. Negative, so it is a maximum.
- At the ends of the range the area is zero (no width, or no height), so this turning point is the greatest area overall.
- Dimensions: width 2 × 2 = 4 m and height 12 − 4 = 8 m. Area = 4 × 8 = 32 m².
- Classic mistake: using x as the full width. x is the distance from the centre, so the width is 2x.
- Check: x = 1.9 gives 3.8 × 8.39 ≈ 31.9 and x = 2.1 gives 4.2 × 7.59 ≈ 31.9, both just under 32.
- Limitation: a real window needs a frame and a gap below the arch, so the usable glass would be a little smaller.
Full working
- corner (x, 12 − x²): width 2x, height 12 − x²symmetric
- A = 2x(12 − x²) = 24x − 2x³, 0 < x < √12
- dAdx = 24 − 6x² = 0, so x = 2
- d²Adx² = −12x = −24 < 0maximum; A = 0 at both ends
- width 4 m, height 8 m, A = 32 m²
- 4 m by 8 m, greatest area 32 m²
An open-topped box has a square base of side x cm and height h cm. It is made from exactly 108 cm² of thin sheet metal. Show that its volume is V = 27x − x³4. Find the dimensions that give the greatest volume, prove it is a maximum, and state the greatest volume.
Hint
Open-topped means one base plus four sides: x² + 4xh = 108. Make h the subject and substitute into V = x²h.
Answer
x = 6 cm and h = 3 cm, giving a greatest volume of 108 cm³
Step by step
- The metal makes the base (x² cm²) and four sides (each x by h, so xh cm² each). There is no lid.
- So x² + 4xh = 108. Make h the subject: h = 108 − x²4x.
- Volume = base area × height: V = x²h = x² × 108 − x²4x = x(108 − x²)4 = 27x − x³4. That is what we had to show.
- Sensible values: h > 0 needs x² < 108, so 0 < x < √108 = 6√3 ≈ 10.4.
- Differentiate: dVdx = 27 − 3x²4. Set it to zero: 3x²4 = 27, so x² = 36 and x = 6 (x must be positive).
- Prove it is a maximum: d²Vdx² = −3x2, which is −9 at x = 6. Negative, so a maximum.
- Height: h = 108 − 364 × 6 = 7224 = 3 cm.
- Greatest volume: V = 6 × 6 × 3 = 108 cm³. Using the formula: 27 × 6 − 2164 = 162 − 54 = 108. They agree.
- Classic mistake: using 2x² + 4xh for the surface area. That counts a lid, but the box is open-topped.
- Check the metal: 36 + 4 × 6 × 3 = 36 + 72 = 108 cm². Correct.
- Notice the best box is twice as wide as it is tall. That is the general shape of the largest open box with a square base.
Full working
- x² + 4xh = 108, so h = 108 − x²4xbase plus four sides, no lid
- V = x²h = 27x − x³4as required
- dVdx = 27 − 3x²4 = 0, so x = 60 < x < 6√3
- d²Vdx² = −3x2 = −9 < 0maximum
- h = 7224 = 3; V = 6 × 6 × 3 = 108
- 6 cm by 6 cm by 3 cm high, V = 108 cm³
Challenge
A solid cone has height 12 cm and base radius 6 cm. A cylinder of radius r cm stands on the cone's base, inside the cone, with its top rim touching the sloping side. Find the radius and height of the cylinder with the greatest volume, prove it is a maximum, and give the greatest volume exactly.
Hint
Look at the cone side on: a triangle. As the cylinder's radius grows by 1 cm, how much height must it lose to stay inside?
Answer
r = 4 cm, h = 4 cm, greatest volume 64π cm³.
Step by step
- Side on, the cone's edge drops 12 cm over a horizontal 6 cm, so 2 cm of height for each 1 cm outward.
- At distance r from the centre, the side is 12 − 2r high, so that is the cylinder's height.
- Write the volume in r only, differentiate and set to 0.
- Reject r = 0 (no cylinder). Check the second derivative is negative.
- Answer with both dimensions and the volume.
Full working
- h = 12 − 2r, 0 < r < 6similar triangles: 12 ÷ 6 = 2 cm of height per cm
- V = πr²(12 − 2r) = π(12r² − 2r³)volume of a cylinder
- dVdr = π(24r − 6r²) = 6πr(4 − r) = 0stationary
- r = 4reject r = 0
- d²Vdr² = π(24 − 12r) = −24π < 0 at r = 4a maximum
- h = 12 − 8 = 4, V = π × 16 × 4 = 64πsubstitute
- r = 4 cm, h = 4 cm, V = 64π cm³
A Rotorua tour costs $120 a person and 40 people book. For every $5 the price drops, 4 more people book. The bus holds at most 60 people. What price gives the greatest takings, and what are the takings? Explain why setting the derivative to zero alone gives the wrong answer.
Hint
Let n be the number of $5 drops. Find the turning point, then check whether it fits on the bus.
Answer
Charge $95 (60 people) for takings of $5700. The turning point n = 7 would need 68 seats.
Step by step
- With n drops of $5, the price is 120 − 5n and the number of people is 40 + 4n.
- Takings R = price × people. Differentiate and set to 0: n = 7.
- But n = 7 means 68 people, and the bus holds only 60, so n can be at most 5.
- R′ is positive for every n below 7, so R keeps rising all the way to n = 5.
- The best allowed choice is the end point n = 5, not the turning point.
Full working
- R = (120 − 5n)(40 + 4n) = 4800 + 280n − 20n²price × people
- R′ = 280 − 40n = 0, so n = 7stationary
- 40 + 4(7) = 68 > 60too many for the bus
- 40 + 4n ≤ 60, so n ≤ 5the bus limit
- R′ = 280 − 40n > 0 for n < 7R is increasing up to n = 5
- R(5) = 95 × 60 = 5700price 120 − 25 = 95
- $95 a person, takings $5700
A window is a rectangle with a semicircle on top; the semicircle's diameter is the top edge of the rectangle. The frame around the whole outside edge is 8 m long. Find the radius that gives the window the greatest area, show that the rectangle's height is then equal to the radius, and give the greatest area exactly and to 2 decimal places.
Hint
Let the radius be r and the rectangle's height be h. The frame is two heights, the bottom edge 2r and the curved arc πr. Use it to write h in terms of r.
Answer
r = 84 + π ≈ 1.12 m, the height is also 84 + π m, and the greatest area is 324 + π ≈ 4.48 m².
Step by step
- The frame is 2h + 2r + πr = 8. Rearrange to get h in terms of r.
- The area is the rectangle 2rh plus the semicircle πr²2. Replace h to get the area in r only.
- Differentiate, set to 0 and solve for r. The second derivative is negative, so it is a maximum.
- Substitute r into h: it simplifies to the same value as r.
- Use (4 + π)r = 8 to simplify the area.
Full working
- 2h + 2r + πr = 8, so h = 8 − 2r − πr2the frame
- A = 2rh + πr²2 = r(8 − 2r − πr) + πr²2 = 8r − 2r² − πr²2area in r
- dAdr = 8 − 4r − πr = 0, so r = 84 + πstationary
- d²Adr² = −(4 + π) < 0a maximum
- h = 8 − (2 + π)r2 = 8(4 + π) − 8(2 + π)2(4 + π) = 84 + πso h = r
- A = r(8 − (4 + π)r2) = r(8 − 4) = 4r = 324 + π ≈ 4.48use (4 + π)r = 8
- r = h = 84 + π ≈ 1.12 m, greatest area 324 + π ≈ 4.48 m²
Practise this
Report a mistake
More in AS 91262
The derivative: what the gradient function means6 min
Differentiating polynomials, fractions and all7 min
Equation of a tangent to a curve, step by step8 min
Turning points: finding and proving max or min8 min
Sketching the gradient graph of a function7 min
Optimisation with calculus: the biggest box8 min
Anti-differentiation and why you need + c7 min
Kinematics: displacement, velocity and acceleration8 min
The derivative: 7 exam questions solved step by step11 min
Differentiating: 7 exam questions solved step by step11 min
Tangents: 7 exam questions solved step by step11 min
Turning points: 7 exam questions solved step by step12 min
Gradient graphs: 7 exam questions solved step by step12 min
Optimisation: 7 exam questions solved step by step11 min
Anti-differentiation: 7 exam questions solved step by step11 min
Kinematics: 7 exam questions solved step by step11 min