BetaFree coursewareRewritten from MIT OpenCourseWareCC BY-NC-SA 4.0
Open CosmologyPhysics & cosmology, from high school to a graduate year

Tangent planes, critical points and least squares

Changing both variables changes f by about Δz ≈ f_x Δx + f_y Δy: the graph is close to its tangent plane z = z₀ + f_x(x − x₀) + f_y(y − y₀). At a local maximum or minimum both partial derivatives vanish, so the tangent plane is horizontal; such points are critical points, and they can also be saddles. Completing squares shows that x² − 2xy + 3y² + 2x − 2y has a minimum at (−1, 0). Least squares fits the line y = ax + b to data by minimising the total square deviation D(a, b), which gives a 2 × 2 linear system for a and b.

You need this first

Full reading path (8 pages)
  1. Vectors (8.01)
  2. Vectors and the dot product (18.02)
  3. Determinants and the cross product (18.02)
  4. Planes through three points, and matrices (18.02)
  5. Equations of planes and square systems (18.02)
  6. Parametric equations of lines and the cycloid (18.02)
  7. Velocity, acceleration and Kepler's second law (18.02)
  8. Functions of two variables and partial derivatives (18.02)
On this page · 7 sections
  1. The approximation formula
  2. The tangent plane
  3. Critical points
  4. An example, and completing squares
  5. Least squares
  6. Other laws
  7. Summary

This lecture uses partial derivatives to approximate a function, to find its minima and maxima, and to fit lines to experimental data (transcript, p. 1).

The approximation formula#

fxf_x tells how ff changes when xx changes a little, fyf_y when yy does. Changing both, the two effects add up, as if xx changed first and then yy. For z=f(x,y)z = f(x, y) (transcript, p. 1; notes, p. 1):

Approximation formula
Δz≈fx Δx+fy Δy\Delta z \approx f_x\,\Delta x + f_y\,\Delta y
In words

capital delta z is approximately f sub x capital delta x plus f sub y capital delta y

It is one of the most important formulas about partial derivatives. It is only an approximation, for small Δx\Delta x and Δy\Delta y; there are higher-order terms with second and third derivatives (p. 1).

The tangent plane#

Why is the formula true? fxf_x and fyf_y are slopes of two lines tangent to the graph, in the slices parallel to the xzxz- and yzyz-planes. Writing a=fx(x0,y0)a = f_x(x_0, y_0) and b=fy(x0,y0)b = f_y(x_0, y_0), the two lines are (p. 1; notes, p. 1):

Two tangent lines
y=y0,  z=z0+a(x−x0)andx=x0,  z=z0+b(y−y0)y = y_0,\ \ z = z_0 + a(x - x_0) \qquad\text{and}\qquad x = x_0,\ \ z = z_0 + b(y - y_0)
In words

y equals y nought, z equals z nought plus a the quantity x minus x nought, and x equals x nought, z equals z nought plus b the quantity y minus y nought

Two lines through a point determine a plane, the tangent plane to the graph (p. 1; notes, p. 1):

Tangent plane
z=z0+fx(x0,y0) (x−x0)+fy(x0,y0) (y−y0)z = z_0 + f_x(x_0, y_0)\,(x - x_0) + f_y(x_0, y_0)\,(y - y_0)
In words

z equals z nought plus f sub x ( x nought, y nought ) the quantity x minus x nought, all plus f sub y ( x nought, y nought ) the quantity y minus y nought

Source: 18.02 lecture summaries, Week 4 (Prof. Auroux), Lecture 9, pp. 1–2, Lecture 9, p. 1

Holding y=y0y = y_0 gives the first line, holding x=x0x = x_0 the second. (The same plane comes out of the cross product of vectors along the two lines, as a normal vector, p. 1.) On the tangent plane Δz\Delta z would equal fxΔx+fyΔyf_x\Delta x + f_y\Delta y exactly; the approximation formula says that the graph is close to its tangent plane near the point (p. 1; notes, p. 1).

Critical points#

To minimise or maximise a function of one variable, set its derivative to zero. With several variables (p. 1): at a local minimum or maximum, both partial derivatives are zero. If fx=0f_x = 0 but fy≠0f_y \ne 0, the point might be a minimum of the slice parallel to the xx-axis, but changing yy would still make ff larger or smaller (pp. 1–2; notes, p. 1). And if both are zero, the approximation formula says ff does not change to first order: only quadratic or higher terms remain. Equivalently, the tangent plane is horizontal, z=z = constant (p. 2; notes, p. 1).

Critical point
fx(x0,y0)=0andfy(x0,y0)=0f_x(x_0, y_0) = 0 \quad\text{and}\quad f_y(x_0, y_0) = 0
In words

f sub x ( x nought, y nought ) equals 0 and f sub y ( x nought, y nought ) equals 0

These conditions are necessary but not sufficient (p. 2). A critical point can be a local minimum (like x2+y2x^2 + y^2 at the origin; "local" because elsewhere the function may go lower), a local maximum, or a saddle point (like y2−x2y^2 - x^2): a mountain pass, where the ground is level but some directions go up and others down. Saddles have no counterpart in one variable (p. 2; notes, p. 1).

An example, and completing squares#

Take the lecture's example f(x,y)=x2−2xy+3y2+2x−2yf(x, y) = x^2 - 2xy + 3y^2 + 2x - 2y (p. 2; notes, p. 1). Then fx=2x−2y+2f_x = 2x - 2y + 2 and fy=−2x+6y−2f_y = -2x + 6y - 2. Setting both to zero: adding the equations gives 4y=04y = 0, so y=0y = 0, and then 2x+2=02x + 2 = 0 gives x=−1x = -1. The only critical point is (−1,0)(-1, 0) (p. 2; notes, p. 1). (A tip from the lecture: simplify two equations by combining them, but always keep two equations, p. 2.)

Is it a minimum? The general test comes next lecture; here completing the square works. x2−2xyx^2 - 2xy starts (x−y)2(x - y)^2, and 2x−2y=2(x−y)2x - 2y = 2(x - y) completes a second square (p. 2; notes, p. 2):

Completing the square
f(x,y)=(x−y)2+2y2+2(x−y)=(x−y+1)2+2y2−1 ≥ −1f(x, y) = (x - y)^2 + 2y^2 + 2(x - y) = (x - y + 1)^2 + 2y^2 - 1 \ \ge\ -1
In words

f(x, y) equals the quantity x minus y, all squared plus 2 y squared plus 2 the quantity x minus y, equals the quantity x minus y plus 1, all squared plus 2 y squared minus 1 is greater than or equal to minus 1

Squares are never negative, so f≥−1f \ge -1, with equality only when x−y+1=0x - y + 1 = 0 and y=0y = 0: at the critical point (−1,0)(-1, 0), which is therefore a minimum (pp. 2–3; notes, p. 2). (Auroux admits he built the example by expanding this form; in general things will not simplify so neatly, p. 2.)

Least squares#

In experimental science you measure pairs of numbers (x1,y1),…,(xn,yn)(x_1, y_1), \dots, (x_n, y_n) that lie roughly on a line, and want the best-fit line y=ax+by = ax + b (transcript, p. 3; notes, p. 2). The unknowns are aa and bb, not xx and yy: the data are given numbers (p. 3). (Here aa and bb are the line's slope and intercept, no longer the partial derivatives of the tangent plane.)

"Best" needs a definition. The usual choice measures, for each data point, the vertical deviation yi−(axi+b)y_i - (ax_i + b) between the measured and the predicted value (often more relevant than perpendicular distance, since xx and yy may be in different units), and minimises the sum of the squares (p. 3; notes, p. 2):

Total square deviation
D(a,b)=∑i=1n(yi−(axi+b))2D(a, b) = \sum_{i=1}^{n} \big(y_i - (ax_i + b)\big)^2
In words

capital D (a, b) equals the sum from i equals 1 to n of the quantity y initial minus the quantity a x sub i plus b, all squared

Minimising the largest deviation instead would give too much weight to one bad measurement; squares make the line look right and, above all, make the minimisation simple (p. 3). Look for a critical point of D(a,b)D(a, b). By the chain rule (p. 3; notes, p. 2):

Critical point of D
∂D∂a=∑2(yi−(axi+b))(−xi)=0,∂D∂b=∑2(yi−(axi+b))(−1)=0\frac{\partial D}{\partial a} = \sum 2\big(y_i - (ax_i + b)\big)(-x_i) = 0, \qquad \frac{\partial D}{\partial b} = \sum 2\big(y_i - (ax_i + b)\big)(-1) = 0
In words

partial capital D over partial a equals the sum of 2 the quantity y initial minus the quantity a x sub i plus b, (- x sub i ) equals 0, partial capital D over partial b equals the sum of 2 the quantity y initial minus the quantity a x sub i plus b, (-1) equals 0

Dropping the factors −2-2 and collecting the aa's and bb's gives a 2 × 2 linear system for aa and bb, whose coefficients are just numbers computed from the data (p. 4; notes, p. 2):

The least-squares equations
(∑xi2)a+(∑xi)b=∑xiyi,(∑xi)a+n b=∑yi\Big(\sum x_i^2\Big)a + \Big(\sum x_i\Big)b = \sum x_iy_i, \qquad \Big(\sum x_i\Big)a + n\,b = \sum y_i
In words

( the sum of x sub i squared )a plus ( the sum of x sub i )b equals the sum of x sub i y initial, ( the sum of x sub i )a plus n b equals the sum of y initial

The critical point found this way is in fact a minimum, which the lecture asks us to trust for now (p. 4).

Other laws#

The method is more general (p. 4; notes, p. 2). Exponential laws y=ceaxy = ce^{ax}: minimising the square error directly gives equations that cannot be solved easily, but ln⁡y=ln⁡c+ax\ln y = \ln c + ax is linear, so fit a straight line to ln⁡y\ln y against xx, with b=ln⁡cb = \ln c. The lecture's example is Moore's law: the number of transistors on a chip, which does not follow a line but does on a log plot, growing exponentially (doubling every 18 months or two years, depending on the version). Quadratic laws y=ax2+bx+cy = ax^2 + bx + c: minimising the total square deviation gives a 3 × 3 linear system for aa, bb, cc (p. 4; notes, p. 2).

Worked example

A tangent plane, and a line through four points

(a) Use the tangent plane of f(x,y)=x2yf(x, y) = x^2 y at (1,2)(1, 2) to estimate f(1.1,1.9)f(1.1, 1.9). (b) Find the least-squares line through (0,1)(0, 1), (1,3)(1, 3), (2,4)(2, 4), (3,6)(3, 6), and its total square deviation.

(a) The tangent plane

f(1,2)=2f(1, 2) = 2, fx=2xy=4f_x = 2xy = 4 and fy=x2=1f_y = x^2 = 1, so the tangent plane is z=2+4(x−1)+(y−2)z = 2 + 4(x - 1) + (y - 2). At (1.1,1.9)(1.1, 1.9): z=2+0.4−0.1=2.3z = 2 + 0.4 - 0.1 = 2.3. Exactly, f(1.1,1.9)=1.21×1.9=2.299f(1.1, 1.9) = 1.21 \times 1.9 = 2.299.

(b) The sums

With n=4n = 4: ∑xi=6\sum x_i = 6, ∑xi2=0+1+4+9=14\sum x_i^2 = 0 + 1 + 4 + 9 = 14, ∑yi=14\sum y_i = 14, ∑xiyi=0+3+8+18=29\sum x_iy_i = 0 + 3 + 8 + 18 = 29. The system is 14a+6b=2914a + 6b = 29 and 6a+4b=146a + 4b = 14.

(b) Solve

From the second equation b=3.5−1.5ab = 3.5 - 1.5a; then 14a+21−9a=2914a + 21 - 9a = 29, so 5a=85a = 8, a=1.6a = 1.6 and b=1.1b = 1.1: the line y=1.6x+1.1y = 1.6x + 1.1. Its deviations are −0.1-0.1, 0.30.3, −0.3-0.3, 0.10.1, so D=0.01+0.09+0.09+0.01=0.2D = 0.01 + 0.09 + 0.09 + 0.01 = 0.2.

Summary#

  • Approximation formula: Δz≈fxΔx+fyΔy\Delta z \approx f_x\Delta x + f_y\Delta y; the graph is close to its tangent plane z=z0+fx(x−x0)+fy(y−y0)z = z_0 + f_x(x - x_0) + f_y(y - y_0).
  • At a local minimum or maximum fx=fy=0f_x = f_y = 0: a critical point, with a horizontal tangent plane. Critical points can also be saddles.
  • x2−2xy+3y2+2x−2y=(x−y+1)2+2y2−1x^2 - 2xy + 3y^2 + 2x - 2y = (x - y + 1)^2 + 2y^2 - 1 has its minimum −1-1 at (−1,0)(-1, 0).
  • Least squares: minimise D(a,b)=∑(yi−(axi+b))2D(a, b) = \sum (y_i - (ax_i + b))^2; ∂D/∂a=∂D/∂b=0\partial D/\partial a = \partial D/\partial b = 0 is a 2 × 2 linear system for aa and bb.
  • Exponential laws are fitted as lines in ln⁡y\ln y; quadratic laws lead to a 3 × 3 system.

Symbols on this page

Show the 35 symbols used here
Δ\Delta capital delta.
A change or difference in a quantity, e.g. Δx = x₂ − x₁. Say it: “capital delta”.
≈\approx approximately equal.
Is approximately equal to. Say it: “is approximately”.
≥\ge greater than or equal.
Is greater than or equal to. Say it: “is greater than or equal to”.
≠\neq not equal.
Is not equal to. Say it: “is not equal to”.
×\times times.
Times (multiplication). Between two vectors: the cross product. Say it: “times”.
∂\partial partial.
Partial derivative: the rate of change with one variable, holding the others fixed. Say it: “partial”.
∑\sum sum.
Sum: add up the terms over the range written below and above. Say it: “the sum of”.
ln⁡\ln natural logarithm.
Natural logarithm (base e ≈ 2.718). Say it: “log”.
aa a.
In the tangent plane, the slope f_x(x₀, y₀); in least squares, the slope of the fitted line (or the rate in an exponential or quadratic law). Say it: “a”.
HH H.
In the cosmology note, the Hubble constant, the slope of the fitted line. Unit: km/s/Mpc. Say it: “H”.
zz z.
The value z = f(x, y), the height on the graph. Say it: “z”.
cc c.
The constant factor of an exponential law y = c e^(ax), or the constant term of a quadratic law. Say it: “c”.
xx x.
The first variable; in least squares, the measured quantity on the horizontal axis. Say it: “x”.
yy y.
The second variable; in least squares, the measured quantity predicted by the fitted law. Say it: “y”.
dd d.
The d of an ordinary derivative, dD/dH. Say it: “d”.
nn n.
The number of data points. Say it: “n”.
ee e.
The base of natural logarithms, about 2.718. Say it: “e”.
ff f.
A function of two variables, f(x, y). Say it: “f”.
vv v.
In the cosmology note, a galaxy's recession velocity. Unit: km/s. Say it: “v”.
rr r.
In the cosmology note, a galaxy's distance. Unit: Mpc. Say it: “r”.
DD D.
The total square deviation of the data from the line, a function of a and b. Say it: “capital D”.
bb b.
In the tangent plane, the slope f_y(x₀, y₀); in least squares, the intercept of the fitted line (b = ln c for an exponential law). Say it: “b”.
x0x_{0} x nought.
The x coordinate of the point where the tangent plane touches. Say it: “x nought”.
y0y_{0} y nought.
The y coordinate of the point where the tangent plane touches. Say it: “y nought”.
viv_{i} initial velocity.
In the cosmology note, the measured velocity of the i-th galaxy. Unit: km/s. Say it: “v sub i”.
rir_{i} r i.
In the cosmology note, the measured distance of the i-th galaxy. Unit: Mpc. Say it: “r sub i”.
x1x_{1} x 1.
The x value of the first data point. Say it: “x one”.
y1y_{1} y 1.
The y value of the first data point. Say it: “y one”.
z0z_{0} z nought.
The value f(x₀, y₀) at that point. Say it: “z nought”.
xnx_{n} x n.
The x value of the last data point. Say it: “x sub n”.
xix_{i} x i.
The x value of the i-th data point. Say it: “x sub i”.
yiy_{i} y i.
The y value of the i-th data point. Say it: “y initial”.
yny_{n} y n.
The y value of the last data point. Say it: “y sub n”.
fxf_{x} f sub x.
The partial derivative ∂f/∂x. Say it: “f sub x”.
fyf_{y} f sub y.
The partial derivative ∂f/∂y. Say it: “f sub y”.

Tap or click a symbol in a formula to see the same explanation. All symbols: symbols and notation.

Words on this page

Show the 31 words used here

New here

tangent plane.
The flat plane that just touches a surface at a point and tilts the same way as the surface there.
local minimum.
A point where a function is smaller than at every nearby point, though it may be larger than somewhere farther away.
local maximum.
A point where a function is larger than at every nearby point, though it may be smaller than somewhere farther away.
Moore's law.
The observation that the number of transistors on a computer chip doubled about every two years, a growth that is exponential.
least squares.
A way to fit a line or curve to data: choose it to make the sum of the squared misses between data and prediction smallest.

Also used

partial derivative.
The rate of change of a function of several variables with respect to one of them, while all the others are held fixed. Explained in Functions of two variables and partial derivatives.
p..
Page, in a reference to a source; pp. means pages, as in pp. 3–5.
derivative.
The rate at which a function changes as its input changes: the slope of its graph at a point. Explained in Position and velocity in one dimension.
tangent.
A straight line that touches a curve at a point and runs in the same direction as the curve there. Explained in Angles, radians and trigonometry.
graph.
The picture of a function: the curve y = f(x) for one variable, or the surface z = f(x, y) for two. Explained in Graphs, straight lines and slope.
cross product.
A way of multiplying two vectors that gives a third vector, at right angles to both, as long as the area of their parallelogram. Explained in Torque and the cross product.
vector.
A quantity with both a size and a direction, such as a velocity or a force, drawn as an arrow. Explained in Vectors.
normal vector.
A vector at right angles to a plane or surface; it fixes which way the plane faces. Explained in Planes through three points, and matrices.
critical point.
A point where a function's derivative is zero, so its graph is level there; maxima and minima are found among such points. Explained in Curve sketching with the first and second derivative.
saddle point.
A point where a surface rises in some directions and falls in others, like the middle of a horse's saddle or a mountain pass. Explained in Functions of two variables and partial derivatives.
completing the square.
Rewriting x² + bx + c as (x + b/2)² plus a number, which turns any quadratic into a shifted square. Explained in Inverse substitution and completing the square.
best-fit line.
The straight line that passes as close as possible to a set of data points, usually chosen by least squares. Explained in Graphs, straight lines and slope.
perpendicular.
At right angles to a line, a surface or another direction. Explained in Inclined planes.
weight.
How much one value counts in a weighted average or sum, compared with the others. Explained in Average value, weighted averages and probability.
chain rule.
The rule for the derivative of a function of a function: multiply the derivative of the outer one by that of the inner one. Explained in Circular motion: polar coordinates, position and velocity.
linear.
Of a relation or equation: using only first powers of the unknowns, so doubling the cause doubles the effect and effects simply add. Explained in Solving and rearranging formulas.
Hubble's law.
The rule that galaxies move away from us with speeds proportional to their distances: twice as far, twice as fast. Explained in Towards the universe: from atoms to the observable universe.
Hubble constant.
Today's expansion rate of the universe: how much faster a galaxy recedes for each extra unit of distance, in km/s per megaparsec. Explained in Towards the universe: redshift, stretched light from moving sources.
velocity.
How fast and in which direction something moves: a vector whose length is the speed and whose direction is the direction of motion. Explained in Velocity, acceleration and Kepler's second law.
galaxy.
A huge system of stars, gas and dust, from thousands to over a trillion stars, held together by gravity inside a dark matter halo. Explained in Towards the universe: weighing the Sun and the Galaxy with orbits.

Academic

approximation.
Close to, but not exactly, the true value; an approximation is such a value or formula, chosen because it is simpler.
transcript.
A written record of exactly what was said in a recorded lecture, word for word.
to first order.
Keeping terms only up to a stated power of a small quantity: to first order keeps the first power and drops squares and higher powers.
counterpart.
Something that plays the same role in another setting.
error.
The difference between a measured or computed value and the true one; often how large that difference may be.
homogeneous.
The same at every place.

Tap or click a word, here or in the text, for its meaning in this lesson. All words: the glossary. How many words are marked in the text: Reading options (the “Aa” button).

Where this leads

In cosmology

32 more cosmology pages that build on this

Pages that build on this

Practise

Check your understanding

  1. If fx=3f_x = 3 and fy=−2f_y = -2 at a point, and xx increases by 0.1 while yy increases by 0.2, ff changes by about…
  2. A critical point of f(x,y)f(x, y) is a point where…
  3. In the least-squares fit of y=ax+by = ax + b to data points (xi,yi)(x_i, y_i), the unknowns are…
  4. To fit y=ceaxy = ce^{ax} by least squares, the lecture suggests…
0 of 4 answered

Flashcards

1 / 3