Tin can with the least metal: a geometric programming example, solved and checked
The tin can with the least metal is a classic geometric programming problem. Here it is solved by a real solver (CLARABEL (geometric program)) and checked: every constraint, and the optimality certificate. Change the numbers below and solve your own.
Solve your own version free, no account needed
The problem
A closed cylindrical can must hold 1000 cm^3. What radius and height use the least metal (surface area)?
How the model was built
The objective as written from the problem, before the numbers are multiplied out:
- Surface = 2πr2 + 2πr h: the top and bottom circles, plus the side, a rectangle 2πr wide (the circle's edge) and h high.
- πr2 h = 1000: the volume, base area times height, is 1000 cm3. So r and h are in cm and the surface in cm2.
The model
Each line has a plain-language note on the right.
| make this as small as possible | |
| limit 1: left side must equal 1000 | |
| radius of the can (cm) cannot be negative | |
| height of the can (cm) cannot be negative |
What is being decided
There are 2 decision variables.
| Variable | Type | Meaning |
|---|---|---|
| r | real number | radius of the can (cm) |
| h | real number | height of the can (cm) |
Goal and limits
Minimize the objective subject to 3 constraints, of which 2 are simple bounds on a single variable.
Problem type
Geometric program, complexity level 4: a geometric program: convex after taking logarithms of the variables, so the optimum is global. Solved with CLARABEL (geometric program) at the Medium solver tier.
Picture
Shaded: every point that satisfies all the constraints. Dot: the optimum. Dashed: the objective's level line through it.
The answer at a glance
The optimal value of each decision, as the solver returned it.
Which constraints hold the answer in place
Binding (no slack left): (1) 3.141592654*h*r^2 = 1000. Changing a binding constraint changes the answer; a slack one can move a little without effect.
| # | Constraint | Value | Limit | Slack | Binding |
|---|---|---|---|---|---|
| 1 | 3.141592654*h*r^2 = 1000 | 1000 | 1000 | 4.81223e-05 | yes |
| 2 | r >= 0 | 5.41895 | 0 | 5.41895 | |
| 3 | h >= 0 | 10.8398 | 0 | 10.8398 |
Algebraic model (low level)
Decision variables, objective and every constraint written out; this is exactly what the solver receives.
Model code (cvxpy)
The same model in cvxpy, ready to run.
import cvxpy as cp
r = cp.Variable(name='r') # radius of the can (cm)
h = cp.Variable(name='h') # height of the can (cm)
objective = cp.Minimize(6.283185307179586*h*r + 6.283185307179586*r**2)
constraints = [
3.141592653589793*h*r**2 == 1000,
r >= 0,
h >= 0,
]
problem = cp.Problem(objective, constraints)
problem.solve(solver='CLARABEL')
print(problem.status, problem.value)
print('r =', r.value)
print('h =', h.value)Solve your own
This is the model as the app reads it. Change any number and solve it in the free box on the front page (no account needed).
minimize 2*3.141592653589793*r^2 + 2*3.141592653589793*r*h
subject to
3.141592653589793*r^2*h = 1000
r, h >= 0
# r = radius of the can (cm)
# h = height of the can (cm)Checked: the app's answer matches the reference answer in our test set. Built 2026-11-10.
Related examples
Try ProvenDecisions free: type, photograph or say an optimization problem; every answer is checked by a solver.