brain

tamnd's digital brain — notes, problems, research

41641 notes

TAOCP 4.6.1 Exercise 21

We are asked to analyze **Algorithm C** for computing the greatest common divisor (gcd) of two integer polynomials of degree $n$ with coefficients bounded in absolute value by $N$, and to prove that i...

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.6.1 Exercise 17

The previous write-up fails at a foundational level because it treats the task as an array-sorting problem, while the exercise is about the structure of the free associative algebra over an alphabet.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.6.1 Exercise 16

Let N(d_1,\ldots,d_n;S_1,\ldots,S_n) = |S_1|\cdots |S_n| -

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.6.1 Exercise 15

Let $A=(a_{ij})$ be an $n\times n$ real matrix, and let $r_i=(a_{i1},a_{i2},\ldots,a_{in})$ denote its $i$th row.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.6.1 Exercise 13

**Corrected Solution to Exercise 4.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.6.1 Exercise 14

The solution does not correctly address the statement being proved, and it does not provide a valid argument that the pseudo-remainder must be divisible by the leading coefficient $l(v)$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.6.1 Exercise 12

The reviewer feedback does not match the exercise being solved.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.6.1 Exercise 11

The question refers to the row-naming convention of Table 1 in §4.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.6.1 Exercise 10

Let $S$ be a unique factorization domain, and let $S[x]$ denote the ring of polynomials in one indeterminate $x$ with coefficients in $S$.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.6.1 Exercise 7

Let $f(x)$ be a unit in the polynomial ring over a unique factorization domain $S$.

taocpmathematicsalgorithmsvolume-1math-simple
TAOCP 4.6.1 Exercise 9

**Solution to Exercise 4.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.6.1 Exercise 8

Let $f(x)$ be a polynomial with integer coefficients, and suppose that $f(x)$ is irreducible over the domain of integers.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.6.1 Exercise 5

Let $S = \mathbb{F}_p$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.6.1 Exercise 6

We are asked whether the _binary gcd algorithm_ (Algorithm 4.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.6.1 Exercise 2

**Problem 2.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 4.6.1 Exercise 4

Let $F=\mathbf F_p$.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.6.1 Exercise 3

We are asked to compute the pseudo-quotient $q(x)$ and pseudo-remainder $r(x)$ over the integers for u(x) = x^6 + x^5 - x^4 + 2x^3 + 3x^2 - x + 2, \qquad v(x) = 2x^2 + 2x^2 - x + 3.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.6.1 Exercise 1

**Exercise 4.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 4.5.4 Exercise 47

We are asked to recover a literary quotation x = x_1 x_2 represented in ASCII, from the ciphertext

taocpmathematicsalgorithmsvolume-1math-research
TAOCP 4.5.4 Exercise 45

We are asked to solve the congruence x^2 - ay^2 \equiv b \pmod{n} for integers $x$ and $y$, given that $a, b \perp n$ and $n$ is odd, without knowledge of the factorization of $n$.

taocpmathematicsalgorithmsvolume-1math-project
TAOCP 4.5.4 Exercise 46

Let G=\langle a\rangle=(\mathbb Z/p\mathbb Z)^\times, where $p$ is prime and $a$ is a primitive root modulo $p$.

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 4.5.4 Exercise 43

Let m=pq be a Blum integer, with

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.5.4 Exercise 42

**Corrected Solution to Exercise 4.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.5.4 Exercise 44

**Solution.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.5.4 Exercise 40

We are asked to consider an abstract computer that can perform the operations $x + y$, $x - y$, $x \cdot y$, and $\lfloor x/y \rfloor$ on integers $x$ and $y$ of arbitrary length in one unit of time,...

taocpmathematicsalgorithmsvolume-1math-project
TAOCP 4.5.4 Exercise 41

The requested solution is a standalone writeup, so I am providing it in a writing block.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.5.4 Exercise 39

We are asked to find a long chain of *successive primes*, where a prime \(q\) is a successor of a prime \(p\) if \[ q = 2^k p + 1 \] for some integer \(k \ge 0\), and both \(p\) and \(q\) are prime.

taocpmathematicsalgorithmsvolume-1project
TAOCP 4.5.4 Exercise 38

The reviewer’s objections are correct.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.5.4 Exercise 37

Let $N = pq$ where $p \equiv 3 \pmod 8$ and $q \equiv 7 \pmod 8$.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.5.4 Exercise 36

Equation (22) has the form T(m)\asymp m+\frac{\ln N}{\ln m}, up to multiplicative factors that vary only slowly with $m$.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 4.5.4 Exercise 35

Let $N = pq$ where $p \equiv 3 \pmod 8$ and $q \equiv 7 \pmod 8$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.4 Exercise 33

**Statement.

taocpmathematicsalgorithmsvolume-1math-research
TAOCP 4.5.4 Exercise 34

Let $N = pq$ be the product of two distinct primes, as in the RSA scheme.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.5.4 Exercise 32

Suppose RSA uses public exponent $e=3$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.4 Exercise 30

Let $N$ be an odd positive integer with prime factorization N = q_1^{f_1} \cdots q_d^{f_d}, where the $q_i$ are distinct primes and $f_i \ge 1$.

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 4.5.4 Exercise 31

We are asked to use exercise 1.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.4 Exercise 29

Let S(n)=\{\,p_1^{e_1}p_2^{e_2}\cdots p_m^{e_m}\le n : e_i\ge0\,\}.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.4 Exercise 28

Let $Q(A,B)=A^2-dB^2,$ and let $v_p(n)$ denote the exponent of the prime $p$ in $n$, with the convention that $v_p(n)=k \iff p^k\mid n,\quad p^{k+1}\nmid n.$ The quantity to be determined is $f(p,d)=\...

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.5.4 Exercise 26

Let N=fr+1,\qquad 0<r\le f+1, and suppose that for every prime divisor $p$ of $f$ there exists an integer $x_p$ such that

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.4 Exercise 25

The statement as printed in the exercise contains a typographical problem in the oscillatory term.

taocpmathematicsalgorithmsvolume-1hm-project
TAOCP 4.5.4 Exercise 27

Let N=5\cdot 2^n+1, and let

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.5.4 Exercise 24

Let $S = {n : 1 < n \le N,\ n\ \text{odd},\ n\ \text{composite}}$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.4 Exercise 23

Let $p \ge 0$ be an integer and $q > 1$ an odd integer.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.5.4 Exercise 21

Let $p$ be a prime number, and consider Algorithm B from Section 4.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.5.4 Exercise 22

Let $n\ge 3$ be odd, and let $p_n$ be the probability that Algorithm P declares $n$ to be prime when $n$ is actually composite.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.5.4 Exercise 20

Let $D$ be a given positive integer, and let $p$ range over odd primes.

taocpmathematicsalgorithmsvolume-1math-research
TAOCP 4.5.4 Exercise 19

Let $D$ be given and let $p$ be any odd prime such that $p-1 \mid D$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.4 Exercise 18

Let $p_n$ and $p_{n-1}$ denote the two largest prime factors in a typical factorization, ordered so that $p_{n-1} \le p_n$.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 4.5.4 Exercise 17

The proof proceeds by structural induction on the Pratt tree.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.4 Exercise 16

A **Mersenne prime** is a prime number of the form $M_p = 2^p - 1,$ where $p$ itself is prime.

taocpmathematicsalgorithmsvolume-1math-research
TAOCP 4.5.4 Exercise 15

Let $P$ and $Q$ be integers with $\gcd(P,Q) = 1$, and define the Lucas sequence $(U_n)$ by $U_0 = 0, \quad U_1 = 1, \quad U_{n+1} = P U_n - Q U_{n-1} \quad (n \ge 1).$ Let $N$ be a positive integer su...

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.5.4 Exercise 14

We are asked to prove that the number $T$ computed in step E3 of Algorithm E (the strong pseudoprime test in Section 4.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.4 Exercise 11

We are asked to determine the outputs of Algorithm E when N = 197209, \quad k = 5, \quad m = 1.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.4 Exercise 10

Let $n>1$ satisfy the hypothesis: for every prime $p \mid (n-1)$ there exists an integer $x_p$ such that x_p^{(n-1)/p} \equiv 1 \pmod n, \qquad x_p^{n-1} \not\equiv 1 \pmod n.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.5.4 Exercise 12

Let N=p_1^{a_1}p_2^{a_2}\cdots p_d^{a_d}, where $p_1,\ldots,p_d$ are the distinct prime factors of $N$.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 4.5.4 Exercise 8

**Exercise 4.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.5.4 Exercise 9

Let $n$ be an odd integer, $n \ge 3$, and suppose that $\lambda(n)$, the Carmichael function of $n$ defined in Theorem 3.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.4 Exercise 7

Algorithm D (Fermat's method) involves iterative calculations modulo various integers $m_i$ to test for squares and compute factors of a number $N$.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.5.4 Exercise 6

We are asked to count the number of integers $x$ with $0 \le x < p$ such that the congruence x^2 - N \equiv y^2 \pmod p has a solution $y$, where $p$ is an odd prime and $p \nmid N$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.4 Exercise 3

Let us construct a number $P$ with the desired property.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.4 Exercise 5

The review correctly identifies the central failure: the solution never completes Fermat’s method by producing an actual $x$, $y$, and hence never factors $11111$.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.5.4 Exercise 4

**Exercise 4.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.5.4 Exercise 2

Step A2 of Algorithm A tests whether the current value of $n$ is equal to $1$, and if so, terminates the algorithm.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 4.5.3 Exercise 41

Let K=\sum_{n\ge 0}2^{-2^{n}} =\frac12+\frac14+\frac1{16}+\frac1{256}+\cdots .

taocpmathematicsalgorithmsvolume-1math-project
TAOCP 4.5.3 Exercise 42

**Corrected Solution to Exercise 4.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.5.4 Exercise 1

In Algorithm A the invariant at step A1 states that $n$ has no prime factors less than $d_k$.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 4.5.3 Exercise 39

Let $h$ be the number of hits and $a$ the number of times at bat.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.3 Exercise 38

Let L(n)=\max_{m\ge 0}T(m,n), where $T(m,n)$ is the number of division steps performed by Euclid's algorithm on inputs $u=m$, $v=n$.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.5.3 Exercise 37

Let $a_1, \ldots, a_n$ be positive integers.

taocpmathematicsalgorithmsvolume-1math-project
TAOCP 4.5.3 Exercise 36

Let g_k=\gcd(u_1,\ldots,u_k)\qquad (1\le k\le n).

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.3 Exercise 35

Let S(n)=\sum_{1\le m<n}s(m,n), where $s(m,n)$ denotes the sum of the partial quotients in the simple continued fraction of $m/n$.

taocpmathematicsalgorithmsvolume-1hm-project
TAOCP 4.5.3 Exercise 34

Let $h_0(n)$ be the number of representations of $n$ as in Exercise **33** such that $d < x'$, plus half the number of representations with $2d = x'$.

taocpmathematicsalgorithmsvolume-1hm-project
TAOCP 4.5.3 Exercise 32

(a) A Morse code sequence of length $n$ consists of $r$ dots and $s$ dashes with $r + 2s = n$.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.5.3 Exercise 29

To produce a fully corrected solution, we must work strictly with the exercise instructions.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.3 Exercise 31

Let the modified algorithm be defined as follows.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.5.3 Exercise 30

Let u=qv+r,\qquad 0\le r<v.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 4.5.3 Exercise 27

The statement of the exercise depends on the explicit forms of equations (43), (54), and (55) in Section 4.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.3 Exercise 28

We prove each of the identities in turn.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.3 Exercise 25

We are asked to construct a set \mathcal{I} = I_1 \cup I_2 \cup I_3 \cup \cdots \subseteq [0,1], where the $I_k$ are **pairwise disjoint intervals**, such that identity (45) fails.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 4.5.3 Exercise 24

Let $X$ be a real number chosen uniformly at random from the interval $[0,1)$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.3 Exercise 26

Let $n \ge 2$ be an integer, and consider the fractions \frac{k}{n}, \quad 1 \le k \le \lfloor n/2 \rfloor.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.3 Exercise 23

**Exercise 4.

taocpmathematicsalgorithmsvolume-1hm-project
TAOCP 4.5.3 Exercise 22

We are asked to develop efficient methods for approximating the quantities $\lambda_1$ and $\Psi_2(x)$ in equation (44) of [_HM46_], for small $y \ge 3$ and $0 \le x \le 1$.

taocpmathematicsalgorithmsvolume-1hm-research
TAOCP 4.5.3 Exercise 20

Let $K_n(x_1,\dots,x_n)$ denote the continuant defined in Section 4.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 4.5.3 Exercise 21

The issue here is that the "Actual output" is empty, which usually indicates that the code is reading input incorrectly.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 4.5.3 Exercise 19

Equation (24) is F(x)=\sum_{m\ge1}\left(F\!

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.3 Exercise 17

By definition (2), \begin{aligned} //x_1,-x_2// &= \frac{1}{x_1+\frac1{-x_2}} = \frac{1}{x_1-\frac1{x_2}}

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.3 Exercise 18

**Exercise 4.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.3 Exercise 15

Let $x = //x_1, x_2, x_3, \ldots//$ be a regular continued fraction in the sense of equation (10).

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.5.3 Exercise 14

Let $X = //A_0, A_1, A_2, \ldots//$ be the regular continued fraction of a real number $X$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.3 Exercise 12

Let $X = (\sqrt{D} - U)/V$ be a quadratic irrationality, where $D$, $U$, $V$ are integers, $D > U^2 \ne 0$, $D$ is not a perfect square, and $V$ divides $D - U^2$.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.5.3 Exercise 13

Unusual activity has been detected from your device.

taocpmathematicsalgorithmsvolume-1math-project
TAOCP 4.5.3 Exercise 10

**Exercise 4.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.5.3 Exercise 11

Let X=A_0+//\!

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.5.3 Exercise 8

We restart from the structural identity behind regular continued fractions: each partial quotient corresponds to a Möbius transformation, and the continuant formulas encode their matrix products.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.3 Exercise 9

Let C(x_1,\ldots,x_n)=//x_1,\ldots,x_n// denote the continued fraction defined recursively by

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.3 Exercise 7

Let $K_n(x_1, x_2, \ldots, x_n)$ denote the continuant polynomial defined by equation (4) in Section 4.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.5.3 Exercise 5

Let C_n = //x_1,x_2,\ldots,x_n// = \frac{p_n}{q_n} be the $n$-th convergent, where $p_n,q_n$ are continuants.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 4.5.3 Exercise 6

First consider the infinite continued fraction X=//B_1,B_2,\ldots//, where each $B_n$ is a positive integer.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.5.3 Exercise 4

We are asked to prove equation (8) of Section 4.

taocpmathematicsalgorithmsvolume-1math-medium