brain

tamnd's digital brain — notes, problems, research

43815 notes

TAOCP 1.2.8 Exercise 7

We use two standard facts about Fibonacci numbers.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.8 Exercise 3

The Fibonacci numbers satisfy the recurrence F_{n+1} = F_n + F_{n-1}, \qquad F_1 = 1,\; F_2 = 1.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 1.2.8 Exercise 5

We use the standard initial values $F_0=0$, $F_1=1$, $F_2=1$, and the recurrence $F_{n+1}=F_n+F_{n-1}$ for $n\ge 1$.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 1.2.8 Exercise 4

The Fibonacci numbers are defined by $F_1=1$, $F_2=1$, and $F_{n+2}=F_{n+1}+F_n$ for $n \ge 1$.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.7 Exercise 24

Define the partial products P_n(x)=xe^{\gamma x}\prod_{k=1}^n\left(\left(1+\frac{x}{k}\right)e^{-x/k}\right).

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.8 Exercise 1

Let $R_n$ be the number of rabbit pairs after $n$ months, starting with one newborn pair at month $0$, and assume each pair becomes productive after one month and then produces one new pair every mont...

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.7 Exercise 25

Let $H_n^{(u)}=\sum_{k=1}^{n}\frac{1}{k^u}$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.8 Exercise 2

From equation (15), F_n = \frac{\phi^n}{\sqrt{5}} \text{ rounded to the nearest integer.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 1.2.7 Exercise 21

Let S=\sum_{k=1}^{n}\frac{H_k}{n+1-k}.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.7 Exercise 22

The error identified in the review is genuine: the admissible region for $(i,j)$ was shifted from $i+j\le n$ to $i+j\le n+1$.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 1.2.7 Exercise 23

Let the digamma function be defined by \psi(x) = \frac{\Gamma'(x)}{\Gamma(x)}.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.7 Exercise 20

Let $f(x)=\sum_{k\ge 0} a_k x^k$ converge at $x=x_0$.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.7 Exercise 18

Let S_n=\sum_{k=1}^n \frac{1}{2k-1}.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 1.2.7 Exercise 19

For $n \ge 0$, the harmonic number is defined by H_n = \sum_{k=1}^{n}\frac{1}{k}, with $H_0 = 0$ by the empty sum convention.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 1.2.7 Exercise 16

Let S=\sum_{k=1}^{n}\frac{1}{2k-1}.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 1.2.7 Exercise 17

Let $p$ be an odd prime and consider H_{p-1}=\sum_{k=1}^{p-1}\frac{1}{k}.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.7 Exercise 15

Let S_n = \sum_{k=1}^{n} H_k^2.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.7 Exercise 12

Let H_{\infty}^{(1000)}=\sum_{k=1}^{\infty}\frac{1}{k^{1000}}=1+R,\qquad R=\sum_{k=2}^{\infty}\frac{1}{k^{1000}}.

taocpmathematicsalgorithmsvolume-1math-simple
TAOCP 1.2.7 Exercise 13

Start with the binomial expansion x^k = (1+(x-1))^k = \sum_{j=0}^{k}\binom{k}{j}(x-1)^j.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.7 Exercise 14

Let S=\sum_{k=1}^{n}\frac{H_k}{k}.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.7 Exercise 10

Let S=\sum_{1\le k<n}(a_{k+1}-a_k)b_k.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.7 Exercise 8

Define A_n=\sum_{k=1}^n H_k,\qquad B_n=\sum_{k=1}^n \ln k=\ln(n!

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.7 Exercise 9

Let S_n=\sum_{k=1}^{n}\binom{n}{k}(-1)^k H_k.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.7 Exercise 11

Let S=\sum_{1<k\le n}\frac{1}{k(k-1)}H_k =\sum_{k=2}^{n}\frac{1}{k(k-1)}H_k.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.7 Exercise 6

Let $\left[{n \atop k}\right]$ denote the Stirling numbers of the first kind, defined by the recurrence \left[{n \atop k}\right] = (n-1)\left[{n-1 \atop k}\right] + \left[{n-1 \atop k-1}\right], with...

taocpmathematicsalgorithmsvolume-1math-simple
TAOCP 1.2.7 Exercise 4

The integral comparison gives \int_1^n \frac{dx}{x} < \sum_{k=1}^n \frac{1}{k} < 1 + \int_1^n \frac{dx}{x}, hence

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.7 Exercise 7

Define T(m,n)=H_m+H_n-H_{mn}, \qquad m,n\in \mathbb{Z}_{>0}.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.7 Exercise 5

We restart the computation from the Euler–Maclaurin expansion and carry all arithmetic consistently to the required precision.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.7 Exercise 3

Let H_n^{(r)} = \sum_{k=1}^{n} \frac{1}{k^r}, \qquad r>1.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.7 Exercise 2

For $m \ge 0$, write H_{2^m} = \sum_{k=1}^{2^m} \frac{1}{k}.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.7 Exercise 1

By definition of harmonic numbers, $H_n = \sum_{k=1}^{n} \frac{1}{k}$, with the convention that an empty sum equals $0$.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.6 Exercise 68

The earlier response failed because it replaced the task instead of proving the stated identity.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 66

Let f_k(r)=\binom{r}{k},\qquad r\ge k-1, for real $r$.

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 1.2.6 Exercise 67

For $k = 0$, the binomial coefficient satisfies $\binom{n}{0} = 1$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 65

The exercise assumes Eqs.

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 1.2.6 Exercise 62

The previous argument failed because it repeatedly used coefficient manipulations that do not respect dependence on the summation index $k$, and it invoked an unproved alternating Vandermonde identity...

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 64

Let $S(n,m)$ denote the number of ways to partition a set of $n$ elements into $m$ nonempty disjoint subsets.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 63

The original solution fails because it introduces an incorrect algebraic factorization and then builds a decoupling argument on it.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 1.2.6 Exercise 59

The core issue is that the recurrence is valid only for $k \ge 1$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 58

Let P_n(x)=\prod_{j=0}^{n-1}(1+q^j x), \qquad n\ge 0.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 60

Let the $n$ objects be labeled $1,2,\ldots,n$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 61

The key failure is the incorrect “recognition step.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 54

Let $P = (p_{ij})_{i,j \ge 0}$ denote Pascal’s triangle matrix defined by p_{ij} = \begin{cases} \binom{i}{j}, & i \ge j,\\ 0, & i < j.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 56

For integers $a>b>c\ge 0$, define the representation n=\binom{a}{3}+\binom{b}{2}+\binom{c}{1}.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 1.2.6 Exercise 55

Let $S(n,k)$ denote Stirling numbers of the second kind and $s(n,k)$ denote Stirling numbers of the first kind in the signed form.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 57

Let $f(n)=\ln(n!)$ and $\Delta f(n)=f(n+1)-f(n)$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 53

Let S_m=\sum_{k=0}^{m}\binom{r}{k}\binom{s}{n-k}\bigl(nr-(r+s)k\bigr).

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 52

Abel’s binomial formula (TAOCP 1.

taocpmathematicsalgorithmsvolume-1hm-simple
TAOCP 1.2.6 Exercise 51

Let $z=x+y$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 47

Let $k \ge 0$ be an integer and $r$ an arbitrary parameter.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 49

From the binomial theorem (13), interpreted as formal power series in $x$, we have (1+x)^r = \sum_{n \ge 0} \binom{r}{n} x^n.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 48

Assume $x \notin {0,-1,-2,\ldots,-n}$ so that all denominators are nonzero.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 50

Abel’s formula (Eq.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 45

Let $k$ be a fixed integer with $k \ge 0$.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.6 Exercise 43

From the definition of the beta function, B\!

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.6 Exercise 46

Stirling’s approximation (Eq.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 44

From the generalized binomial coefficient (Exercise 42), for real $r$ and real $k$ we use \binom{r}{k}=\frac{\Gamma(r+1)}{\Gamma(k+1)\Gamma(r-k+1)}.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.6 Exercise 40

For $x>0$, B(x,1)=\int_0^1 t^{x-1}(1-t)^{0}\,dt=\int_0^1 t^{x-1}\,dt.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.6 Exercise 42

From the factorial representation (5), \binom{r}{k}=\frac{\Gamma(r+1)}{\Gamma(k+1)\Gamma(r-k+1)}.

taocpmathematicsalgorithmsvolume-1hm-simple
TAOCP 1.2.6 Exercise 41

Let $x>0$ and $y>0$.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.6 Exercise 39

The numbers $\left[{n \atop k}\right]$ count permutations of $n$ objects with exactly $k$ cycles.

taocpmathematicsalgorithmsvolume-1math-simple
TAOCP 1.2.6 Exercise 38

Let $n,m,k$ be integers with $m \ge 1$.

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 1.2.6 Exercise 37

Let S=\binom{n}{0}+\binom{n}{2}+\binom{n}{4}+\cdots .

taocpmathematicsalgorithmsvolume-1math-simple
TAOCP 1.2.6 Exercise 36

From the binomial theorem (13) with $x=1$, $y=1$, (1+1)^n=\sum_k \binom{n}{k}1^k1^{n-k}=\sum_k \binom{n}{k}, so

taocpmathematicsalgorithmsvolume-1math-simple
TAOCP 1.2.6 Exercise 33

Proceed by induction on $n$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 34

Let R_n(x,y)=\sum_{k} \binom{n}{k}\,x\,(x-kz+1)^{\overline{k-1}}(y+kz)^{\overline{n-k}}.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 35

Let the Stirling numbers of the second kind $S(n,k)$ and the Stirling numbers of the first kind $s(n,k)$ be defined by Eqs.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 32

The stated identity is incorrect, so no proof of it can be completed as written.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 31

Let A=m-r+s,\qquad B=n+r-s,\qquad M=m+n.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 29

Let Eq.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 30

Let Example 3 define S=\sum_{k} \binom{r}{k}\binom{s}{m+k}, where the sum is over all integers $k$ for which the binomial coefficients are defined, i.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 26

Let z = x^t(x-1), \qquad x = 1 + z x^{-t}.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.6 Exercise 25

The previous solution fails because it assumes, without proof, that the polynomials $A_k(r,t)$ coincide with the Taylor coefficients of $x^r$ in the variable $z=x^{t+1}-x^t$.

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 1.2.6 Exercise 27

The error in the previous solution is not in the Lagrange inversion part, but in the attempt to derive Eq.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 1.2.6 Exercise 28

Let L_n(r,s,t)=\sum_{k\ge 0} \binom{r+tk}{k}\binom{s-tk}{n-k},\qquad R_n(r,s,t)=\sum_{k\ge 0} \binom{r+s-k}{n-k}t^k.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 22

Equation (26) is the binomial convolution identity \binom{r+s}{n}=\sum_{k=0}^{n}\binom{r}{k}\binom{s}{n-k}, which follows by comparing coefficients of $x^n$ in two expansions of $(1+x)^{r+s}$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 23

Let Eq.

taocpmathematicsalgorithmsvolume-1math-simple
TAOCP 1.2.6 Exercise 24

Let $P(r,s,t,n)$ denote the statement of Eq.

taocpmathematicsalgorithmsvolume-1math-simple
TAOCP 1.2.6 Exercise 21

Both sides of Eq.

taocpmathematicsalgorithmsvolume-1math-simple
TAOCP 1.2.6 Exercise 19

Let S_n = \sum_{k=0}^{n} (-1)^k \binom{r}{k}.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 20

Start from Eq.

taocpmathematicsalgorithmsvolume-1math-medium
CF 105348D - String Traversal Paradigm 2

Codeforces 105348D: String Traversal Paradigm 2

codeforcescompetitive-programming
TAOCP 1.2.6 Exercise 18

Equation (21) (Chu–Vandermonde) states \sum_{k}\binom{r}{k}\binom{s}{n-k}=\binom{r+s}{n}, \qquad \text{integer } n.

taocpmathematicsalgorithmsvolume-1math-simple
TAOCP 1.2.6 Exercise 17

Equation (15) gives the binomial expansion (1+x)^r = \sum_{k} \binom{r}{k} x^k, valid for all real $r$ and integer $k \ge 0$, and similarly

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 16

For integers $k \ge 0$, definition (3) gives \binom{-n}{k-1} = \prod_{j=1}^{k-1} \frac{-n+1-j}{j} = \prod_{j=1}^{k-1} \frac{-(n-1+j)}{j}.

taocpmathematicsalgorithmsvolume-1math-simple
TAOCP 1.2.6 Exercise 14

From Eq.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 15

Induction on $r$ is used.

taocpmathematicsalgorithmsvolume-1math-simple
TAOCP 1.2.6 Exercise 11

Let $p$ be prime and write the base-$p$ expansions a = \sum_{i \ge 0} a_i p^i,\qquad b = \sum_{i \ge 0} b_i p^i,\qquad 0 \le a_i,b_i \le p-1.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 13

Fix a real number $r$ and an integer $n \ge 0$.

taocpmathematicsalgorithmsvolume-1math-simple
TAOCP 1.2.6 Exercise 12

Let $n$ be a positive integer and consider the $n$th row of Pascal’s triangle, consisting of the numbers $\binom{n}{k}$ for $0 \le k \le n$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 10

Let $p$ be prime.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 1.2.6 Exercise 7

Let $n$ be a fixed positive integer and consider the sequence $\binom{n}{k}$ for integers $k$, $0 \le k \le n$.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.6 Exercise 9

Let $n \ge 0$ be an integer.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.6 Exercise 8

Equation (6) states that \binom{n}{k} = \binom{n}{n-k}.

taocpmathematicsalgorithmsvolume-1
TAOCP 1.2.6 Exercise 4

The number of bridge hands is \binom{52}{13} = \frac{52!

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.6 Exercise 6

For negative $r$, the entries are determined by Eq.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.6 Exercise 5

From Pascal’s triangle, the row corresponding to $r=4$ is \binom{4}{0},\ \binom{4}{1},\ \binom{4}{2},\ \binom{4}{3},\ \binom{4}{4} = 1,\ 4,\ 6,\ 4,\ 1.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 1.2.6 Exercise 3

A bridge hand consists of choosing 13 cards from a deck of 52 distinct cards, where order is irrelevant.

taocpmathematicsalgorithmsvolume-1
TAOCP 1.2.6 Exercise 2

For integer exponents, the identity $a^0 = 1$ is defined for all $a \ne 0$, while $0^k = 0$ for all integers $k > 0$.

taocpmathematicsalgorithmsvolume-1
TAOCP 1.2.6 Exercise 1

The number of combinations of $n$ objects taken $n-1$ at a time is $\binom{n}{n-1}$.

taocpmathematicsalgorithmsvolume-1