Mathematics · Book 3 · Bachelor Year 1

University Mathematics — Year 1

University Mathematics — Year 1 · Bachelor Year 1

25Functions of Two Variables

The year ends with a first walk into higher dimension: functions f(x,y)f(x, y) of two real variables. Everything generalizes — limits, continuity, derivatives, extrema — but each notion gains a twist: limits can be approached along every direction at once, derivatives split into partials, and the gradient points the way uphill. The full theory (differentials, general Rn\R^n, submanifolds) belongs to the second year; here we set the vocabulary and the first honest theorems.

25.1 The plane R2\R^2; continuity

Definition 25.1

On R2\R^2, use the Euclidean norm ∥(x,y)∥=x2+y2\norm{(x,y)} = \sqrt{x^2 + y^2} (Chapter 23). Open balls, neighborhoods, open subsets of R2\R^2 are defined exactly as in Chapter 12, with balls in place of intervals. A function f ⁣:U→Rf \colon U \to \R (U⊆R2U \subseteq \R^2 open) is continuous at a∈Ua \in U when

∀ε>0, ∃δ>0,∥X−a∥≤δ  ⟹  ∣f(X)−f(a)∣≤ε,\forall\varepsilon > 0,\ \exists\delta > 0, \quad \norm{X - a} \leq \delta \implies \abs{f(X) - f(a)} \leq \varepsilon,

with the same sequential characterization as in one variable. Sums, products, quotients and compositions with continuous one-variable functions preserve continuity; the coordinate maps are continuous, hence so are polynomials in (x,y)(x,y).

Example 25.2 (The polar bound, the clean way to prove a limit)

Show that f(x,y)=x2y2x2+y2f(x, y) = \dfrac{x^2y^2}{x^2 + y^2} (with f(0,0)=0f(0,0) = 0) is continuous at the origin. In polar coordinates x=ρcos⁡θx = \rho\cos\theta, y=ρsin⁡θy = \rho\sin\theta:

∣f∣=ρ4cos⁡2θsin⁡2θρ2=ρ2 (cos⁡θsin⁡θ)2≤ρ24→ρ→00,\abs{f} = \frac{\rho^4\cos^2\theta\sin^2\theta}{\rho^2} = \rho^2\,(\cos\theta\sin\theta)^2 \leq \frac{\rho^2}{4} \xrightarrow[\rho \to 0]{} 0 ,

a bound independent of θ\theta: whatever the direction of approach, the values are squeezed to 00. That uniformity in θ\theta is the whole point — a bound like ∣g∣=∣cos⁡θsin⁡θ∣\abs g = \abs{\cos\theta\sin\theta} (no ρ\rho left) proves nothing, and indeed that gg is the discontinuous radial trap of the next example.

Example 25.3 (The radial trap)

Let f(x,y)=xyx2+y2f(x, y) = \dfrac{xy}{x^2 + y^2} for (x,y)≠(0,0)(x,y) \neq (0,0), f(0,0)=0f(0, 0) = 0. Along each axis, f=0→0f = 0 \to 0; but along the diagonal y=xy = x, f(x,x)=12↛0f(x, x) = \frac12 \not\to 0. No limit at the origin: approaching along every line, and even finding the same limit along each, is not enough (here the line limits disagree; worse examples agree along all lines yet fail along a parabola, Exercise 25.3). Continuity in each variable separately does not imply continuity.

25.2 Partial derivatives

Definition 25.4

The partial derivatives of ff at (a,b)(a, b) are the one-variable derivatives along the axes:

∂f∂x(a,b)=lim⁡h→0f(a+h,b)−f(a,b)h,∂f∂y(a,b)=lim⁡k→0f(a,b+k)−f(a,b)k.\frac{\partial f}{\partial x}(a,b) = \lim_{h \to 0} \frac{f(a + h, b) - f(a,b)}{h}, \qquad \frac{\partial f}{\partial y}(a,b) = \lim_{k \to 0} \frac{f(a, b + k) - f(a,b)}{k}.

ff is of class C1C^1 on UU when both exist and are continuous on UU. The gradient is ∇f(a,b)=(∂f∂x, ∂f∂y)(a,b)\nabla f(a,b) = \bigl(\frac{\partial f}{\partial x},\, \frac{\partial f}{\partial y}\bigr)(a,b).

Theorem 25.5 (C1C^1 implies a tangent plane)

Let ff be C1C^1 on UU and (a,b)∈U(a,b) \in U. Then, as (h,k)→(0,0)(h, k) \to (0,0):

f(a+h,b+k)=f(a,b)+h ∂f∂x(a,b)+k ∂f∂y(a,b)+o(∥(h,k)∥).f(a + h, b + k) = f(a, b) + h\,\frac{\partial f}{\partial x}(a,b) + k\,\frac{\partial f}{\partial y}(a,b) + o\bigl(\norm{(h,k)}\bigr) .

In particular ff is continuous, and the graph z=f(x,y)z = f(x,y) has at each point the tangent plane read off the formula.

Example 25.6 (Linear approximation in action)

Estimate f(1.02, 0.99)f(1.02,\ 0.99) for f(x,y)=x3y2f(x, y) = x^3y^2. At (1,1)(1, 1): f=1f = 1, ∂f∂x=3x2y2=3\frac{\partial f}{\partial x} = 3x^2y^2 = 3, ∂f∂y=2x3y=2\frac{\partial f}{\partial y} = 2x^3y = 2, so Theorem 25.5 gives

f(1.02, 0.99)≈1+3 (0.02)+2 (−0.01)=1.04,f(1.02,\ 0.99) \approx 1 + 3\,(0.02) + 2\,(-0.01) = 1.04 ,

against the true value 1.023×0.992=1.04006…1.02^3 \times 0.99^2 = 1.04006\dots — the error is of second order in the increments, as the o(∥(h,k)∥)o(\norm{(h,k)}) promises. The tangent plane to the graph at (1,1,1)(1, 1, 1) is z=1+3(x−1)+2(y−1)z = 1 + 3(x - 1) + 2(y - 1), the equation implicit in the estimate.

Proof. Move one coordinate at a time:

f(a+h,b+k)−f(a,b)=[f(a+h,b+k)−f(a,b+k)]+[f(a,b+k)−f(a,b)].f(a+h, b+k) - f(a,b) = \bigl[f(a+h, b+k) - f(a, b+k)\bigr] + \bigl[f(a, b+k) - f(a,b)\bigr].

By the one-variable mean value theorem (Theorem 14.9), the first bracket is h ∂f∂x(a+θh, b+k)h\, \frac{\partial f}{\partial x}(a + \theta h,\, b + k) for some θ∈(0, 1)\theta \in \intoo{0}{1}, and the second is k ∂f∂y(a, b+θ′k)k\,\frac{\partial f}{\partial y}(a,\, b + \theta' k). Continuity of the partials at (a,b)(a,b) lets us write each as (value at (a,b)(a,b)) ++ (error →0\to 0); the total error is h ε1+k ε2=o(∥(h,k)∥)h\,\varepsilon_1 + k\,\varepsilon_2 = o(\norm{(h,k)}) since ∣h∣,∣k∣≤∥(h,k)∥\abs h, \abs k \leq \norm{(h,k)}. ∎

Theorem 25.7 (Chain rule)

Let ff be C1C^1 on UU and t↦(x(t),y(t))t \mapsto (x(t), y(t)) be C1C^1 from an interval into UU. Then g(t)=f(x(t),y(t))g(t) = f\bigl(x(t), y(t)\bigr) is C1C^1, with

g′(t)=x′(t) ∂f∂x(x(t),y(t))+y′(t) ∂f∂y(x(t),y(t))=⟨∇f, (x′,y′)⟩.g'(t) = x'(t)\,\frac{\partial f}{\partial x}\bigl(x(t),y(t)\bigr) + y'(t)\,\frac{\partial f}{\partial y}\bigl(x(t),y(t)\bigr) = \bigl\langle \nabla f,\ (x', y')\bigr\rangle .

Proof. Apply Theorem 25.5 at (x(t),y(t))(x(t), y(t)) with (h,k)=(x(t+s)−x(t), y(t+s)−y(t))(h, k) = (x(t+s) - x(t),\, y(t+s) - y(t)): as s→0s \to 0, one-variable differentiability gives h=s x′(t)+o(s)h = s\,x'(t) + o(s) and k=s y′(t)+o(s)k = s\,y'(t) + o(s), so ∥(h,k)∥=O(s)\norm{(h, k)} = O(s) and

g(t+s)−g(t)=h ∂f∂x+k ∂f∂y+o(∥(h,k)∥)=s (x′ ∂f∂x+y′ ∂f∂y)+o(s),g(t+s) - g(t) = h\,\frac{\partial f}{\partial x} + k\,\frac{\partial f}{\partial y} + o\bigl(\norm{(h,k)}\bigr) = s\,\Bigl(x'\,\frac{\partial f}{\partial x} + y'\,\frac{\partial f}{\partial y}\Bigr) + o(s) ,

the final error absorbing both the o(s)o(s)’s of hh and kk (multiplied by the fixed values of the partials) and the o(O(s))o(O(s)) of the tangent-plane estimate. Divide by ss and let s→0s \to 0. Continuity of g′g' follows from that of all ingredients. ∎

Example 25.8 (The chain rule, verified both ways)

Let f(x,y)=x2yf(x, y) = x^2 y and g(t)=f(t,t2)g(t) = f(t, t^2). Directly: g(t)=t2⋅t2=t4g(t) = t^2\cdot t^2 = t^4, so g′(t)=4t3g'(t) = 4t^3. By the chain rule: ∂f∂x=2xy\frac{\partial f}{\partial x} = 2xy and ∂f∂y=x2\frac{\partial f}{\partial y} = x^2, evaluated along the curve (t,t2)(t, t^2):

g′(t)=1⋅2t⋅t2+2t⋅t2=2t3+2t3=4t3.g'(t) = 1\cdot 2t\cdot t^2 + 2t\cdot t^2 = 2t^3 + 2t^3 = 4t^3 .

The two computations agree, and the split is meaningful: 2t32t^3 of the growth comes from moving rightward through the xx-slope, 2t32t^3 from moving upward through the yy-slope. On curves where no closed form for gg exists, only the second computation survives — that is the theorem’s point.

Remark 25.9 (Reading the gradient)

Along a unit direction uu, the chain rule on t↦f(a+tu)t \mapsto f(a + tu) gives the directional derivative ⟨∇f(a),u⟩\langle \nabla f(a), u\rangle: maximal when uu points along ∇f(a)\nabla f(a) (by Cauchy–Schwarz, Theorem 23.4). The gradient is the direction of steepest ascent, and it is orthogonal to the level curves {f=c}\{f = c\} (differentiate ff along a curve drawn in a level set: the chain rule gives ⟨∇f, tangent⟩=0\langle\nabla f,\, \text{tangent}\rangle = 0).

Example 25.10 (Level curves and gradients, on one function)

Take f(x,y)=x2−y2f(x, y) = x^2 - y^2. Its level sets: {f=c}\{f = c\} is a hyperbola opening left-right for c>0c > 0, up-down for c<0c < 0, and the crossed pair of lines y=±xy = \pm x for c=0c = 0 — the contour map of a mountain pass, with the saddle point at the origin where the two zero-level lines cross. Gradient: ∇f=(2x,−2y)\nabla f = (2x, -2y). At the point (2,1)(2, 1) (on the level c=3c = 3): ∇f=(4,−2)\nabla f = (4, -2), while the tangent vector of the level curve, parametrized near that point by (t,t2−3)\bigl(t, \sqrt{t^2 - 3}\bigr), is (1,tt2−3)=(1,2)\bigl(1, \frac{t}{\sqrt{t^2 - 3}}\bigr) = (1, 2) at t=2t = 2 — and indeed

⟨(4,−2), (1,2)⟩=4−4=0:\langle (4, -2),\ (1, 2)\rangle = 4 - 4 = 0 :

gradient perpendicular to the contour, pointing toward higher values of ff (here: away from the yy-axis). Two more readings: the gradient vanishes exactly at the saddle, where the contour map pinches; and the tangent line to the level curve at (2,1)(2,1) is 4(x−2)−2(y−1)=04(x - 2) - 2(y - 1) = 0, i.e. 2x−y=32x - y = 3 — the equation “⟨∇f, M−M0⟩=0\langle \nabla f,\ M - M_0\rangle = 0” that generalizes the ellipse tangent of Exercise 24.11.

Theorem 25.11 (Schwarz)

If ff is of class C2C^2 (partials of partials exist and are continuous), then

∂2f∂x ∂y=∂2f∂y ∂x.\frac{\partial^2 f}{\partial x\,\partial y} = \frac{\partial^2 f}{\partial y\,\partial x} .

Proof. Admitted at this level. ∎

25.3 Local extrema

Method 25.12 (Extremum studies, organized)

  1. Solve ∇f=0\nabla f = 0 completely. Factor each partial whenever possible (products of linear factors split the system into transparent cases, as in Example 25.16 below); a forgotten case is a forgotten critical point.
  2. Classify each point with the Monge data r,s,tr, s, t — recomputed at each point, never once for all.
  3. If rt−s2=0rt - s^2 = 0, examine ff directly along well-chosen curves through the point (lines first, then parabolas), hunting either for two signs (no extremum) or for a locked sign with an argument covering all directions.
  4. Step back for the global picture: check the behavior at infinity (a local minimum may be no global one), and if the domain is not open, treat its boundary separately (Exercise 25.12) — the critical point theorem sees interior points only.

Theorem 25.13 (Critical points)

If ff (C1C^1 on the open set UU) has a local extremum at (a,b)∈U(a,b) \in U, then ∇f(a,b)=(0,0)\nabla f(a,b) = (0,0): the point is critical.

Proof. The one-variable functions x↦f(x,b)x \mapsto f(x, b) and y↦f(a,y)y \mapsto f(a, y) have interior local extrema at aa, resp. bb: Proposition 14.7 kills both partials. ∎

Method 25.14 (Second-order test (Monge notation))

At a critical point of a C2C^2 function, set

r=∂2f∂x2,s=∂2f∂x∂y,t=∂2f∂y2(values at the point).r = \frac{\partial^2 f}{\partial x^2}, \qquad s = \frac{\partial^2 f}{\partial x \partial y}, \qquad t = \frac{\partial^2 f}{\partial y^2} \qquad (\text{values at the point}).
  • If rt−s2>0rt - s^2 > 0: local extremum — minimum for r>0r > 0, maximum for r<0r < 0;
  • if rt−s2<0rt - s^2 < 0: no extremum (a saddle point);
  • if rt−s2=0rt - s^2 = 0: the test is silent; examine directly.

(Justification — a Taylor–Young expansion at order 22 and the sign study of the quadratic form rh2+2shk+tk2r h^2 + 2shk + tk^2 — is carried out in the second year; the test is used here as a working tool.)

Example 25.15

f(x,y)=x3+y3−3xyf(x,y) = x^3 + y^3 - 3xy. Critical points: ∇f=(3x2−3y,  3y2−3x)=0\nabla f = (3x^2 - 3y,\; 3y^2 - 3x) = 0 gives y=x2y = x^2 and x=y2x = y^2, so x=x4x = x^4: x∈{0,1}x \in \{0, 1\}: points (0,0)(0,0) and (1,1)(1,1).

Second derivatives: r=6xr = 6x, s=−3s = -3, t=6yt = 6y. At (0,0)(0,0): rt−s2=−9<0rt - s^2 = -9 < 0: saddle. At (1,1)(1,1): rt−s2=36−9>0rt - s^2 = 36 - 9 > 0, r=6>0r = 6 > 0: local minimum, f(1,1)=−1f(1,1) = -1. (Not global: f(x,0)=x3→−∞f(x, 0) = x^3 \to -\infty.)

Example 25.16 (A four-point study, in full)

f(x,y)=xy (3−x−y)=3xy−x2y−xy2f(x, y) = xy\,(3 - x - y) = 3xy - x^2y - xy^2. Gradient:

∂f∂x=y (3−2x−y),∂f∂y=x (3−x−2y).\frac{\partial f}{\partial x} = y\,(3 - 2x - y), \qquad \frac{\partial f}{\partial y} = x\,(3 - x - 2y).

Critical points: if y=0y = 0, the second equation gives x∈{0,3}x \in \{0, 3\}; if x=0x = 0, the first gives y∈{0,3}y \in \{0, 3\}; if xy≠0xy \neq 0, solve 2x+y=32x + y = 3, x+2y=3x + 2y = 3: x=y=1x = y = 1. Four points: (0,0)(0,0), (3,0)(3,0), (0,3)(0,3), (1,1)(1,1). Second derivatives: r=−2yr = -2y, s=3−2x−2ys = 3 - 2x - 2y, t=−2xt = -2x.

  • (1,1)(1,1): r=−2r = -2, s=−1s = -1, t=−2t = -2: rt−s2=3>0rt - s^2 = 3 > 0, r<0r < 0: local maximum, f(1,1)=1f(1,1) = 1.
  • (0,0)(0,0): r=t=0r = t = 0, s=3s = 3: rt−s2=−9<0rt - s^2 = -9 < 0: saddle; likewise (3,0)(3, 0) (s=−3s = -3) and (0,3)(0, 3): three saddles.

The maximum is only local: f(−T,−T)=T2(3+2T)→+∞f(-T, -T) = T^2(3 + 2T) \to +\infty. Symmetry check: f(x,y)=f(y,x)f(x, y) = f(y, x), and indeed the critical set and the classification are symmetric in x↔yx \leftrightarrow y. Interpretation: among rectangles-with-slack x,y≥0x, y \geq 0, x+y≤3x + y \leq 3, the product xy(3−x−y)xy(3 - x - y) of the three “parts” of 33 is largest when the parts are equal — a two-variable shadow of the AM–GM principle.

The two curves f = 0 for f = x3 + y3 - 3xy intersect at the critical points (0,0) (saddle) and (1,1) (local minimum).
The two curves ∇f=0\nabla f = 0 for f=x3+y3−3xyf = x^3 + y^3 - 3xy intersect at the critical points (0,0)(0,0) (saddle) and (1,1)(1,1) (local minimum).

Remark 25.17 (Common pitfalls)

Partial derivatives may exist at a point of discontinuity: the radial trap g(x,y)=xyx2+y2g(x,y) = \frac{xy}{x^2+y^2} of Example 25.3 has ∂g∂x(0,0)=∂g∂y(0,0)=0\frac{\partial g}{\partial x}(0,0) = \frac{\partial g}{\partial y}(0,0) = 0 (both axis restrictions vanish identically), yet gg has no limit at the origin — partials probe two directions only, continuity needs all of them; only the C1C^1 hypothesis restores order (Theorem 25.5). Line limits never suffice: Exercise 25.3’s function has limit 00 along every line and still no limit — always try parabolas (or polar bounds valid uniformly in θ\theta). Critical is necessary, not sufficient: saddles abound (three of four points in Example 25.16); and the theorem holds on open sets only — on a closed disc, extrema may sit on the boundary with nonzero gradient (Exercise 25.12). The silent case rt−s2=0rt - s^2 = 0 is genuinely silent: x4+y4x^4 + y^4 (minimum) and x3+y3x^3 + y^3 (neither) both have r=s=t=0r = s = t = 0 at the origin; only a direct sign study decides (Exercise 25.6, function hh). The gradient is orthogonal to level curves, not along them: to follow a contour line, move perpendicular to ∇f\nabla f; to climb fastest, move along it — mixing the two reverses the geometry of every contour map.

Remark 25.18 (Where two variables lead)

This chapter is a doorway. The gradient and the chain rule extend verbatim to nn variables in the Year 2 volume, where the o(∥(h,k)∥)o(\norm{(h,k)}) of Theorem 25.5 becomes the differential and the Monge test is proved in full via the order-two Taylor formula and quadratic forms. The special case that can be settled this year — quadratic functions, for which the second-order expansion is exact — is the subject of the weekend problem, and it happens to be the case that runs the world’s data fitting: least squares regression. Constrained extrema (Exercise 25.5 was a preview) become Lagrange multipliers in Year 2; harmonic functions (Exercise 25.7) return in the complex analysis of the Year 3 volume.

Remark 25.19 (Perspectives inside Book 3: the year, closed)

This chapter is where the volume’s two halves shake hands. The analysis half supplied its tools one derivative at a time: the mean value theorem drives Theorem 25.5, Taylor expansions drive the extremum tests, and the ε\varepsilon’s of Chapter 12 came back with balls instead of intervals. The algebra half supplied the geometry: the gradient is read through the inner product of Chapter 23 (Cauchy–Schwarz makes it the steepest direction), the Monge data (r,s,t)(r, s, t) is a symmetric matrix of Chapter 21 with the determinant test of Chapter 22, and the weekend problem runs orthogonal projection on data vectors. Even the curves of Chapter 24 return as level sets. A reader who can reconstruct why each of these five hand-offs works has, in effect, revised the entire year — which is the real purpose of this final chapter.

Least squares in one picture: four data points, the regression line y = 1.4x - 0.1, and the vertical residuals (dashed) whose squares the line minimizes — total 0.2, the smallest achievable. The weekend problem computes this line, proves it is the unique minimizer, and identifies the whole construction with an orthogonal projection in ℝ4.
Least squares in one picture: four data points, the regression line y=1.4x−0.1y = 1.4x - 0.1, and the vertical residuals (dashed) whose squares the line minimizes — total 0.20.2, the smallest achievable. The weekend problem computes this line, proves it is the unique minimizer, and identifies the whole construction with an orthogonal projection in R4\R^4.

25.4 Exercises

Exercise 25.1 ★

Compute the partial derivatives: f(x,y)=x2y+exyf(x,y) = x^2 y + \eu^{xy};   g(x,y)=ln⁡(x2+y2)\;g(x,y) = \ln(x^2 + y^2) (on R2∖{0}\R^2\setminus\{0\});   h(x,y)=arctan⁡yx\;h(x,y) = \arctan\frac yx (on x>0x > 0).

Solution

Solution of Exercise 25.1.

∂f∂x=2xy+y exy\dfrac{\partial f}{\partial x} = 2xy + y\,\eu^{xy}, ∂f∂y=x2+x exy\dfrac{\partial f}{\partial y} = x^2 + x\,\eu^{xy}.

∂g∂x=2xx2+y2\dfrac{\partial g}{\partial x} = \dfrac{2x}{x^2+y^2}, ∂g∂y=2yx2+y2\dfrac{\partial g}{\partial y} = \dfrac{2y}{x^2+y^2}.

∂h∂x=−y/x21+y2/x2=−yx2+y2\dfrac{\partial h}{\partial x} = \dfrac{-y/x^2}{1 + y^2/x^2} = \dfrac{-y}{x^2+y^2}, ∂h∂y=xx2+y2\dfrac{\partial h}{\partial y} = \dfrac{x}{x^2+y^2}.

Exercise 25.2 ★

Study the continuity at (0,0)(0,0) (with value 00 there) of:

f(x,y)=x2yx2+y2,g(x,y)=xyx2+y2,h(x,y)=x3+y3x2+y2.f(x,y) = \frac{x^2 y}{x^2 + y^2}, \qquad g(x,y) = \frac{xy}{x^2 + y^2}, \qquad h(x,y) = \frac{x^3 + y^3}{x^2 + y^2}.

(Polar coordinates x=ρcos⁡θx = \rho\cos\theta, y=ρsin⁡θy = \rho\sin\theta help: bound by a function of ρ\rho alone when possible.)

Solution

Solution of Exercise 25.2.

In polar coordinates (ρ→0\rho \to 0):

∣f∣=ρ3∣cos⁡2θsin⁡θ∣ρ2≤ρ→0\abs{f} = \dfrac{\rho^3\abs{\cos^2\theta\sin\theta}}{\rho^2} \leq \rho \to 0: continuous.

g=cos⁡θsin⁡θg = \cos\theta\sin\theta: independent of ρ\rho, taking different values along different rays (cf. Example 25.3): no limit, not continuous.

∣h∣≤ρ3(∣cos⁡3θ∣+∣sin⁡3θ∣)ρ2≤2ρ→0\abs h \leq \dfrac{\rho^3(\abs{\cos^3\theta} + \abs{\sin^3\theta})}{\rho^2} \leq 2\rho \to 0: continuous.

Exercise 25.3 ★★

Let f(x,y)=x2yx4+y2f(x,y) = \dfrac{x^2 y}{x^4 + y^2} (f(0,0)=0f(0,0) = 0). Prove that ff has limit 00 at the origin along every straight line, but that f(x,x2)=12f\bigl(x, x^2\bigr) = \frac12: ff is not continuous at (0,0)(0,0).

Solution

Solution of Exercise 25.3.

Along y=mxy = mx: f(x,mx)=mx3x4+m2x2=mxx2+m2→0f(x, mx) = \dfrac{m x^3}{x^4 + m^2 x^2} = \dfrac{mx}{x^2 + m^2} \to 0 (for m≠0m \neq 0; along y=0y = 0 and the yy-axis, f=0f = 0). So every straight-line limit is 00. But on the parabola y=x2y = x^2:

f(x,x2)=x4x4+x4=12:f(x, x^2) = \frac{x^4}{x^4 + x^4} = \frac12 :

the sequence (1n,1n2)→(0,0)\bigl(\frac1n, \frac{1}{n^2}\bigr) \to (0,0) has f→12≠0f \to \frac12 \neq 0. Not continuous: lines do not suffice to test two-variable limits.

Exercise 25.4 ★

Verify Schwarz’s theorem by hand on f(x,y)=x3y2+sin⁡(xy)f(x, y) = x^3 y^2 + \sin(xy).

Solution

Solution of Exercise 25.4.

∂f∂x=3x2y2+ycos⁡(xy)\frac{\partial f}{\partial x} = 3x^2y^2 + y\cos(xy); then

∂2f∂y ∂x=6x2y+cos⁡(xy)−xysin⁡(xy).\frac{\partial^2 f}{\partial y\,\partial x} = 6x^2 y + \cos(xy) - xy\sin(xy) .

∂f∂y=2x3y+xcos⁡(xy)\frac{\partial f}{\partial y} = 2x^3 y + x\cos(xy); then

∂2f∂x ∂y=6x2y+cos⁡(xy)−xysin⁡(xy):\frac{\partial^2 f}{\partial x\,\partial y} = 6x^2 y + \cos(xy) - xy\sin(xy) :

equal, as Schwarz promises.

Exercise 25.5 ★★

Let ff be C1C^1 on R2\R^2 and g(t)=f(cos⁡t,sin⁡t)g(t) = f(\cos t, \sin t). Express g′(t)g'(t) via the chain rule. Deduce that ff restricted to the unit circle attains extrema at points where ∇f\nabla f is parallel to the radius vector.

Solution

Solution of Exercise 25.5.

By Theorem 25.7 with (x,y)=(cos⁡t,sin⁡t)(x, y) = (\cos t, \sin t):

g′(t)=−sin⁡t ∂f∂x(cos⁡t,sin⁡t)+cos⁡t ∂f∂y(cos⁡t,sin⁡t)=⟨∇f, (−sin⁡t,cos⁡t)⟩.g'(t) = -\sin t\,\frac{\partial f}{\partial x}(\cos t, \sin t) + \cos t\,\frac{\partial f}{\partial y}(\cos t, \sin t) = \bigl\langle \nabla f,\ (-\sin t, \cos t)\bigr\rangle .

At an extremum of gg, g′(t)=0g'(t) = 0: ∇f\nabla f is orthogonal to the tangent vector (−sin⁡t,cos⁡t)(-\sin t, \cos t) of the circle, hence parallel to the radius vector (cos⁡t,sin⁡t)(\cos t, \sin t) (the plane orthogonal complement of a unit vector is the line it spans, taken perpendicular). This is the simplest instance of a Lagrange multiplier.

Exercise 25.6 ★★

Find and classify the critical points of:

f(x,y)=x2+xy+y2−3x,g(x,y)=x2−y2+4y,h(x,y)=x4+y4−2(x−y)2.f(x, y) = x^2 + xy + y^2 - 3x, \qquad g(x, y) = x^2 - y^2 + 4y, \qquad h(x, y) = x^4 + y^4 - 2(x - y)^2 .

(For hh, the determinant test is silent at the origin: examine h(x,x)h(x, x) and h(x,−x)h(x, -x).)

Solution

Solution of Exercise 25.6.

ff: ∇f=(2x+y−3,  x+2y)=0\nabla f = (2x + y - 3,\; x + 2y) = 0: y=−x2y = -\frac x2 and 2x−x2=32x - \frac x2 = 3: x=2x = 2, y=−1y = -1. Second order: r=2r = 2, s=1s = 1, t=2t = 2: rt−s2=3>0rt - s^2 = 3 > 0, r>0r > 0: local (indeed global — quadratic) minimum at (2,−1)(2, -1), value f(2,−1)=−3f(2,-1) = -3.

gg: ∇g=(2x,  −2y+4)=0\nabla g = (2x,\; -2y + 4) = 0: point (0,2)(0, 2); r=2r = 2, s=0s = 0, t=−2t = -2: rt−s2=−4<0rt - s^2 = -4 < 0: saddle.

hh: ∇h=(4x3−4(x−y),  4y3+4(x−y))=0\nabla h = \bigl(4x^3 - 4(x - y),\; 4y^3 + 4(x-y)\bigr) = 0. Adding: x3+y3=0x^3 + y^3 = 0, so y=−xy = -x; substituting: 4x3−8x=04x^3 - 8x = 0: x∈{0,±2}x \in \{0, \pm\sqrt2\}. Critical points: (0,0)(0,0), (2,−2)(\sqrt2, -\sqrt2), (−2,2)(-\sqrt2, \sqrt2). At (±2,∓2)(\pm\sqrt2, \mp\sqrt2): r=12x2−4=20r = 12x^2 - 4 = 20, s=4s = 4, t=20t = 20: rt−s2>0rt - s^2 > 0, r>0r > 0: local minima (value h=4+4−16=−8h = 4 + 4 - 16 = -8). At (0,0)(0,0): r=t=−4r = t = -4, s=4s = 4: rt−s2=0rt - s^2 = 0: silent. Examine: h(x,x)=2x4>0h(x, x) = 2x^4 > 0 and h(x,−x)=2x4−8x2<0h(x, -x) = 2x^4 - 8x^2 < 0 for small x≠0x \neq 0: both signs in every neighborhood — no extremum at the origin.

Exercise 25.7 ★★

A function ff is harmonic when ∂2f∂x2+∂2f∂y2=0\frac{\partial^2 f}{\partial x^2} + \frac{\partial^2 f}{\partial y^2} = 0. Check that x2−y2x^2 - y^2, xyxy, excos⁡y\eu^x\cos y and ln⁡(x2+y2)\ln(x^2 + y^2) (off the origin) are harmonic.

Solution

Solution of Exercise 25.7.

x2−y2x^2 - y^2: second partials 22 and −2-2: sum 00. xyxy: both pure second partials vanish. excos⁡y\eu^x\cos y: ∂2∂x2=excos⁡y\frac{\partial^2}{\partial x^2} = \eu^x\cos y, ∂2∂y2=−excos⁡y\frac{\partial^2}{\partial y^2} = -\eu^x\cos y: sum 00. ln⁡(x2+y2)\ln(x^2+y^2): from Exercise 25.1,

∂2∂x2ln⁡(x2+y2)=2(x2+y2)−4x2(x2+y2)2=2(y2−x2)(x2+y2)2,\frac{\partial^2}{\partial x^2}\ln(x^2+y^2) = \frac{2(x^2+y^2) - 4x^2}{(x^2+y^2)^2} = \frac{2(y^2 - x^2)}{(x^2+y^2)^2},

and the yy-version is its opposite: sum 00.

Exercise 25.8 ★★★

Find the point of the plane {x+2y−z=4}⊆R3\{x + 2y - z = 4\} \subseteq \R^3 closest to the origin, two ways: by orthogonal projection (Chapter 23), and by minimizing the two-variable function f(x,y)=x2+y2+(x+2y−4)2f(x, y) = x^2 + y^2 + (x + 2y - 4)^2 obtained by eliminating zz.

Solution

Solution of Exercise 25.8.

Projection: the plane PP has normal n=(1,2,−1)n = (1, 2, -1) and passes through A=(4,0,0)A = (4, 0, 0). The closest point to the origin is OO projected: p=O+⟨A−O,n⟩∥n∥2 n=46(1,2,−1)=(23,43,−23)p = O + \frac{\langle A - O, n\rangle}{\norm n^2}\,n = \frac{4}{6}(1,2,-1) = \bigl(\frac23, \frac43, -\frac23\bigr), at distance 46\frac{4}{\sqrt 6}. (Formula: distance from origin to plane ⟨X,n⟩=c\langle X, n \rangle = c is ∣c∣∥n∥\frac{\abs c}{\norm n} with c=4c = 4.)

Minimization: f(x,y)=x2+y2+(x+2y−4)2f(x,y) = x^2 + y^2 + (x + 2y - 4)^2. Writing w=x+2y−4w = x + 2y - 4 for the last factor:

∇f=(2x+2w,  2y+4w)=0  ⟺  x=−w and y=−2w.\nabla f = \bigl(2x + 2w,\; 2y + 4w\bigr) = 0 \iff x = -w \text{ and } y = -2w .

Substituting into the definition of ww: w=−w−4w−4w = -w - 4w - 4, so w=−23w = -\frac23, giving x=23x = \frac23, y=43y = \frac43, and z=w=−23z = w = -\frac23. Same point as by projection, at distance 49+169+49=263=46\sqrt{\frac49 + \frac{16}{9} + \frac49} = \frac{2\sqrt 6}{3} = \frac{4}{\sqrt6}; it is a minimum since f→∞f \to \infty at infinity (a positive-definite quadratic plus linear terms).

Exercise 25.9 ★★★

(Laplacian in polar coordinates, first contact) Let ff be C2C^2 on R2∖{0}\R^2 \setminus \{0\} and radial: f(x,y)=φ(x2+y2)f(x, y) = \varphi\bigl(\sqrt{x^2+y^2}\bigr) with φ\varphi of class C2C^2 on (0, +∞)\intoo{0}{+\infty}. Prove that

∂2f∂x2+∂2f∂y2=φ′′(ρ)+φ′(ρ)ρ,ρ=x2+y2,\frac{\partial^2 f}{\partial x^2} + \frac{\partial^2 f}{\partial y^2} = \varphi''(\rho) + \frac{\varphi'(\rho)}{\rho}, \qquad \rho = \sqrt{x^2 + y^2},

and find all radial harmonic functions on the punctured plane.

Solution

Solution of Exercise 25.9.

With ρ=x2+y2\rho = \sqrt{x^2+y^2}: ∂ρ∂x=xρ\frac{\partial \rho}{\partial x} = \frac{x}{\rho}, so

∂f∂x=φ′(ρ) xρ,∂2f∂x2=φ′′(ρ) x2ρ2+φ′(ρ) (1ρ−x2ρ3),\frac{\partial f}{\partial x} = \varphi'(\rho)\,\frac{x}{\rho}, \qquad \frac{\partial^2 f}{\partial x^2} = \varphi''(\rho)\,\frac{x^2}{\rho^2} + \varphi'(\rho)\,\Bigl(\frac{1}{\rho} - \frac{x^2}{\rho^3}\Bigr),

(quotient and chain rules). Adding the symmetric yy-expression: the φ′′\varphi'' terms collect x2+y2ρ2=1\frac{x^2 + y^2}{\rho^2} = 1, the φ′\varphi' terms collect 2ρ−x2+y2ρ3=1ρ\frac{2}{\rho} - \frac{x^2 + y^2}{\rho^3} = \frac{1}{\rho}:

Δf=φ′′+φ′ρ.\Delta f = \varphi'' + \frac{\varphi'}{\rho} .

Radial harmonic: solve φ′′+φ′ρ=0\varphi'' + \frac{\varphi'}{\rho} = 0: the first-order equation u′+uρ=0u' + \frac u\rho = 0 for u=φ′u = \varphi' gives u=cρu = \frac{c}{\rho} (Theorem 5.2), then φ=cln⁡ρ+d\varphi = c\ln\rho + d. The radial harmonic functions are c ln⁡x2+y2+dc\,\ln\sqrt{x^2 + y^2} + d — the logarithmic potential of Exercise 25.7 and the constants, nothing else.

Exercise 25.10 ★★

Give the equation of the tangent plane to the graph z=xyz = xy at the point (1,1,1)(1, 1, 1). Then find all points of the graph of f(x,y)=x3+y3−3xyf(x,y) = x^3 + y^3 - 3xy where the tangent plane is horizontal, and relate the answer to Example 25.15.

Solution

Solution of Exercise 25.10.

For z=xyz = xy at (1,1)(1,1): partials y=1y = 1 and x=1x = 1, tangent plane z=1+(x−1)+(y−1)=x+y−1z = 1 + (x - 1) + (y - 1) = x + y - 1. Horizontal tangent plane means both partials vanish, i.e. ∇f=0\nabla f = 0: by Example 25.15, exactly the critical points (0,0)(0, 0) and (1,1)(1, 1), with horizontal planes z=0z = 0 and z=−1z = -1. “Horizontal tangent plane” and “critical point” are the same notion, seen on the graph and in the formula.

Exercise 25.11 ★★

Let ff be C1C^1 on R2\R^2.

  1. If ∂f∂x=0\frac{\partial f}{\partial x} = 0 everywhere, prove that f(x,y)f(x, y) depends only on yy.
  2. Find all C1C^1 solutions of the equation ∂f∂x=∂f∂y\frac{\partial f}{\partial x} = \frac{\partial f}{\partial y} on R2\R^2. (Set g(u,v)=f(u+v2,u−v2)g(u, v) = f\bigl(\frac{u+v}2, \frac{u-v}2\bigr) and compute ∂g∂v\frac{\partial g}{\partial v} by the chain rule.)
Solution

Solution of Exercise 25.11.

  1. For fixed yy, the one-variable function x↦f(x,y)x \mapsto f(x,y) has zero derivative on R\R, hence is constant (Theorem 14.9): f(x,y)=f(0,y)f(x, y) = f(0, y) for all xx: ff depends only on yy.
  2. Let g(u,v)=f(u+v2,u−v2)g(u, v) = f\bigl(\frac{u+v}2, \frac{u-v}2\bigr). By the chain rule (Theorem 25.7, applied in the variable vv with uu frozen):

    ∂g∂v=12 ∂f∂x−12 ∂f∂y=0.\frac{\partial g}{\partial v} = \frac12\,\frac{\partial f}{\partial x} - \frac12\,\frac{\partial f}{\partial y} = 0 .

    By (1), gg depends only on uu: g(u,v)=φ(u)g(u, v) = \varphi(u) with φ\varphi of class C1C^1, and reversing the change of variables (u=x+yu = x + y, v=x−yv = x - y),

    f(x,y)=φ(x+y).f(x, y) = \varphi(x + y).

    Conversely every such ff satisfies fx=fy=φ′f_x = f_y = \varphi': the solutions are exactly the C1C^1 functions of x+yx + y.

Exercise 25.12 ★★★

Find the global maximum and minimum of f(x,y)=xyf(x, y) = xy on the closed disc x2+y2≤1x^2 + y^2 \leq 1. (Admit the two-variable extreme value theorem: a continuous function on the closed disc attains its bounds — proved in the Year 2 volume. Treat the open disc by critical points and the boundary circle by the parametrization of Exercise 25.5.)

Solution

Solution of Exercise 25.12.

On the open disc, an extremum would be critical: ∇f=(y,x)=0\nabla f = (y, x) = 0 only at (0,0)(0,0), where f=0f = 0; it is a saddle (f(±ε,±ε)=ε2>0>−ε2=f(±ε,∓ε)f(\pm \varepsilon, \pm\varepsilon) = \varepsilon^2 > 0 > -\varepsilon^2 = f(\pm\varepsilon, \mp\varepsilon)), so no extremum there. By the admitted extreme value theorem the bounds are attained, necessarily on the boundary circle. There, with Exercise 25.5,

f(cos⁡t,sin⁡t)=cos⁡tsin⁡t=sin⁡2t2∈[−12, 12],f(\cos t, \sin t) = \cos t\sin t = \frac{\sin 2t}{2} \in \intcc{-\tfrac12}{\tfrac12},

with maximum 12\frac12 at t=π4,5π4t = \frac\pi4, \frac{5\pi}4 (points ±12(1,1)\pm\frac{1}{\sqrt2}(1,1)) and minimum −12-\frac12 at t=3π4,7π4t = \frac{3\pi}4, \frac{7\pi}4 (points ±12(1,−1)\pm\frac{1}{\sqrt2}(1,-1)). Global maximum 12\frac12, global minimum −12-\frac12.

25.5 Problem: least squares and the regression line

Problem 25.1

Given nn data points, which straight line passes “closest” to all of them? Legendre and Gauss answered: the line minimizing the sum of the squared vertical errors — because that minimization is exactly solvable by linear algebra. This problem first proves the Monge test of Method 25.14 honestly for quadratic functions (the one case where the second-order expansion is exact), then builds the normal equations, the regression line, and the correlation coefficient on top of the Euclidean geometry of Chapter 23.

Part I — Quadratic functions: the Monge test, proved. Fix reals r,s,tr, s, t and let q(h,k)=rh2+2shk+tk2q(h, k) = r h^2 + 2s hk + t k^2.

  1. Suppose r≠0r \neq 0. Establish the completed-square form

    q(h,k)=r(h+srk) ⁣2+rt−s2r k2,q(h, k) = r\Bigl(h + \frac{s}{r}k\Bigr)^{\!2} + \frac{rt - s^2}{r}\,k^2 ,

    and deduce: if rt−s2>0rt - s^2 > 0, qq has the strict sign of rr off the origin; if rt−s2<0rt - s^2 < 0, qq takes both signs.

  2. Settle the remaining cases: r=0r = 0, t≠0t \neq 0 (symmetric); and r=t=0r = t = 0 (q=2shkq = 2shk). Conclude: qq takes both signs iff rt−s2<0rt - s^2 < 0, and qq vanishes only at the origin iff rt−s2>0rt - s^2 > 0.
  3. Let now f(x,y)=12(rx2+2sxy+ty2)+βx+γy+δf(x, y) = \frac12\bigl(r x^2 + 2s xy + t y^2\bigr) + \beta x + \gamma y + \delta be a quadratic function with a critical point X0=(a,b)X_0 = (a, b). Prove the exact expansion

    f(X0+(h,k))=f(X0)+12 q(h,k)(no remainder),f(X_0 + (h,k)) = f(X_0) + \tfrac12\,q(h, k) \qquad (\text{no remainder}),

    and deduce the Monge classification for quadratic functions: strict global minimum if rt−s2>0rt - s^2 > 0, r>0r > 0; strict global maximum if rt−s2>0rt - s^2 > 0, r<0r < 0; saddle if rt−s2<0rt - s^2 < 0.

  4. Suppose rt−s2>0rt - s^2 > 0 and r>0r > 0 (so also t>0t > 0). Prove the explicit coercivity bound

    q(h,k)≥c (h2+k2),c=rt−s2r+t>0.q(h, k) \geq c\,(h^2 + k^2), \qquad c = \frac{rt - s^2}{r + t} > 0 .

    (Show that the quadratic form q−c(h2+k2)q - c(h^2 + k^2), with coefficients r−cr - c, ss, t−ct - c, still has nonnegative discriminant-test data.)

  5. Deduce that a quadratic function with positive definite quadratic part tends to +∞+\infty as ∥(x,y)∥→∞\norm{(x,y)} \to \infty, and therefore has a unique global minimizer: its critical point. Contrast with Example 25.15, where a local minimum of a nonquadratic function was not global.

Part II — The normal equations. Let C1,C2,b∈RnC_1, C_2, b \in \R^n (canonical inner product), and

f(u,v)=∥u C1+v C2−b∥2.f(u, v) = \norm{u\,C_1 + v\,C_2 - b}^2 .
  1. Expand ff and show it is a quadratic function of (u,v)(u, v) with quadratic-part coefficients r=2∥C1∥2r = 2\norm{C_1}^2, s=2⟨C1,C2⟩s = 2\langle C_1, C_2\rangle, t=2∥C2∥2t = 2\norm{C_2}^2.
  2. Show that rt−s2>0rt - s^2 > 0 if and only if (C1,C2)(C_1, C_2) is free (the equality case of Cauchy–Schwarz, Theorem 23.4); assume this from now on.
  3. Show that the critical equations ∇f=0\nabla f = 0 are the normal equations

    (∥C1∥2⟨C1,C2⟩⟨C1,C2⟩∥C2∥2)(uv)=(⟨C1,b⟩⟨C2,b⟩)\begin{pmatrix} \norm{C_1}^2 & \langle C_1, C_2\rangle\\ \langle C_1, C_2\rangle & \norm{C_2}^2 \end{pmatrix} \begin{pmatrix} u\\ v\end{pmatrix} = \begin{pmatrix} \langle C_1, b\rangle\\ \langle C_2, b\rangle\end{pmatrix}

    — the Gram matrix of Exercise 23.11 on the left — and that they say exactly: b−(uC1+vC2)⊥C1,C2b - (uC_1 + vC_2) \perp C_1, C_2. Conclude with Part I and Theorem 23.10: the unique minimizer gives p=uC1+vC2=p = uC_1 + vC_2 = the orthogonal projection of bb onto Vect⁡(C1,C2)\operatorname{Vect}(C_1, C_2).

  4. Show that the minimal value is ∥b∥2−⟨p,b⟩=∥b−p∥2\norm{b}^2 - \langle p, b\rangle = \norm{b - p}^2, and draw the Pythagorean picture.

Part III — The regression line. Data points (x1,y1),…,(xn,yn)(x_1, y_1), \dots, (x_n, y_n), not all xix_i equal. Minimize

E(α,β)=∑i=1n(yi−α−βxi)2.E(\alpha, \beta) = \sum_{i=1}^{n}\bigl(y_i - \alpha - \beta x_i\bigr)^2 .

Write xˉ=1n∑xi\bar x = \frac1n\sum x_i, yˉ=1n∑yi\bar y = \frac1n\sum y_i, vx=1n∑xi2−xˉ2v_x = \frac1n\sum x_i^2 - \bar x^2, vy=1n∑yi2−yˉ2v_y = \frac1n\sum y_i^2 - \bar y^2, cxy=1n∑xiyi−xˉyˉc_{xy} = \frac1n\sum x_i y_i - \bar x\bar y.

  1. Recognize Part II with C1=(1,…,1)C_1 = (1, \dots, 1), C2=(x1,…,xn)C_2 = (x_1, \dots, x_n), b=(y1,…,yn)b = (y_1, \dots, y_n), and write the normal equations

    nα+(∑xi)β=∑yi,(∑xi)α+(∑xi2)β=∑xiyi.n\alpha + \Bigl(\sum x_i\Bigr)\beta = \sum y_i, \qquad \Bigl(\sum x_i\Bigr)\alpha + \Bigl(\sum x_i^2\Bigr)\beta = \sum x_i y_i .
  2. Solve them:

    β=cxyvx,α=yˉ−β xˉ,\beta = \frac{c_{xy}}{v_x}, \qquad \alpha = \bar y - \beta\,\bar x ,

    and observe that the regression line y=α+βxy = \alpha + \beta x passes through the mean point (xˉ,yˉ)(\bar x, \bar y).

  3. Check vx>0v_x > 0 exactly when the xix_i are not all equal, and match this with question 7.
  4. Prove that the minimal error is

    Emin⁡=n(vy−cxy2vx)=n vy (1−ρ2),ρ=cxyvxvy(vy≠0).E_{\min} = n\Bigl(v_y - \frac{c_{xy}^2}{v_x}\Bigr) = n\,v_y\,(1 - \rho^2), \qquad \rho = \frac{c_{xy}}{\sqrt{v_x v_y}} \quad (v_y \neq 0).

    Deduce ∣ρ∣≤1\abs\rho \leq 1, with ∣ρ∣=1\abs\rho = 1 if and only if the data are perfectly aligned.

  5. Worked example: for the data (0,0)(0,0), (1,1)(1,1), (2,3)(2,3), (3,4)(3,4), compute xˉ,yˉ,vx,cxy\bar x, \bar y, v_x, c_{xy}, the regression line, the four residuals and Emin⁡E_{\min}.
  6. Prove that the residuals εi=yi−α−βxi\varepsilon_i = y_i - \alpha - \beta x_i of the optimal line satisfy ∑iεi=0\sum_i \varepsilon_i = 0 and ∑ixiεi=0\sum_i x_i\varepsilon_i = 0, and interpret both via orthogonality.

Part IV — Variations and applications.

  1. (Best constant) Show that the constant α\alpha minimizing ∑i(yi−α)2\sum_i (y_i - \alpha)^2 is the mean yˉ\bar y, and that the minimal value is n vyn\,v_y: the variance measures the failure of the data to be constant.
  2. (Line through the origin) Show that the slope minimizing ∑i(yi−βxi)2\sum_i (y_i - \beta x_i)^2 is β0=∑xiyi∑xi2\beta_0 = \frac{\sum x_iy_i}{\sum x_i^2}, and give a condition on the data for β0\beta_0 to coincide with the slope cxy/vxc_{xy}/v_x of question 11.
  3. (Distance to a line, again) For a point MM and the line DD through P0P_0 directed by the unit vector ww, minimize g(τ)=∥P0+τw−M∥2g(\tau) = \norm{P_0 + \tau w - M}^2 and deduce d(M,D)2=∥M−P0∥2−⟨M−P0,w⟩2d(M, D)^2 = \norm{M - P_0}^2 - \langle M - P_0, w\rangle^2; recover the formula d=∣ax0+by0+c∣a2+b2d = \frac{\abs{a x_0 + b y_0 + c}}{\sqrt{a^2 + b^2}} for the line ax+by+c=0ax + by + c = 0 in the plane.
  4. (Analysis of variance) Prove the decomposition vy=β2vx+Emin⁡nv_y = \beta^2 v_x + \frac{E_{\min}}n: the variance of the yiy_i splits into the part explained by the line plus the residual variance.
  5. (Parabolic fit) To fit y=a+bx+cx2y = a + bx + cx^2, show that the normal equations are the 3×33 \times 3 system with the moment matrix

    (n∑xi∑xi2∑xi∑xi2∑xi3∑xi2∑xi3∑xi4),\begin{pmatrix} n & \sum x_i & \sum x_i^2\\ \sum x_i & \sum x_i^2 & \sum x_i^3\\ \sum x_i^2 & \sum x_i^3 & \sum x_i^4 \end{pmatrix},

    a Gram matrix which is invertible as soon as three of the xix_i are distinct (freeness of (1,X,X2)(1, X, X^2) sampled at the data, Exercise 23.11; compare the moment matrices of the weekend problem of Chapter 22).

Part V — Robustness, and synthesis.

  1. Classify the critical points of the three quadratic functions

    x2+xy+y2,x2+3xy+y2,x2+2xy+y2,x^2 + xy + y^2, \qquad x^2 + 3xy + y^2, \qquad x^2 + 2xy + y^2 ,

    by Part I, treating the degenerate third case by hand (where is the minimum attained?).

  2. (Outlier experiment) Append the point (10,0)(10, 0) to the data of question 14 and recompute the slope β\beta. What happened, and why is the squared error so sensitive to one distant point?
  3. (Weighted least squares) Given weights wi>0w_i > 0, minimize ∑iwi(yi−α−βxi)2\sum_i w_i(y_i - \alpha - \beta x_i)^2: show the solution is given by the same formulas as question 11 with weighted means, variance and covariance (define them).
  4. Show that for the optimal line, Emin⁡=0E_{\min} = 0 forces all points to lie exactly on it, and connect with the equality case ∣ρ∣=1\abs\rho = 1 of question 13; test on the aligned data (1,1),(2,3),(3,5)(1,1), (2,3), (3,5).
  5. Synthesis, in four sentences: why quadratic functions are the one class where this chapter’s second-order test needs no admitted theorem; how the normal equations identify the analytic minimization with the orthogonal projection of Chapter 23; what the correlation coefficient measures and which inequality bounds it; and which pieces of Chapters 18–23 (bases, Gram and moment matrices, projections) reappeared. Name the method and the equations studied in Parts II–III.
Solution

Solution of Problem 25.1.

1. Expanding the right-hand side:

r(h+srk) ⁣2+rt−s2rk2=rh2+2shk+s2rk2+rt−s2rk2=q(h,k).r\Bigl(h + \frac srk\Bigr)^{\!2} + \frac{rt - s^2}{r}k^2 = rh^2 + 2shk + \frac{s^2}{r}k^2 + \frac{rt - s^2}{r}k^2 = q(h,k) .

If rt−s2>0rt - s^2 > 0: both squares carry the factor sign of rr, and q(h,k)=0q(h,k) = 0 forces k=0k = 0 then h=0h = 0: strict sign of rr off the origin. If rt−s2<0rt - s^2 < 0: q(1,0)=rq(1, 0) = r while q(−sr,1)=rt−s2rq\bigl(-\frac sr, 1\bigr) = \frac{rt - s^2}{r} has the opposite sign: both signs occur.

2. If r=0≠tr = 0 \neq t, exchange the roles of hh and kk (the completed square in kk), with the same conclusions; note rt−s2=−s2<0rt - s^2 = -s^2 < 0 as soon as s≠0s \neq 0, and indeed q=2shk+tk2q = 2shk + tk^2 takes both signs then (kk small against hh). If r=t=0r = t = 0: q=2shkq = 2shk, both signs iff s≠0s \neq 0, i.e. iff rt−s2=−s2<0rt - s^2 = -s^2 < 0. Summary: qq takes both signs   ⟺  rt−s2<0\iff rt - s^2 < 0; qq vanishes only at the origin (definite)   ⟺  rt−s2>0\iff rt - s^2 > 0 (which forces r≠0r \neq 0, since r=0r = 0 gives q(1,0)=0q(1,0) = 0).

3. With fx=rx+sy+βf_x = rx + sy + \beta and fy=sx+ty+γf_y = sx + ty + \gamma, direct expansion gives

f(a+h,b+k)=f(a,b)+h fx(a,b)+k fy(a,b)+12q(h,k),f(a + h, b + k) = f(a, b) + h\,f_x(a,b) + k\,f_y(a,b) + \tfrac12 q(h, k),

with no higher terms (the function is a polynomial of degree 22). At a critical point the linear part vanishes: f(X0+H)−f(X0)=12q(H)f(X_0 + H) - f(X_0) = \frac12 q(H) exactly, so the sign study of questions 1–2 classifies: strict global minimum (rt−s2>0rt - s^2 > 0, r>0r > 0), strict global maximum (rt−s2>0rt - s^2 > 0, r<0r < 0), saddle — both signs in every neighborhood — when rt−s2<0rt - s^2 < 0. This proves Method 25.14 for quadratic functions.

4. The form q−c(h2+k2)q - c(h^2 + k^2) has data r−cr - c, ss, t−ct - c. With c=rt−s2r+tc = \frac{rt - s^2}{r + t} (note t>0t > 0 since rt>s2≥0rt > s^2 \geq 0 and r>0r > 0):

(r−c)(t−c)−s2=rt−s2−c(r+t)+c2=c2≥0,(r - c)(t - c) - s^2 = rt - s^2 - c(r + t) + c^2 = c^2 \geq 0,

and r−c≥0r - c \geq 0 (c≤r  ⟺  rt−s2≤r2+rtc \leq r \iff rt - s^2 \leq r^2 + rt, true). If r−c>0r - c > 0, the completed square of question 1 shows q−c(h2+k2)≥0q - c(h^2 + k^2) \geq 0; if r−c=0r - c = 0, then s=0s = 0 (from −s2=−c2≤…-s^2 = -c^2 \leq \dots forcing the displayed quantity ≥0\geq 0 with first factor 00) and the form is (t−c)k2≥0(t - c)k^2 \geq 0. In both cases q(h,k)≥c(h2+k2)q(h,k) \geq c(h^2 + k^2).

5. By questions 3–4, f(X)=f(X0)+12q(X−X0)≥f(X0)+c2∥X−X0∥2→+∞f(X) = f(X_0) + \frac12 q(X - X_0) \geq f(X_0) + \frac c2\norm{X - X_0}^2 \to +\infty as ∥X∥→∞\norm X \to \infty: ff is coercive, and the inequality is strict for X≠X0X \neq X_0: the critical point is the unique global minimizer. For the cubic f=x3+y3−3xyf = x^3 + y^3 - 3xy of Example 25.15, no such conclusion holds: f(x,0)=x3→−∞f(x,0) = x^3 \to -\infty, and the local minimum at (1,1)(1,1) is not global — exactness of the quadratic expansion is what failed.

6. Expanding the squared norm:

f(u,v)=u2∥C1∥2+2uv ⟨C1,C2⟩+v2∥C2∥2−2u ⟨C1,b⟩−2v ⟨C2,b⟩+∥b∥2,f(u,v) = u^2\norm{C_1}^2 + 2uv\,\langle C_1, C_2\rangle + v^2\norm{C_2}^2 - 2u\,\langle C_1, b\rangle - 2v\,\langle C_2, b\rangle + \norm b^2 ,

a quadratic function of (u,v)(u, v) whose quadratic part is 12(ru2+2suv+tv2)\frac12(ru^2 + 2suv + tv^2) with r=2∥C1∥2r = 2\norm{C_1}^2, s=2⟨C1,C2⟩s = 2\langle C_1, C_2\rangle, t=2∥C2∥2t = 2\norm{C_2}^2.

7. rt−s2=4(∥C1∥2∥C2∥2−⟨C1,C2⟩2)≥0rt - s^2 = 4\bigl(\norm{C_1}^2\norm{C_2}^2 - \langle C_1, C_2\rangle^2\bigr) \geq 0 by Cauchy–Schwarz (Theorem 23.4), with equality exactly when C1,C2C_1, C_2 are proportional (or one is zero), i.e. when the pair is linked. So rt−s2>0  ⟺  (C1,C2)rt - s^2 > 0 \iff (C_1, C_2) free.

8. ∇f=0\nabla f = 0 reads

∥C1∥2u+⟨C1,C2⟩v=⟨C1,b⟩,⟨C1,C2⟩u+∥C2∥2v=⟨C2,b⟩,\norm{C_1}^2 u + \langle C_1, C_2\rangle v = \langle C_1, b\rangle, \qquad \langle C_1, C_2\rangle u + \norm{C_2}^2 v = \langle C_2, b\rangle,

the normal equations with the Gram matrix on the left; they say ⟨uC1+vC2−b, Ci⟩=0\langle uC_1 + vC_2 - b,\ C_i\rangle = 0 for i=1,2i = 1, 2, i.e. b−p⊥Vect⁡(C1,C2)b - p \perp \operatorname{Vect}(C_1, C_2) for p=uC1+vC2p = uC_1 + vC_2. By Part I (questions 3, 5) the unique critical point is the unique global minimizer, and by Theorem 23.10 the characterization “p∈Fp \in F, b−p⊥Fb - p \perp F” identifies pp as the orthogonal projection of bb onto F=Vect⁡(C1,C2)F = \operatorname{Vect}(C_1, C_2).

9. ∥b−p∥2=∥b∥2−2⟨b,p⟩+∥p∥2\norm{b - p}^2 = \norm b^2 - 2\langle b, p\rangle + \norm p^2, and ⟨p,b−p⟩=0\langle p, b - p\rangle = 0 gives ∥p∥2=⟨p,b⟩\norm p^2 = \langle p, b\rangle: the minimum equals ∥b∥2−⟨p,b⟩\norm b^2 - \langle p, b\rangle. Pythagoras: ∥b∥2=∥p∥2+∥b−p∥2\norm b^2 = \norm p^2 + \norm{b - p}^2 — the data vector splits into its explained part pp and its residual part b−pb - p, orthogonal to each other.

10. E(α,β)=∥αC1+βC2−b∥2E(\alpha, \beta) = \norm{\alpha C_1 + \beta C_2 - b}^2 with the stated C1,C2,bC_1, C_2, b; the normal equations of question 8 are, entrywise,

nα+(∑xi)β=∑yi,(∑xi)α+(∑xi2)β=∑xiyi.n\alpha + \Bigl(\sum x_i\Bigr)\beta = \sum y_i, \qquad \Bigl(\sum x_i\Bigr)\alpha + \Bigl(\sum x_i^2\Bigr)\beta = \sum x_i y_i .

11. Dividing by nn: α+βxˉ=yˉ\alpha + \beta\bar x = \bar y and αxˉ+β(vx+xˉ2)=cxy+xˉyˉ\alpha\bar x + \beta\bigl(v_x + \bar x^2\bigr) = c_{xy} + \bar x\bar y. Substituting α=yˉ−βxˉ\alpha = \bar y - \beta\bar x into the second: βvx=cxy\beta v_x = c_{xy}, so

β=cxyvx,α=yˉ−βxˉ,\beta = \frac{c_{xy}}{v_x}, \qquad \alpha = \bar y - \beta\bar x ,

and the first equation says precisely that (xˉ,yˉ)(\bar x, \bar y) lies on the line.

12. vx=1n∑(xi−xˉ)2≥0v_x = \frac1n\sum(x_i - \bar x)^2 \geq 0, zero iff every xix_i equals xˉ\bar x. And rt−s2=4(n∑xi2−(∑xi)2)=4n2vxrt - s^2 = 4\bigl(n\sum x_i^2 - (\sum x_i)^2\bigr) = 4n^2 v_x: question 7’s freeness condition is vx>0v_x > 0, i.e. the xix_i not all equal.

13. With α=yˉ−βxˉ\alpha = \bar y - \beta\bar x, center the data (x~i=xi−xˉ\tilde x_i = x_i - \bar x, y~i=yi−yˉ\tilde y_i = y_i - \bar y):

E(α,β)=∑i(y~i−βx~i)2=n vy−2β n cxy+β2n vx,E(\alpha, \beta) = \sum_i(\tilde y_i - \beta\tilde x_i)^2 = n\,v_y - 2\beta\,n\,c_{xy} + \beta^2 n\,v_x ,

minimized at β=cxy/vx\beta = c_{xy}/v_x with value Emin⁡=n(vy−cxy2vx)=nvy(1−ρ2)E_{\min} = n\bigl(v_y - \frac{c_{xy}^2}{v_x}\bigr) = n v_y(1 - \rho^2). Since Emin⁡≥0E_{\min} \geq 0 and vy>0v_y > 0: ρ2≤1\rho^2 \leq 1, and ∣ρ∣=1\abs\rho = 1 iff Emin⁡=0E_{\min} = 0, i.e. iff every residual vanishes: the points lie exactly on the line.

14. n=4n = 4: xˉ=64=1.5\bar x = \frac64 = 1.5, yˉ=2\bar y = 2, ∑xi2=14\sum x_i^2 = 14 so vx=3.5−2.25=1.25v_x = 3.5 - 2.25 = 1.25, ∑xiyi=0+1+6+12=19\sum x_iy_i = 0 + 1 + 6 + 12 = 19 so cxy=4.75−3=1.75c_{xy} = 4.75 - 3 = 1.75. Hence

β=1.751.25=1.4,α=2−1.4×1.5=−0.1:y=1.4 x−0.1.\beta = \frac{1.75}{1.25} = 1.4, \qquad \alpha = 2 - 1.4\times1.5 = -0.1 : \qquad y = 1.4\,x - 0.1 .

Fitted values −0.1, 1.3, 2.7, 4.1-0.1,\ 1.3,\ 2.7,\ 4.1; residuals 0.1, −0.3, 0.3, −0.10.1,\ -0.3,\ 0.3,\ -0.1; Emin⁡=0.01+0.09+0.09+0.01=0.2E_{\min} = 0.01 + 0.09 + 0.09 + 0.01 = 0.2 (check: vy=264−4=2.5v_y = \frac{26}4 - 4 = 2.5 and 4(2.5−1.7521.25)=4(2.5−2.45)=0.24(2.5 - \frac{1.75^2}{1.25}) = 4(2.5 - 2.45) = 0.2).

15. The two normal equations of question 10 are exactly ∑iεi=0\sum_i\varepsilon_i = 0 and ∑ixiεi=0\sum_i x_i\varepsilon_i = 0: the residual vector is orthogonal to C1=(1,…,1)C_1 = (1, \dots, 1) and to C2=(xi)C_2 = (x_i) — to the whole model space. In particular the optimal line always balances its errors: they sum to zero.

16.  ⁣d ⁣dα∑(yi−α)2=−2∑(yi−α)=0\frac{\dd}{\dd\alpha}\sum(y_i - \alpha)^2 = -2\sum(y_i - \alpha) = 0 gives α=yˉ\alpha = \bar y (and the second derivative 2n>02n > 0 makes it the global minimum, the function being a coercive quadratic in one variable). Minimal value ∑(yi−yˉ)2=nvy\sum(y_i - \bar y)^2 = n v_y: the variance is the irreducible quadratic error of a constant model.

17.  ⁣d ⁣dβ∑(yi−βxi)2=−2∑xi(yi−βxi)=0\frac{\dd}{\dd\beta}\sum(y_i - \beta x_i)^2 = -2\sum x_i(y_i - \beta x_i) = 0 gives β0=∑xiyi∑xi2\beta_0 = \frac{\sum x_iy_i}{\sum x_i^2}. Writing both slopes over centered quantities: β0=cxy+xˉyˉvx+xˉ2\beta_0 = \frac{c_{xy} + \bar x\bar y}{v_x + \bar x^2} equals cxyvx\frac{c_{xy}}{v_x} iff cxyxˉ2=xˉyˉ vxc_{xy}\bar x^2 = \bar x\bar y\,v_x, i.e. iff xˉ=0\bar x = 0 (centered abscissas) or yˉ=βxˉ\bar y = \beta\bar x — the latter meaning α=0\alpha = 0: the full regression line already passes through the origin.

18. g(τ)=∥M−P0∥2−2τ⟨M−P0,w⟩+τ2g(\tau) = \norm{M - P_0}^2 - 2\tau\langle M - P_0, w\rangle + \tau^2 is minimal at τ∗=⟨M−P0,w⟩\tau^* = \langle M - P_0, w\rangle, with value d(M,D)2=∥M−P0∥2−⟨M−P0,w⟩2d(M,D)^2 = \norm{M - P_0}^2 - \langle M - P_0, w\rangle^2. In the plane, complete ww into an orthonormal basis (w,n)(w, n) with n=(a,b)a2+b2n = \frac{(a, b)}{\sqrt{a^2+b^2}} (unit normal of DD): then ∥M−P0∥2=⟨M−P0,w⟩2+⟨M−P0,n⟩2\norm{M - P_0}^2 = \langle M - P_0, w\rangle^2 + \langle M - P_0, n\rangle^2, so d(M,D)=∣⟨M−P0,n⟩∣d(M, D) = \abs{\langle M - P_0, n\rangle}, and with aP0x+bP0y=−caP_{0x} + bP_{0y} = -c:

d=∣ax0+by0+c∣a2+b2.d = \frac{\abs{a x_0 + b y_0 + c}}{\sqrt{a^2 + b^2}} .

19. From Emin⁡/n=vy−cxy2vxE_{\min}/n = v_y - \frac{c_{xy}^2}{v_x} and β2vx=cxy2vx\beta^2 v_x = \frac{c_{xy}^2}{v_x}:

vy=β2vx+Emin⁡n:v_y = \beta^2 v_x + \frac{E_{\min}}n :

total variance == variance along the fitted line ++ residual variance. (Dividing by vyv_y: 1=ρ2+(1−ρ2)1 = \rho^2 + (1 - \rho^2), the share of variance “explained” by the line is ρ2\rho^2.)

20. The model space is Vect⁡(C1,C2,C3)\operatorname{Vect}\bigl(C_1, C_2, C_3\bigr) with C1=(1)C_1 = (1), C2=(xi)C_2 = (x_i), C3=(xi2)C_3 = (x_i^2); minimizing ∥aC1+bC2+cC3−b∥2\norm{aC_1 + bC_2 + cC_3 - b}^2 leads, exactly as in question 8, to the 3×33\times3 Gram system, whose matrix has entries ⟨Ci,Cj⟩=∑kxk i+j−2\langle C_i, C_j\rangle = \sum_k x_k^{\,i+j-2}: the displayed moment matrix. It is invertible iff (C1,C2,C3)(C_1, C_2, C_3) is free (Exercise 23.11); a relation a+bxk+cxk2=0a + bx_k + cx_k^2 = 0 for all kk makes every xkx_k a root of one polynomial of degree ≤2\leq 2, impossible with three distinct values unless a=b=c=0a = b = c = 0. Compare the moment matrices of the weekend problem of Chapter 22, where their determinants were squared Vandermonde values.

21. First: r=2,s=1,t=2r = 2, s = 1, t = 2, rt−s2=3>0rt - s^2 = 3 > 0, r>0r > 0: strict global minimum at the origin. Second: r=2,s=3,t=2r = 2, s = 3, t = 2, rt−s2=−5<0rt - s^2 = -5 < 0: saddle. Third: r=s=t=2r = s = t = 2, rt−s2=0rt - s^2 = 0: degenerate — but x2+2xy+y2=(x+y)2≥0x^2 + 2xy + y^2 = (x + y)^2 \geq 0 vanishes on the whole line y=−xy = -x: a (non-strict) global minimum attained along a line, invisible to the determinant test.

22. New sums (n=5n = 5): xˉ=3.2\bar x = 3.2, yˉ=1.6\bar y = 1.6, ∑xiyi=19\sum x_iy_i = 19 so cxy=3.8−5.12=−1.32c_{xy} = 3.8 - 5.12 = -1.32, ∑xi2=114\sum x_i^2 = 114 so vx=22.8−10.24=12.56v_x = 22.8 - 10.24 = 12.56. New slope:

β=−1.3212.56≈−0.105:\beta = \frac{-1.32}{12.56} \approx -0.105 :

one point turned a clearly increasing trend (β=1.4\beta = 1.4) into a slightly decreasing one. The squared error charges a residual ε2\varepsilon^2, so a single distant point — large ∣xi−xˉ∣\abs{x_{i} - \bar x} and large residual — dominates both cxyc_{xy} and vxv_x: least squares is efficient but not robust.

23. Set W=∑wiW = \sum w_i and define xˉw=1W∑wixi\bar x_w = \frac1W\sum w_ix_i, yˉw\bar y_w likewise, vxw=1W∑wixi2−xˉw2v_x^w = \frac1W\sum w_ix_i^2 - \bar x_w^2, cxyw=1W∑wixiyi−xˉwyˉwc^w_{xy} = \frac1W\sum w_ix_iy_i - \bar x_w\bar y_w. The map ⟨u,v⟩w=∑iwiuivi\langle u, v\rangle_w = \sum_i w_iu_iv_i is an inner product on Rn\R^n (wi>0w_i > 0 gives definiteness), so Part II applies verbatim and the normal equations divide by WW into

α+βxˉw=yˉw,αxˉw+β(vxw+xˉw2)=cxyw+xˉwyˉw,\alpha + \beta\bar x_w = \bar y_w, \qquad \alpha\bar x_w + \beta(v^w_x + \bar x_w^2) = c^w_{xy} + \bar x_w\bar y_w ,

whence β=cxyw/vxw\beta = c^w_{xy}/v^w_x and α=yˉw−βxˉw\alpha = \bar y_w - \beta\bar x_w: the same formulas, with every average weighted.

24. Emin⁡=∑εi2=0E_{\min} = \sum\varepsilon_i^2 = 0 forces every εi=0\varepsilon_i = 0: all points exactly on the line; by question 13 this is the case ∣ρ∣=1\abs\rho = 1. Test: for (1,1),(2,3),(3,5)(1,1), (2,3), (3,5): xˉ=2\bar x = 2, yˉ=3\bar y = 3, vx=143−4=23v_x = \frac{14}3 - 4 = \frac23, cxy=223−6=43c_{xy} = \frac{22}3 - 6 = \frac43: β=2\beta = 2, α=−1\alpha = -1, and indeed yi=2xi−1y_i = 2x_i - 1 for all three points; vy=353−9=83v_y = \frac{35}3 - 9 = \frac83 and ρ2=(4/3)2(2/3)(8/3)=1\rho^2 = \frac{(4/3)^2}{(2/3)(8/3)} = 1.

25. (i) For quadratic functions the order-two expansion is an identity, so the sign study of the quadratic form — pure algebra, questions 1–2 — classifies critical points with no admitted Taylor theorem. (ii) The normal equations say “residual orthogonal to the model space”, so the analytic minimum is the orthogonal projection of the data vector: calculus and Euclidean geometry compute the same object. (iii) The correlation ρ=cxy/vxvy\rho = c_{xy}/\sqrt{v_xv_y} measures the share ρ2\rho^2 of the variance explained by the line, and Cauchy–Schwarz bounds it: ∣ρ∣≤1\abs\rho \leq 1, with equality only for aligned data. (iv) Bases and freeness (Chapter 18), Gram and moment matrices and their determinants (Chapters 22–23), and orthogonal projection (Chapter 23) all reappeared as the working parts of one algorithm. Parts II–III develop the method of least squares (Legendre, Gauss) through its normal equations.

Terms defined in this chapter

See all 395 terms in the glossary