brain

tamnd's digital brain — notes, problems, research

41311 notes

TAOCP 4.3.1 Exercise 14

We prove the validity of Algorithm M by induction on the outer loop variable $j$, using the method of inductive assertions from Section 1.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.3.1 Exercise 15

The solution correctly addresses the exercise.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.3.1 Exercise 12

Exercise 4.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.3.1 Exercise 13

Let the multiplicand be stored in memory as U=(u_{n-1}\ldots u_1u_0)_b, with one digit per word, and let $v$ be a single precision number,

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.3.1 Exercise 10

Program S represents the quantity $1+k$ in register A.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.3.1 Exercise 9

Exercise 4.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.3.1 Exercise 11

Compare the digits beginning with the most significant position.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 4.3.1 Exercise 7

Exercise 4.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.3.1 Exercise 8

Exercise 5 of section 4.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.3.1 Exercise 5

Unusual activity has been detected from your device.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.3.1 Exercise 6

We are asked to design an algorithm that adds two numbers digit by digit from **most significant to least significant**, producing each output digit only when it cannot possibly be affected by future...

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.3.1 Exercise 3

A single-precision floating point number in MIX, as defined in Section 4.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.3.1 Exercise 2

**Solution: Generalizing Algorithm A for Column Addition of $m$ Nonnegative $n$-Place Integers** Let $x_1, x_2, \dots, x_m$ be $m$ nonnegative integers, each expressed in base $b$ as $n$-digit numbers...

taocpmathematicsalgorithmsvolume-1simple
TAOCP 4.3.1 Exercise 1

Exercise 4.

taocpmathematicsalgorithmsvolume-1
TAOCP 4.2.4 Exercise 8

We restate (10) in the form relevant here.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 4.2.4 Exercise 5

Let $U$ be uniformly distributed on $[0,1)$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.2.4 Exercise 4

Let a page of the antilogarithm table correspond to a fixed interval of the argument $y = \log_{10} x$, for example a unit interval $[k, k+1)$, where the table returns $x = 10^y$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.2.4 Exercise 6

Let a positive normalized radix $16$ floating point number have fraction part $f$ satisfying $1/16 \le f < 1$.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.2.4 Exercise 3

Let $U>0$ be a floating decimal number.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 4.2.4 Exercise 2

This exercise is experimental.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.2.4 Exercise 1

Write the floating point decimal numbers in normalized form: u=10^{e_u}f_u,\qquad v=10^{e_v}f_v, where

taocpmathematicsalgorithmsvolume-1simple
TAOCP 4.2.3 Exercise 6

A single-precision floating point number in MIX, as defined in Section 4.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.2.3 Exercise 5

**Exercise 4.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.2.3 Exercise 3

Program M computes a double-precision product by expanding each normalized operand into high and low halves, forming four partial products, then discarding all terms that lie strictly to the right of...

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.2.3 Exercise 4

**Exercise 4.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.2.3 Exercise 1

We write all numbers in the TAOCP double–precision format with \epsilon = \frac{1}{100}.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.2.3 Exercise 2

Program **B** is designed to perform a sequence of numerical calculations using the X-register of a hypothetical or HP-style RPN calculator.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.2.2 Exercise 32

We are asked to determine all pairs $(a, b)$ such that \text{round}(b, \text{even}(x)) = \lfloor ax + b \rfloor + \lfloor ax - b \rfloor holds for all real $x$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.2.2 Exercise 31

The phenomenon arises from catastrophic cancellation.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.2.2 Exercise 30

Let x(y)=\left(\frac13-y^2\right)(3+3.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.2.2 Exercise 28

Let $F$ be the set of floating point numbers in the interval $[x_0 \mathinner{\ldotp\ldotp} x_1]$.

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 4.2.2 Exercise 29

Solution to TAOCP 4.2.2 Exercise 29.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.2.2 Exercise 26

Let $u$, $u'$, $v$, and $v'$ be positive floating point numbers such that $u \sim u'$ ($r$) and $v \sim v'$ ($s$), where $r$ and $s$ are small relative errors in normalized arithmetic.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.2.2 Exercise 25

The point is that _cancellation_ is often misunderstood.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 4.2.2 Exercise 27

Let x = 1 \ominus u.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.2.2 Exercise 23

The statement is **false**.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.2.2 Exercise 24

We need to construct interval arithmetic for extended floating-point intervals, including signed zeros and infinities, with the ordering -\infty < -x < -0 < 0 < +0 < +x < +\infty for all positive $x$.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.2.2 Exercise 21

**Solution to Exercise 4.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.2.2 Exercise 22

Let T(x)=(x\otimes v)\oslash v, so that

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.2.2 Exercise 20

The bug in the previous solution is not in the algorithm itself but in the testing harness and how the function `can_divide` is scoped and used.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.2.2 Exercise 19

Solution to TAOCP 4.2.2 Exercise 19.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.2.2 Exercise 18

We work in **unnormalized floating-point arithmetic** with base $b$ and precision $p$, and assume that no overflow or underflow occurs.

taocpmathematicsalgorithmsvolume-1math-project
TAOCP 4.2.2 Exercise 17

The solution does address the exact question.

taocpmathematicsalgorithmsvolume-1hard
TAOCP 4.2.2 Exercise 16

The previous solution is completely unrelated to the exercise.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.2.2 Exercise 14

Let $u$, $v$, and $w$ be floating point numbers, not necessarily normalized, and consider _unnormalized multiplication_, denoted by $\otimes$.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.2.2 Exercise 15

We are asked whether, in floating-point arithmetic, the computed midpoint of an interval always lies between the endpoints.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.2.2 Exercise 13

Let $m$ and $n\ne 0$ be integers represented exactly as normalized floating point numbers with $p$ significant digits in base $b$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.2.2 Exercise 12

The proposed solution does **not** answer the question asked.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.2.2 Exercise 11

We are asked to **prove Lemma T** (TAOCP, Section 4.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.2.2 Exercise 8

In one's complement notation, the value represented by $(e,+.f)$ is $+.f\times 2^e$.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.2.2 Exercise 9

Equation (33) in Section 4.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.2.2 Exercise 10

Let the radix be $b$ and let the precision be $p$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.2.2 Exercise 7

Consider binary floating point arithmetic with a small precision.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.2.2 Exercise 6

We consider each identity in turn, assuming that all operations are normalized floating point operations as defined in Section 4.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.2.2 Exercise 4

**Solution.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 4.2.2 Exercise 3

All computations are performed in eight-digit floating decimal arithmetic with rounding to the nearest floating point number, as in Section 4.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.2.2 Exercise 5

The answer is **no**.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.2.2 Exercise 2

Assume that $x\ge0$ and $y\ge0$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.2.2 Exercise 1

**Exercise 4.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.2.1 Exercise 19

The running time of the FADD subroutine in Program A depends on several characteristics of the input floating point numbers $u = (e_u, f_u)$ and $v = (e_v, f_v)$, and on the parameters $b$ (byte size)...

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.2.1 Exercise 18

Let the machine be as described: 36-bit words, positive floating numbers represented as (0\,e_1 e_2 \ldots e_6 \, f_1 f_2 \ldots f_{27})_2, with an excess-64 exponent $(e_1\ldots e_6)_2$ and a 27-bit...

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.2.1 Exercise 17

The goal is to design a single-word floating-point representation in which the exponent range increases as its magnitude increases, while the precision of the fraction decreases correspondingly.

taocpmathematicsalgorithmsvolume-1project
TAOCP 4.2.1 Exercise 15

We correct the solution by making all intermediate operations explicit in MIX terms and by giving a complete MIXAL-level subroutine.

taocpmathematicsalgorithmsvolume-1hard
TAOCP 4.2.1 Exercise 16

Let $(a+bi)/(c+di)$ be a complex quotient with real floating point numbers $a$, $b$, $c$, and $d$, where $c+d \ne 0$.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 4.2.1 Exercise 13

The key failure in the previous solution is the assumption that rounding only occurs in Algorithm N.

taocpmathematicsalgorithmsvolume-1hard
TAOCP 4.2.1 Exercise 14

Let the input in register $A$ represent a floating point number in MIX format, possibly unnormalized.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.2.1 Exercise 12

Let the floating point numbers be represented in normalized form with base $b$, precision $p$, and excess-$q$ exponent, as described in Section 4.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.2.1 Exercise 11

We are asked to exhibit normalized, eight-digit floating decimal numbers $u$ and $v$, with excess 50, such that multiplication of $u$ and $v$ results in _rounding overflow_.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.2.1 Exercise 10

We are asked to construct **normalized eight-digit floating decimal numbers** $u$ and $v$ whose **sum produces rounding overflow** in the sense of TAOCP, Section 4.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 4.2.1 Exercise 9

Work in the TAOCP floating-point model: base $10$, precision $p=8$, normalized numbers $0.d_1d_2\ldots d_8\times 10^e$, with exponent range $-50\le e<50$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.2.1 Exercise 8

We consider floating point arithmetic in the context of base-$b$ digits with normalized representation, following Section 4.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.2.1 Exercise 7

**Problem.

taocpmathematicsalgorithmsvolume-1hard
TAOCP 4.2.1 Exercise 6

The answer is determined by the normalization routine used by FADD.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.2.1 Exercise 5

Let f_e=b^{p-2}F_e, where $F_e$ is an integer.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.2.1 Exercise 2

We are asked to determine the largest and smallest positive values representable in a base-$b$, excess-$q$, $p$-digit floating point system, both in general and under the _normalized_ constraint.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 4.2.1 Exercise 4

We are asked to compute the result of Algorithm A for the given pairs of floating-point numbers in base $b=10$ with precision $p=8$.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.2.1 Exercise 3

The proposed solution does **not** address the exercise that was asked.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 4.2.1 Exercise 1

In MIX floating point with byte size $100$, a number is represented as (\text{sign})\,(e,b_1,b_2,b_3,b_4), where

taocpmathematicsalgorithmsvolume-1simple
TAOCP 4.1 Exercise 34

Let n=\sum_{i\ge0} a_i2^i, \qquad a_i\in\{-1,0,1\}.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.1 Exercise 31

Let u=(\ldots u_3u_2u_1u_0.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.1 Exercise 33

Let S_n=\left\{\sum_{i=0}^{n-1} a_i3^i : a_i\in D=\{-1,0,3\}\right\}, and let

taocpmathematicsalgorithmsvolume-1math-project
TAOCP 4.1 Exercise 32

Let A=\left\{\sum_{i\ge 0}\varepsilon_i3^i:\varepsilon_i\in\{0,1\}\right\}, \qquad B=\left\{\sum_{j\ge 0}\delta_j5^j:\delta_j\in\{0,1\}\right\}.

taocpmathematicsalgorithmsvolume-1math-project
TAOCP 4.1 Exercise 30

Let b_0,b_1,b_2,\ldots be a binary basis, that is, every integer has a unique representation

taocpmathematicsalgorithmsvolume-1math-project
TAOCP 4.1 Exercise 29

Let ${T_0, T_1, T_2, \ldots}$ be a collection of sets of nonnegative integers that satisfies **Property B**; that is, every nonnegative integer $n$ can be written uniquely as n = t_0 + t_1 + t_2 + \cd...

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.1 Exercise 28

Let $z = a + bi$ be a nonzero Gaussian integer, where $a, b \in \mathbb{Z}$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.1 Exercise 27

Let $n$ be a nonzero integer.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.1 Exercise 26

A skater moves on horizontal ice with both skate blades in contact with the surface.

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 4.1 Exercise 24

Let D_t=\{0,1,2,3,4,5,6,7,8,10+t\}, \qquad t=0,1,2,\ldots We shall prove that every $D_t$ satisfies conditions (i), (ii), and (iii).

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.1 Exercise 25

Let x=\frac{u}{v}, where $b\ge2$, $u>0$, $v>0$, and

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.1 Exercise 22

**Exercise 4.

taocpmathematicsalgorithmsvolume-1hm-medium
TAOCP 4.1 Exercise 21

Let the digit set be D=\left\{-\frac{9}{2},-\frac{7}{2},-\frac{5}{2},-\frac{3}{2},-\frac{1}{2},\frac{1}{2},\frac{3}{2},\frac{5}{2},\frac{7}{2},\frac{9}{2}\right\}.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.1 Exercise 23

Let $D={d_1,\dots,d_b}\subset \mathbb{R}$ be a finite digit set with the property that every positive real number admits at least one representation of the form x=\sum_{k\le n} a_k b^k,\qquad a_k\in D...

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 4.1 Exercise 20

**Exercise 4.

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 4.1 Exercise 19

Let $D$ be a set of $b$ integers such that for each residue $j$ modulo $b$, there exists exactly one element $a \in D$ with a \equiv j \pmod{b}, \quad 0 \le j < b.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.1 Exercise 18

Let $B = i - 1$ denote the base of the number system under consideration.

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 4.1 Exercise 16

Let (a_n a_{n-1} \ldots a_1 a_0)_{i-1} = \sum_{j=0}^{n} a_j (i-1)^j be a number in the $(i-1)$-ary system, where each digit satisfies

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.1 Exercise 17

Let $\beta = i + 1$.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.1 Exercise 15

We correct the missing justification by giving a fully constructive expansion algorithm for the negative decimal system and then completing the standard argument for the quater-imaginary system.

taocpmathematicsalgorithmsvolume-1math-medium
CF 104664E - Riddle Me This (Easy Version)

We are given an even number of arrays, each array is a permutation of numbers from 1 to some common length $n$. The key operation allowed on any array is a cyclic rotation, where the last element moves to the front.

codeforcescompetitive-programming
TAOCP 4.1 Exercise 14

Let the base be $2i$, as in the quater-imaginary system.

taocpmathematicsalgorithmsvolume-1simple