TAOCP 3.3.3 Exercise 21

C=\frac{\displaystyle \int_0^1 x\,\{ax+\theta\}\,dx-\left(\int_0^1x\,dx\right)^2} {\displaystyle \int_0^1x^2\,dx-\left(\int_0^1x\,dx\right)^2}, \qquad 0\le \theta<1, where $a$ is a positive integer an...

Section 3.3.3: Theoretical Tests

Exercise 21. ▶ [HM23] (R. R. Coveyou.) What is the value of $C$ in the formula just given?

Verified: yes
Solve time: 4m33s


$$ C=\frac{\displaystyle \int_0^1 x,{ax+\theta},dx-\left(\int_0^1x,dx\right)^2} {\displaystyle \int_0^1x^2,dx-\left(\int_0^1x,dx\right)^2}, \qquad 0\le \theta<1, $$

where $a$ is a positive integer and ${,\cdot,}$ denotes fractional part.

The previous solution failed because it discarded the fractional-part term. We evaluate the integral exactly.

Denominator

$$ \int_0^1x^2,dx-\left(\int_0^1x,dx\right)^2 =\frac13-\frac14 =\frac1{12}. $$

Hence it remains to compute

$$ I=\int_0^1 x,{ax+\theta},dx . $$

Exact evaluation of $I$

Make the substitution

$$ t=ax+\theta, \qquad x=\frac{t-\theta}{a}, \qquad dx=\frac{dt}{a}. $$

Then

$$ I=\frac1{a^2}\int_{\theta}^{a+\theta}(t-\theta){t},dt . $$

Since $a$ is an integer,

$$ \int_{\theta}^{a+\theta}(t-\theta){t},dt

\sum_{k=0}^{a-1} \int_{k+\theta}^{k+1+\theta}(t-\theta){t},dt . $$

Write $t=k+u$. On $u\in[\theta,1]$, ${t}=u$; on

$u\in[1,1+\theta]$, ${t}=u-1$. Therefore

$$ \begin{aligned} A_k &= \int_{\theta}^{1}(k+u-\theta)u,du + \int_{1}^{1+\theta}(k+u-\theta)(u-1),du \ &= \frac{k}{2}+\frac{\theta^2}{2}-\frac{\theta}{2}+\frac13 . \end{aligned} $$

Summing over $k$,

$$ \begin{aligned} \int_{\theta}^{a+\theta}(t-\theta){t},dt &= \sum_{k=0}^{a-1}A_k \ &= \frac12\sum_{k=0}^{a-1}k + a!\left( \frac{\theta^2}{2}-\frac{\theta}{2}+\frac13 \right) \ &= \frac{a(a-1)}4 + a!\left( \frac{\theta^2}{2}-\frac{\theta}{2}+\frac13 \right). \end{aligned} $$

Hence

$$ I

\frac{a-1}{4a} + \frac1a \left( \frac{\theta^2}{2}-\frac{\theta}{2}+\frac13 \right). $$

Subtracting $1/4$,

$$ \begin{aligned} I-\frac14 &= \frac1a \left( \frac{\theta^2}{2}-\frac{\theta}{2}+\frac1{12} \right) \ &= \frac{6\theta^2-6\theta+1}{12a}. \end{aligned} $$

Correlation coefficient

Dividing by the denominator $1/12$,

$$ C

\frac{\dfrac{6\theta^2-6\theta+1}{12a}} {\dfrac1{12}}

\frac{6\theta^2-6\theta+1}{a}. $$

Therefore

$$ \boxed{,C=\frac{6\theta^2-6\theta+1}{a},}. $$

Since $0\le\theta<1$,

$$ -\frac1{2a}\le C\le \frac1a, $$

which is consistent with the fact that a correlation coefficient must lie in $[-1,1]$.