Calculus › Section N · Functions of several variables › Topic N.9
Applications of extrema
The second partials test earns its keep here: minimum material, shortest distance, maximum profit and the best-fit line through data all come down to the same two moves.
From one variable to a plan of attack
An applied optimisation problem in one variable follows a script: name the variable, write the quantity to optimise, use the constraint, differentiate, check. With two variables the script is nearly the same, and the previous topic supplied the new tool for the checking step: the discriminant \(d = f_{xx} f_{yy} - (f_{xy})^2\). This topic runs that script on problems that matter, from the sheet metal in a crate to a workshop's profit and the line a statistician draws through data.
The optimisation playbook
Every problem in this topic follows the same playbook. First, name the variables and their units. Second, write the quantity to be optimised as a formula in those variables. Third, use each constraint to eliminate a variable: every independent constraint removes exactly one variable, so a two-variable problem with one constraint becomes one variable before you differentiate. Fourth, find the critical points. Fifth, classify them with the second partials test, or with the one-variable second derivative if the substitution left a single variable. Sixth, sanity-check the answer: are the dimensions positive, is the profit plausible, does the point lie in the region the problem allows?
Worked example: an open-top box
A crate with a square base and no top must hold \(32{,}000\) cubic centimetres. Minimise the material. Let \(x\) be the base edge and \(h\) the height, both in centimetres. The material is the base plus four sides, \(S = x^2 + 4xh\), and the volume constraint is \(x^2 h = 32{,}000\). One constraint eliminates one variable: \(h = \frac{32{,}000}{x^2}\), so
Then \(S'(x) = 2x - \frac{128{,}000}{x^2} = 0\) gives \(x^3 = 64{,}000\), so \(x = 40\) centimetres and \(h = \frac{32{,}000}{1{,}600} = 20\) centimetres. The second derivative \(S''(x) = 2 + \frac{256{,}000}{x^3}\) is \(6 > 0\) at \(x = 40\), confirming a minimum. The crate uses \(1{,}600 + 4(40)(20) = 4{,}800\) square centimetres of material, and the height is exactly half the base edge.
Worked example: the closest point on a plane
Which point of the plane \(x + y + z = 9\) is closest to the origin? Minimise the distance, or rather its square, \(D = x^2 + y^2 + z^2\): squaring keeps the same minimiser, since \(t^2\) is an increasing function of the distance \(t \ge 0\), and it spares us the square root. Substituting \(z = 9 - x - y\) leaves a two-variable function \(f(x, y) = x^2 + y^2 + (9 - x - y)^2\). Setting the partials to zero gives \(2x + y = 9\) and \(x + 2y = 9\), so \(x = y = 3\) and \(z = 3\). The second partials are \(f_{xx} = 4\), \(f_{yy} = 4\), \(f_{xy} = 2\), so \(d = 16 - 4 = 12 > 0\) with \(f_{xx} > 0\): a minimum, at distance \(\sqrt{27} = 3\sqrt{3} \approx 5.2\). As a check, the point \((9, 0, 0)\) on the plane is 9 away. The winner \((3, 3, 3)\) is the foot of the perpendicular from the origin to the plane.
Worked example: maximum profit with two products
A workshop makes \(x\) chairs and \(y\) tables per week. A model for weekly profit is
measured in US dollars, valid for \(x, y \ge 0\). The negative product term says the two lines compete for the same materials and labour. Setting the partials to zero: \(120 - 2x - 2y = 0\) gives \(x + y = 60\), and \(160 - 4y - 2x = 0\) gives \(x + 2y = 80\). Subtracting, \(y = 20\), so \(x = 40\). The second partials are \(P_{xx} = -2\), \(P_{yy} = -4\), \(P_{xy} = -2\), so \(d = 8 - 4 = 4 > 0\) with \(P_{xx} < 0\): a maximum, worth \(P(40, 20) = 4{,}800 + 3{,}200 - 1{,}600 - 800 - 1{,}600 = \$4{,}000\) per week. Both production levels are positive, so the answer respects the model's domain.
Fitting a line to data
Fitting a straight line to a scatter of points \((x_1, y_1), \ldots, (x_n, y_n)\) is one of the most-used calculations in statistics. For a candidate line \(y = mx + b\), each data point misses the line by a residual, the vertical gap \(y_i - (mx_i + b)\) between the observed value and the predicted one. The least squares idea is to choose \(m\) and \(b\) to minimise the sum of the squared residuals:
Squaring, just as with the distance problem, treats overshoots and undershoots symmetrically and keeps everything non-negative so misses of opposite sign cannot cancel each other. This is a genuine two-variable minimisation, and calculus solves it exactly.
Worked example: a least squares line
Fit a line to \((1, 2)\), \((2, 3)\), \((3, 5)\), \((4, 6)\). Tabulate the sums: \(n = 4\), \(\sum x_i = 10\), \(\sum y_i = 16\), \(\sum x_i^2 = 30\), \(\sum x_i y_i = 47\). Setting \(\frac{\partial S}{\partial m}\) and \(\frac{\partial S}{\partial b}\) to zero simplifies to two linear equations, \(30m + 10b = 47\) and \(10m + 4b = 16\). Subtracting \(2.5\) times the second from the first removes \(b\): \(5m = 7\), so \(m = 1.4\), and then \(b = \frac{16 - 14}{4} = 0.5\). The line is \(y = 1.4x + 0.5\). The residuals are \(0.1, -0.3, 0.3, -0.1\): they sum to zero, a built-in property of least squares fits. Their squares total \(0.2\), whereas the rival line \(y = 1.5x + 0.4\) scores \(0.34\), so the fit truly is better. The discriminant \(d = (2\sum x_i^2)(2n) - (2\sum x_i)^2 = 80\) confirms a minimum.
Respecting the physical domain
Applied variables usually live in restricted regions: chairs and tables cannot be produced in negative quantities, and a box needs positive height. When the critical point of the model lands inside that region, the playbook ends there. When it lands outside, or when the region's boundary could beat the interior, the previous topic's sweep applies: restrict the function to each boundary curve, which is a one-variable problem, and check the corners. A profit maximised at \(x = 40\) chairs is useless advice if the workshop's floor only fits 30; then the true maximum sits on the boundary \(x = 30\), and you find it by optimising \(P(30, y)\) over the allowed \(y\).
Common mistakes to avoid
The most damaging slip is differentiating with too many variables still in play: substitute the constraint first, because a quantity treated as a variable that is really fixed silently breaks the chain of reasoning. Second, answer the question asked: if the problem asks for the dimensions, report the dimensions, not the minimum value of \(S\), and keep the units straight, since an area \(x^2\) and a term \(4xh\) only match when lengths share one unit. Third, do not accept a critical point that violates the physical domain. Fourth, in the distance problem, minimise the squared distance but report the distance itself, remembering the square root at the end.
Key takeaways
Applied optimisation in several variables is a fixed playbook: name variables, write the target quantity, use each constraint to eliminate one variable, find critical points, classify with the discriminant, and check the answer against the problem's domain and units. Minimising a squared distance or a sum of squared residuals gives the same optimiser as the original and differentiates far more easily. The least squares line solves two linear equations built from the data's sums, and its residuals always sum to zero. When the model's region is restricted, sweep the boundary as well as the interior before declaring an absolute optimum.
Flashcards
Flashcard
Name variables, write the target, eliminate one variable per constraint, find critical points, classify, sanity-check
Test your understanding
Question 1 of 5
A crate with a square base and no top must hold 4,000 cm³. Its material area is S = x² + 4xh, with volume constraint x²h = 4,000. What dimensions minimise S?
Question 2 of 5
A model for weekly profit is P(x, y) = 200x + 160y - 2x² - 2y² - 2xy dollars. What is the maximum profit?
Question 3 of 5
Which point on the plane x + y + z = 12 is closest to the origin?
Question 4 of 5
What is the least squares line for the data (1, 3), (2, 4), (3, 4), (4, 6)?
Question 5 of 5
Why does least squares minimise the sum of squared residuals rather than the sum of the residuals themselves?
Standards: Beyond AP
