brain

tamnd's digital brain — notes, problems, research

41641 notes

TAOCP 4.3.2 Exercise 2

We are asked whether Theorem C from _The Art of Computer Programming_ would still hold if the variables $a$, $u_1, u_2, \dots, u_r$, and $u$ were allowed to be arbitrary real numbers instead of intege...

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.3.2 Exercise 4

Equation (13) is obtained by the rule stated immediately before it.

taocpmathematicsalgorithmsvolume-1hard
TAOCP 4.3.2 Exercise 3

Let m=\operatorname{lcm}(m_1,m_2,\ldots,m_r).

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.3.2 Exercise 1

Find all integers $u$ satisfying u \equiv 1 \pmod 7, \qquad u \equiv 0 \pmod{11}, \qquad

taocpmathematicsalgorithmsvolume-1project
TAOCP 4.3.1 Exercise 43

The desired value of $w$ is the nearest integer to $uv/255$.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.3.1 Exercise 40

Let $u$ be a $2n$-place number and $v$ an $n$-place number in base $b$, with $0 \le u < b^{2n}$, $0 \le v < b^n$, and assume $u = vq$ so the remainder is zero.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.3.1 Exercise 41

We are given a directed graph whose vertices are cities and whose root is city 1, the capital.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.3.1 Exercise 42

Let u_i=(u_{i,n-1}\cdots u_{i,1}u_{i,0})_b, \qquad 0\le u_i<b^n, and let

taocpmathematicsalgorithmsvolume-1hm-hard
TAOCP 4.3.1 Exercise 38

Let $x = uv$, where $0 \le u,v < 2^n$.

taocpmathematicsalgorithmsvolume-1
TAOCP 4.3.1 Exercise 39

The solution attempts to prove the lower bound on the true remainder when the trial quotient $\hat q$ underestimates the true quotient $q$ by 1.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.3.1 Exercise 36

Let \(\phi\) be given to \(n\) digits of precision in a fixed radix \(b\).

taocpmathematicsalgorithmsvolume-1
TAOCP 4.3.1 Exercise 37

In Algorithm D, step D1 multiplies both the dividend and the divisor by the same power of $b$ so that the leading digit of the divisor satisfies $v_{n-1} \ge \lfloor b/2 \rfloor$.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.3.1 Exercise 34

A correct solution must design algorithms, not analyze radix transformations.

taocpmathematicsalgorithmsvolume-1project
TAOCP 4.3.1 Exercise 35

A correct design must first remove the ambiguity about what “word-level scaling” means and then express every operation in terms of explicit operations on fixed-size word arrays.

taocpmathematicsalgorithmsvolume-1project
TAOCP 4.3.1 Exercise 31

Assume first that $v \ne 0$.

taocpmathematicsalgorithmsvolume-1hard
TAOCP 4.3.1 Exercise 32

**Solution to Exercise 4.

taocpmathematicsalgorithmsvolume-1
TAOCP 4.3.1 Exercise 30

In Algorithm A, each digit $w_j$ is computed from the expression $u_j + v_j + k$, where $k$ is the carry from the previous position.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.3.1 Exercise 29

The claim is: > At the beginning of step D3 of Algorithm D, we always have $u_{j+n} = 0$.

taocpmathematicsalgorithmsvolume-1simple
TAOCP 4.3.1 Exercise 28

Let $v = (.v_{n-1}\,v_{n-2}\,\ldots v_1\,v_0)_b$ with $v_{n-1} \ne 0$.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.3.1 Exercise 27

**Solution to Exercise 4.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.3.1 Exercise 25

**Corrected Solution to Exercise 4.

taocpmathematicsalgorithmsvolume-1hard
TAOCP 4.3.1 Exercise 26

Step D8 in Program D performs the correction after an over-subtraction in the trial quotient step of the division algorithm.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.3.1 Exercise 22

Let the dividend be $(u_3 u_2 u_1 u_0)_{10} = (8500)_{10}$ and the divisor be $(v_2 v_1 v_0)_{10} = (101)_{10}$.

taocpmathematicsalgorithmsvolume-1medium
TAOCP 4.3.1 Exercise 23

Let $b,v\in\mathbb{Z}$ with $1\le v<b$.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.3.1 Exercise 24

Section 4.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.3.1 Exercise 21

Let $u$ and $v$ be positive integers with $n$ digits in base $b$, written in the notation of Exercises 19 and 20: u = u_{n-1} b^{\,n-1} + u_{n-2} b^{\,n-2} + \cdots + u_0, \qquad v = v_{n-1} b^{\,n-1}...

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.3.1 Exercise 20

**Solution to Exercise 4.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.3.1 Exercise 19

In the setting of Fig.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.3.1 Exercise 16

**Solution to Exercise 4.

taocpmathematicsalgorithmsvolume-1project
TAOCP 4.3.1 Exercise 18

The solution correctly addresses the exercise.

taocpmathematicsalgorithmsvolume-1math-hard
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 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 12

Exercise 4.

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 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 5

Unusual activity has been detected from your device.

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 1

Exercise 4.

taocpmathematicsalgorithmsvolume-1
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.2.4 Exercise 8

We restate (10) in the form relevant here.

taocpmathematicsalgorithmsvolume-1hm-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 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 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.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.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 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 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 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 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 22

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

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.2.2 Exercise 21

**Solution to Exercise 4.

taocpmathematicsalgorithmsvolume-1math-hard
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 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 16

The previous solution is completely unrelated to the exercise.

taocpmathematicsalgorithmsvolume-1math-hard
TAOCP 4.2.2 Exercise 17

The solution does address the exact question.

taocpmathematicsalgorithmsvolume-1hard
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 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 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 11

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

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 9

Equation (33) in 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 10

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

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 7

Consider binary floating point arithmetic with a small precision.

taocpmathematicsalgorithmsvolume-1math-medium
TAOCP 4.2.2 Exercise 5

The answer is **no**.

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 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 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 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 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 14

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

taocpmathematicsalgorithmsvolume-1medium
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 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