taocp

This site has no text of the book. Keep your own copy of TAOCP next to it. See what is checked.

Exercise · Volume 1 · 1.2.3-31

Exercise 1.2.3-31

proved in Lean solution written

RatingM20
MarkersM (mathematical)
KindK3, find a value: compute a number, a set or a closed form from the written solution
SectionSection 1.2.3 of Volume 1. Companion chapter: Sums and products

The task

Find a closed form for the sum of (uj−uk)(vj−vk)(u_j - u_k)(v_j - v_k) over all pairs j<kj < k. Use only ∑ujvj\sum u_j v_j, ∑uj\sum u_j, ∑vj\sum v_j and nn.

The exact wording is in your copy of the book.

Hints

Open one hint at a time. Try the exercise again after each.

Hint 1

The identity of Exercise 1.2.3-30 has a sum over pairs j<kj < k on the right. Choose its four sequences so that each pair term becomes (uj−uk)(vj−vk)(u_j - u_k)(v_j - v_k).

Hint 2

Two of the four sequences must be constant, equal to 11.

Solution

Show the solution

Binet's identity reads (∑jajxj)(∑jbjyj)−(∑jajyj)(∑jbjxj)=∑j<k(ajbk−akbj)(xjyk−xkyj).\Bigl(\sum_j a_j x_j\Bigr)\Bigl(\sum_j b_j y_j\Bigr) - \Bigl(\sum_j a_j y_j\Bigr)\Bigl(\sum_j b_j x_j\Bigr) = \sum_{j<k} (a_j b_k - a_k b_j)(x_j y_k - x_k y_j). Put aj=uja_j = u_j, bj=1b_j = 1, xj=vjx_j = v_j, yj=1y_j = 1. Then ajbk−akbj=uj−uka_j b_k - a_k b_j = u_j - u_k and xjyk−xkyj=vj−vkx_j y_k - x_k y_j = v_j - v_k. The right side is the sum that the task asks for. The four sums on the left are ∑jajxj=∑jujvj,∑jbjyj=n,∑jajyj=∑juj,∑jbjxj=∑jvj.\sum_j a_j x_j = \sum_j u_j v_j, \quad \sum_j b_j y_j = n, \quad \sum_j a_j y_j = \sum_j u_j, \quad \sum_j b_j x_j = \sum_j v_j. Hence ∑1≤j<k≤n(uj−uk)(vj−vk)=n∑j=1nujvj−(∑j=1nuj)(∑j=1nvj).\sum_{1 \le j < k \le n} (u_j - u_k)(v_j - v_k) = n \sum_{j=1}^n u_j v_j - \Bigl(\sum_{j=1}^n u_j\Bigr)\Bigl(\sum_{j=1}^n v_j\Bigr).

Check

Take n=5n = 5, u=(3,1,4,1,5)u = (3,1,4,1,5) and v=(2,7,1,8,2)v = (2,7,1,8,2). Then ∑ujvj=6+7+4+8+10=35\sum u_j v_j = 6 + 7 + 4 + 8 + 10 = 35, ∑uj=14\sum u_j = 14 and ∑vj=20\sum v_j = 20, so the formula gives 5⋅35−14⋅20=−1055 \cdot 35 - 14 \cdot 20 = -105. The ten pair terms add up to −105-105 as well (computed with python3).

Remarks

For u=vu = v the identity says that ∑j<k(uj−uk)2=n∑uj2−(∑uj)2\sum_{j<k}(u_j - u_k)^2 = n \sum u_j^2 - (\sum u_j)^2. Divided by n2n^2 it relates the variance of a list to the mean of the squared differences of its pairs.

This solution is checked, and a person has not reviewed it yet. The source.

In Lean

proved The statement and its proof are in Lean. The kernel accepts the proof, and it uses the standard axioms only.

The status is computed from the Lean build. The node of the map.

Something is wrong? Report it.