brain

tamnd's digital brain — notes, problems, research

43815 notes

TAOCP 1.2.3 Exercise 7

Define the transformation $p(j)=c-j$.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.3 Exercise 6

Let $R,S \subseteq \mathbb{Z}$, and let $(a_j)$ be an arbitrary real-valued sequence.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.3 Exercise 5

Let A_n=\sum_{i=1}^n a_i,\qquad B_m=\sum_{j=1}^m b_j, and assume both series $\sum_i a_i$ and $\sum_j b_j$ converge, so

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.3 Exercise 2

The notation $\sum_{1 \le j \le n} a_j$ means the sum of $a_j$ over all integers $j$ satisfying $1 \le j \le n$.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.3 Exercise 1

The expression $a_1 + a_2 + \cdots + a_0$ contains no indices $j$ satisfying $1 \le j \le 0$, so it is a sum over an empty set of indices and is defined to be $0$.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.3 Exercise 3

For the first sum, the condition $0 \le n \le 5$ restricts $n$ to the six integers $0,1,2,3,4,5$.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.3 Exercise 4

For $n = 3$, the left-hand side of Eq.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.2 Exercise 30

Let $t = \ln x$.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.2 Exercise 28

The goal is to compute $b^x$ for $0 \le x < 1$ using only shifting, addition, and subtraction, and to analyze accuracy.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 1.2.2 Exercise 29

For $b>1$, $b \log_b x = b \frac{\ln x}{\ln b} = (\ln x)\frac{b}{\ln b}.$ Since $x>1$, the factor $\ln x$ is positive and independent of $b$, so minimizing $b \log_b x$ is equivalent to minimizing $g(...

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.2 Exercise 26

We restart from a consistent floating-point model and propagate the error through the iterative state update.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 1.2.2 Exercise 24

Let $x > 0$.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.2 Exercise 25

The key error in the previous solution is the assumption that a right shift implements exact division by a power of two.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 1.2.2 Exercise 27

The reviewer’s objections identify a real structural gap: the original proof implicitly assumed identical normalization behavior and uncontrolled error collapse.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.2 Exercise 22

For $x>0$, the binary, natural, and common logarithms are related by change of base: $\lg x = \frac{\ln x}{\ln 2}, \qquad \log_{10} x = \frac{\ln x}{\ln 10}.$ Hence $\ln x + \log_{10} x = \ln x \left(...

taocpmathematicsalgorithmsvolume-1medium
TAOCP 1.2.2 Exercise 23

Let $\ln x$ be interpreted as the area described in Fig.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.2 Exercise 21

Assume $b>0$, $b\ne 1$, and $x>1$ so that all logarithms and iterated logarithms are defined.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.2 Exercise 18

Using the change of base formula (14) with base $2$, \log_8 x = \frac{\log_2 x}{\log_2 8}.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.2 Exercise 19

A 14-digit decimal integer $n$ satisfies $10^{13} \le n \le 10^{14} - 1.$ A computer word with 47 bits for magnitude and one sign bit can represent integers in the range $- (2^{47} - 1) \le n \le 2^{4...

taocpmathematicsalgorithmsvolume-1medium
TAOCP 1.2.2 Exercise 17

$\lg 32 = \log_2 32 = 5$, because $2^5 = 32$.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.2 Exercise 20

From equation (14), taking base $b=2$ and $c=10$, one obtains $\log_{10} 2 = \frac{\log_2 2}{\log_2 10}.$ Since $\log_2 2 = 1$ by equation (9), this simplifies to $\log_{10} 2 = \frac{1}{\log_2 10}.$...

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.2 Exercise 14

Let $b > 0$, $b \ne 1$, $c > 0$, and let $y$ be a real number.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.2 Exercise 16

From equation (14), with $b = e$ and $c = 10$, one obtains $\log_{10} x = \frac{\log_e x}{\log_e 10}.$ By definition (15), $\log_e x = \ln x$ and $\log_e 10 = \ln 10$, hence $\log_{10} x = \frac{\ln x...

taocpmathematicsalgorithmsvolume-1
TAOCP 1.2.2 Exercise 13

Let $x>0$ and let $n$ be a positive integer.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.2 Exercise 15

For $x,y>0$, write $\frac{x}{y} = x \cdot \frac{1}{y}.$ Using Eq.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.2 Exercise 12

Since $10^x$ is strictly increasing for real $x$ when $10>1$, the inequalities in (8) imply $10^{0.30102999} < 2 < 10^{0.30103000}.$ Applying the monotonicity of $10^x$ and the definition of logarithm...

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.2 Exercise 11

Let $y = 10^x$.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.2 Exercise 10

Assume that $\log_{10} 2$ is rational.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 1.2.2 Exercise 9

Let $b>0$, and let $x=\frac{p}{q}$ and $y=\frac{r}{s}$, where $p,r\in\mathbb{Z}$ and $q,s$ are positive integers.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.2 Exercise 8

Let $m$ be a positive integer and let $u>0$.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 1.2.2 Exercise 6

The issue is that decimal expansions are not unique.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.2 Exercise 5

A real number $x$ can be defined by a binary expansion $x = n + 0.b_1 b_2 b_3 \ldots,$ where $n$ is an integer and each $b_i \in {0,1}$, with the restriction that the sequence does not end in infinite...

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.2 Exercise 7

Let the exponentiation of an integer exponent be defined as in Eq.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.2 Exercise 4

We compute (0.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.2 Exercise 1

Let $r$ be a positive rational number.

taocpmathematicsalgorithmsvolume-1
TAOCP 1.2.2 Exercise 3

Let $b^n$ be defined for integer $n$ by the rules in (4).

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.11.3 Exercise 20

The flaw in the previous solution is not the asymptotic analysis itself, but the unjustified introduction of the factor $(n/2)^{1-k/2}$.

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 1.2.2 Exercise 2

The expression $1 + 0.239999999\ldots$ equals the real number whose fractional part is $0.239999999\ldots$, hence it represents $1.239999999\ldots$.

taocpmathematicsalgorithmsvolume-1
TAOCP 1.2.11.3 Exercise 18

The function $Q(n)$ is defined in this section so that its normalization removes the factor $n^n$ from sums of the form \sum_{k=0}^n \binom{n}{k} k^k (n-k)^{n-k}.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.11.3 Exercise 17

For fixed integer $n>0$, consider the series S(n) = 1 + \frac{n}{n+1} + \frac{n}{n+1}\frac{n+1}{n+2} + \cdots = \sum_{k \ge 0} a_k,

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 1.2.11.3 Exercise 16

The previous argument fails because it never uses a valid definition of $Q(k)$ and therefore cannot justify any of the inversion steps.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.11.3 Exercise 19

Write C_n=\int_0^r e^{-nx}f(x)\,dx+\int_r^\infty e^{-nx}f(x)\,dx = A_n+B_n.

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 1.2.11.3 Exercise 8

Start from the identity \left(1+\frac{u}{x}\right)^x = \exp\!

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 1.2.11.3 Exercise 7

We restart from the integrand and determine all contributions that survive after integration down to order $O(x^{-2})$.

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 1.2.11.3 Exercise 15

Consider I=\int_0^\infty \left(1+\frac{z}{n}\right)^n e^{-z}\,dz.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.11.3 Exercise 4

From the definition, v = u - \ln(1+u).

taocpmathematicsalgorithmsvolume-1hm-simple
TAOCP 1.2.11.3 Exercise 5

The errors in the previous solution stem from treating the Euler–Maclaurin remainder and the size of $f^{(3)}$ in a purely global way, and from introducing an unsupported “cancellation” step.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.11.3 Exercise 6

Start from the exact factorization \frac{(n+\alpha)^n}{n^{n+\beta}} = n^{-\beta}\left(1+\frac{\alpha}{n}\right)^n.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.11.3 Exercise 3

Start from Eq.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.11.3 Exercise 2

Let \gamma(a,x)=\int_0^x e^{-t}t^{a-1}\,dt,\qquad a>0,\ x\ge 0.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.11.2 Exercise 12

The previous solution fails because it treats a non-power-series manipulation as if it were coefficient algebra.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.11.3 Exercise 1

Let S_n(x)=\sum_{k=0}^{n}\frac{x^k}{k!

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.11.2 Exercise 13

Assume $g(n)=\Omega(f(n))$.

taocpmathematicsalgorithmsvolume-1math-simple
TAOCP 1.2.11.2 Exercise 11

From the definition of the exponential function, e^x = \sum_{k\ge 0}\frac{x^k}{k!

taocpmathematicsalgorithmsvolume-1math-simple
CF 105348C - String Traversal Paradigm 1

We are given a string s of length n, and we should think of every occurrence of a character as a position on a line. Moving between two positions has a cost that depends on whether the characters are the same.

codeforcescompetitive-programming
TAOCP 1.2.11.2 Exercise 8

Let m = an^2 + bn.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.11.2 Exercise 9

Let \binom{2n}{n}=\frac{(2n)!

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.11.2 Exercise 10

Let $u(z)=O(z^m)$ as $z\to 0$.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.11.2 Exercise 4

Let $f(x)=x^m$.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.11.2 Exercise 7

Let P_n = 1^1 2^2 3^3 \cdots n^n.

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 1.2.11.2 Exercise 5

Assume n!

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 1.2.11.2 Exercise 6

We restart the argument using a representation of $\Gamma$ that avoids any delicate extraction from the digamma kernel.

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 1.2.11.2 Exercise 2

Equation (10) is obtained in Euler’s summation formula by repeated application of finite-difference identities that depend on a specific sequence of coefficients introduced in Eq.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.11.2 Exercise 1

Equation (7) in Section 1.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.11.2 Exercise 3

Let $m=2k>0$ and assume $f^{(m)}(x)$ has constant sign on $1\le x\le n$.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.10 Exercise 21

The error in the previous solution is not in the Chernoff optimization step or the reduction to a KL divergence, but in the justification of the quadratic lower bound.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.10 Exercise 20

Let $d_k = a_k - b_k$, where $b_1 \le b_2 \le \cdots \le b_n$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.10 Exercise 22

Let $G(z)=\prod_{k=1}^n (q_k+p_k z)$ be the probability generating function of $X$.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.10 Exercise 19

Let $a_1a_2\ldots a_n$ be a permutation of ${1,2,\ldots,n}$ and let $b_1b_2\ldots b_n$ be its inverse, so that a_k = l \iff b_l = k.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.10 Exercise 16

Let $g_i(z)=\sum_k p^{(i)}_k z^k$ be the generating function of distribution $g_i$, so $p^{(i)}_k$ is the probability that the value equals $k$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.10 Exercise 15

The probability that the quantity has value $k$ is $e^{-\mu}\frac{\mu^k}{k!}$.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.10 Exercise 18

Let the multiset consist of $k_i$ copies of value $i$, $1\le i\le n$, with \sum_{i=1}^n k_i = n.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 1.2.10 Exercise 17

Let f(z)=\sum_{k\ge 0} a_k z^k,\qquad g(z)=\sum_{n\ge 0} b_n z^n be probability generating functions.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 1.2.10 Exercise 12

Let F(t)=G(e^t)=\sum_{k\ge 0} p_k e^{kt}.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.10 Exercise 11

Let $G(z)=\sum_k p_k z^k$ be the probability generating function of a distribution for a random variable $A$.

taocpmathematicsalgorithmsvolume-1math-simple
TAOCP 1.2.10 Exercise 13

Let G_n(z)=\prod_{k=2}^{n}\frac{z+k-1}{k} be the probability generating function in Eq.

taocpmathematicsalgorithmsvolume-1hm-project
TAOCP 1.2.10 Exercise 14

Let $G_n(z) = (q + pz)^n$ be the generating function of the binomial distribution, where $p+q=1$, $q=1-p$, $0<p<1$.

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 1.2.10 Exercise 8

Let the sample space consist of all sequences $(X[1],X[2],\ldots,X[n])$ with each $X[k]$ chosen independently from a set of $M$ distinct elements.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.10 Exercise 10

Let $X[1],\ldots,X[n]$ be independent uniform draws from a set of $M$ objects.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.10 Exercise 9

Let $X[1],X[2],\ldots,X[n]$ be chosen independently from a set of $M$ distinct elements, each of the $M^n$ sequences being equally likely.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.10 Exercise 4

Let $X_1,\ldots,X_n$ be independent trials with $\Pr(X_i=\text{head})=p$ and $\Pr(X_i=\text{tail})=q=1-p$.

taocpmathematicsalgorithmsvolume-1math-simple
TAOCP 1.2.10 Exercise 7

Let $X[1],X[2],\ldots,X[n]$ be a random sequence containing exactly $m$ distinct values.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 1.2.10 Exercise 5

The distribution in Fig.

taocpmathematicsalgorithmsvolume-1math-simple
TAOCP 1.2.10 Exercise 6

Let $G(z)=\sum_k p_k z^k$ be a probability generating function with $G(1)=1$.

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 1.2.10 Exercise 2

Let G(z)=\sum_{k} p_k z^k, \qquad G(1)=\sum_k p_k=1.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.10 Exercise 3

For Algorithm M, the number of times step M4 is executed is the random variable $A$, whose distribution satisfies the results of Section 1.

taocpmathematicsalgorithmsvolume-1math-simple
TAOCP 1.2.10 Exercise 1

From (4) with $k=0$, p_{n0}=\frac{1}{n}p_{n-1,-1}+\frac{n-1}{n}p_{n-1,0}.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.1 Exercise 15

Let $\prec$ be a relation on a set $S$ satisfying properties (i)–(iii) of the exercise, so that $S$ is well-ordered by $\prec$.

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 1.2.1 Exercise 14

A correct solution must avoid any assumption that Floyd verification conditions are decidable by semantic truth tables.

taocpmathematicsalgorithmsvolume-1research
TAOCP 1.2.1 Exercise 12

The solution must be rebuilt because the central issue is not a norm estimate but the fact that the _text’s intended generalization of Algorithm E is not a Euclidean algorithm in_ $\mathbb{Z}[\sqrt{2}...

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.1 Exercise 13

Let the original Algorithm E be augmented so that at the beginning of every execution of each step E1, E2, E3, and E4, the operation $T \leftarrow T + 1$ is performed, with $T = 0$ initially.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.1 Exercise 10

We prove by induction on integers $n \ge 10$ that 2^n > n^3.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.1 Exercise 11

The previous solution failed because the proposed identity was incorrect.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 1.2.1 Exercise 8

Let $P(n)$ denote the statement that n^3 = (n^2 - n + 1) + (n^2 - n + 3) + \cdots + (n^2 + n - 1).

taocpmathematicsalgorithmsvolume-1medium
TAOCP 1.2.1 Exercise 9

Let $P(n)$ be the statement $(1 - a)^n \ge 1 - na$ for a fixed real number $a$ satisfying $0 < a < 1$, and for all positive integers $n$.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 1.2.1 Exercise 7

Let $S_n = n^2 - (n-1)^2 + (n-2)^2 - \cdots + (-1)^{n-1} 1^2$ for positive integers $n$.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 1.2.1 Exercise 4

Let $P(n)$ denote the statement $F_n \ge \phi^{,n-2}$ for all positive integers $n$, where $F_0 = 0$, $F_1 = 1$, $F_{n+1} = F_n + F_{n-1}$, and $\phi = (1 + \sqrt{5})/2$.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 1.2.1 Exercise 6

Before step E4, equations (6) state that $a' m + b' n = c,$ $a m + b n = d.$ Step E2 supplies integers $q$ and $r$ such that $c = qd + r.$ After step E4, the updated variables are

taocpmathematicsalgorithmsvolume-1medium
TAOCP 1.2.1 Exercise 5

Let $P(n)$ denote the statement that every integer $n>1$ can be written as a product of one or more prime numbers, where a prime number is considered a product consisting of itself alone.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 1.2.1 Exercise 3

Let S_n = \frac{1}{1 \times 2} + \frac{1}{2 \times 3} + \cdots + \frac{1}{(n - 1)n}.

taocpmathematicsalgorithmsvolume-1medium