diff options
Diffstat (limited to 'vol2')
| -rw-r--r-- | vol2/3.1.lyx | 1204 | ||||
| -rw-r--r-- | vol2/3.2.1.1.lyx | 719 | ||||
| -rw-r--r-- | vol2/3.2.1.2.lyx | 1542 | ||||
| -rw-r--r-- | vol2/3.2.1.3.lyx | 273 | ||||
| -rw-r--r-- | vol2/3.2.1.lyx | 320 | ||||
| -rw-r--r-- | vol2/3.2.2.lyx | 834 | ||||
| -rw-r--r-- | vol2/3.3.1.lyx | 607 | ||||
| -rw-r--r-- | vol2/3.3.2.lyx | 1009 | ||||
| -rw-r--r-- | vol2/3.3.3.lyx | 1383 | ||||
| -rw-r--r-- | vol2/3.3.4.lyx | 781 | ||||
| -rw-r--r-- | vol2/3.4.1.lyx | 1677 | ||||
| -rw-r--r-- | vol2/3.4.2.lyx | 537 | ||||
| -rw-r--r-- | vol2/3.5.lyx | 1191 | ||||
| -rw-r--r-- | vol2/3.6.lyx | 496 | ||||
| -rw-r--r-- | vol2/4.1.lyx | 1922 | ||||
| -rw-r--r-- | vol2/index.lyx | 1394 |
16 files changed, 15889 insertions, 0 deletions
diff --git a/vol2/3.1.lyx b/vol2/3.1.lyx new file mode 100644 index 0000000..81d7d26 --- /dev/null +++ b/vol2/3.1.lyx @@ -0,0 +1,1204 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 620 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass book +\begin_preamble +\input defs +\end_preamble +\use_default_options true +\maintain_unincluded_children no +\language english +\language_package default +\inputencoding utf8 +\fontencoding auto +\font_roman "default" "default" +\font_sans "default" "default" +\font_typewriter "default" "default" +\font_math "auto" "auto" +\font_default_family default +\use_non_tex_fonts false +\font_sc false +\font_roman_osf false +\font_sans_osf false +\font_typewriter_osf false +\font_sf_scale 100 100 +\font_tt_scale 100 100 +\use_microtype false +\use_dash_ligatures true +\graphics default +\default_output_format default +\output_sync 0 +\bibtex_command default +\index_command default +\float_placement class +\float_alignment class +\paperfontsize default +\spacing single +\use_hyperref false +\papersize default +\use_geometry false +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\cite_engine basic +\cite_engine_type default +\biblio_style plain +\use_bibtopic false +\use_indices false +\paperorientation portrait +\suppress_date false +\justification true +\use_refstyle 1 +\use_formatted_ref 0 +\use_minted 0 +\use_lineno 0 +\index Index +\shortcut idx +\color #008000 +\end_index +\secnumdepth 3 +\tocdepth 3 +\paragraph_separation indent +\paragraph_indentation default +\is_math_indent 0 +\math_numbering_side default +\quotes_style english +\dynamic_quotes 0 +\papercolumns 1 +\papersides 1 +\paperpagestyle default +\tablestyle default +\tracking_changes false +\output_changes false +\change_bars false +\postpone_fragile_content false +\html_math_output 0 +\html_css_as_file 0 +\html_be_strict false +\docbook_table_output 0 +\docbook_mathml_prefix 1 +\end_header + +\begin_body + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc1[20] +\end_layout + +\end_inset + +Suppose that you wish to obtain a decimal digit at random, + not using a computer. + Which of the following methods would be suitable? +\end_layout + +\begin_layout Enumerate +Open a telephone directory to a random place by sticking your finger in it somewhere, + and use the units digit of the first number found on the selected page. +\end_layout + +\begin_layout Enumerate +Same as (a), + but use the units digit of the +\emph on +page +\emph default + number. +\end_layout + +\begin_layout Enumerate +Roll a die that is in the shape of a regular icosahedron, + whose twenty faces have been labeled with the digits 0, + 0, + 1, + 1, + ..., + 9, + 9. + Use the digit that appears on the top, + when the die comes to rest. + (A felt-covered table with a hard surface is recommended for rolling dice.) +\end_layout + +\begin_layout Enumerate +Expose a geiger counter to a source of radioactivity for one minute (shielding yourself) and use the units digit of the resulting count. + Assume that the geiger counter displays the number of counts in decimal notation, + and that the count is initially zero. +\end_layout + +\begin_layout Enumerate +Glance at your wristwatch; + and if the position of the second-hand is between +\begin_inset Formula $6n$ +\end_inset + + and +\begin_inset Formula $6(n+1)$ +\end_inset + + seconds, + choose the digit +\begin_inset Formula $n$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Ask a friend to think of a random digit, + and use the digit he names. +\end_layout + +\begin_layout Enumerate +Ask an enemy to think of a random digit, + and use the digit he names. +\end_layout + +\begin_layout Enumerate +Assume that 10 horses are entered in a race and that you know nothing whatever about their qualifications. + Assign to these horses the digits 0 to 9, + in arbitrary fashion, + and after the race use the winner's digit. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Enumerate +This would work for a typical phone book. + It wouldn't work if the book has, + say, + entries ordered by number with a fixed number of entries per page that is a multiple of 2 or 5. + And, + according to the official solution, + in some places people can choose phone numbers (presumably in the US where Knuth lives) so it wouldn't work there as people would tend to choose round numbers. +\end_layout + +\begin_layout Enumerate +This would be suitable, + although some adjustment would have to be made to account for the fact that left pages would have even numbers and right pages would have round numbers (say, + we could take the even number and divide it by two) and to avoid the last few pages if the total number is not a multiple of 20. +\end_layout + +\begin_layout Enumerate +This would work very well. +\end_layout + +\begin_layout Enumerate +This would work well assuming there are several digits between the most significant one and the units. +\end_layout + +\begin_layout Enumerate +This would work assuming you only have to do it once at a time and not at a specific time. +\end_layout + +\begin_layout Enumerate +This wouldn't work, + as humans are not good at mentally generating random numbers. +\end_layout + +\begin_layout Enumerate +This definitely wouldn't work, + as the enemy would probably be compelled to choose the number strategically instead of randomly. +\end_layout + +\begin_layout Enumerate +This could work, + although it would be time consuming. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc3[10] +\end_layout + +\end_inset + +What number follows 1010101010 in the middle-square method? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Formula $1010101010^{2}=1020304050403020100$ +\end_inset + +, + so the next number would be 3040504030. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc6[M21] +\end_layout + +\end_inset + +Suppose that we want to generate a sequence of integers +\begin_inset Formula $X_{0},X_{1},X_{2},\dots$ +\end_inset + +, + in the range +\begin_inset Formula $0\leq X_{n}<m$ +\end_inset + +. + Let +\begin_inset Formula $f(x)$ +\end_inset + + be any function such that +\begin_inset Formula $0\leq x<m$ +\end_inset + + implies +\begin_inset Formula $0\leq f(x)<m$ +\end_inset + +. + Consider a sequence formed by the rule +\begin_inset Formula $X_{n+1}=f(X_{n})$ +\end_inset + +. + (Examples are the middle-square method and Algorithm K.) +\end_layout + +\begin_layout Enumerate +Show that the sequence is ultimately periodic, + in the sense that there exist numbers +\begin_inset Formula $\lambda$ +\end_inset + + and +\begin_inset Formula $\mu$ +\end_inset + + for which the values +\begin_inset Formula +\[ +X_{0},X_{1},\dots,X_{\mu},\dots,X_{\mu+\lambda-1} +\] + +\end_inset + +are distinct, + but +\begin_inset Formula $X_{n+\lambda}=X_{n}$ +\end_inset + + when +\begin_inset Formula $n\geq\mu$ +\end_inset + +. + Find the maximum and minimum possible values of +\begin_inset Formula $\mu$ +\end_inset + + and +\begin_inset Formula $\lambda$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +\begin_inset CommandInset label +LatexCommand label +name "enu:e316b" + +\end_inset + +(R. + W. + Floyd.) Show that there exists an +\begin_inset Formula $n>0$ +\end_inset + + such that +\begin_inset Formula $X_{n}=X_{2n}$ +\end_inset + +; + and the smallest such value of +\begin_inset Formula $n$ +\end_inset + + lies in the range +\begin_inset Formula $\mu\le n\leq\mu+\lambda$ +\end_inset + +. + Furthermore the value of +\begin_inset Formula $X_{n}$ +\end_inset + + is unique in the sense that if +\begin_inset Formula $X_{n}=X_{2n}$ +\end_inset + + and +\begin_inset Formula $X_{r}=X_{2r}$ +\end_inset + +, + then +\begin_inset Formula $X_{r}=X_{n}$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Use the idea of part +\begin_inset CommandInset ref +LatexCommand ref +reference "enu:e316b" +plural "false" +caps "false" +noprefix "false" +nolink "false" + +\end_inset + + to design an algorithm that calculates +\begin_inset Formula $\mu$ +\end_inset + + and +\begin_inset Formula $\lambda$ +\end_inset + + for any given function +\begin_inset Formula $f$ +\end_inset + + and any given +\begin_inset Formula $X_{0}$ +\end_inset + +, + using only +\begin_inset Formula $O(\mu+\lambda)$ +\end_inset + + steps and only a bounded number of memory locations. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Assume +\begin_inset Formula $f:\mathbb{Z}_{m}\to\mathbb{Z}_{m}$ +\end_inset + +, + as otherwise the statements below are not necessarily true (e.g. + if +\begin_inset Formula $f:\mathbb{R}\to\mathbb{R}$ +\end_inset + +, + +\begin_inset Formula $f(x)\coloneqq\frac{x}{2}$ +\end_inset + +, + and +\begin_inset Formula $X_{0}=\frac{m}{2}$ +\end_inset + +). +\end_layout + +\begin_layout Enumerate +Require that +\begin_inset Formula $\mu\in\mathbb{N}$ +\end_inset + + and +\begin_inset Formula $\lambda\in\mathbb{N}^{*}$ +\end_inset + +, + as otherwise it is unclear what is meant and, + in particular, + the statement is obviously true when +\begin_inset Formula $\mu\in\mathbb{N}$ +\end_inset + + and +\begin_inset Formula $\lambda=0$ +\end_inset + +. + Now, + since +\begin_inset Formula $\{X_{0},\dots,X_{m}\}\subseteq\{0,\dots,m-1\}$ +\end_inset + +, + then +\begin_inset Formula $|\{X_{0},\dots,X_{m}\}|\leq m$ +\end_inset + + and there must be integers +\begin_inset Formula $i$ +\end_inset + + and +\begin_inset Formula $j$ +\end_inset + +, + +\begin_inset Formula $0\leq i<j\leq m$ +\end_inset + +, + such that +\begin_inset Formula $X_{i}=X_{j}$ +\end_inset + +. + We choose +\begin_inset Formula $i$ +\end_inset + + and +\begin_inset Formula $j$ +\end_inset + + such that +\begin_inset Formula $j$ +\end_inset + + is minimum, + which ensures that +\begin_inset Formula $X_{0},\dots,X_{j-1}$ +\end_inset + + are distinct and uniquely determines +\begin_inset Formula $i$ +\end_inset + +, + and we set +\begin_inset Formula $\mu\coloneqq i$ +\end_inset + + and +\begin_inset Formula $\lambda\coloneqq j-i$ +\end_inset + +; + then +\begin_inset Formula $X_{0},\dots,X_{\mu+\lambda-1=j-1}$ +\end_inset + + are all distinct and, + for +\begin_inset Formula $n\geq\mu$ +\end_inset + +, +\begin_inset Formula +\[ +X_{n+\lambda}=X_{n-i+j}=f^{n-i}(X_{j})=f^{n-i}(X_{i})=X_{n}. +\] + +\end_inset + +It's easy to check that these values are unique: + +\begin_inset Formula $\mu+\lambda$ +\end_inset + + must be the first value such that +\begin_inset Formula $X_{\mu+\lambda}$ +\end_inset + + equals some other value earlier in the sequence, + and +\begin_inset Formula $\mu$ +\end_inset + + must be the only value less than +\begin_inset Formula $\mu+\lambda$ +\end_inset + + such that +\begin_inset Formula $X_{\mu}=X_{\mu+\lambda}$ +\end_inset + +. +\end_layout + +\begin_deeper +\begin_layout Standard +As for the maximum and minimum, + since +\begin_inset Formula $0\leq i<j\leq m$ +\end_inset + +, + we have +\begin_inset Formula $0\leq\mu\leq m-1$ +\end_inset + + and +\begin_inset Formula $1\leq\lambda\leq m$ +\end_inset + +. + These bounds can be reached: + when +\begin_inset Formula $f$ +\end_inset + + is the identity, + +\begin_inset Formula $\mu=0$ +\end_inset + + and +\begin_inset Formula $\lambda=1$ +\end_inset + +; + when +\begin_inset Formula $f(x)=(x+1)\bmod m$ +\end_inset + +, + +\begin_inset Formula $\lambda=m$ +\end_inset + +, + and when +\begin_inset Formula $f(x)=\max\{0,x-1\}$ +\end_inset + + and +\begin_inset Formula $X_{0}=m-1$ +\end_inset + +, + +\begin_inset Formula $\mu=m-1$ +\end_inset + +. +\end_layout + +\end_deeper +\begin_layout Enumerate +Let +\begin_inset Formula $k\coloneqq\lceil\frac{\mu}{\lambda}\rceil$ +\end_inset + + and +\begin_inset Formula $n\coloneqq k\lambda$ +\end_inset + +, + then +\begin_inset Formula $\frac{\mu}{\lambda}\leq k\leq\frac{\mu}{\lambda}+1$ +\end_inset + + and therefore +\begin_inset Formula $\mu\leq n\leq\mu+\lambda$ +\end_inset + +, + and +\begin_inset Formula $X_{n}=X_{n+\lambda}=X_{n+2\lambda}=\dots=X_{n+k\lambda=2n}$ +\end_inset + +. + For the uniqueness, + let +\begin_inset Formula $r>0$ +\end_inset + + be such that +\begin_inset Formula $X_{r}=X_{2r}$ +\end_inset + +, + so necessarily +\begin_inset Formula $2r\geq\mu+\lambda$ +\end_inset + +. + We note that, + for any +\begin_inset Formula $s\geq\mu$ +\end_inset + +, + by induction, + +\begin_inset Formula $X_{s}=X_{s-\lfloor\frac{s-\mu}{\lambda}\rfloor\lambda}=X_{\mu+((s-\mu)\bmod\lambda)}$ +\end_inset + +, + and we call +\begin_inset Formula $R(s)\coloneqq\mu+((s-\mu)\bmod\lambda)\in\{\mu,\dots,\mu+\lambda-1\}$ +\end_inset + +. + With this, + +\begin_inset Formula $X_{R(2r)}=X_{2r}=X_{r}$ +\end_inset + +, + so either +\begin_inset Formula $r=R(2r)$ +\end_inset + + or +\begin_inset Formula $r\geq\mu+\lambda$ +\end_inset + +; + in any case +\begin_inset Formula $r\geq\mu$ +\end_inset + + and +\begin_inset Formula $X_{R(2r)}=X_{R(r)}$ +\end_inset + +. + This means +\begin_inset Formula $R(2r)=R(r)$ +\end_inset + +, + so +\begin_inset Formula $r\equiv0\mod{\lambda}$ +\end_inset + + and +\begin_inset Formula $R(r)=\mu+(-\mu\bmod\lambda)\equiv0\bmod\lambda$ +\end_inset + +, + so +\begin_inset Formula $R(r)$ +\end_inset + + is unique and +\begin_inset Formula $X_{r}=X_{R(r)}=X_{R(n)}=X_{n}$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +First we set +\begin_inset Formula $a,b\gets X_{0}$ +\end_inset + + and then repeatedly set +\begin_inset Formula $a\gets f(a)$ +\end_inset + + and +\begin_inset Formula $b\gets f^{2}(b)$ +\end_inset + + until +\begin_inset Formula $a=b$ +\end_inset + +; + the number of times we do this operation is +\begin_inset Formula $n$ +\end_inset + +, + and in the end +\begin_inset Formula $a=X_{n}$ +\end_inset + +. + Then we set +\begin_inset Formula $b\gets a$ +\end_inset + + and repeat +\begin_inset Formula $b\gets f(b)$ +\end_inset + + until +\begin_inset Formula $b=a$ +\end_inset + +; + the number of times we do this operation is +\begin_inset Formula $\lambda$ +\end_inset + +. + Finally, + since +\begin_inset Formula $a$ +\end_inset + + is a multiple of +\begin_inset Formula $\lambda$ +\end_inset + +, + +\begin_inset Formula $X_{\mu}=X_{\mu+n}$ +\end_inset + +, + so we set +\begin_inset Formula $b\gets X_{0}$ +\end_inset + + and repeat +\begin_inset Formula $b\gets f(b)$ +\end_inset + + and +\begin_inset Formula $a\gets f(a)$ +\end_inset + + until +\begin_inset Formula $a=b$ +\end_inset + +; + the number of times we do this operation is +\begin_inset Formula $\mu$ +\end_inset + +. + In total this uses two slots of memory and runs in time +\begin_inset Formula $O(n)+O(\lambda)+O(\mu)=O(\mu+\lambda)$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc7[M21] +\end_layout + +\end_inset + +(R. + P. + Brent, + 1977.) Let +\begin_inset Formula $\ell(n)$ +\end_inset + + be the greatest power of 2 that is less than or equal to +\begin_inset Formula $n$ +\end_inset + +; + thus, + for example, + +\begin_inset Formula $\ell(15)=8$ +\end_inset + + and +\begin_inset Formula $\ell(\ell(n))=\ell(n)$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Show that, + in terms of the notation in exercise 6, + there exists an +\begin_inset Formula $n>0$ +\end_inset + + such that +\begin_inset Formula $X_{n}=X_{\ell(n)-1}$ +\end_inset + +. + Find a formula that expresses the least such +\begin_inset Formula $n$ +\end_inset + + in terms of the periodicity numbers +\begin_inset Formula $\mu$ +\end_inset + + and +\begin_inset Formula $\lambda$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Apply this result to design an algorithm that can be used in conjunction with any random number generator of the type +\begin_inset Formula $X_{n+1}=f(X_{n})$ +\end_inset + +, + to prevent it from cycling indefinitely. + Your algorithm should calculate the period length +\begin_inset Formula $\lambda$ +\end_inset + +, + and it should only use a small amount of memory space— +you must not simply store all the computed sequence values! +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Enumerate +For sufficiently large +\begin_inset Formula $r$ +\end_inset + +, + +\begin_inset Formula $n\coloneqq2^{r}-1+\lambda<2^{r+1}$ +\end_inset + + and then +\begin_inset Formula $X_{\ell(n)-1}=X_{2^{r}-1}=X_{n}$ +\end_inset + +, + and it's easy to convince ourselves that all such +\begin_inset Formula $n$ +\end_inset + + are of the form +\begin_inset Formula $2^{r}-1+k\lambda$ +\end_inset + + with +\begin_inset Formula $r\in\mathbb{N}$ +\end_inset + +, + +\begin_inset Formula $k\in\mathbb{N}^{*}$ +\end_inset + +, + +\begin_inset Formula $k\lambda-1<2^{r}$ +\end_inset + +, + and +\begin_inset Formula $2^{r}-1\geq\mu$ +\end_inset + +. + The minimum value, + then, + happens with +\begin_inset Formula $k=1$ +\end_inset + + and +\begin_inset Formula $2^{r}$ +\end_inset + + is the minimum such that +\begin_inset Formula $\lambda,\mu+1\leq2^{r}$ +\end_inset + +, + so if +\begin_inset Formula $u(n)$ +\end_inset + + is the lowest power of 2 that is greater than or equal to +\begin_inset Formula $n$ +\end_inset + +, + then +\begin_inset Formula +\[ +n=u(\max\{\lambda,\mu+1\})+\lambda-1. +\] + +\end_inset + + +\end_layout + +\begin_layout Enumerate +We set +\begin_inset Formula $a\gets b\gets X_{0}$ +\end_inset + + and +\begin_inset Formula $r\gets0$ +\end_inset + +. + Then repeat +\begin_inset Formula $b\gets f(b)$ +\end_inset + + up to +\begin_inset Formula $2^{r}$ +\end_inset + + times; + if at any point +\begin_inset Formula $b=a$ +\end_inset + +, + terminate with +\begin_inset Formula $\lambda$ +\end_inset + + equal to the number of times that +\begin_inset Formula $b\gets f(b)$ +\end_inset + + has been run in this iteration; + otherwise set +\begin_inset Formula $a\gets b$ +\end_inset + +, + +\begin_inset Formula $r\gets r+1$ +\end_inset + +, + and repeat this step. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc16[15] +\end_layout + +\end_inset + +A sequence generated as in exercise 6 must begin to repeat after at most +\begin_inset Formula $m$ +\end_inset + + values have been generated. + Suppose we generalize the method so that +\begin_inset Formula $X_{n+1}$ +\end_inset + + depends on +\begin_inset Formula $X_{n-1}$ +\end_inset + + as well as on +\begin_inset Formula $X_{n}$ +\end_inset + +; + formally, + let +\begin_inset Formula $f(x,y)$ +\end_inset + + be a function such that +\begin_inset Formula $0\leq x,y<m$ +\end_inset + + implies +\begin_inset Formula $0\leq f(x,y)<m$ +\end_inset + +. + The sequence is constructed by selecting +\begin_inset Formula $X_{0}$ +\end_inset + + and +\begin_inset Formula $X_{1}$ +\end_inset + + arbitrarily, + and then letting +\begin_inset Formula +\begin{align*} +X_{n+1} & =f(X_{n},X_{n-1}), & \text{for }n & >0. +\end{align*} + +\end_inset + +What is the maximum period conceivably attainable in this case? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +See exercise 17. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc17[10] +\end_layout + +\end_inset + +Generalize the situation in the previous exercise so that +\begin_inset Formula $X_{n+1}$ +\end_inset + + depends on the preceding +\begin_inset Formula $k$ +\end_inset + + values of the sequence. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +The maximum conceivable would be +\begin_inset Formula $m^{k}$ +\end_inset + +. + Why this is always attainable is not at all obvious. +\end_layout + +\end_body +\end_document diff --git a/vol2/3.2.1.1.lyx b/vol2/3.2.1.1.lyx new file mode 100644 index 0000000..7eec653 --- /dev/null +++ b/vol2/3.2.1.1.lyx @@ -0,0 +1,719 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 620 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass book +\begin_preamble +\input defs +\end_preamble +\use_default_options true +\maintain_unincluded_children no +\language english +\language_package default +\inputencoding utf8 +\fontencoding auto +\font_roman "default" "default" +\font_sans "default" "default" +\font_typewriter "default" "default" +\font_math "auto" "auto" +\font_default_family default +\use_non_tex_fonts false +\font_sc false +\font_roman_osf false +\font_sans_osf false +\font_typewriter_osf false +\font_sf_scale 100 100 +\font_tt_scale 100 100 +\use_microtype false +\use_dash_ligatures true +\graphics default +\default_output_format default +\output_sync 0 +\bibtex_command default +\index_command default +\float_placement class +\float_alignment class +\paperfontsize default +\spacing single +\use_hyperref false +\papersize default +\use_geometry false +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\cite_engine basic +\cite_engine_type default +\biblio_style plain +\use_bibtopic false +\use_indices false +\paperorientation portrait +\suppress_date false +\justification true +\use_refstyle 1 +\use_formatted_ref 0 +\use_minted 0 +\use_lineno 0 +\index Index +\shortcut idx +\color #008000 +\end_index +\secnumdepth 3 +\tocdepth 3 +\paragraph_separation indent +\paragraph_indentation default +\is_math_indent 0 +\math_numbering_side default +\quotes_style english +\dynamic_quotes 0 +\papercolumns 1 +\papersides 1 +\paperpagestyle default +\tablestyle default +\tracking_changes false +\output_changes false +\change_bars false +\postpone_fragile_content false +\html_math_output 0 +\html_css_as_file 0 +\html_be_strict false +\docbook_table_output 0 +\docbook_mathml_prefix 1 +\end_header + +\begin_body + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc3[M25] +\end_layout + +\end_inset + +Many computers do not provide the ability to divide a two-word number by a one-word number; + they provide only operations on single-word numbers, + such as +\begin_inset Formula $\text{himult}(x,y)=\lfloor xy/w\rfloor$ +\end_inset + + and +\begin_inset Formula $\text{lomult}(x,y)=xy\bmod w$ +\end_inset + +, + when +\begin_inset Formula $x$ +\end_inset + + and +\begin_inset Formula $y$ +\end_inset + + are nonnegative integers less than the word size +\begin_inset Formula $w$ +\end_inset + +. + Explain how to evaluate +\begin_inset Formula $ax\bmod m$ +\end_inset + + in terms of +\begin_inset Formula $\text{himult}$ +\end_inset + + and +\begin_inset Formula $\text{lomult}$ +\end_inset + +, + assuming that +\begin_inset Formula $0\leq a,x<m<w$ +\end_inset + + and that +\begin_inset Formula $m\bot w$ +\end_inset + +. + You may use precomputed constants that depend on +\begin_inset Formula $a$ +\end_inset + +, + +\begin_inset Formula $m$ +\end_inset + +, + and +\begin_inset Formula $w$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Note Greyedout +status open + +\begin_layout Plain Layout +(I had to look up the answer, + I would have never guessed it.) +\end_layout + +\end_inset + +Let +\begin_inset Formula $b\coloneqq aw\bmod m$ +\end_inset + + and +\begin_inset Formula $c\in\{0,\dots,w-1\}$ +\end_inset + + such that +\begin_inset Formula $mc\equiv1\pmod w$ +\end_inset + +, + we compute +\begin_inset Formula $y\gets\text{lomult}(b,x)$ +\end_inset + +, + +\begin_inset Formula $z\gets\text{himult}(b,x)$ +\end_inset + +, + +\begin_inset Formula $t\gets\text{lomult}(c,y)$ +\end_inset + +, + and +\begin_inset Formula $u\gets\text{himult}(m,t)$ +\end_inset + +, + and return +\begin_inset Formula $z-u+[z<u]m$ +\end_inset + +. +\end_layout + +\begin_layout Standard +To see that this works, + we note that +\begin_inset Formula +\[ +mt=m(cbx\bmod w)\equiv mcbx\equiv bx\pmod w, +\] + +\end_inset + +so +\begin_inset Formula +\[ +bx-mt=\left(\left\lfloor \frac{bx}{w}\right\rfloor -\left\lfloor \frac{mt}{w}\right\rfloor \right)w=(z-u)w +\] + +\end_inset + +and, + taking modulo +\begin_inset Formula $m$ +\end_inset + + on both sides, + +\begin_inset Formula $awx\bmod m=(z-u)w\bmod m$ +\end_inset + + and +\begin_inset Formula $ax\bmod m=(z-u)\bmod m$ +\end_inset + + by canceling +\begin_inset Formula $w$ +\end_inset + +. + Finally, + +\begin_inset Formula $0\leq z=\lfloor\frac{(aw\bmod m)x}{w}\rfloor\leq\lfloor\frac{mx}{w}\rfloor<m$ +\end_inset + + and +\begin_inset Formula $0\leq u=\lfloor\frac{m(cy\bmod w)}{w}\rfloor<m$ +\end_inset + +, + so +\begin_inset Formula $-m<z-u<m$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc4[21] +\end_layout + +\end_inset + +Discuss the calculation of linear congruential sequences with +\begin_inset Formula $m=2^{32}$ +\end_inset + + on two's-complement machines such as the System/370 series. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +When multiplying +\begin_inset Formula $a$ +\end_inset + + times +\begin_inset Formula $x$ +\end_inset + +, + one or two of them could instead be +\begin_inset Formula $a-m$ +\end_inset + + or +\begin_inset Formula $x-m$ +\end_inset + +; + however, + for +\begin_inset Formula $i,j\in\{0,1\}$ +\end_inset + +, + +\begin_inset Formula $(a-im)(x-jm)\equiv am\pmod m$ +\end_inset + +, + so no further action is necessary given that taking modulo +\begin_inset Formula $m=2^{32}$ +\end_inset + + is trivial. + Of course, + the resulting number could be negative, + but the bit pattern would be the same. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc6[20] +\end_layout + +\end_inset + +The previous exercise suggests that subtraction mod +\begin_inset Formula $m$ +\end_inset + + is easier to perform than addition mod +\begin_inset Formula $m$ +\end_inset + +. + Discuss sequences generated by the rule +\begin_inset Formula +\[ +X_{n+1}=(aX_{n}-c)\bmod m. +\] + +\end_inset + +Are these sequences essentially different from linear congruential sequences as defined in the text? + Are they more suited to efficient computer calculation? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +These are the same, + as subtracting +\begin_inset Formula $c$ +\end_inset + + is the same modulo +\begin_inset Formula $m$ +\end_inset + + as adding +\begin_inset Formula $m-c$ +\end_inset + +. + Although they are equivalent, + computing them this way could be slightly more efficient. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc8[20] +\end_layout + +\end_inset + +Write a +\family typewriter +MIX +\family default + program analogous to (2) that computes +\begin_inset Formula $(aX)\bmod(w-1)$ +\end_inset + +. + The values 0 and +\begin_inset Formula $w-1$ +\end_inset + + are to be treated as equivalent in the input and output of your program. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Let +\begin_inset Formula $c\coloneqq\text{himult}(a,X)$ +\end_inset + + and +\begin_inset Formula $d\coloneqq\text{lomult}(a,X)$ +\end_inset + +, + then +\begin_inset Formula +\[ +aX=cw+d\equiv(cw+d)-c(w-1)=c+d\pmod m, +\] + +\end_inset + +so assuming the overflow bit was off, + we could write: +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +LDA X +\end_layout + +\begin_layout Plain Layout + +MUL A +\end_layout + +\begin_layout Plain Layout + +STX TEMP +\end_layout + +\begin_layout Plain Layout + +ADD TEMP +\end_layout + +\begin_layout Plain Layout + +JNOV *+2 +\end_layout + +\begin_layout Plain Layout + +INCA 1 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +The last instruction is valid because the value of +\begin_inset Formula $c+d$ +\end_inset + + can never reach +\begin_inset Formula $2w-1$ +\end_inset + +, + so +\family typewriter +INCA +\family default + cannot produce a second overflow. + However +\begin_inset Formula $c+d$ +\end_inset + + could be +\begin_inset Formula $w-1$ +\end_inset + + or 0 and no effort is made to make rA be equal in these two cases. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc9[M25] +\end_layout + +\end_inset + +Most high-level programming languages do not provide a good way to divide a two-word integer by a one-word integer, + nor do they provide the +\begin_inset Formula $\text{himult}$ +\end_inset + + operation of exercise 3. + The purpose of this exercise is to find a reasonable way to cope with such limitations when we wish to evaluate +\begin_inset Formula $ax\bmod m$ +\end_inset + + for variable +\begin_inset Formula $x$ +\end_inset + + and for constants +\begin_inset Formula $0<a<m$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Prove that if +\begin_inset Formula $q=\lfloor m/a\rfloor$ +\end_inset + +, + we have +\begin_inset Formula $a(x-(x\bmod q))=\lfloor x/q\rfloor(m-(m\bmod a))$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Use the identity of part 1 to evaluate +\begin_inset Formula $ax\bmod m$ +\end_inset + + without computing any numbers that exceed +\begin_inset Formula $m$ +\end_inset + + in absolute value, + assuming that +\begin_inset Formula $a^{2}\leq m$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +First I challenge the idea that most high-level languages do not provide these features. + While this might have been true when the book was written, + it's not true today with languages like Python, + Ruby, + or JavaScript dominating the industry, + you can do that but it's slow. + (I guess the the text said +\begin_inset Quotes eld +\end_inset + +most +\begin_inset Quotes erd +\end_inset + + was about the Lisp family of languages.) Anyway, + a lot of them like Go are still stuck in the 70s so... +\end_layout + +\begin_layout Enumerate +\begin_inset Formula $a(x-(x\bmod q))=a\lfloor\frac{x}{q}\rfloor q=\lfloor\frac{x}{q}\rfloor a\lfloor\frac{m}{a}\rfloor=\lfloor\frac{x}{q}\rfloor(m-(m\bmod a))$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +If we operate modulo +\begin_inset Formula $m$ +\end_inset + +, +\begin_inset Formula +\[ +ax=a(x\bmod q)+\left\lfloor \frac{x}{q}\right\rfloor (m-(m\bmod a))\equiv a(x\bmod q)-\left\lfloor \frac{x}{q}\right\rfloor (m\bmod a)\mod m, +\] + +\end_inset + +so +\begin_inset Formula $ax\bmod m=\left(a(x\bmod q)-\lfloor\frac{x}{q}\rfloor(m\bmod a)\right)\bmod m$ +\end_inset + +. + Since +\begin_inset Formula $a^{2}\leq m$ +\end_inset + +, + +\begin_inset Formula $a\leq\frac{m}{a}$ +\end_inset + + and therefore +\begin_inset Formula $a\leq q$ +\end_inset + +, + so +\begin_inset Formula $\lfloor\frac{x}{q}\rfloor\leq\lfloor\frac{x}{a}\rfloor\leq\frac{x}{a}$ +\end_inset + + and, + multiplied by +\begin_inset Formula $m\bmod a$ +\end_inset + + (a constant), + the product is no greater than +\begin_inset Formula $x$ +\end_inset + +. + In the first factor, + however, + +\begin_inset Formula $x\bmod q\leq q\leq\frac{m}{a}$ +\end_inset + +, + so again the product by +\begin_inset Formula $a$ +\end_inset + + is no greater than +\begin_inset Formula $m$ +\end_inset + +. +\end_layout + +\end_body +\end_document diff --git a/vol2/3.2.1.2.lyx b/vol2/3.2.1.2.lyx new file mode 100644 index 0000000..ad58b78 --- /dev/null +++ b/vol2/3.2.1.2.lyx @@ -0,0 +1,1542 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 620 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass book +\begin_preamble +\input defs +\end_preamble +\use_default_options true +\maintain_unincluded_children no +\language english +\language_package default +\inputencoding utf8 +\fontencoding auto +\font_roman "default" "default" +\font_sans "default" "default" +\font_typewriter "default" "default" +\font_math "auto" "auto" +\font_default_family default +\use_non_tex_fonts false +\font_sc false +\font_roman_osf false +\font_sans_osf false +\font_typewriter_osf false +\font_sf_scale 100 100 +\font_tt_scale 100 100 +\use_microtype false +\use_dash_ligatures true +\graphics default +\default_output_format default +\output_sync 0 +\bibtex_command default +\index_command default +\float_placement class +\float_alignment class +\paperfontsize default +\spacing single +\use_hyperref false +\papersize default +\use_geometry false +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\cite_engine basic +\cite_engine_type default +\biblio_style plain +\use_bibtopic false +\use_indices false +\paperorientation portrait +\suppress_date false +\justification true +\use_refstyle 1 +\use_formatted_ref 0 +\use_minted 0 +\use_lineno 0 +\index Index +\shortcut idx +\color #008000 +\end_index +\secnumdepth 3 +\tocdepth 3 +\paragraph_separation indent +\paragraph_indentation default +\is_math_indent 0 +\math_numbering_side default +\quotes_style english +\dynamic_quotes 0 +\papercolumns 1 +\papersides 1 +\paperpagestyle default +\tablestyle default +\tracking_changes false +\output_changes false +\change_bars false +\postpone_fragile_content false +\html_math_output 0 +\html_css_as_file 0 +\html_be_strict false +\docbook_table_output 0 +\docbook_mathml_prefix 1 +\end_header + +\begin_body + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc1[10] +\end_layout + +\end_inset + +What is the length of the period of the linear congruential sequence with +\begin_inset Formula $X_{0}=5772156648$ +\end_inset + +, + +\begin_inset Formula $a=3141592621$ +\end_inset + +, + +\begin_inset Formula $c=2718281829$ +\end_inset + +, + and +\begin_inset Formula $m=10000000000$ +\end_inset + +? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Obviously +\begin_inset Formula $c$ +\end_inset + + is relatively prime to +\begin_inset Formula $m$ +\end_inset + +. + Furthermore, + the prime divisors of +\begin_inset Formula $m$ +\end_inset + + are 2 and 5 and +\begin_inset Formula $a-1$ +\end_inset + + is a multiple of both 4 and 5. + Therefore the length is +\begin_inset Formula $m$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc2[10] +\end_layout + +\end_inset + +Are the following two conditions sufficient to guarantee the maximum length period, + when +\begin_inset Formula $m$ +\end_inset + + is a power of 2? +\end_layout + +\begin_layout Enumerate +\begin_inset Formula $c$ +\end_inset + + is odd; +\end_layout + +\begin_layout Enumerate +\begin_inset Formula $a\bmod4=1$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Yes, + by theorem A. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc6[20] +\end_layout + +\end_inset + +Find all multipliers +\begin_inset Formula $a$ +\end_inset + + that satisfy the conditions of Theorem A when +\begin_inset Formula $m=10^{6}-1$ +\end_inset + +. + (See Table 3.2.1.1–1.) +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +By the table, + +\begin_inset Formula $m=3^{3}\cdot7\cdot11\cdot13\cdot37$ +\end_inset + +. + Multipliers are numbers +\begin_inset Formula $a$ +\end_inset + + such that +\begin_inset Formula +\[ +a\bmod3=a\bmod7=a\bmod11=a\bmod13=a\bmod37=1. +\] + +\end_inset + +These identities tell us that +\begin_inset Formula $a\equiv1\pmod{3\cdot7\cdot11\cdot13\cdot37=m/3^{2}=111111}$ +\end_inset + +, + so the possible values are +\begin_inset Formula $1,111112,222223,333334,444445,555556,666667,777778,888889$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc7[M23] +\end_layout + +\end_inset + +The period of a congruential sequence need not start with +\begin_inset Formula $X_{0}$ +\end_inset + +, + but we can always find indices +\begin_inset Formula $\mu\geq0$ +\end_inset + + and +\begin_inset Formula $\lambda>0$ +\end_inset + + such that +\begin_inset Formula $X_{n+\lambda}=X_{n}$ +\end_inset + + whenever +\begin_inset Formula $n\geq\mu$ +\end_inset + +, + and for which +\begin_inset Formula $\mu$ +\end_inset + + and +\begin_inset Formula $\lambda$ +\end_inset + + are the smallest possible values with this property. + (See exercises 3.1–6 and 3.2.1–1.) If +\begin_inset Formula $\mu_{j}$ +\end_inset + + and +\begin_inset Formula $\lambda_{j}$ +\end_inset + + are the indices corresponding to the sequences +\begin_inset Formula +\[ +(X_{0}\bmod p_{j}^{e_{j}},a\bmod p_{j}^{e_{j}},c\bmod p_{j}^{e_{j}},p_{j}^{e_{j}}), +\] + +\end_inset + +and if +\begin_inset Formula $\mu$ +\end_inset + + and +\begin_inset Formula $\lambda$ +\end_inset + + correspond to the composite sequence +\begin_inset Formula $(X_{0},a,c,p_{1}^{e_{1}}\cdots p_{t}^{e_{t}})$ +\end_inset + +, + Lemma Q states that +\begin_inset Formula $\lambda$ +\end_inset + + is the least common multiple of +\begin_inset Formula $\lambda_{1},\dots,\lambda_{t}$ +\end_inset + +. + What is the value of +\begin_inset Formula $\mu$ +\end_inset + + in terms of the values of +\begin_inset Formula $\mu_{1},\dots,\mu_{t}$ +\end_inset + +? + What is the maximum possible value of +\begin_inset Formula $\mu$ +\end_inset + + obtainable by varying +\begin_inset Formula $X_{0}$ +\end_inset + +, + +\begin_inset Formula $a$ +\end_inset + +, + and +\begin_inset Formula $c$ +\end_inset + +, + when +\begin_inset Formula $m=p_{1}^{e_{1}}\cdots p_{t}^{e_{t}}$ +\end_inset + + is fixed? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Since the +\begin_inset Formula $j$ +\end_inset + +th sequence has values +\begin_inset Formula $X_{n}\bmod p_{j}^{e_{j}}$ +\end_inset + +, + and the +\begin_inset Formula $X_{n}$ +\end_inset + + are uniquely determined by such values for all +\begin_inset Formula $j$ +\end_inset + +, + +\begin_inset Formula $(X_{n})_{n}$ +\end_inset + + enters into a loop whenever all the +\begin_inset Formula $X_{n}\bmod p_{j}^{e_{j}}$ +\end_inset + + have entered into a loop, + that is, + +\begin_inset Formula $\mu=\max_{j}\mu_{j}$ +\end_inset + +. + We are left to see what is the maximum +\begin_inset Formula $\mu$ +\end_inset + + when +\begin_inset Formula $m=p^{e}$ +\end_inset + + for some prime number +\begin_inset Formula $p$ +\end_inset + + and positive integer +\begin_inset Formula $e$ +\end_inset + + (for +\begin_inset Formula $m=1$ +\end_inset + +, + +\begin_inset Formula $\mu=0$ +\end_inset + +). + In this case, + +\begin_inset Formula $\mu$ +\end_inset + + is the lowest number such that +\begin_inset Formula +\[ +X_{\mu}=X_{\mu+\lambda}\equiv X_{\mu}a^{\lambda}+\frac{a^{\lambda}-1}{a-1}c\pmod{p^{e}}, +\] + +\end_inset + +if and only if +\begin_inset Formula $X_{\mu}(1-a^{\lambda})\equiv\frac{a^{\lambda}-1}{a-1}c\pmod{p^{e}}$ +\end_inset + +, + so for +\begin_inset Formula $\mu>0$ +\end_inset + +, + +\begin_inset Formula $\mu-1$ +\end_inset + + must be a number such that +\begin_inset Formula +\begin{align*} +X_{\mu-1}(1-a^{\lambda}) & \not\equiv\frac{a^{\lambda}-1}{a-1}c, & aX_{\mu-1}(1-a^{\lambda}) & \equiv a\frac{a^{\lambda}-1}{a-1}c & & \pmod{p^{e}}, +\end{align*} + +\end_inset + +where the first equation comes from changing +\begin_inset Formula $\mu$ +\end_inset + + to +\begin_inset Formula $\mu-1$ +\end_inset + + above and the second one from changing +\begin_inset Formula $X_{\mu}$ +\end_inset + + to +\begin_inset Formula $aX_{\mu-1}+c$ +\end_inset + + and rearranging terms. + This means that +\begin_inset Formula $a$ +\end_inset + + must be a multiple of +\begin_inset Formula $p$ +\end_inset + +. + Then, +\begin_inset Formula +\begin{align*} +X_{e} & \equiv X_{0}a^{e}+\frac{a^{e}-1}{a-1}c\equiv(a^{e-1}+a^{e-2}+\dots+a+1)c, & \pmod{p^{e}},\\ +X_{e+\lambda} & \equiv X_{0}a^{e+\lambda}+\frac{a^{e+\lambda}-1}{a-1}c\equiv(a^{e-1}+a^{e-2}+\dots+a+1)c, & \pmod{p^{e}}, +\end{align*} + +\end_inset + +since +\begin_inset Formula $a^{e}\equiv0$ +\end_inset + +, + so +\begin_inset Formula $\mu\leq e$ +\end_inset + +. + The value +\begin_inset Formula $\mu=e$ +\end_inset + + is reached when +\begin_inset Formula $(X_{0},a,c)=(1,p,0)$ +\end_inset + +. + Summing up, + the maximum for +\begin_inset Formula $m=p_{1}^{e_{1}}\cdots p_{t}^{e_{t}}$ +\end_inset + + is +\begin_inset Formula $\max\{e_{1},\dots,e_{t}\}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc9[M22] +\end_layout + +\end_inset + +(W. + E. + Thompson.) When +\begin_inset Formula $c=0$ +\end_inset + + and +\begin_inset Formula $m=2^{e}\geq16$ +\end_inset + +, + Theorems B and C say that the period has length +\begin_inset Formula $2^{e-2}$ +\end_inset + + if and only if the multiplier +\begin_inset Formula $a$ +\end_inset + + satisfies +\begin_inset Formula $a\bmod8=3$ +\end_inset + + or +\begin_inset Formula $a\bmod8=5$ +\end_inset + +. + Show that every such sequence is essentially a linear congruential sequence with +\begin_inset Formula $m=2^{e-2}$ +\end_inset + +, + having +\emph on +full +\emph default + period, + in the following sense: +\end_layout + +\begin_layout Enumerate +If +\begin_inset Formula $X_{n+1}=(4c+1)X_{n}\bmod2^{e}$ +\end_inset + +, + and +\begin_inset Formula $X_{n}=4Y_{n}+1$ +\end_inset + +, + then +\begin_inset Formula +\[ +Y_{n+1}=((4c+1)Y_{n}+c)\bmod2^{e-2}. +\] + +\end_inset + + +\end_layout + +\begin_layout Enumerate +If +\begin_inset Formula $X_{n+1}=(4c-1)X_{n}\bmod2^{e}$ +\end_inset + +, + and +\begin_inset Formula $X_{n}=((-1)^{n}(4Y_{n}+1))\bmod2^{e}$ +\end_inset + +, + then +\begin_inset Formula +\[ +Y_{n+1}=((1-4c)Y_{n}-c)\bmod2^{e-2}. +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We start with +\begin_inset Formula $(Y_{n})_{n}$ +\end_inset + + as defined and see that +\begin_inset Formula $(X_{n})_{n}$ +\end_inset + + calculated from there matches the initial definition of +\begin_inset Formula $(X_{n})_{n}$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +We have +\begin_inset Formula $Y_{n}=\left((4c+1)^{n}Y_{0}+\frac{(4c+1)^{n}-1}{4\cancel{c}}\cancel{c}\right)\bmod2^{e-2}$ +\end_inset + +, + so +\begin_inset Formula +\[ +4Y_{n}+1\equiv(4Y_{0}+1)(4c+1)^{n}\equiv(4c+1)^{n}X_{0}\equiv X_{n}\pmod{2^{e}}. +\] + +\end_inset + + +\end_layout + +\begin_layout Enumerate +We have +\begin_inset Formula $Y_{n}=\left((1-4c)^{n}Y_{0}-\frac{(1-4c)^{n}-1}{-4c}c\right)\bmod2^{e-2}$ +\end_inset + +, + so +\begin_inset Formula +\begin{multline*} +(-1)^{n}(4Y_{n}+1)\equiv(-1)^{n}\left(4(1-4c)^{n}Y_{0}+(1-4c)^{n}\right)=(4Y_{0}+1)(4c-1)^{n}=\\ +=(4c-1)^{n}X_{0}\equiv X_{n+1}\pmod{2^{e}}. +\end{multline*} + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc16[M24] +\end_layout + +\end_inset + + +\emph on +(Existence of primitive roots.) +\emph default + Let +\begin_inset Formula $p$ +\end_inset + + be a prime number. +\end_layout + +\begin_layout Enumerate +Consider the polynomial +\begin_inset Formula $f(x)=x^{n}+c_{1}x^{n-1}+\dots+c_{n}$ +\end_inset + +, + where the +\begin_inset Formula $c$ +\end_inset + +'s are integers. + Given that +\begin_inset Formula $a$ +\end_inset + + is an integer for which +\begin_inset Formula $f(a)\equiv0\pmod p$ +\end_inset + +, + show that there exists a polynomial +\begin_inset Formula +\[ +q(x)=x^{n-1}+q_{1}x^{n-2}+\dots+q_{n-1} +\] + +\end_inset + +with integer coefficients such that +\begin_inset Formula $f(x)\equiv(x-a)q(x)\pmod p$ +\end_inset + + for all integers +\begin_inset Formula $x$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Let +\begin_inset Formula $f(x)$ +\end_inset + + be a polynomial as in (1). + Show that +\begin_inset Formula $f(x)$ +\end_inset + + has at most +\begin_inset Formula $n$ +\end_inset + + distinct +\begin_inset Quotes eld +\end_inset + +roots +\begin_inset Quotes erd +\end_inset + + modulo +\begin_inset Formula $p$ +\end_inset + +; + that is, + there are at most +\begin_inset Formula $n$ +\end_inset + + integers +\begin_inset Formula $a$ +\end_inset + +, + with +\begin_inset Formula $0\leq a<p$ +\end_inset + +, + such that +\begin_inset Formula $f(a)\equiv0\pmod p$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Because of exercise 15(2), + the polynomial +\begin_inset Formula $f(x)=x^{\lambda(p)}-1$ +\end_inset + + has +\begin_inset Formula $p-1$ +\end_inset + + distinct roots; + hence there is an integer +\begin_inset Formula $a$ +\end_inset + + with order +\begin_inset Formula $p-1$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Enumerate +It suffices to prove that, + for +\begin_inset Formula $f\in\mathbb{Z}_{p}[X]$ +\end_inset + + and +\begin_inset Formula $a\in\mathbb{Z}_{p}$ +\end_inset + + with +\begin_inset Formula $f(a)=0$ +\end_inset + +, + there exists +\begin_inset Formula $q\in\mathbb{Z}_{p}[X]$ +\end_inset + + such that +\begin_inset Formula $f(x)\equiv(x-a)q(x)$ +\end_inset + +, + since then, + for +\begin_inset Formula $f$ +\end_inset + + to have degree +\begin_inset Formula $n$ +\end_inset + + and leading coefficient 1, + +\begin_inset Formula $q$ +\end_inset + + must have degree +\begin_inset Formula $n-1$ +\end_inset + + and leading coefficient +\begin_inset Formula $q$ +\end_inset + +. + This is immediate for +\begin_inset Formula $f=0$ +\end_inset + +, + so we prove it by induction on the degree +\begin_inset Formula $n\geq0$ +\end_inset + + of +\begin_inset Formula $f$ +\end_inset + +. + If +\begin_inset Formula $n=0$ +\end_inset + +, + +\begin_inset Formula $f(a)=c_{0}\neq0\#$ +\end_inset + +, + so this follows trivially. + If +\begin_inset Formula $n>0$ +\end_inset + +, + let +\begin_inset Formula $g(x)\coloneqq f(x)-c_{0}(x-a)x^{n-1}$ +\end_inset + + is a polynomial of degree +\begin_inset Formula $n-1$ +\end_inset + + such that +\begin_inset Formula $g(a)=f(a)=0$ +\end_inset + +, + so by induction there exists +\begin_inset Formula $r\in\mathbb{Z}_{p}(x)$ +\end_inset + + with +\begin_inset Formula $g(x)=(x-a)r(x)$ +\end_inset + +. + But then +\begin_inset Formula $f(x)=g(x)+c_{0}(x-a)x^{n-1}=(x-a)(r(x)+c_{0}x^{n-1})$ +\end_inset + +. + Note that this proof is valid even when changing +\begin_inset Formula $\mathbb{Z}_{p}$ +\end_inset + + to any other domain. +\end_layout + +\begin_layout Enumerate +If +\begin_inset Formula $a$ +\end_inset + + and +\begin_inset Formula $b$ +\end_inset + + are different roots of +\begin_inset Formula $f$ +\end_inset + +, + then +\begin_inset Formula $f(x)=(x-a)q(x)$ +\end_inset + + for some +\begin_inset Formula $q\in\mathbb{Z}_{p}[X]$ +\end_inset + +, + and +\begin_inset Formula $b$ +\end_inset + + is still a root of +\begin_inset Formula $q$ +\end_inset + + as, + if it wasn't, + it wouldn't be a root of +\begin_inset Formula $f$ +\end_inset + + either. + Therefore, + by induction, + a polynomial +\begin_inset Formula $f\in\mathbb{Z}_{p}[X]\setminus0$ +\end_inset + + with +\begin_inset Formula $n$ +\end_inset + + different roots has at least degree +\begin_inset Formula $n$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Yes. + Trivial. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc20[M24] +\end_layout + +\end_inset + +(G. + Marsaglia.) The purpose of this exercise is to study the period length of an +\emph on +arbitrary +\emph default + linear congruential sequence. + Let +\begin_inset Formula $Y_{n}=1+a+\dots+a^{n-1}$ +\end_inset + +, + so that +\begin_inset Formula $X_{n}=(AY_{n}+X_{0})\bmod m$ +\end_inset + + for some constant +\begin_inset Formula $A$ +\end_inset + + by Eq. + 3.2.1–(8). +\end_layout + +\begin_layout Enumerate +Prove that the period length of +\begin_inset Formula $\langle X_{n}\rangle$ +\end_inset + + is the period length of +\begin_inset Formula $\langle Y_{n}\bmod m'\rangle$ +\end_inset + +, + where +\begin_inset Formula $m'=m/\gcd(A,m)$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Prove that the period length of +\begin_inset Formula $\langle Y_{n}\bmod p^{e}\rangle$ +\end_inset + + satisfies the following when +\begin_inset Formula $p$ +\end_inset + + is prime: +\end_layout + +\begin_deeper +\begin_layout Enumerate +If +\begin_inset Formula $a\bmod p=0$ +\end_inset + +, + it is 1. +\end_layout + +\begin_layout Enumerate +If +\begin_inset Formula $a\bmod p=1$ +\end_inset + +, + it is +\begin_inset Formula $p^{e}$ +\end_inset + +, + except when +\begin_inset Formula $p=2$ +\end_inset + + and +\begin_inset Formula $e\geq2$ +\end_inset + + and +\begin_inset Formula $a\bmod4=3$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +If +\begin_inset Formula $p=2$ +\end_inset + +, + +\begin_inset Formula $e\geq2$ +\end_inset + +, + and +\begin_inset Formula $a\bmod4=3$ +\end_inset + +, + it is twice the order of +\begin_inset Formula $a$ +\end_inset + + modulo +\begin_inset Formula $p^{e}$ +\end_inset + + (see exercise 11), + unless +\begin_inset Formula $a\equiv-1\pmod{2^{e}}$ +\end_inset + + when it is 2. +\end_layout + +\begin_layout Enumerate +If +\begin_inset Formula $a\bmod p>1$ +\end_inset + +, + it is the order of +\begin_inset Formula $a$ +\end_inset + + modulo +\begin_inset Formula $p^{e}$ +\end_inset + +. +\end_layout + +\end_deeper +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Enumerate +\begin_inset Formula +\[ +X_{n}=X_{n+m}\iff AY_{n}\equiv AY_{n+m}\pmod m\iff Y_{n}\equiv Y_{n+m}\pmod{m'}. +\] + +\end_inset + +Note that +\begin_inset Formula $\langle Y_{n}\bmod t\rangle$ +\end_inset + +, + +\begin_inset Formula $t\in\mathbb{Z}^{+}$ +\end_inset + +, + is the linear congruential sequence with +\begin_inset Formula $Y_{0}=0$ +\end_inset + +, + +\begin_inset Formula $c=1$ +\end_inset + +, + +\begin_inset Formula $a=a$ +\end_inset + +, + and +\begin_inset Formula $m=t$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +\begin_inset Note Note +status open + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\end_layout + +\begin_deeper +\begin_layout Enumerate +For +\begin_inset Formula $n\geq e-1$ +\end_inset + +, + +\begin_inset Formula $Y_{n}=(1+a+a^{2}+\dots+a^{e-1})\bmod p$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Then we're in the conditions of Theorem A. +\end_layout + +\begin_layout Enumerate +If +\begin_inset Formula $e=2$ +\end_inset + +, + then +\begin_inset Formula $a\equiv-1\pmod 4$ +\end_inset + + and this part doesn't apply, + so we assume +\begin_inset Formula $e>2$ +\end_inset + +. + Let +\begin_inset Formula $\lambda$ +\end_inset + + be the order of +\begin_inset Formula $a$ +\end_inset + + modulo +\begin_inset Formula $2^{e}$ +\end_inset + +, + obviously +\begin_inset Formula $\lambda>1$ +\end_inset + +, + so +\begin_inset Formula +\begin{multline*} +Y_{k}=1+a+\dots+a^{k-1}=\frac{a^{k}-1}{a-1}\equiv Y_{0}=0\pmod{2^{e}}\iff\\ +\iff a^{k}-1\equiv0\pmod{2^{e}(a-1)}\iff2^{e}(a-1)\mid a^{k}-1. +\end{multline*} + +\end_inset + +The order +\begin_inset Formula $\lambda$ +\end_inset + + of +\begin_inset Formula $a$ +\end_inset + + modulo +\begin_inset Formula $2^{e}$ +\end_inset + + is the smallest number such that +\begin_inset Formula $2^{e}\mid a^{k}-1$ +\end_inset + +, + and in fact +\begin_inset Formula +\[ +2^{e}\mid a^{k}-1\iff a^{k}\equiv1\pmod{2^{e}}\iff\lambda\mid k. +\] + +\end_inset + +Exercise 11 gives us an unique +\begin_inset Formula $f>1$ +\end_inset + + such that +\begin_inset Formula $a\bmod2^{f+1}=2^{f}\pm1$ +\end_inset + +, + and then says that +\begin_inset Formula $\lambda=2^{e-f}$ +\end_inset + +. + This can be used to prove that +\begin_inset Formula $a^{\lambda}-1$ +\end_inset + + is not a multiple of +\begin_inset Formula $2^{e}(a-1)$ +\end_inset + +, + as if this were the case, + then +\begin_inset Formula $a^{\lambda-1}$ +\end_inset + + would be a multiple of +\begin_inset Formula $2^{e+1}$ +\end_inset + + because +\begin_inset Formula $a-1$ +\end_inset + + is even, + but by Exercise 11 the order of +\begin_inset Formula $a$ +\end_inset + + modulo +\begin_inset Formula $e+1$ +\end_inset + + is +\begin_inset Formula $2^{e+1-f}>\lambda\#$ +\end_inset + +. + However, + since +\begin_inset Formula $a^{\lambda}-1$ +\end_inset + + is a multiple of both +\begin_inset Formula $2^{e}$ +\end_inset + + and +\begin_inset Formula $a^{\lambda}-1$ +\end_inset + +, + it is a multiple of +\begin_inset Formula $\text{lcm}\{2^{e},a^{\lambda}-1\}=\frac{2^{e}(a^{\lambda}-1)}{2}$ +\end_inset + + and therefore +\begin_inset Formula $a^{2\lambda}-1=(a^{\lambda}-1)(a^{\lambda}+1)=(a^{\lambda}-1)^{2}+2(a^{\lambda}-1)$ +\end_inset + + is a multiple of +\begin_inset Formula $2^{e}(a^{\lambda}-1)$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Like before, + +\begin_inset Formula $Y_{k}\equiv0\pmod{2^{e}}\iff p^{e}(a-1)\mid a^{k}-1$ +\end_inset + +. + This time, + however, + +\begin_inset Formula $\gcd\{a-1,p^{e}\}=1$ +\end_inset + +, + so +\begin_inset Formula $p^{e}(a-1)\mid a^{k}-1\iff p^{e},a-1\mid a^{k}-1\iff p^{e}\mid a^{k}-1$ +\end_inset + +, + and the lowest +\begin_inset Formula $k$ +\end_inset + + for which this happens is precisely the order of +\begin_inset Formula $a$ +\end_inset + + modulo +\begin_inset Formula $p^{e}$ +\end_inset + +. +\end_layout + +\end_deeper +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc22[M25] +\end_layout + +\end_inset + +Discuss the problem of finding moduli +\begin_inset Formula $m=b^{k}\pm b^{l}\pm1$ +\end_inset + + so that the subtract-with-borrow and add-with-carry generators of exercise 3.2.1.1–14 will have very long periods. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +First we would need the prime factorization of +\begin_inset Formula $m$ +\end_inset + +, + which is not easily characterized from +\begin_inset Formula $b$ +\end_inset + +, + +\begin_inset Formula $k$ +\end_inset + +, + and +\begin_inset Formula $l$ +\end_inset + +. + Once we have that we may apply Theorems A–C. + The solution in the book suggests looking for +\begin_inset Formula $m$ +\end_inset + + to be prime. +\end_layout + +\end_body +\end_document diff --git a/vol2/3.2.1.3.lyx b/vol2/3.2.1.3.lyx new file mode 100644 index 0000000..e94ce2c --- /dev/null +++ b/vol2/3.2.1.3.lyx @@ -0,0 +1,273 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 620 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass book +\begin_preamble +\input defs +\end_preamble +\use_default_options true +\maintain_unincluded_children no +\language english +\language_package default +\inputencoding utf8 +\fontencoding auto +\font_roman "default" "default" +\font_sans "default" "default" +\font_typewriter "default" "default" +\font_math "auto" "auto" +\font_default_family default +\use_non_tex_fonts false +\font_sc false +\font_roman_osf false +\font_sans_osf false +\font_typewriter_osf false +\font_sf_scale 100 100 +\font_tt_scale 100 100 +\use_microtype false +\use_dash_ligatures true +\graphics default +\default_output_format default +\output_sync 0 +\bibtex_command default +\index_command default +\float_placement class +\float_alignment class +\paperfontsize default +\spacing single +\use_hyperref false +\papersize default +\use_geometry false +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\cite_engine basic +\cite_engine_type default +\biblio_style plain +\use_bibtopic false +\use_indices false +\paperorientation portrait +\suppress_date false +\justification true +\use_refstyle 1 +\use_formatted_ref 0 +\use_minted 0 +\use_lineno 0 +\index Index +\shortcut idx +\color #008000 +\end_index +\secnumdepth 3 +\tocdepth 3 +\paragraph_separation indent +\paragraph_indentation default +\is_math_indent 0 +\math_numbering_side default +\quotes_style english +\dynamic_quotes 0 +\papercolumns 1 +\papersides 1 +\paperpagestyle default +\tablestyle default +\tracking_changes false +\output_changes false +\change_bars false +\postpone_fragile_content false +\html_math_output 0 +\html_css_as_file 0 +\html_be_strict false +\docbook_table_output 0 +\docbook_mathml_prefix 1 +\end_header + +\begin_body + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc1[M10] +\end_layout + +\end_inset + +Show that, + no matter what the byte size +\begin_inset Formula $B$ +\end_inset + + of +\family typewriter +MIX +\family default + happens to be, + the code (3) yields a random number generator of maximum period. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +This generator has +\begin_inset Formula $a=B^{2}+1$ +\end_inset + +, + +\begin_inset Formula $c=1$ +\end_inset + +, + and +\begin_inset Formula $m=B^{5}$ +\end_inset + +. + Since the prime divisors of +\begin_inset Formula $B^{5}$ +\end_inset + + and +\begin_inset Formula $B^{2}$ +\end_inset + + are the same, + the conditions of Theorem 3.2.1.2A are satisfied. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc2[10] +\end_layout + +\end_inset + +What is the potency of the generator represented by the +\family typewriter +MIX +\family default + code (3)? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +3. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc6[20] +\end_layout + +\end_inset + +Which of the values of +\begin_inset Formula $m=w\pm1$ +\end_inset + + in Table 3.2.1–1 can be used in a linear congruential sequence of maximum period whose potency is 4 or more? + (Use the result of exercise 5.) +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +By exercise 5, + for a modulus +\begin_inset Formula $m=p_{1}^{e_{1}}\cdots p_{t}^{e_{t}}$ +\end_inset + + with +\begin_inset Formula $e_{1}\geq\dots\geq e_{t}$ +\end_inset + +, + +\begin_inset Formula $a=p_{1}+1$ +\end_inset + + has the maximum potency, + which is +\begin_inset Formula $e_{1}$ +\end_inset + +, + except that if +\begin_inset Formula $m=p_{1}$ +\end_inset + +, + then the maximum potency is 0, + corresponding to +\begin_inset Formula $a=1$ +\end_inset + +. + Thus the values from the table that can be used are +\begin_inset Formula $10^{9}-1=3^{4}\cdot37\cdot333667$ +\end_inset + + and +\begin_inset Formula $2^{27}+1=3^{4}\cdot19\cdot87211$ +\end_inset + +. +\end_layout + +\end_body +\end_document diff --git a/vol2/3.2.1.lyx b/vol2/3.2.1.lyx new file mode 100644 index 0000000..f78e3ee --- /dev/null +++ b/vol2/3.2.1.lyx @@ -0,0 +1,320 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 620 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass book +\begin_preamble +\input defs +\end_preamble +\use_default_options true +\maintain_unincluded_children no +\language english +\language_package default +\inputencoding utf8 +\fontencoding auto +\font_roman "default" "default" +\font_sans "default" "default" +\font_typewriter "default" "default" +\font_math "auto" "auto" +\font_default_family default +\use_non_tex_fonts false +\font_sc false +\font_roman_osf false +\font_sans_osf false +\font_typewriter_osf false +\font_sf_scale 100 100 +\font_tt_scale 100 100 +\use_microtype false +\use_dash_ligatures true +\graphics default +\default_output_format default +\output_sync 0 +\bibtex_command default +\index_command default +\float_placement class +\float_alignment class +\paperfontsize default +\spacing single +\use_hyperref false +\papersize default +\use_geometry false +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\cite_engine basic +\cite_engine_type default +\biblio_style plain +\use_bibtopic false +\use_indices false +\paperorientation portrait +\suppress_date false +\justification true +\use_refstyle 1 +\use_formatted_ref 0 +\use_minted 0 +\use_lineno 0 +\index Index +\shortcut idx +\color #008000 +\end_index +\secnumdepth 3 +\tocdepth 3 +\paragraph_separation indent +\paragraph_indentation default +\is_math_indent 0 +\math_numbering_side default +\quotes_style english +\dynamic_quotes 0 +\papercolumns 1 +\papersides 1 +\paperpagestyle default +\tablestyle default +\tracking_changes false +\output_changes false +\change_bars false +\postpone_fragile_content false +\html_math_output 0 +\html_css_as_file 0 +\html_be_strict false +\docbook_table_output 0 +\docbook_mathml_prefix 1 +\end_header + +\begin_body + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc1[10] +\end_layout + +\end_inset + +Example (3) shows a situation in which +\begin_inset Formula $X_{4}=X_{0}$ +\end_inset + +, + so the sequence begins again from the beginning. + Give an example of a linear congruential sequence with +\begin_inset Formula $m=10$ +\end_inset + + for which +\begin_inset Formula $X_{0}$ +\end_inset + + never appears again in the sequence. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +This happens if +\begin_inset Formula $a=c=0$ +\end_inset + + and +\begin_inset Formula $0<X_{0}<m$ +\end_inset + +; + then the sequence starts with +\begin_inset Formula $X_{0}\neq0$ +\end_inset + + and then it's constant at 0. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc2[M20] +\end_layout + +\end_inset + +Show that if +\begin_inset Formula $a$ +\end_inset + + and +\begin_inset Formula $m$ +\end_inset + + are relatively prime, + the number +\begin_inset Formula $X_{0}$ +\end_inset + + will always appear in the period. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +For +\begin_inset Formula $a\geq2$ +\end_inset + +, + by Euler's theorem, + +\begin_inset Formula $a^{\varphi(m)}\equiv1\mod m$ +\end_inset + +, + so +\begin_inset Formula $X_{\varphi(m)}=X_{0}$ +\end_inset + + by Equation (6). + For +\begin_inset Formula $a=1$ +\end_inset + +, + +\begin_inset Formula $X_{m}=(X_{0}+mc)\bmod m=X_{0}$ +\end_inset + +, + and for +\begin_inset Formula $a=0$ +\end_inset + +, + +\begin_inset Formula $a$ +\end_inset + + and +\begin_inset Formula $m$ +\end_inset + + are not relatively prime. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc3[M10] +\end_layout + +\end_inset + +If +\begin_inset Formula $a$ +\end_inset + + and +\begin_inset Formula $m$ +\end_inset + + are not relatively prime, + explain why the sequence will be somewhat handicapped and probably not very random; + hence we will generally want the multiplier +\begin_inset Formula $a$ +\end_inset + + to be relatively prime to the modulus +\begin_inset Formula $m$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Let +\begin_inset Formula $p$ +\end_inset + + be a common prime between +\begin_inset Formula $a$ +\end_inset + + and +\begin_inset Formula $c$ +\end_inset + +, +\begin_inset Formula +\[ +X_{n}=(a^{n}X_{0}+(a^{n-1}+a^{n-2}+\dots+1)c)\bmod m, +\] + +\end_inset + +so +\begin_inset Formula +\[ +X_{n}\bmod p=c\bmod p +\] + +\end_inset + + for any +\begin_inset Formula $n\geq1$ +\end_inset + +. +\end_layout + +\end_body +\end_document diff --git a/vol2/3.2.2.lyx b/vol2/3.2.2.lyx new file mode 100644 index 0000000..173f721 --- /dev/null +++ b/vol2/3.2.2.lyx @@ -0,0 +1,834 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 620 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass book +\begin_preamble +\input defs +\end_preamble +\use_default_options true +\maintain_unincluded_children no +\language english +\language_package default +\inputencoding utf8 +\fontencoding auto +\font_roman "default" "default" +\font_sans "default" "default" +\font_typewriter "default" "default" +\font_math "auto" "auto" +\font_default_family default +\use_non_tex_fonts false +\font_sc false +\font_roman_osf false +\font_sans_osf false +\font_typewriter_osf false +\font_sf_scale 100 100 +\font_tt_scale 100 100 +\use_microtype false +\use_dash_ligatures true +\graphics default +\default_output_format default +\output_sync 0 +\bibtex_command default +\index_command default +\float_placement class +\float_alignment class +\paperfontsize default +\spacing single +\use_hyperref false +\papersize default +\use_geometry false +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\cite_engine basic +\cite_engine_type default +\biblio_style plain +\use_bibtopic false +\use_indices false +\paperorientation portrait +\suppress_date false +\justification true +\use_refstyle 1 +\use_formatted_ref 0 +\use_minted 0 +\use_lineno 0 +\index Index +\shortcut idx +\color #008000 +\end_index +\secnumdepth 3 +\tocdepth 3 +\paragraph_separation indent +\paragraph_indentation default +\is_math_indent 0 +\math_numbering_side default +\quotes_style english +\dynamic_quotes 0 +\papercolumns 1 +\papersides 1 +\paperpagestyle default +\tablestyle default +\tracking_changes false +\output_changes false +\change_bars false +\postpone_fragile_content false +\html_math_output 0 +\html_css_as_file 0 +\html_be_strict false +\docbook_table_output 0 +\docbook_mathml_prefix 1 +\end_header + +\begin_body + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc1[12] +\end_layout + +\end_inset + +In practice, + we form random numbers using +\begin_inset Formula $X_{n+1}=(aX_{n}+c)\bmod m$ +\end_inset + +, + where the +\begin_inset Formula $X$ +\end_inset + +'s are +\emph on +integers +\emph default +, + afterwards treating them as the +\emph on +fractions +\emph default + +\begin_inset Formula $U_{n}=X_{n}/m$ +\end_inset + +. + The recurrence relation for +\begin_inset Formula $U_{n}$ +\end_inset + + is actually +\begin_inset Formula +\[ +U_{n+1}=(aU_{n}+c/m)\bmod1. +\] + +\end_inset + +Discuss the generation of random sequences using this relation +\emph on +directly +\emph default +, + by making use of floating point arithmetic on the computer. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Despite the appeal of the idea for simplicity, + there is the problem of precision, + as the computer needs to be able to represent numbers as high as +\begin_inset Formula $a$ +\end_inset + + (almost) with a precision of +\begin_inset Formula $1/m$ +\end_inset + +; + otherwise some numbers would be truncated and the period would be smaller than expected. + Also, + there might be issues due to rounding if +\begin_inset Formula $m$ +\end_inset + + is not a divisor of a power of the computer's base (i.e. + 2, + or in some old computers 10), + but if it is, + then it's just faster to use integer arithmetic. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc2[M20] +\end_layout + +\end_inset + +A good source of random numbers will have +\begin_inset Formula $X_{n-1}<X_{n+1}<X_{n}$ +\end_inset + + about one-sixth of the time, + since each of the six possible relative orders of +\begin_inset Formula $X_{n-1}$ +\end_inset + +, + +\begin_inset Formula $X_{n}$ +\end_inset + +, + and +\begin_inset Formula $X_{n+1}$ +\end_inset + + should be equally probable. + However, + show that the ordering above +\emph on +never +\emph default + occurs if the Fibonacci sequence (5) is used. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +If +\begin_inset Formula $X_{n+1}<X_{n}$ +\end_inset + +, + then +\begin_inset Formula $X_{n-1}=(X_{n+1}-X_{n})\bmod m=X_{n+1}-X_{n}+m>X_{n+1}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc4[00] +\end_layout + +\end_inset + +Why is the most significant byte used in the first line of program (14), + instead of some other byte? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +It follows Algorithm B, + and it's the byte that's the most random. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc5[20] +\end_layout + +\end_inset + +Discuss using +\begin_inset Formula $X_{n}=Y_{n}$ +\end_inset + + in Algorithm M, + in order to improve the speed of generation. + Is the result analogous to Algorithm B? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +This would use the next element in the sequence to choose which of the previous elements to use. + By the discussion about Exercise 15, + the period of the sequence would be the same as the original one, + and the resulting might actually be less random. + This is different than Algorithm B where the element used to choose is the one that was chosen from the table in the previous iteration, + so the index +\begin_inset Formula $j$ +\end_inset + + itself is shuffled. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc6[10] +\end_layout + +\end_inset + +In the binary method (10), + the text states that the low-order bit of +\family typewriter +X +\family default + is random, + if the code is performed repeatedly. + Why isn't the entire +\emph on +word +\emph default + +\family typewriter +X +\family default + random? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Because there is a high correlation between one element and the next: + if the higher order bit is 0, + the next word is simply twice the previous one. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc9[M24] +\end_layout + +\end_inset + +(R. + R. + Coveyou.) Use the result of exercise 8 to prove that the modified middle-square method (4) has a period of length +\begin_inset Formula $2^{e-2}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +After several trials of the middle-square method, + we hypothesize that, + when +\begin_inset Formula $e\geq2$ +\end_inset + +, + +\begin_inset Formula $X_{n}=4Y_{n}+2$ +\end_inset + + for each +\begin_inset Formula $n\geq0$ +\end_inset + +, + where +\begin_inset Formula $(Y_{n})_{n}$ +\end_inset + + is the quadratic congruential sequence given by +\begin_inset Formula +\begin{align*} +X_{0} & =4Y_{0}+2, & Y_{n+1} & =(4Y_{n}+1)(Y_{n}+1)\bmod2^{e-2}. +\end{align*} + +\end_inset + +This sequence has +\begin_inset Formula $d=4$ +\end_inset + +, + +\begin_inset Formula $a=5$ +\end_inset + +, + and +\begin_inset Formula $c=1$ +\end_inset + +, + so it meets the conditions from exercise 8 and therefore has period +\begin_inset Formula $2^{e-2}$ +\end_inset + +. + We can prove this identity by induction, + as if +\begin_inset Formula $X_{n}=4Y_{n}+2$ +\end_inset + +, + then +\begin_inset Formula +\begin{multline*} +X_{n+1}=X_{n}(X_{n}+1)\bmod2^{e}=(4Y_{n}+2)(4Y_{n}+3)\bmod2^{e}=\\ +=16Y_{n}^{2}+20Y_{n}+6\bmod2^{e}=4(4Y_{n}+1)(Y_{n}+1)+2\bmod2^{e}=4Y_{n+1}+2. +\end{multline*} + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc22[M24] +\end_layout + +\end_inset + +The text restricts discussion of the extended linear sequences (8) to the case that +\begin_inset Formula $m$ +\end_inset + + is prime. + Prove that reasonably long periods can also be obtained when +\begin_inset Formula $m$ +\end_inset + + is +\begin_inset Quotes eld +\end_inset + +squarefree, +\begin_inset Quotes erd +\end_inset + + that is, + the product of distinct primes. + (Examinations of Table 3.2.1.1–1 shows that +\begin_inset Formula $m=w\pm1$ +\end_inset + + often satisfies this hypothesis; + many of the results of the text can therefore be carried over to that case, + which is somewhat more convenient for calculation.) +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +If +\begin_inset Formula $m=p_{1}\cdots p_{t}$ +\end_inset + + where the +\begin_inset Formula $p_{k}$ +\end_inset + + are distinct primes, + then integers +\begin_inset Formula $a\in\{0,\dots,m-1\}$ +\end_inset + + can be associated with the tuples +\begin_inset Formula $(a\bmod p_{1},\dots,a\bmod p_{t})$ +\end_inset + + because of the Chinese remainder theorem. + Furthermore, + equation (8) respects this association, + in the sense that +\begin_inset Formula $X_{n}\bmod p_{i}=((a_{1}\bmod p_{i})(X_{n-1}\bmod p_{i})+\dots+(a_{k}\bmod p_{i})(X_{n-k}\bmod p_{i}))\bmod p_{i}$ +\end_inset + + and therefore we could as well calculate the sequence using these +\begin_inset Quotes eld +\end_inset + +coordinates +\begin_inset Quotes erd +\end_inset + +. + We also know that the +\begin_inset Formula $a_{j}\bmod p_{i}$ +\end_inset + + can be chosen to make +\begin_inset Formula $(X_{n}\bmod p_{i})_{n}$ +\end_inset + + have period +\begin_inset Formula $p_{i}^{k}-1$ +\end_inset + +, + so the +\begin_inset Formula $a_{j}$ +\end_inset + + can be chosen to make +\begin_inset Formula $(X_{n})_{n}$ +\end_inset + + have period +\begin_inset Formula $\text{lcm}\{p_{1}^{k}-1,\dots,p_{t}^{k}-1\}$ +\end_inset + +, + which we deem reasonably long. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc23[20] +\end_layout + +\end_inset + +Discuss the sequence defined by +\begin_inset Formula $X_{n}=(X_{n-55}-X_{n-24})\bmod m$ +\end_inset + + as an alternative to (7). +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +The period is still at least +\begin_inset Formula $2^{55}-1$ +\end_inset + +, + since the sequence defined by the lowest bit in (7) has this period and the one defined by the lowest bit in this formula is exactly the same. + We don't know if exercise 30 still applies as we haven't done it. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +begin{samepage} +\end_layout + +\end_inset + + +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc33[M23] +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Enumerate +Let +\begin_inset Formula $g_{n}(z)=X_{n+30}+X_{n+29}z+\dots+X_{n}z^{30}+X_{n+54}z^{31}+\dots+X_{n+31}z^{54}$ +\end_inset + +, + where the +\begin_inset Formula $X$ +\end_inset + +'s satisfy the lagged Fibonacci recurrence (7). + Find a simple relation between +\begin_inset Formula $g_{n}(z)$ +\end_inset + + and +\begin_inset Formula $g_{n+t}(z)$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Express +\begin_inset Formula $X_{500}$ +\end_inset + + in terms of +\begin_inset Formula $X_{0},\dots,X_{54}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +end{samepage} +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Note Greyedout +status open + +\begin_layout Plain Layout +(I obviously had to look at the answers.) +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Enumerate +\begin_inset Formula +\begin{align*} +g_{n+1}(z) & =X_{n+31}+X_{n+30}z+\dots+X_{n+1}z^{30}+X_{n+55}z^{31}+\dots+X_{n+32}z^{54}\\ + & =zg_{n}(z)+X_{n+31}-X_{n}z^{31}+X_{n+55}z^{31}-X_{n+31}z^{55}\\ + & =zg_{n}(z)+X_{n+31}(z^{31}-z^{55}+1)+km, +\end{align*} + +\end_inset + +for some small integer +\begin_inset Formula $k$ +\end_inset + +. + If we see the +\begin_inset Formula $g_{n}$ +\end_inset + + as polynomials on +\begin_inset Formula $z$ +\end_inset + +, + in the domain +\begin_inset Formula $\mathbb{Z}[X]$ +\end_inset + +, + then +\begin_inset Formula $g_{n+t}(z)\equiv z^{t}g_{n}(z)$ +\end_inset + + in +\begin_inset Formula $A\coloneqq\mathbb{Z}[X]/(m\mathbb{Z}[X]+(z^{55}-z^{31}-1)\mathbb{Z}[X])\cong\mathbb{Z}_{m}[X]/(z^{55}-z^{31}-1)\mathbb{Z}_{m}[X]$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +We prove by strong induction that, + if +\begin_inset Formula $a_{0}+\dots+a_{54}z^{54}=z^{k}\bmod(z^{55}-z^{31}-1)$ +\end_inset + + in +\begin_inset Formula $\mathbb{Z}_{m}[X]$ +\end_inset + +, + then +\begin_inset Formula $X_{k}=a_{0}X_{0}+\dots+a_{54}X^{54}\bmod m$ +\end_inset + +. + If +\begin_inset Formula $k<55$ +\end_inset + +, + this is obvious; + otherwise +\begin_inset Formula $X_{k}=X_{k-55}+X_{k-24}$ +\end_inset + + and +\begin_inset Formula $z^{k}\bmod(z^{55}-z^{31}-1)=(z^{k-55}+z^{k-24})\bmod(z^{55}-z^{31}-1)$ +\end_inset + + by the division algorithm. + With this, + we run +\family typewriter +divide(z^500, + z^55-z^31-1, + z) +\family default + in Maxima and we get that +\begin_inset Formula $X_{500}=120X_{54}+462X_{50}+455X_{57}+X_{44}+120X_{43}+1001X_{40}+18X_{37}+9X_{36}+1287X_{33}+16X_{30}+462X_{26}+105X_{23}+210X_{19}+364X_{16}+X_{13}+36X_{12}+715X_{9}+17X_{6}+X_{5}+792X_{2}\bmod m$ +\end_inset + +. +\end_layout + +\end_body +\end_document diff --git a/vol2/3.3.1.lyx b/vol2/3.3.1.lyx new file mode 100644 index 0000000..f2bfc5c --- /dev/null +++ b/vol2/3.3.1.lyx @@ -0,0 +1,607 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 620 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass book +\begin_preamble +\input defs +\end_preamble +\use_default_options true +\maintain_unincluded_children no +\language english +\language_package default +\inputencoding utf8 +\fontencoding auto +\font_roman "default" "default" +\font_sans "default" "default" +\font_typewriter "default" "default" +\font_math "auto" "auto" +\font_default_family default +\use_non_tex_fonts false +\font_sc false +\font_roman_osf false +\font_sans_osf false +\font_typewriter_osf false +\font_sf_scale 100 100 +\font_tt_scale 100 100 +\use_microtype false +\use_dash_ligatures true +\graphics default +\default_output_format default +\output_sync 0 +\bibtex_command default +\index_command default +\float_placement class +\float_alignment class +\paperfontsize default +\spacing single +\use_hyperref false +\papersize default +\use_geometry false +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\cite_engine basic +\cite_engine_type default +\biblio_style plain +\use_bibtopic false +\use_indices false +\paperorientation portrait +\suppress_date false +\justification true +\use_refstyle 1 +\use_formatted_ref 0 +\use_minted 0 +\use_lineno 0 +\index Index +\shortcut idx +\color #008000 +\end_index +\secnumdepth 3 +\tocdepth 3 +\paragraph_separation indent +\paragraph_indentation default +\is_math_indent 0 +\math_numbering_side default +\quotes_style english +\dynamic_quotes 0 +\papercolumns 1 +\papersides 1 +\paperpagestyle default +\tablestyle default +\tracking_changes false +\output_changes false +\change_bars false +\postpone_fragile_content false +\html_math_output 0 +\html_css_as_file 0 +\html_be_strict false +\docbook_table_output 0 +\docbook_mathml_prefix 1 +\end_header + +\begin_body + +\begin_layout Standard +\begin_inset FormulaMacro +\newcommand{\stirla}[2]{\genfrac[]{0pt}{}{#1}{#2}} +{\begin{bmatrix}{\textstyle #1}\\ +{\textstyle #2} +\end{bmatrix}} +\end_inset + + +\begin_inset FormulaMacro +\newcommand{\stirlb}[2]{\genfrac\{\}{0pt}{}{#1}{#2}} +{\begin{Bmatrix}{\textstyle #1}\\ +{\textstyle #2} +\end{Bmatrix}} +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc1[00] +\end_layout + +\end_inset + +What line of the chi-square table should be used to check whether or not the value +\begin_inset Formula $V=7\frac{7}{48}$ +\end_inset + + of Eq. + (5) is improbably high? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Row +\begin_inset Formula $\nu=k-1=11-1=10$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc3[23] +\end_layout + +\end_inset + +Some dice that were loaded as described in the previous exercise were rolled 144 times, + and the following values were observed: +\begin_inset Formula +\[ +\begin{array}{rrrrrrrrrrrr} +\text{value of }s= & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12\\ +\text{observed number, }Y_{s}= & 2 & 6 & 10 & 16 & 18 & 32 & 20 & 13 & 16 & 9 & 2 +\end{array} +\] + +\end_inset + +Apply the chi-square test to +\emph on +these +\emph default + values, + using the probabilities in (1), + pretending that the dice are not in fact known to be faulty. + Does the chi-square test detect the bad dice? + If not, + explain why not. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We take the values +\begin_inset Formula $np_{s}$ +\end_inset + + from (2), + to get: +\begin_inset Formula +\begin{align*} +V & =\sum_{s=2}^{12}\frac{(Y_{s}-np_{s})^{2}}{np_{s}}=\frac{4}{4}+\frac{4}{8}+\frac{4}{12}+\frac{0}{16}+\frac{4}{20}+\frac{64}{24}+\frac{0}{20}+\frac{9}{16}+\frac{16}{12}+\frac{1}{8}+\frac{4}{4}\\ + & =1+\frac{1}{2}+\frac{1}{3}+\frac{1}{5}+\frac{8}{3}+\frac{9}{16}+\frac{4}{3}+\frac{1}{8}+1=2+\frac{13}{3}+\frac{19}{16}+\frac{1}{5}\\ + & =7+\frac{80+45+48}{240}=7+\frac{173}{240}. +\end{align*} + +\end_inset + +Using +\begin_inset Formula $n=10$ +\end_inset + + we get a probability between +\begin_inset Formula $.25$ +\end_inset + + and +\begin_inset Formula $.5$ +\end_inset + +, + which is not suspect. + This seems to be because the bias of one die compensates that of the other, + smoothing out the probability differences. + The difference could be discovered with a large enough value of +\begin_inset Formula $n$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc4[23] +\end_layout + +\end_inset + +The author actually obtained the data in experiment 1 of (9) by simulating dice in which one was normal, + the other was loaded so that it always turned up 1 or 6. + (The latter two possibilities were equally probable.) Compute the probabilities that replace (1) in this case, + and by using a chi-square test decide if the results of that experiment are consistent with the dice being loaded in this way. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We compute the table with the sum of the two dice: +\begin_inset Formula +\[ +\begin{array}{r|rrrrrr} + & 1 & 2 & 3 & 4 & 5 & 6\\ +\hline 1 & 2 & 3 & 4 & 5 & 6 & 7\\ +6 & 7 & 8 & 9 & 10 & 11 & 12 +\end{array} +\] + +\end_inset + +This gives us the following table of probabilities: +\begin_inset Formula +\[ +\begin{array}{rrrrrrrrrrrr} +s= & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12\\ +144p_{s}= & 12 & 12 & 12 & 12 & 12 & 24 & 12 & 12 & 12 & 12 & 12 +\end{array} +\] + +\end_inset + +Thus, +\begin_inset Formula +\begin{align*} +V & =\frac{1}{12}\left(8^{2}+2^{2}+2^{2}+1^{2}+8^{2}+\frac{6^{2}}{2}+6^{2}+1^{2}+1^{2}+2^{2}+1^{2}\right)\\ + & =\frac{1}{12}(64+4+4+1+64+18+26+1+1+2+1)=\frac{186}{12}=15+\frac{1}{2}. +\end{align*} + +\end_inset + +With +\begin_inset Formula $n=10$ +\end_inset + +, + this is somewhat in the middle of +\begin_inset Formula $p=.75$ +\end_inset + + and +\begin_inset Formula $p=.95$ +\end_inset + +, + which is consistent. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc8[00] +\end_layout + +\end_inset + +The text describes an experiment in which 20 values of the statistic +\begin_inset Formula $K_{10}^{+}$ +\end_inset + + were obtained in the study of a random sequence. + These values were plotted, + to obtain Fig. + 4, + and a KS statistic was computed from the resulting graph. + Why were the table entries for +\begin_inset Formula $n=20$ +\end_inset + + used to study the resulting statistic, + instead of the table entries for +\begin_inset Formula $n=10$ +\end_inset + +? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Because the value of +\begin_inset Formula $n$ +\end_inset + + to use is not about the underlying probability distribution (which can be an arbitrary real-valued one, + not just +\begin_inset Formula $K_{n}^{+}$ +\end_inset + + or +\begin_inset Formula $K_{n}^{-}$ +\end_inset + +), + but rather it is the number of observations we make for this distribution, + which is 20. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc9[20] +\end_layout + +\end_inset + +The experiment described in the text consisted of plotting 20 values of +\begin_inset Formula $K_{10}^{+}$ +\end_inset + +, + computed from the maximum-of-5 test applied to different parts of a random sequence. + We could have computed also the corresponding 20 values of +\begin_inset Formula $K_{10}^{-}$ +\end_inset + +; + since +\begin_inset Formula $K_{10}^{-}$ +\end_inset + + has the same distribution as +\begin_inset Formula $K_{10}^{+}$ +\end_inset + +, + we could lump together the 40 values thus obtained (that is, + 20 of the +\begin_inset Formula $K_{10}^{+}$ +\end_inset + +'s and 20 of the +\begin_inset Formula $K_{10}^{-}$ +\end_inset + +'s), + and a KS test could be applied so that we would get new values +\begin_inset Formula $K_{40}^{+}$ +\end_inset + +, + +\begin_inset Formula $K_{40}^{-}$ +\end_inset + +. + Discuss the merits of this idea. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +The issue here is that the 40 points would not be independent; + if the maximum of 5 is low, + the minimum of 5 must be necessarily lower, + the probability of it being higher is 0. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc10[20] +\end_layout + +\end_inset + +Suppose a chi-square test is done by making +\begin_inset Formula $n$ +\end_inset + + observations, + and the value +\begin_inset Formula $V$ +\end_inset + + is obtained. + Now we repeat the test on these same +\begin_inset Formula $n$ +\end_inset + + observations over again (getting, + of course, + the same results), + and we put together the data from both tests, + regarding it as a single chi-square test with +\begin_inset Formula $2n$ +\end_inset + + observations. + (This procedure violates the text's stipulation that all of the observations must be independent of one another.) How is the second value of +\begin_inset Formula $V$ +\end_inset + + related to the first one? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Let +\begin_inset Formula $Y'_{s}=2Y_{s}$ +\end_inset + + be the number of observations of category +\begin_inset Formula $s$ +\end_inset + + in the second test, + the second value of +\begin_inset Formula $V$ +\end_inset + + is +\begin_inset Formula +\[ +V'=\sum_{s=1}^{k}\frac{(Y'_{s}-2np_{s})^{2}}{2np_{s}}=\sum_{s=1}^{k}\frac{(2Y_{s}-2np_{s})^{2}}{2np_{s}}=2V. +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc11[10] +\end_layout + +\end_inset + +Solve exercise 10 substituting the KS test for the chi-square test. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +This time, + after sorting the +\begin_inset Formula $2n$ +\end_inset + + observations +\begin_inset Formula $X'_{1},\dots,X'_{2n}$ +\end_inset + +, + we have +\begin_inset Formula $X_{j}=X'_{2j-1}=X'_{2j}$ +\end_inset + +, + so +\begin_inset Formula +\[ +K_{2n}^{+}=\sqrt{2n}\max_{1\leq j\leq2n}\left(\frac{j}{2n}-F(X'_{j})\right)=\sqrt{2n}\max_{1\leq j\leq n}\left(\frac{2j}{2n}-F(X_{j})\right)=\sqrt{2}K_{n}^{+}, +\] + +\end_inset + +and similarly, +\begin_inset Formula +\[ +K_{2n}^{-}=\sqrt{2n}\max_{1\leq j\leq2n}\left(F(X'_{j})-\frac{j-1}{2n}\right)=\sqrt{2n}\max_{1\leq j\leq n}\left(F(X_{j})-\frac{2j-2}{2n}\right)=\sqrt{2}K_{n}^{-}. +\] + +\end_inset + + +\end_layout + +\end_body +\end_document diff --git a/vol2/3.3.2.lyx b/vol2/3.3.2.lyx new file mode 100644 index 0000000..03a3027 --- /dev/null +++ b/vol2/3.3.2.lyx @@ -0,0 +1,1009 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 620 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass book +\begin_preamble +\input defs +\end_preamble +\use_default_options true +\maintain_unincluded_children no +\language english +\language_package default +\inputencoding utf8 +\fontencoding auto +\font_roman "default" "default" +\font_sans "default" "default" +\font_typewriter "default" "default" +\font_math "auto" "auto" +\font_default_family default +\use_non_tex_fonts false +\font_sc false +\font_roman_osf false +\font_sans_osf false +\font_typewriter_osf false +\font_sf_scale 100 100 +\font_tt_scale 100 100 +\use_microtype false +\use_dash_ligatures true +\graphics default +\default_output_format default +\output_sync 0 +\bibtex_command default +\index_command default +\float_placement class +\float_alignment class +\paperfontsize default +\spacing single +\use_hyperref false +\papersize default +\use_geometry false +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\cite_engine basic +\cite_engine_type default +\biblio_style plain +\use_bibtopic false +\use_indices false +\paperorientation portrait +\suppress_date false +\justification true +\use_refstyle 1 +\use_formatted_ref 0 +\use_minted 0 +\use_lineno 0 +\index Index +\shortcut idx +\color #008000 +\end_index +\secnumdepth 3 +\tocdepth 3 +\paragraph_separation indent +\paragraph_indentation default +\is_math_indent 0 +\math_numbering_side default +\quotes_style english +\dynamic_quotes 0 +\papercolumns 1 +\papersides 1 +\paperpagestyle default +\tablestyle default +\tracking_changes false +\output_changes false +\change_bars false +\postpone_fragile_content false +\html_math_output 0 +\html_css_as_file 0 +\html_be_strict false +\docbook_table_output 0 +\docbook_mathml_prefix 1 +\end_header + +\begin_body + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc1[10] +\end_layout + +\end_inset + +Why should the serial test described in part B be applied to +\begin_inset Formula +\[ +(Y_{0},Y_{1}),(Y_{2},Y_{3}),\dots,(Y_{2n-2},Y_{2n-1}) +\] + +\end_inset + +instead of to +\begin_inset Formula $(Y_{0},Y_{1}),(Y_{1},Y_{2}),\dots,(Y_{n-1},Y_{n})$ +\end_inset + +? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Otherwise the points wouldn't be independent. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc2[10] +\end_layout + +\end_inset + +State an appropriate way to generalize the serial test to triples, + quadruples, + etc., + instead of pairs. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +For +\begin_inset Formula $k$ +\end_inset + +-tuples, + use points +\begin_inset Formula $(Y_{0},\dots,Y_{k-1}),(Y_{k},\dots,Y_{2k-1}),\dots,(Y_{k(n-1)},\dots,Y_{kn-1})$ +\end_inset + +. + The chi-square method is applied to the +\begin_inset Formula $d^{k}$ +\end_inset + + possible categories and at least +\begin_inset Formula $5d^{k}$ +\end_inset + + values of +\begin_inset Formula $U$ +\end_inset + + should be taken. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc3[M20] +\end_layout + +\end_inset + +How many +\begin_inset Formula $U$ +\end_inset + +'s need to be examined in the gap test (Algorithm G) before +\begin_inset Formula $n$ +\end_inset + + gaps have been found, + on average, + assuming that the sequence is random? + What is the standard deviation of this quantity? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +The probability of a given value being the end of a gap is +\begin_inset Formula $p\coloneqq\frac{1}{\beta-\alpha}$ +\end_inset + +, + so the gap lengths have approximately exponential distribution and therefore we should take about +\begin_inset Formula $np=\frac{n}{\beta-\alpha}$ +\end_inset + + +\begin_inset Formula $U$ +\end_inset + +'s. + More precisely, + let +\begin_inset Formula $q\coloneqq1-p$ +\end_inset + +, + the probability of a gap with length +\begin_inset Formula $k$ +\end_inset + + is +\begin_inset Formula $q^{k-1}p$ +\end_inset + +, + so the average is +\begin_inset Formula +\[ +\sum_{k=1}^{\infty}q^{k-1}pk=p\sum_{k=1}^{\infty}kq^{k-1}=p\sum_{j=1}^{\infty}\sum_{k=j}^{\infty}q^{k-1}=p\sum_{j=1}^{\infty}\frac{q^{j-1}}{1-q}=\sum_{j=0}^{\infty}q^{j}=\frac{1}{1-q}=\frac{1}{p}, +\] + +\end_inset + +so the approximation above is actually the exact value of the mean gap length and the average is exactly +\begin_inset Formula $\frac{n}{\beta-\alpha}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc7[08] +\end_layout + +\end_inset + +Apply the coupon collector's test procedure (Algorithm C), + with +\begin_inset Formula $d=3$ +\end_inset + + and +\begin_inset Formula $n=7$ +\end_inset + +, + to the sequence 1101221022120202001212201010201121. + What length do the seven subsequences have? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Formula $5,3,5,6,5,5,4$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc8[M22] +\end_layout + +\end_inset + +How many +\begin_inset Formula $U$ +\end_inset + +'s need to be examined in the coupon collector's test, + on the average, + before +\begin_inset Formula $n$ +\end_inset + + complete sets have been found by Algorithm C, + assuming that the sequence is random? + What is the standard deviation? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Given that +\begin_inset Formula $\stirlb rd=0$ +\end_inset + + for +\begin_inset Formula $r<d$ +\end_inset + +, + we can write the generating function corresponding to the coupon collector's probability distribution as +\begin_inset Formula +\begin{align*} +F(z) & \coloneqq\sum_{r\geq1}\frac{d!}{d^{r}}\stirlb{r-1}{d-1}z^{r}=d!\frac{z}{d}\sum_{r\geq0}\stirlb r{d-1}\left(\frac{z}{d}\right)^{r}=\frac{(d-1)!z\left(\frac{z}{d}\right)^{d-1}}{(1-\tfrac{1}{d}z)(1-\tfrac{2}{d}z)\cdots(1-\tfrac{d-1}{d}z)}\\ + & =\frac{(d-1)!z^{d}}{(d-z)(d-2z)\cdots(d-(d-1)z)}=\frac{z^{d}}{(d-z)(\frac{d}{2}-z)\cdots(\frac{d}{d-1}-z)}. +\end{align*} + +\end_inset + +using Eq. + 1.2.9(28). + We derive this to get +\begin_inset Formula +\begin{align*} +F'(z) & =\frac{dz^{d-1}}{(d-z)\cdots(\frac{d}{d-1}-z)}-\frac{z^{d}(d-z)\cdots(\frac{d}{d-1}-z)\left(-\frac{1}{d-z}-\dots-\frac{1}{\frac{d}{d-1}-z}\right)}{(d-z)^{2}\cdots(\tfrac{d}{d-1}-z)^{2}}\\ + & =\frac{dz^{d-1}+z^{d}\left(\frac{1}{d-z}+\dots+\frac{1}{\frac{d}{d-1}-z}\right)}{(d-z)\cdots(\frac{d}{d-1}-z)};\\ +F''(z) & =\frac{d(d-1)z^{d-2}+dz^{d-1}\left(\frac{1}{d-z}+\dots+\frac{1}{\frac{d}{d-1}-z}\right)+z^{d}\left(\frac{1}{(d-z)^{2}}+\dots+\frac{1}{(\frac{d}{d-1}-z)^{2}}\right)}{(d-z)\cdots(\frac{d}{d-1}-z)}+\\ + & +\left(\frac{1}{d-z}+\dots+\frac{1}{\frac{d}{d-1}-z}\right)\frac{dz^{d-1}+z^{d}\left(\frac{1}{d-z}+\dots+\frac{1}{\frac{d}{d-1}-z}\right)}{(d-z)\cdots(\frac{d}{d-1}-z)}. +\end{align*} + +\end_inset + +We are interested in +\begin_inset Formula $F'(1)$ +\end_inset + + and +\begin_inset Formula $F''(1)$ +\end_inset + +, + for which we should note that +\begin_inset Formula +\begin{align*} +\frac{1}{\frac{d}{k}-1} & =\frac{k}{d-k}, & (d-1)(\tfrac{d}{2}-1)\cdots(\tfrac{d}{d-2}-1)(\tfrac{d}{d-1}-1) & =(d-1)\tfrac{d-2}{2}\cdots\tfrac{2}{d-2}\tfrac{1}{d-1}=1. +\end{align*} + +\end_inset + + +\end_layout + +\begin_layout Standard +Thus, + if +\begin_inset Formula $D_{1}\coloneqq\sum_{k=1}^{d}\frac{k}{d-k}$ +\end_inset + + and +\begin_inset Formula $D_{2}\coloneqq\sum_{k=1}^{d}\left(\frac{k}{d-k}\right)^{2}$ +\end_inset + +, +\begin_inset Formula +\begin{align*} +F'(1)= & D_{1}+d; & F''(1)= & d(d-1)+dD_{1}+dD_{1}+D_{1}^{2}+D_{2}=(d+D_{1})^{2}-d+D_{2}. +\end{align*} + +\end_inset + +With this, +\begin_inset Formula +\begin{align*} +\mu & =F'(1)=D_{1}+d;\\ +\sigma & =\sqrt{F''(1)+F'(1)-F'(1)^{2}}=\sqrt{D_{2}+D_{1}}. +\end{align*} + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc11[00] +\end_layout + +\end_inset + +The +\begin_inset Quotes eld +\end_inset + +runs up +\begin_inset Quotes erd +\end_inset + + in a particular permutation are displayed in (9); + what are the +\begin_inset Quotes eld +\end_inset + +runs down +\begin_inset Quotes erd +\end_inset + + in that permutation? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Formula +\[ +\begin{array}{|c|c|cccc|c|cc|c|} +1 & 2 & 9 & 8 & 5 & 3 & 6 & 7 & 0 & 4\end{array}. +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc14[M15] +\end_layout + +\end_inset + +If we +\begin_inset Quotes eld +\end_inset + +throw away +\begin_inset Quotes erd +\end_inset + + the element that immediately follows a run, + so that when +\begin_inset Formula $X_{j}$ +\end_inset + + is greater than +\begin_inset Formula $X_{j+1}$ +\end_inset + + we start the next run with +\begin_inset Formula $X_{j+2}$ +\end_inset + +, + the run lengths are independent, + and a simple chi-square test may be used (instead of the horribly complicated method derived in the text). + What are the appropriate run-length probabilities for this simple run test? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +When the +\begin_inset Formula $X_{j}$ +\end_inset + + are real numbers, + the probability of a repeated element in a finite sample is 0, + so we can unambiguously take a permutation of the elements in such a way that all permutations are equally likely. + Let +\begin_inset Formula $p_{r}$ +\end_inset + + be the probability that +\begin_inset Formula $U_{1},U_{2},U_{3},\dots$ +\end_inset + + starts with a run of length +\begin_inset Formula $r$ +\end_inset + + for +\begin_inset Formula $1\leq r<t$ +\end_inset + +, + and let +\begin_inset Formula $p_{t}$ +\end_inset + + be the probability that it starts with a run of length +\begin_inset Formula $t$ +\end_inset + + or more, + we have +\begin_inset Formula $p_{r}=\frac{r}{(r+1)!}$ +\end_inset + +, + since +\begin_inset Formula $U_{1},\dots,U_{r}$ +\end_inset + + must be ordered like +\begin_inset Formula $U_{1}<\dots<U_{r}$ +\end_inset + + and +\begin_inset Formula $U_{r+1}$ +\end_inset + + must be inserted in this permutation in any of the +\begin_inset Formula $r$ +\end_inset + + places that is not the last one (that is, + +\begin_inset Formula $U_{r+1}<U_{r}$ +\end_inset + +). + Similarly, + +\begin_inset Formula $p_{t}=\frac{1}{t!}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc15[M10] +\end_layout + +\end_inset + +In the maximum-of- +\begin_inset Formula $t$ +\end_inset + + test, + why are +\begin_inset Formula $V_{0}^{t},V_{1}^{t},\dots,V_{n-1}^{t}$ +\end_inset + + supposed to be uniformly distributed between zero and one? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Formula $P(V_{0}^{t}\leq x)=P(V_{0}\leq\sqrt[t]{x})=\sqrt[t]{x}^{t}=x$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc6[15] +\end_layout + +\end_inset + +Mr. + J. + H. + Quick (a student) wanted to perform the maximum-of- +\begin_inset Formula $t$ +\end_inset + + test for several different values of +\begin_inset Formula $t$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Letting +\begin_inset Formula $Z_{jt}=\max(U_{j},U_{j+1},\dots,U_{j+t-1})$ +\end_inset + + he found a clever way to go from the sequence +\begin_inset Formula $Z_{0(t-1)},Z_{1(t-1)},\dots$ +\end_inset + +, + to the sequence +\begin_inset Formula $Z_{0t},Z_{1t},\dots$ +\end_inset + +, + using very little time and space. + What was his bright idea? +\end_layout + +\begin_layout Enumerate +He decided to modify the maximum-of- +\begin_inset Formula $t$ +\end_inset + + method so that the +\begin_inset Formula $j$ +\end_inset + +th observation would be +\begin_inset Formula $\max(U_{j},\dots,U_{j+t-1})$ +\end_inset + +; + in other words, + he took +\begin_inset Formula $V_{j}=Z_{jt}$ +\end_inset + + instead of +\begin_inset Formula $V_{j}=Z_{(tj)t}$ +\end_inset + + as the text says. + He reasoned that +\emph on +all +\emph default + of the +\begin_inset Formula $Z$ +\end_inset + +'s should have the same distribution, + so the test is even stronger if each +\begin_inset Formula $Z_{jt}$ +\end_inset + +, + +\begin_inset Formula $0\leq j<n$ +\end_inset + +, + is used instead of just every +\begin_inset Formula $t$ +\end_inset + +th one. + But when he tried a chi-square equidistribution test on the values of +\begin_inset Formula $V_{j}^{t}$ +\end_inset + +, + he got extremely high values of the statistic +\begin_inset Formula $V$ +\end_inset + +, + which got even higher as +\begin_inset Formula $t$ +\end_inset + + increased. + Why did this happen? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Enumerate +\begin_inset Formula +\begin{multline*} +Z_{jt}=\max\{U_{j},\dots,U_{j+t-1}\}=\\ +=\max\{\max\{U_{j},\dots,U_{j+t-2}\},\max\{U_{j+1},\dots,U_{j+t-1}\}\}=\max\{Z_{j,t-1},Z_{j+1,t-1}\}. +\end{multline*} + +\end_inset + + +\end_layout + +\begin_layout Enumerate +The values of the +\begin_inset Formula $Z_{jt}$ +\end_inset + + for fixed +\begin_inset Formula $t$ +\end_inset + + and for all +\begin_inset Formula $j$ +\end_inset + + are not independent, + as they represent overlapping ranges of elements in +\begin_inset Formula $(U_{j})_{j}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc31[M21] +\end_layout + +\end_inset + +The recurrence +\begin_inset Formula $Y_{n}=(Y_{n-24}+Y_{n-55})\bmod2$ +\end_inset + +, + which describe the least significant bits of the lagged Fibonacci generator 3.2.2–(7) as well as the second-least significant bits of 3.2.2–(7'), + is known to have period length +\begin_inset Formula $2^{55}-1$ +\end_inset + +; + hence every possible nonzero pattern of bits +\begin_inset Formula $(Y_{n},Y_{n+1},\dots,Y_{n+54})$ +\end_inset + + occurs equally often. + Nevertheless, + prove that if we generate 79 consecutive random bits +\begin_inset Formula $Y_{n},\dots,Y_{n+78}$ +\end_inset + + starting at a random point in the period, + the probability is more than +\begin_inset Formula $\unit[51]{\%}$ +\end_inset + + that there are more 1s than 0s. + If we use such bits to define a +\begin_inset Quotes eld +\end_inset + +random walk +\begin_inset Quotes erd +\end_inset + + that moves to the right when the bit is 1 and to the left when the bit is 0, + we'll finish to the right of our starting point significantly more than half of the time. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +The values +\begin_inset Formula $(Y_{n},\dots,Y_{n+54})$ +\end_inset + + can be any nonzero pattern of bits with equal probability. + It is enough to prove this when also include the zero pattern, + as the probability of finding more 1s than 0s is even higher when we don't. + +\end_layout + +\begin_layout Standard +In this case, + each +\begin_inset Formula $Y_{n+j}$ +\end_inset + +, + +\begin_inset Formula $0\leq j\leq54$ +\end_inset + +, + can be 0 or 1 with equal probability, + each independent of the other, + and +\begin_inset Formula $Y_{n+j}=(Y_{n+j-55}+Y_{n+j-24})\bmod2$ +\end_inset + + for +\begin_inset Formula $55\leq j\leq78$ +\end_inset + +. + Then, + for +\begin_inset Formula $0\leq j\leq23$ +\end_inset + +, + +\begin_inset Formula $Z_{n+j}\coloneqq Y_{n+j}+Y_{n+31+j}+Y_{n+55+j}$ +\end_inset + + is 2 with probability +\begin_inset Formula $\frac{3}{4}$ +\end_inset + + and 0 with probability +\begin_inset Formula $\frac{1}{4}$ +\end_inset + +, + and for +\begin_inset Formula $24\leq j\leq30$ +\end_inset + +, + +\begin_inset Formula $Y_{n+j}$ +\end_inset + + is 1 or 0 with equal probability +\begin_inset Formula $\frac{1}{2}$ +\end_inset + +. + Furthermore, + these probabilities are now independent. +\end_layout + +\begin_layout Standard +With this in mind, +\begin_inset Formula +\begin{align*} +F(z) & \coloneqq\sum_{k}P(Y_{n}+\dots+Y_{n+78}=k)z^{k}\\ + & =\sum_{k_{0},\dots,k_{30}}P(Z_{n}=k_{0})\cdots P(Z_{n+23}=k_{23})P(Y_{24}=k_{24})\cdots P(Y_{30}=k_{30})z^{k_{1}+\dots+k_{30}}\\ + & =\left(\frac{3}{4}z^{2}+\frac{1}{4}\right)^{24}\left(\frac{1}{2}(z+1)\right)^{7}. +\end{align*} + +\end_inset + + +\end_layout + +\begin_layout Standard +In Maxima, + we can type +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +p:''(expand((3/4*z^2+1/4)^24*(1/2*(z+1))^7))$ +\end_layout + +\begin_layout Plain Layout + +sum(coeff(p,z,j),j,40,79),numer; +\end_layout + +\end_inset + +giving us a probability of having 1s than 0s of +\begin_inset Formula $0.5137...$ +\end_inset + + +\end_layout + +\end_body +\end_document diff --git a/vol2/3.3.3.lyx b/vol2/3.3.3.lyx new file mode 100644 index 0000000..d03c773 --- /dev/null +++ b/vol2/3.3.3.lyx @@ -0,0 +1,1383 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 620 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass book +\begin_preamble +\input defs +\end_preamble +\use_default_options true +\maintain_unincluded_children no +\language english +\language_package default +\inputencoding utf8 +\fontencoding auto +\font_roman "default" "default" +\font_sans "default" "default" +\font_typewriter "default" "default" +\font_math "auto" "auto" +\font_default_family default +\use_non_tex_fonts false +\font_sc false +\font_roman_osf false +\font_sans_osf false +\font_typewriter_osf false +\font_sf_scale 100 100 +\font_tt_scale 100 100 +\use_microtype false +\use_dash_ligatures true +\graphics default +\default_output_format default +\output_sync 0 +\bibtex_command default +\index_command default +\float_placement class +\float_alignment class +\paperfontsize default +\spacing single +\use_hyperref false +\papersize default +\use_geometry false +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\cite_engine basic +\cite_engine_type default +\biblio_style plain +\use_bibtopic false +\use_indices false +\paperorientation portrait +\suppress_date false +\justification true +\use_refstyle 1 +\use_formatted_ref 0 +\use_minted 0 +\use_lineno 0 +\index Index +\shortcut idx +\color #008000 +\end_index +\secnumdepth 3 +\tocdepth 3 +\paragraph_separation indent +\paragraph_indentation default +\is_math_indent 0 +\math_numbering_side default +\quotes_style english +\dynamic_quotes 0 +\papercolumns 1 +\papersides 1 +\paperpagestyle default +\tablestyle default +\tracking_changes false +\output_changes false +\change_bars false +\postpone_fragile_content false +\html_math_output 0 +\html_css_as_file 0 +\html_be_strict false +\docbook_table_output 0 +\docbook_mathml_prefix 1 +\end_header + +\begin_body + +\begin_layout Subsubsection +First Set +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc1[M10] +\end_layout + +\end_inset + +Express +\begin_inset Formula $x\bmod y$ +\end_inset + + in terms of the sawtooth and +\begin_inset Formula $\delta$ +\end_inset + + functions. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We have +\begin_inset Formula $((x))-\frac{1}{2}\delta(x)=x-\lfloor x\rfloor-\frac{1}{2}$ +\end_inset + +, + so +\begin_inset Formula $\lfloor x\rfloor=x-((x))+\tfrac{1}{2}(\delta(x)-1)$ +\end_inset + +. + Therefore +\begin_inset Formula +\begin{multline*} +x\bmod y=x-y\left\lfloor \frac{x}{y}\right\rfloor =x-y\left(\frac{x}{y}-\left(\left(\frac{x}{y}\right)\right)+\frac{1}{2}\left(\delta(\tfrac{x}{y})-1\right)\right)=\\ +=\left(\left(\left(\frac{x}{y}\right)\right)+\frac{1-\delta(\frac{x}{y})}{2}\right)y. +\end{multline*} + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc4[M19] +\end_layout + +\end_inset + +If +\begin_inset Formula $m=10^{10}$ +\end_inset + +, + what is the highest possible value of +\begin_inset Formula $d$ +\end_inset + + (in the notation of Theorem P), + given that the potency of the generator is 10? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +It's +\begin_inset Formula $d=2\cdot5^{10}$ +\end_inset + +. + First, + we note that +\begin_inset Formula +\[ +(2\cdot5^{10})^{9}\bmod10^{10}=2^{9}5^{90}\bmod2^{10}5^{10}=2^{9}5^{10}(5^{80}\bmod2)=m/2\neq0, +\] + +\end_inset + + and that +\begin_inset Formula $(2\cdot5^{10})^{10}\bmod10^{10}=2^{10}5^{100}\bmod2^{10}5^{10}=0$ +\end_inset + +, + so if +\begin_inset Formula $b=d$ +\end_inset + + we have potency 10. + Second, + we note that, + since +\begin_inset Formula $d\mid m$ +\end_inset + +, + and any divisor of +\begin_inset Formula $m$ +\end_inset + + greater that +\begin_inset Formula $2\cdot5^{10}$ +\end_inset + + has to be a multiple at least of +\begin_inset Formula $2^{2}$ +\end_inset + + and of +\begin_inset Formula $5^{2}$ +\end_inset + +, + and therefore of 100, + then +\begin_inset Formula $b$ +\end_inset + + would have to be a multiple of 100 and the potency would be at most 5. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc7[M24] +\end_layout + +\end_inset + +Give a proof of the reciprocity law (19), + when +\begin_inset Formula $c=0$ +\end_inset + +, + by using the general reciprocity law of exercise 1.2.4–45. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Note Greyedout +status open + +\begin_layout Plain Layout +(I had to look up the solution, + obviously.) +\end_layout + +\end_inset + +In this case, + the law reduces to +\begin_inset Formula +\begin{multline*} +\sigma(h,k,0)+\sigma(k,h,0)=\\ +=12\sum_{0\leq j<k}\left(\left(\frac{j}{k}\right)\right)\left(\left(\frac{hj}{k}\right)\right)+12\sum_{0\leq j<h}\left(\left(\frac{j}{h}\right)\right)\left(\left(\frac{kj}{h}\right)\right)=\frac{h}{k}+\frac{k}{h}+\frac{1}{hk}-3. +\end{multline*} + +\end_inset + +where +\begin_inset Formula $0<h\leq k$ +\end_inset + + are coprime integers. + The last equation from exercise 1.2.4–45 with +\begin_inset Formula $k=2$ +\end_inset + + tells us that +\begin_inset Formula +\[ +\sum_{1\leq j<n}\left\lfloor \frac{mj}{n}\right\rfloor \left(\left\lfloor \frac{mj}{n}\right\rfloor +1\right)+2\sum_{1\leq j<m}j\left\lceil \frac{jn}{m}\right\rceil =nm(m-1) +\] + +\end_inset + +for +\begin_inset Formula $m,n\in\mathbb{N}$ +\end_inset + +, + where we multiply by 2 and then set the lower bound of the sums to 1 because terms with +\begin_inset Formula $j=0$ +\end_inset + + evaluate to 0. + Now, + since +\begin_inset Formula $h$ +\end_inset + + and +\begin_inset Formula $k$ +\end_inset + + are coprime, + for +\begin_inset Formula $j\in\{1,\dots,k-1\}$ +\end_inset + +, +\begin_inset Formula +\begin{align*} +\left(\left(\frac{hj}{k}\right)\right) & =\frac{hj}{k}-\left\lfloor \frac{hj}{k}\right\rfloor -\frac{1}{2}=\frac{hj}{k}-\left\lceil \frac{hj}{k}\right\rceil +\frac{1}{2}, +\end{align*} + +\end_inset + +so substituting above, +\begin_inset Formula +\begin{multline*} +S\coloneqq kh(h-1)=\\ +=\sum_{j=1}^{k-1}\left(\frac{hj}{k}-\left(\left(\frac{hj}{k}\right)\right)-\frac{1}{2}\right)\left(\frac{hj}{k}-\left(\left(\frac{hj}{k}\right)\right)+\frac{1}{2}\right)+\\ ++2\sum_{j=1}^{h-1}j\left(\frac{kj}{h}-\left(\left(\frac{kj}{h}\right)\right)+\frac{1}{2}\right)=\\ +=\frac{h^{2}}{k^{2}}\sum_{j=1}^{k-1}j^{2}-\frac{2h}{k}\sum_{j=1}^{k-1}j\left(\left(\frac{hj}{k}\right)\right)+\sum_{j=1}^{k-1}\left(\left(\frac{hj}{k}\right)\right)^{2}-\frac{k-1}{4}+\frac{2k}{h}\sum_{j=1}^{h-1}j^{2}-\\ +-2\sum_{j=1}^{h-1}j\left(\left(\frac{kj}{h}\right)\right)+\frac{h^{2}-h}{2}. +\end{multline*} + +\end_inset + +Now, +\begin_inset Formula +\begin{align*} +\sum_{j=1}^{k-1}\left(\left(\frac{hj}{k}\right)\right) & =\sum_{j=1}^{k-1}\left(\left(\frac{j}{k}\right)\right)=\sum_{j=1}^{k-1}\left(\frac{j}{k}-\frac{1}{2}\right)=\frac{k(k-1)}{2k}-\frac{k-1}{2}=0, +\end{align*} + +\end_inset + +so +\begin_inset Formula +\begin{multline*} +\sigma(h,k,0)=12\sum_{j=0}^{k-1}\left(\left(\frac{j}{k}\right)\right)\left(\left(\frac{hj}{k}\right)\right)=12\sum_{j=1}^{k-1}\left(\frac{j}{k}-\frac{1}{2}\right)\left(\left(\frac{hj}{k}\right)\right)=\\ +=12\sum_{j=1}^{k-1}\frac{j}{k}\left(\left(\frac{hj}{k}\right)\right). +\end{multline*} + +\end_inset + +In addition, +\begin_inset Formula +\[ +\sum_{j=1}^{k-1}j^{2}=\frac{(k-1)k(2k-1)}{6}=\frac{k}{6}(2k^{2}-3k+1)=\frac{k^{3}}{3}-\frac{k^{2}}{2}+\frac{k}{6}, +\] + +\end_inset + +and in particular +\begin_inset Formula +\begin{align*} +\sum_{j=1}^{k-1}\left(\left(\frac{hj}{k}\right)\right)^{2} & =\sum_{j=1}^{k-1}\left(\left(\frac{j}{k}\right)\right)^{2}\\ + & =\sum_{j=1}^{k-1}\frac{j^{2}}{k^{2}}-\sum_{j=1}^{k-1}\frac{j}{k}+\frac{k-1}{4}=\frac{k}{3}-\frac{1}{2}+\frac{1}{6k}-\frac{k-1}{2}+\frac{k-1}{4}\\ + & =\frac{k}{3}-\frac{1}{2}+\frac{1}{6k}-\frac{k-1}{4}, +\end{align*} + +\end_inset + +so finally +\begin_inset Formula +\begin{align*} +S= & \frac{kh^{2}}{3}-\frac{h^{2}}{2}+\frac{h^{2}}{6k}-\frac{h}{6}\sigma(h,k,0)+\frac{k}{3}-\frac{1}{2}+\frac{1}{6k}-\frac{k-1}{2}+\frac{2kh^{2}}{3}-kh+\\ + & +\frac{k}{3}-\frac{h}{6}\sigma(k,h,0)+\frac{h^{2}}{2}-\frac{h}{2}\\ += & kh(h-1)-\frac{h}{2}+\frac{h^{2}}{6k}+\frac{k}{6}+\frac{1}{6k}-\frac{h}{6}\sigma(h,k,0)-\frac{h}{6}\sigma(k,h,0). +\end{align*} + +\end_inset + +With this, +\begin_inset Formula +\[ +\sigma(h,k,0)+\sigma(k,h,0)=-3+\frac{h}{k}+\frac{k}{h}+\frac{1}{hk}. +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc14[M20] +\end_layout + +\end_inset + +The linear congruential generator that has +\begin_inset Formula $m=2^{35}$ +\end_inset + +, + +\begin_inset Formula $a=2^{18}+1$ +\end_inset + +, + +\begin_inset Formula $c=1$ +\end_inset + +, + was given the serial correlation test on three batches of 1000 consecutive numbers, + and the result was a very high correlation, + between +\begin_inset Formula $0.2$ +\end_inset + + and +\begin_inset Formula $0.3$ +\end_inset + +, + in each case. + What is the serial correlation of this generator, + taken over all +\begin_inset Formula $2^{35}$ +\end_inset + + numbers of the period? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +The generator has full period by 3.2.1.2–A, + and +\begin_inset Formula $x'\coloneqq2^{18}-1$ +\end_inset + + gives us +\begin_inset Formula $S(x')=0$ +\end_inset + +. + Thus, + by (17), + +\begin_inset Formula $C=(2^{35}\sigma(2^{18}+1,2^{35},1)-3+6(2^{35}-2^{18}))/(2^{70}-1)$ +\end_inset + +. + Now we calculate the Dedekind coefficient by Theorem D. +\begin_inset Formula +\begin{align*} +2^{35} & =(2^{17}-1)(2^{18}+1)+(2^{17}+1), & 1 & =0(2^{18}+1)+1;\\ +2^{18}+1 & =1(2^{17}+1)+2^{17}, & 1 & =0(2^{17}+1)+1;\\ +2^{17}+1 & =1\cdot2^{17}+1 & 1 & =0(2^{17})+1;\\ +2^{17} & =2^{17}\cdot1+0, & 1 & =1\cdot1+0. +\end{align*} + +\end_inset + +The number +\begin_inset Formula $h'\coloneqq2^{35}-2^{18}+1$ +\end_inset + + gives us +\begin_inset Formula $(2^{18}+1)h'\equiv1\pmod{2^{35}}$ +\end_inset + +, + so +\begin_inset Formula +\begin{multline*} +\sigma(2^{18}+1,2^{35},1)=\frac{(\cancel{2^{18}}+1)+(2^{35}\cancel{-2^{18}}+1)}{2^{35}}+\left((2^{17}-1)-6\cdot0+6\frac{1^{2}}{2^{35}(2^{18}+1)}\right)-\\ +-\left(1-6\cdot0+\frac{6\cdot1^{2}}{(2^{18}+1)(2^{17}+1)}\right)+\left(1-6\cdot0+6\frac{1^{2}}{(2^{17}+1)2^{17}}\right)-\left(2^{17}-6\cdot1+6\frac{1^{2}}{2^{17}}\right)\\ +\\-3-2+1=\\ +=\cancel{1}+\frac{2}{2^{35}}\cancel{+2^{17}}\cancel{-1}+\frac{6}{2^{53}+2^{35}}\cancel{-1}-\frac{6}{2^{35}+2^{18}+2^{17}+1}\cancel{+1}+\frac{6}{2^{34}+2^{17}}\cancel{-2^{17}}+6-\frac{6}{2^{17}}-4=\\ +=2+\frac{1}{2^{34}}+6\left(\frac{1}{2^{53}+2^{35}}-\frac{1}{2^{35}+3\cdot2^{17}+1}+\frac{1}{2^{34}+2^{17}}-\frac{1}{2^{17}}\right)=\\ +=2+\frac{1}{2^{34}}+6\frac{2^{17}+1-2^{35}\cancel{+2^{36}+2^{18}}-2^{53}\cancel{-2^{36}}-2^{35}\cancel{-2^{18}}}{2^{35}(2^{18}+1)(2^{17}+1)}=\\ +=2+\frac{1}{2^{34}}+3\frac{(-2^{36}+1)\cancel{(2^{17}+1)}}{2^{34}(2^{18}+1)\cancel{(2^{17}+1)}}=2+\frac{1}{2^{34}}-3\frac{2^{18}-1}{2^{34}}=2-\frac{3\cdot2^{18}-4}{2^{34}}=\\ +=2-\frac{3\cdot2^{16}-1}{2^{32}}=\frac{2^{33}-2^{17}-2^{16}+1}{2^{32}}=\frac{(2^{17}-1)(2^{16}-1)}{2^{32}}. +\end{multline*} + +\end_inset + +Thus, +\begin_inset Formula +\begin{multline*} +C=\frac{8(2^{17}-1)(2^{16}-1)-3+6\cdot2^{18}(2^{17}-1)}{2^{70}-1}=\frac{91624920407}{393530540239137101141}\cong\\ +\cong2.33\cdot10^{-10}. +\end{multline*} + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc18[M23] +\end_layout + +\end_inset + +(U. + Dieter.) Given positive integers +\begin_inset Formula $h$ +\end_inset + +, + +\begin_inset Formula $k$ +\end_inset + +, + +\begin_inset Formula $z$ +\end_inset + +, + let +\begin_inset Formula +\[ +S(h,k,c,z)=\sum_{0\leq j<z}\left(\left(\frac{hj+c}{k}\right)\right). +\] + +\end_inset + +Show that this sum can be evaluated in closed form, + in terms of the generalized Dedekind sums and the sawtooth function. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Let +\begin_inset Formula $S_{j}\coloneqq\left(\left(\frac{hj+c}{k}\right)\right)$ +\end_inset + + and note that +\begin_inset Formula $S_{j}=S_{j+k}$ +\end_inset + + for all +\begin_inset Formula $j$ +\end_inset + +. + Thus, + if +\begin_inset Formula $z>k$ +\end_inset + +, +\begin_inset Formula +\[ +\sum_{0\leq j<z}\left(\left(\frac{hj+c}{k}\right)\right)=\left\lfloor \frac{z}{k}\right\rfloor \sum_{0\leq j<k}\left(\left(\frac{hj+c}{k}\right)\right)+\sum_{0\leq j<z\bmod k}\left(\left(\frac{hj+c}{k}\right)\right), +\] + +\end_inset + +so we may assume +\begin_inset Formula $z\leq k$ +\end_inset + + from now on. + Now, + +\begin_inset Formula $\left\lfloor \frac{j}{k}\right\rfloor -\left\lfloor \frac{j-z}{k}\right\rfloor $ +\end_inset + + is 1 when +\begin_inset Formula $0\leq j<z$ +\end_inset + + and 0 when +\begin_inset Formula $z\leq j<k$ +\end_inset + +, + so +\begin_inset Formula +\begin{multline*} +S(h,k,c,z)=\sum_{0\leq j<k}\left(\left\lfloor \frac{j}{k}\right\rfloor -\left\lfloor \frac{j-z}{k}\right\rfloor \right)\left(\left(\frac{hj+c}{k}\right)\right)=\\ +=\sum_{0\leq j<k}\left(\cancel{\frac{j}{k}}-\left(\left(\frac{j}{k}\right)\right)\cancel{-\frac{1}{2}}-\frac{\cancel{j}-z}{k}+\left(\left(\frac{j-z}{k}\right)\right)\cancel{+\frac{1}{2}}\right)\left(\left(\frac{hj+c}{k}\right)\right)+\\ ++\frac{1}{2}\left(\left(\frac{c}{k}\right)\right)-\frac{1}{2}\left(\left(\frac{hz+c}{k}\right)\right)=\\ +=\sum_{0\leq j<k}\left(\left(\left(\frac{j-z}{k}\right)\right)+\frac{z}{k}-\left(\left(\frac{j}{k}\right)\right)\right)\left(\left(\frac{hj+c}{k}\right)\right)+\frac{1}{2}\left(\left(\frac{c}{k}\right)\right)-\frac{1}{2}\left(\left(\frac{hz+c}{k}\right)\right). +\end{multline*} + +\end_inset + +Let's evaluate the sum term by term. + Clearly the term +\begin_inset Formula $-\left(\left(\frac{j}{k}\right)\right)$ +\end_inset + + sums to +\begin_inset Formula $-\frac{1}{12}\sigma(h,k,c)$ +\end_inset + +. + For the term with +\begin_inset Formula $\frac{z}{k}$ +\end_inset + +, + which is constant, + we use the argument used to derive Eq. + (13) in the text with +\begin_inset Formula $d\coloneqq\gcd\{h,k\}$ +\end_inset + +. + Finally, +\begin_inset Formula +\begin{multline*} +\sum_{0\leq j<k}\left(\left(\frac{j-z}{k}\right)\right)\left(\left(\frac{hj+c}{k}\right)\right)=\sum_{-z\leq j<k-z}\left(\left(\frac{j}{k}\right)\right)\left(\left(\frac{hj+c+hz}{k}\right)\right)=\\ +=\frac{1}{12}\sigma(h,k,c+hz). +\end{multline*} + +\end_inset + +Putting it all together, +\begin_inset Formula +\[ +S(h,k,c,z)=\frac{1}{12}\sigma(h,k,c+hz)-\frac{1}{12}\sigma(h,k,c)+\frac{zd}{k}\left(\left(\frac{c}{d}\right)\right)+\frac{1}{2}\left(\left(\frac{c}{k}\right)\right)-\frac{1}{2}\left(\left(\frac{hz+c}{k}\right)\right). +\] + +\end_inset + +For +\begin_inset Formula $z=k$ +\end_inset + +, + this simplifies to +\begin_inset Formula $d\left(\left(\frac{c}{d}\right)\right)$ +\end_inset + +, + and since +\begin_inset Formula $\left\lfloor \frac{z}{k}\right\rfloor +\frac{z\bmod k}{k}=\frac{z}{k}$ +\end_inset + +, + it's easy to check that this formula still applies when +\begin_inset Formula $z>k$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc19[M23] +\end_layout + +\end_inset + +Show that the +\emph on +serial test +\emph default + can be analyzed over the full period, + in terms of generalized Dedekind sums, + by finding a formula for the probability that +\begin_inset Formula $\alpha\leq X_{n}<\beta$ +\end_inset + + and +\begin_inset Formula $\alpha'\leq X_{n+1}<\beta'$ +\end_inset + +, + when +\begin_inset Formula $\alpha$ +\end_inset + +, + +\begin_inset Formula $\beta$ +\end_inset + +, + +\begin_inset Formula $\alpha'$ +\end_inset + +, + and +\begin_inset Formula $\beta'$ +\end_inset + + are given integers with +\begin_inset Formula $0\leq\alpha<\beta\leq m$ +\end_inset + + and +\begin_inset Formula $0\leq\alpha'<\beta'\leq m$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Formula $P(x)\coloneqq\left\lfloor \frac{x-\alpha}{m}\right\rfloor -\left\lfloor \frac{x-\beta}{m}\right\rfloor $ +\end_inset + + is 1 precisely when +\begin_inset Formula $x\in[\alpha,\beta)$ +\end_inset + + and 0 for any other +\begin_inset Formula $x\in[0,1)$ +\end_inset + +. + +\begin_inset Formula $Q(x)\coloneqq\left\lfloor \frac{x-\alpha'}{m}\right\rfloor -\left\lfloor \frac{x-\beta'}{m}\right\rfloor $ +\end_inset + + works in an analogous manner. + For a linear congruential sequence given by +\begin_inset Formula $S(x)\coloneqq(ax+c)\bmod m$ +\end_inset + + that has maximum period, + the probability that +\begin_inset Formula $x_{n}\in[\alpha,\beta)\land x_{n+1}\in[\alpha',\beta')$ +\end_inset + + is +\begin_inset Formula +\begin{multline*} +\frac{1}{m}\sum_{0\leq x<m}P(x)Q(ax+c)=\\ +=\frac{1}{m}\sum_{0\leq x<m}\left(\left\lfloor \frac{x-\alpha}{m}\right\rfloor -\left\lfloor \frac{x-\beta}{m}\right\rfloor \right)\left(\left\lfloor \frac{S(x)-\alpha'}{m}\right\rfloor -\left\lfloor \frac{S(x)-\beta'}{m}\right\rfloor \right) +\end{multline*} + +\end_inset + +Now, +\begin_inset Formula +\begin{align*} +\left\lfloor \frac{x-\alpha}{m}\right\rfloor & =\frac{x}{m}-\frac{\alpha}{m}-\frac{1}{2}-\left(\left(\frac{x-\alpha}{m}\right)\right)+\frac{1}{2}\delta_{x,\alpha},\\ +\left\lfloor \frac{S(x)-\alpha'}{m}\right\rfloor & =\frac{(ax+c)\bmod m-\alpha'}{m}-\left(\left(\frac{ax+c-\alpha'}{m}\right)\right)-\frac{1}{2}+\frac{1}{2}\delta_{S(x)\alpha'}=\\ + & =\left(\left(\frac{ax+c}{m}\right)\right)-\left(\left(\frac{ax+c-\alpha'}{m}\right)\right)-\frac{\alpha'}{m}+\frac{1}{2}(\delta_{S(x)\alpha'}-\delta_{S(x)0}). +\end{align*} + +\end_inset + +Thus, + +\begin_inset Formula +\begin{multline*} +\sum_{0\leq x<m}\left\lfloor \frac{x-\alpha}{m}\right\rfloor \left\lfloor \frac{S(x)-\alpha'}{m}\right\rfloor =\\ +=\sum_{0\leq x<m}\left(\left(\frac{x}{m}-\frac{1}{2}\right)-\frac{\alpha}{m}-\left(\left(\frac{x-\alpha}{m}\right)\right)\right)\\ +\left(\left(\left(\frac{ax+c}{m}\right)\right)-\left(\left(\frac{ax+c-\alpha'}{m}\right)\right)-\frac{\alpha'}{m}\right)+\\ ++\frac{1}{2}\left(\left\lfloor \frac{S(\alpha)-\alpha'}{m}\right\rfloor +\left\lfloor \frac{S^{-1}(\alpha')-\alpha}{m}\right\rfloor -\left\lfloor \frac{S^{-1}(0)-\alpha}{m}\right\rfloor \right)+\frac{1}{4}([S(\alpha)=\alpha']-[S(\alpha)=0]). +\end{multline*} + +\end_inset + +The terms outside this last sum can be calculated directly. + Inside the sum, + we have a product of two sums with three terms each, + which we may expand into 9 terms. + For these, + note that +\begin_inset Formula $\frac{x}{m}-\frac{1}{2}=\left(\left(\frac{x}{m}\right)\right)-\frac{1}{2}[x=0]$ +\end_inset + +, + so for example +\begin_inset Formula +\[ +\sum_{0\leq x<m}\left(\frac{x}{m}-\frac{1}{2}\right)\left(\left(\frac{ax+c-\alpha'}{m}\right)\right)=\frac{1}{12}\delta(a,m,c-\alpha')-\left(\left(\frac{c-\alpha'}{m}\right)\right), +\] + +\end_inset + +and similarly, +\begin_inset Formula +\begin{multline*} +\sum_{0\leq x<m}\left(\left(\frac{x-\alpha}{m}\right)\right)\left(\left(\frac{ax+c-\alpha'}{m}\right)\right)=\\ +=\sum_{-\alpha\leq x<m-\alpha}\left(\left(\frac{x}{m}\right)\right)\left(\left(\frac{ax+c-\alpha'+\alpha}{m}\right)\right)=\frac{1}{12}\sigma(a,m,c-\alpha'+\alpha). +\end{multline*} + +\end_inset + +The other terms do not include sawtooth functions and can be expanded mechanically using that +\begin_inset Formula $\sum_{0\leq x<m}x=\frac{m(m-1)}{2}$ +\end_inset + +. + Then we can compute the initial sum as the sum of 4 of these sums. +\end_layout + +\begin_layout Subsubsection +Second Set +\end_layout + +\begin_layout Standard +In many cases, + exact computations with integers are quite difficult to carry out, + but we can attempt to study the probabilities that arise when we take the average real values of +\begin_inset Formula $x$ +\end_inset + + instead of restricting the calculation to integer values. + Although these results are only approximate, + they shed some light on the subject. +\end_layout + +\begin_layout Standard +It is convenient to deal with numbers +\begin_inset Formula $U_{n}$ +\end_inset + + between zero and one; + for linear congruential sequences, + +\begin_inset Formula $U_{n}=X_{n}/m$ +\end_inset + +, + and we have +\begin_inset Formula $U_{n+1}=\{aU_{n}+\theta\}$ +\end_inset + +, + where +\begin_inset Formula $\theta=c/m$ +\end_inset + + and +\begin_inset Formula $\{x\}$ +\end_inset + + denotes +\begin_inset Formula $x\bmod1$ +\end_inset + +. + For example, + the formula for serial correlation now becomes +\begin_inset Formula +\[ +C=\left(\int_{0}^{1}x\{ax+\theta\}\text{d}x-\left(\int_{0}^{1}x\text{d}x\right)^{2}\right)\biggg/\left(\int_{0}^{1}x^{2}\text{d}x-\left(\int_{0}^{1}x\text{d}x\right)^{2}\right). +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc21[HM23] +\end_layout + +\end_inset + +(R. + R. + Coveyou.) What is the value of +\begin_inset Formula $C$ +\end_inset + + in the formula just given? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We have +\begin_inset Formula +\begin{align*} +\int_{0}^{1}x\text{d}x & =\left.\frac{x^{2}}{2}\right|_{x=0}^{1}=\frac{1}{2}, & \int_{0}^{1}x^{2}\text{d}x & =\left.\frac{x^{3}}{3}\right|_{x=0}^{1}=\frac{1}{3}, +\end{align*} + +\end_inset + +and we just need to calculate the more complex integral. + Assume +\begin_inset Formula $a>0$ +\end_inset + +. + Then the graph for +\begin_inset Formula $\{ax+\theta\}$ +\end_inset + + is a sequence of lines. + The first goes from +\begin_inset Formula $(0,\theta)$ +\end_inset + + to +\begin_inset Formula $(\frac{1-\theta}{a},1)$ +\end_inset + +, + the next one from +\begin_inset Formula $(\frac{1-\theta}{a},0)$ +\end_inset + + to +\begin_inset Formula $(\frac{2-\theta}{a},1)$ +\end_inset + +, + etc., + and the last one goes from +\begin_inset Formula $(1-\tfrac{\theta}{a},0)$ +\end_inset + + to +\begin_inset Formula $(1,\theta)$ +\end_inset + + (we used that +\begin_inset Formula $a$ +\end_inset + + is an integer to calculate this). + Thus +\begin_inset Formula +\[ +\int_{0}^{1}x\{ax+\theta\}\text{d}x=\sum_{k=1}^{a-1}\int_{\frac{k-\theta}{a}}^{\frac{k+1-\theta}{a}}x(ax+\theta-k)\text{d}x+\int_{0}^{\frac{1-\theta}{a}}x(ax+\theta)\text{d}x+\int_{1-\frac{\theta}{a}}^{1}x(ax+\theta-a)\text{d}x. +\] + +\end_inset + +Now, +\begin_inset Formula +\[ +\int x(ax+\theta-k)\text{d}x=\frac{a}{3}x^{3}+\frac{\theta-k}{2}x^{2}+C, +\] + +\end_inset + +so if we call +\begin_inset Formula $x_{k}\coloneqq\frac{k-\theta}{a}$ +\end_inset + + except that +\begin_inset Formula $x_{0}\coloneqq0$ +\end_inset + + and +\begin_inset Formula $x_{a+1}\coloneqq1$ +\end_inset + +, + we have +\begin_inset Formula +\begin{multline*} +\int_{0}^{1}x\{ax+\theta\}\text{d}x=\sum_{0\leq k\leq a}\int_{x_{k}}^{x_{k+1}}x(ax+\theta-k)\text{d}x=\\ +=\sum_{0\leq k\leq a}\left(\frac{a}{3}x_{k+1}^{3}+\frac{\theta-k}{2}x_{k+1}^{2}-\frac{a}{3}x_{k}^{3}-\frac{\theta-k}{2}x_{k}^{2}\right)=\frac{a}{3}+\frac{\theta-a}{2}+\sum_{0<k\leq a}\frac{1}{2}x_{k}^{2}=\\ +=\frac{a}{3}+\frac{\theta-a}{2}+\frac{1}{2a^{2}}\sum_{k=1}^{a}(k^{2}-2k\theta+\theta^{2})=\frac{\theta}{2}-\frac{a}{6}+\frac{(a+1)(2a+1)}{12a}-\frac{(a+1)\theta}{2a}+\frac{\theta^{2}}{2a}=\\ +=\frac{\theta(\theta-1)}{2a}+\frac{1}{12a}+\frac{1}{4}. +\end{multline*} + +\end_inset + +Putting it all together, +\begin_inset Formula +\[ +C=\left(\frac{\theta(\theta-1)}{2a}+\frac{1}{12a}+\frac{1}{4}-\frac{1}{4}\right)\biggg/\left(\frac{1}{3}-\frac{1}{4}\right)=\frac{6\theta(\theta-1)+1}{a}. +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc22[M22] +\end_layout + +\end_inset + +Let +\begin_inset Formula $a$ +\end_inset + + be an integer, + and let +\begin_inset Formula $0\leq\theta<1$ +\end_inset + +. + If +\begin_inset Formula $x$ +\end_inset + + is a random real number, + uniformly distributed between 0 and 1, + and if +\begin_inset Formula $s(x)=\{ax+\theta\}$ +\end_inset + +, + what is the probability that +\begin_inset Formula $s(x)<x$ +\end_inset + +? + (This is the +\begin_inset Quotes eld +\end_inset + +real number +\begin_inset Quotes erd +\end_inset + + analog of Theorem P.) +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +As in the previous exercise, + let +\begin_inset Formula $x_{0}\coloneqq0$ +\end_inset + +, + +\begin_inset Formula $x_{k}\coloneqq\frac{k-\theta}{a}$ +\end_inset + + for +\begin_inset Formula $k\in\{1,\dots,a\}$ +\end_inset + +, + and +\begin_inset Formula $x_{a+1}\coloneqq1$ +\end_inset + +, + for +\begin_inset Formula $k\in\{0,\dots,a\}$ +\end_inset + + and +\begin_inset Formula $x\in[x_{k},x_{k+1})$ +\end_inset + + we have +\begin_inset Formula $\lfloor ax+\theta\rfloor=k$ +\end_inset + + and +\begin_inset Formula +\[ +s(x)=ax+\theta-\lfloor ax+\theta\rfloor<x\iff(a-1)x<\lfloor ax+\theta\rfloor-\theta=k-\theta\iff x<\frac{k-\theta}{a-1}, +\] + +\end_inset + +so in particular +\begin_inset Formula $s(x)\geq x$ +\end_inset + + for +\begin_inset Formula $x<x_{1}$ +\end_inset + + and the probability is +\begin_inset Formula +\begin{multline*} +\int_{0}^{1}[s(x)<x]\text{d}x=\sum_{k=1}^{a}\int_{x_{k}}^{x_{k+1}}[x<\tfrac{k-\theta}{a-1}]\text{d}x=\sum_{k=1}^{a-1}\left(\frac{k-\theta}{a-1}-\frac{k-\theta}{a}\right)+1-\frac{a-\theta}{a}=\\ +=\sum_{k=1}^{a-1}\frac{k-\theta}{a(a-1)}+\frac{\theta}{a}=\left(\frac{1}{2}-\frac{\theta}{a}\right)+\frac{\theta}{a}=\frac{1}{2}. +\end{multline*} + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc25[M25] +\end_layout + +\end_inset + +Let +\begin_inset Formula $\alpha$ +\end_inset + +, + +\begin_inset Formula $\beta$ +\end_inset + +, + +\begin_inset Formula $\alpha'$ +\end_inset + +, + +\begin_inset Formula $\beta'$ +\end_inset + + be real numbers with +\begin_inset Formula $0\leq\alpha<\beta\leq1$ +\end_inset + +, + +\begin_inset Formula $0\leq\alpha'<\beta'\leq1$ +\end_inset + +. + Under the assumptions of exercise 22, + what is the probability that +\begin_inset Formula $\alpha\leq x<\beta$ +\end_inset + + and +\begin_inset Formula $\alpha'\leq s(x)<\beta'$ +\end_inset + +? + (This is the +\begin_inset Quotes eld +\end_inset + +real number +\begin_inset Quotes erd +\end_inset + + analog of exercise 19.) +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +In the notation of the answer to exercise 22, + assume that +\begin_inset Formula $\alpha\in[x_{p},x_{p+1})$ +\end_inset + + and +\begin_inset Formula $\beta\in[x_{q},x_{q+1})$ +\end_inset + +, + with +\begin_inset Formula $0\leq p\leq q\leq a$ +\end_inset + +. + For +\begin_inset Formula $x\in[x_{k},x_{k+1})$ +\end_inset + +, +\begin_inset Formula +\[ +\alpha'\leq s(x)<\beta'\iff\alpha'\leq ax+\theta-k<\beta'\iff x\in\left[\frac{\alpha'+k-\theta}{a},\frac{\beta'+k-\theta}{a}\right). +\] + +\end_inset + +Note that, + since +\begin_inset Formula $s(x)$ +\end_inset + + goes from 0 to 1 when +\begin_inset Formula $x$ +\end_inset + + goes from +\begin_inset Formula $x_{k}$ +\end_inset + + to +\begin_inset Formula $x_{k+1}$ +\end_inset + +, + each of these intervals has +\begin_inset Formula $s(x)$ +\end_inset + + enter and exit +\begin_inset Formula $[\alpha',\beta')$ +\end_inset + + and fully contains the interval above. + Let +\begin_inset Formula $s_{k}^{-1}(y)\coloneqq\frac{y+k-\theta}{a}$ +\end_inset + +. + If +\begin_inset Formula $p=q$ +\end_inset + +, + the probability is +\begin_inset Formula +\[ +\int_{\alpha}^{\beta}[\alpha'\leq s(x)<\beta']\text{d}x=\max\left\{ 0,\min\{\beta,s_{p}^{-1}(\beta')\}-\max\{\alpha,s_{p}^{-1}(\alpha')\}\right\} . +\] + +\end_inset + +If +\begin_inset Formula $p\neq q$ +\end_inset + +, + we have to consider the two extremes and the +\begin_inset Formula $q-p-1$ +\end_inset + + intervals in the middle, + each of which contributes +\begin_inset Formula $\frac{\beta'-\alpha'}{a}$ +\end_inset + +, + so the probability in this case is +\begin_inset Formula +\begin{multline*} +\max\left\{ 0,s_{p}^{-1}(\beta')-\max\{\alpha,s_{p}^{-1}(\alpha')\}\right\} +(q-p-1)\frac{\beta'-\alpha'}{a}+\\ ++\max\left\{ 0,\min\{\beta,s_{q}^{-1}(\beta')\}-s_{q}^{-1}(\alpha')\right\} . +\end{multline*} + +\end_inset + +Note that this last formula is still valid when +\begin_inset Formula $p=q$ +\end_inset + +. +\end_layout + +\end_body +\end_document diff --git a/vol2/3.3.4.lyx b/vol2/3.3.4.lyx new file mode 100644 index 0000000..1c06b60 --- /dev/null +++ b/vol2/3.3.4.lyx @@ -0,0 +1,781 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 620 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass book +\begin_preamble +\input defs +\end_preamble +\use_default_options true +\maintain_unincluded_children no +\language english +\language_package default +\inputencoding utf8 +\fontencoding auto +\font_roman "default" "default" +\font_sans "default" "default" +\font_typewriter "default" "default" +\font_math "auto" "auto" +\font_default_family default +\use_non_tex_fonts false +\font_sc false +\font_roman_osf false +\font_sans_osf false +\font_typewriter_osf false +\font_sf_scale 100 100 +\font_tt_scale 100 100 +\use_microtype false +\use_dash_ligatures true +\graphics default +\default_output_format default +\output_sync 0 +\bibtex_command default +\index_command default +\float_placement class +\float_alignment class +\paperfontsize default +\spacing single +\use_hyperref false +\papersize default +\use_geometry false +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\cite_engine basic +\cite_engine_type default +\biblio_style plain +\use_bibtopic false +\use_indices false +\paperorientation portrait +\suppress_date false +\justification true +\use_refstyle 1 +\use_formatted_ref 0 +\use_minted 0 +\use_lineno 0 +\index Index +\shortcut idx +\color #008000 +\end_index +\secnumdepth 3 +\tocdepth 3 +\paragraph_separation indent +\paragraph_indentation default +\is_math_indent 0 +\math_numbering_side default +\quotes_style english +\dynamic_quotes 0 +\papercolumns 1 +\papersides 1 +\paperpagestyle default +\tablestyle default +\tracking_changes false +\output_changes false +\change_bars false +\postpone_fragile_content false +\html_math_output 0 +\html_css_as_file 0 +\html_be_strict false +\docbook_table_output 0 +\docbook_mathml_prefix 1 +\end_header + +\begin_body + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc1[M10] +\end_layout + +\end_inset + +To what does the spectral test reduce in +\emph on +one +\emph default + dimension? + (In other words, + what happens when +\begin_inset Formula $t=1$ +\end_inset + +?) +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +In this case +\begin_inset Formula $\nu_{1}^{-1}$ +\end_inset + + is the maximum distance between points in +\begin_inset Formula $\{x/m\}_{x=0}^{m-1}$ +\end_inset + +, + which is +\begin_inset Formula $m^{-1}$ +\end_inset + +, + so +\begin_inset Formula $\nu_{1}=m$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc4[M23] +\end_layout + +\end_inset + +Let +\begin_inset Formula $u_{11}$ +\end_inset + +, + +\begin_inset Formula $u_{12}$ +\end_inset + +, + +\begin_inset Formula $u_{21}$ +\end_inset + +, + +\begin_inset Formula $u_{22}$ +\end_inset + + be elements of a +\begin_inset Formula $2\times2$ +\end_inset + + integer matrix such that +\begin_inset Formula $u_{11}+au_{12}\equiv u_{21}+au_{22}\equiv0\pmod m$ +\end_inset + + and +\begin_inset Formula $u_{11}u_{22}-u_{21}u_{12}=m$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Prove that all integer solutions +\begin_inset Formula $(y_{1},y_{2})$ +\end_inset + + to the congruence +\begin_inset Formula $y_{1}+ay_{2}\equiv0\pmod m$ +\end_inset + + have the form +\begin_inset Formula $(y_{1},y_{2})=(x_{1}u_{11}+x_{2}u_{21},x_{1}u_{12}+x_{2}u_{22})$ +\end_inset + + for integer +\begin_inset Formula $x_{1}$ +\end_inset + +, + +\begin_inset Formula $x_{2}$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +If, + in addition, + +\begin_inset Formula $2|u_{11}u_{21}+u_{12}u_{22}|\leq u_{11}^{2}+u_{12}^{2}\leq u_{21}^{2}+u_{22}^{2}$ +\end_inset + +, + prove that +\begin_inset Formula $(y_{1},y_{2})=(u_{11},u_{12})$ +\end_inset + + minimizes +\begin_inset Formula $y_{1}^{2}+y_{2}^{2}$ +\end_inset + + over all nonzero solutions to the congruence. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Assume +\begin_inset Formula $a\in\mathbb{Z}$ +\end_inset + + and +\begin_inset Formula $m\in\mathbb{N}^{*}$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Clearly all pairs of integers +\begin_inset Formula $(p,q)$ +\end_inset + + can be written as +\begin_inset Formula $(p,q)=z_{1}(m,0)+z_{2}(-a,1)+z_{3}(1,0)$ +\end_inset + + for some +\begin_inset Formula $z_{1},z_{2},z_{3}\in\mathbb{Z}$ +\end_inset + + with +\begin_inset Formula $0\leq z_{3}<m$ +\end_inset + +. + Moreover, + solutions to the congruence are precisely those pairs with +\begin_inset Formula $z_{3}=0$ +\end_inset + +, + and we just have to prove that +\begin_inset Formula $(m,0)$ +\end_inset + + and +\begin_inset Formula $(-a,1)$ +\end_inset + + can be expressed as an integer linear combination of +\begin_inset Formula $(u_{11},u_{12})$ +\end_inset + + and +\begin_inset Formula $(u_{21},u_{22})$ +\end_inset + +. + +\end_layout + +\begin_deeper +\begin_layout Standard +For +\begin_inset Formula $(m,0)$ +\end_inset + +, + +\begin_inset Formula $u_{22}(u_{11},u_{12})-u_{12}(u_{21},u_{22})=(m,0)$ +\end_inset + +. + For +\begin_inset Formula $(a,-1)$ +\end_inset + +, + if +\begin_inset Formula $j,k\in\mathbb{Z}$ +\end_inset + + are such that +\begin_inset Formula $u_{11}=jm-au_{12}$ +\end_inset + + and +\begin_inset Formula $u_{21}=km-au_{22}$ +\end_inset + +, + we can expand to get +\begin_inset Formula $m=u_{11}u_{22}-u_{21}u_{12}=ju_{22}m-ku_{12}m$ +\end_inset + +, + so +\begin_inset Formula $ju_{22}-ku_{12}=1$ +\end_inset + +, + and then +\begin_inset Formula $ju_{21}-ku_{11}=-aju_{22}+aku_{12}=-a(ju_{22}-ku_{12})=-a$ +\end_inset + +, + so +\begin_inset Formula $(-a,1)=-k(u_{11},u_{12})+j(u_{21},u_{22})$ +\end_inset + +. +\end_layout + +\end_deeper +\begin_layout Enumerate +If +\begin_inset Formula $x_{1},x_{2}\in\mathbb{Z}$ +\end_inset + + are not both 0, + then +\begin_inset Formula +\begin{multline*} +(x_{1}u_{11}+x_{2}u_{21})^{2}+(x_{1}u_{12}+x_{2}u_{22})^{2}=\\ +=x_{1}^{2}(u_{11}^{2}+u_{12}^{2})+x_{2}^{2}(u_{21}^{2}+u_{22}^{2})+2x_{1}x_{2}(u_{11}u_{21}+u_{21}u_{22}). +\end{multline*} + +\end_inset + +If +\begin_inset Formula $x_{1}x_{2}(u_{11}u_{21}+u_{21}u_{22})\geq0$ +\end_inset + +, + then this is greater or equal to +\begin_inset Formula +\[ +x_{1}^{2}(u_{11}^{2}+u_{12}^{2})+x_{2}^{2}(u_{21}^{2}+u_{22}^{2})\geq(x_{1}^{2}+x_{2}^{2})(u_{11}^{2}+u_{12}^{2})\geq u_{11}^{2}+u_{12}^{2}. +\] + +\end_inset + +Otherwise +\begin_inset Formula $x_{1},x_{2}\neq0$ +\end_inset + + and, + if +\begin_inset Formula $|x_{1}|\leq|x_{2}|$ +\end_inset + +, + then the above is greater than or equal to +\begin_inset Formula +\[ +x_{1}^{2}(u_{11}^{2}+u_{12}^{2}-2(u_{11}u_{21}+u_{21}u_{22}))+x_{2}^{2}(u_{21}^{2}+u_{22}^{2})\geq x_{2}^{2}(u_{21}^{2}+u_{22}^{2})\geq u_{11}^{2}+u_{12}^{2}, +\] + +\end_inset + +whereas the case with +\begin_inset Formula $|x_{1}|\geq|x_{2}|$ +\end_inset + + is analogous. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc15[M20] +\end_layout + +\end_inset + +Let +\begin_inset Formula $U$ +\end_inset + + be an integer vector satisfying (15). + How many of the +\begin_inset Formula $(t-1)$ +\end_inset + +-dimensional hyperplanes defined by +\begin_inset Formula $U$ +\end_inset + + intersect the unit hypercube +\begin_inset Formula $\{(x_{1},\dots,x_{t})\mid0\leq x_{j}<1\text{ for }1\leq j\leq t\}$ +\end_inset + +? + (This is approximately the number of hyperplanes in the family that will suffice to cover +\begin_inset Formula $L_{0}$ +\end_inset + +.) +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +The hyperplanes are defined by +\begin_inset Formula $\{\{X\mid X\cdot U=q\}\}_{q\in\mathbb{Z}}$ +\end_inset + +, + so we need to find the maximum and minimum integer values for +\begin_inset Formula $X\cdot U$ +\end_inset + + when +\begin_inset Formula $X\in[0,1)^{n}$ +\end_inset + +, + which exist because +\begin_inset Formula $0\cdot U=0\in\mathbb{Z}$ +\end_inset + +. + The maximum and minimum real values when +\begin_inset Formula $X\in[0,1]^{n}$ +\end_inset + + are, + respectively, + +\begin_inset Formula $M\coloneqq u_{1}\frac{1+\text{sgn}u_{1}}{2}+\dots+u_{t}\frac{1+\text{sgn}u_{t}}{2}$ +\end_inset + + and +\begin_inset Formula $m\coloneqq u_{1}\frac{1-\text{sgn}u_{1}}{2}+\dots+u_{t}\frac{1-\text{sgn}u_{t}}{2}$ +\end_inset + +, + which happen to be integers, + so we have +\begin_inset Formula +\[ +M-m+1=u_{1}\text{sgn}u_{1}+\dots+u_{t}\text{sgn}u_{t}+1=|u_{1}|+\dots+|u_{t}|+1 +\] + +\end_inset + +hyperplanes. +\end_layout + +\begin_layout Standard +However, + one of these hyperplanes might only cover points in +\begin_inset Formula $[0,1]^{n}\setminus[0,1)^{n}$ +\end_inset + +. + This happens precisely when +\begin_inset Formula $(1,\dots,1)\cdot U=u_{1}+\dots+u_{t}$ +\end_inset + + is either +\begin_inset Formula $M$ +\end_inset + + or +\begin_inset Formula $m$ +\end_inset + +, + that is, + when all of the +\begin_inset Formula $u_{i}$ +\end_inset + + are nonnegative or nonpositive. + Thus, + the actual number of hyperplanes is +\begin_inset Formula +\[ +|u_{1}|+\dots+|u_{t}|+1-[u_{1},\dots,u_{t}\leq0]-[u_{1},\dots,u_{t}\geq0]. +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc19[HM25] +\end_layout + +\end_inset + +Suppose step S5 were changed slightly, + so that a transformation with +\begin_inset Formula $q=1$ +\end_inset + + would be performed when +\begin_inset Formula $2V_{i}\cdot V_{j}=V_{j}\cdot V_{j}$ +\end_inset + +. + (Thus, + +\begin_inset Formula $q=\lfloor(V_{i}\cdot V_{j}/V_{j}\cdot V_{j})+\frac{1}{2}\rfloor$ +\end_inset + + whenever +\begin_inset Formula $i\neq j$ +\end_inset + +.) Would it still be possible for Algorithm S to get into an infinite loop? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +No. + If +\begin_inset Formula $2|V_{i}\cdot V_{j}|>V_{j}\cdot V_{j}$ +\end_inset + + in some step, + then +\begin_inset Formula +\[ +(V_{i}-qV_{j})\cdot(V_{i}-qV_{j})=V_{i}\cdot V_{i}-2qV_{i}\cdot V_{j}+V_{j}\cdot V_{j}<V_{i}\cdot V_{i}, +\] + +\end_inset + +because +\begin_inset Formula $q$ +\end_inset + + has the same sign as +\begin_inset Formula $V_{i}\cdot V_{j}$ +\end_inset + + and therefore +\begin_inset Formula $V_{j}\cdot V_{j}<2|V_{i}\cdot V_{j}|\leq2qV_{i}\cdot V_{j}$ +\end_inset + +, + so +\begin_inset Formula $V_{i}\cdot V_{i}$ +\end_inset + + decreases and, + since it is an integer, + it cannot decrease for infinitely many steps. + Thus, + an infinite loop would eventually only contain steps where +\begin_inset Formula $2V_{i}\cdot V_{j}=V_{j}\cdot V_{j}$ +\end_inset + +, + which are the ones we allow now, + and since there are only finitely many integer vectors with a given norm, + +\begin_inset Formula $V$ +\end_inset + + would have to repeat at some point. + However, + in these cases +\begin_inset Formula $q=1$ +\end_inset + +, + so the steps are equivalent to multiplying +\begin_inset Formula $V$ +\end_inset + + by an elementary matrix with 1s at the diagonal and at some other value and 0s everywhere else. + These matrices cannot result in an identity matrix when multiplying them because they don't have negative entries. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc32[M21] +\end_layout + +\end_inset + +Let +\begin_inset Formula $m_{1}=2^{31}-1$ +\end_inset + + and +\begin_inset Formula $m_{2}=2^{31}-249$ +\end_inset + + be the moduli of generator (38). +\end_layout + +\begin_layout Enumerate +Show that if +\begin_inset Formula $U_{n}=(X_{n}/m_{1}-Y_{n}/m_{2})\bmod1$ +\end_inset + +, + we have +\begin_inset Formula $U_{n}\approx Z_{n}/m_{1}$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Let +\begin_inset Formula $W_{0}=(X_{0}m_{2}-Y_{0}m_{1})\bmod m$ +\end_inset + + and +\begin_inset Formula $W_{n+1}=aW_{n}\bmod m$ +\end_inset + +, + where +\begin_inset Formula $a$ +\end_inset + + and +\begin_inset Formula $m$ +\end_inset + + have the values stated in the text following (38). + Prove that there is a simple relation between +\begin_inset Formula $W_{n}$ +\end_inset + + and +\begin_inset Formula $U_{n}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Enumerate +\begin_inset Formula $Z_{n}/m_{1}=(X_{n}/m_{1}-Y_{n}/m_{1})\bmod1\approx(X_{n}/m_{1}-Y_{n}/m_{2})\bmod1=U_{n}$ +\end_inset + +. + The difference is at most +\begin_inset Formula $|Y_{n}/m_{1}-Y_{n}/m_{2}|=Y_{n}\left|\frac{1}{2^{31}-1}-\frac{1}{2^{31}-249}\right|=Y_{n}\frac{248}{(2^{31}-1)(2^{31}-249)}<\frac{248}{2^{31}-1}<2^{-23}$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +We have +\begin_inset Formula $mU_{0}=(X_{0}m/m_{1}-Y_{0}m/m_{2})\bmod m=(X_{0}m_{2}-Y_{0}m_{1})\bmod m=W_{0}$ +\end_inset + +, + and also +\begin_inset Formula +\begin{multline*} +U_{n+1}=(aX_{n}\bmod m_{1}/m_{1}-aY_{n}\bmod m_{2}/m_{2})\bmod1=\\ +=a(X_{n}/m_{1}-Y_{n}/m_{2})\bmod1=aU_{n}\bmod1, +\end{multline*} + +\end_inset + +so by induction +\begin_inset Formula $W_{n}\equiv mU_{n}$ +\end_inset + +. +\end_layout + +\end_body +\end_document diff --git a/vol2/3.4.1.lyx b/vol2/3.4.1.lyx new file mode 100644 index 0000000..2cd7261 --- /dev/null +++ b/vol2/3.4.1.lyx @@ -0,0 +1,1677 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 620 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass book +\begin_preamble +\input defs +\end_preamble +\use_default_options true +\maintain_unincluded_children no +\language english +\language_package default +\inputencoding utf8 +\fontencoding auto +\font_roman "default" "default" +\font_sans "default" "default" +\font_typewriter "default" "default" +\font_math "auto" "auto" +\font_default_family default +\use_non_tex_fonts false +\font_sc false +\font_roman_osf false +\font_sans_osf false +\font_typewriter_osf false +\font_sf_scale 100 100 +\font_tt_scale 100 100 +\use_microtype false +\use_dash_ligatures true +\graphics default +\default_output_format default +\output_sync 0 +\bibtex_command default +\index_command default +\float_placement class +\float_alignment class +\paperfontsize default +\spacing single +\use_hyperref false +\papersize default +\use_geometry false +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\cite_engine basic +\cite_engine_type default +\biblio_style plain +\use_bibtopic false +\use_indices false +\paperorientation portrait +\suppress_date false +\justification true +\use_refstyle 1 +\use_formatted_ref 0 +\use_minted 0 +\use_lineno 0 +\index Index +\shortcut idx +\color #008000 +\end_index +\secnumdepth 3 +\tocdepth 3 +\paragraph_separation indent +\paragraph_indentation default +\is_math_indent 0 +\math_numbering_side default +\quotes_style english +\dynamic_quotes 0 +\papercolumns 1 +\papersides 1 +\paperpagestyle default +\tablestyle default +\tracking_changes false +\output_changes false +\change_bars false +\postpone_fragile_content false +\html_math_output 0 +\html_css_as_file 0 +\html_be_strict false +\docbook_table_output 0 +\docbook_mathml_prefix 1 +\end_header + +\begin_body + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc1[10] +\end_layout + +\end_inset + +If +\begin_inset Formula $\alpha$ +\end_inset + + and +\begin_inset Formula $\beta$ +\end_inset + + are real numbers with +\begin_inset Formula $\alpha<\beta$ +\end_inset + +, + how would you generate a random real number uniformly distributed between +\begin_inset Formula $\alpha$ +\end_inset + + and +\begin_inset Formula $\beta$ +\end_inset + +? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +By taking a uniformly distributed real number +\begin_inset Formula $U$ +\end_inset + + between 0 and 1 and returning +\begin_inset Formula $\alpha+(\beta-\alpha)U$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc3[14] +\end_layout + +\end_inset + +Discuss treating +\begin_inset Formula $U$ +\end_inset + + as an integer and computing its +\emph on +remainder +\emph default + +\begin_inset Formula $\bmod k$ +\end_inset + + to get a random integer between 0 and +\begin_inset Formula $k-1$ +\end_inset + +, + instead of multiplying as suggested in the text. + Thus (1) would be changed to +\begin_inset Formula +\begin{align*} + & \mathtt{ENTA\ 0}; & & \mathtt{LDX\ U}; & & \mathtt{DIV\ K}, +\end{align*} + +\end_inset + +with the result appearing in register X. + Is this a good method? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +While in theory it's as good as the other one, + less significant bits tend to be less random in many random number generation methods, + so we prefer the method in the text. + This is specially important if we use a linear congruential method where +\begin_inset Formula $k$ +\end_inset + + is not relatively prime to +\begin_inset Formula $m$ +\end_inset + +. + In addition, + if +\begin_inset Formula $k$ +\end_inset + + is not much smaller than +\begin_inset Formula $m$ +\end_inset + +, + numbers lower than +\begin_inset Formula $m\bmod k$ +\end_inset + + will have a larger probability of appearing, + whereas in the method of the text a similar effect is observed but the numbers with higher probability are more evenly distributed. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc5[21] +\end_layout + +\end_inset + +Suggest an efficient way to compute a random variable with the distribution +\begin_inset Formula $F(x)=px+qx^{2}+rx^{3}$ +\end_inset + +, + where +\begin_inset Formula $p\geq0$ +\end_inset + +, + +\begin_inset Formula $q\geq0$ +\end_inset + +, + +\begin_inset Formula $r\geq0$ +\end_inset + +, + and +\begin_inset Formula $p+q+r=1$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Assume this formula for the distribution is valid for +\begin_inset Formula $x\in[0,1]$ +\end_inset + +, + as +\begin_inset Formula $F(0)=0$ +\end_inset + + and +\begin_inset Formula $F(1)=1$ +\end_inset + +. + Now, + +\begin_inset Formula $F(x)=x(rx^{2}+qx+p)$ +\end_inset + +, + or more precisely, +\begin_inset Formula +\[ +F(x)=\max\{0,\min\{1,x\}\}\cdot\begin{cases} +0, & x\leq-\tfrac{q}{2r};\\ +\min\{1,rx^{2}+qx+p\}, & x\geq-\tfrac{q}{2r}, +\end{cases} +\] + +\end_inset + +so we may take +\begin_inset Formula $U_{1}$ +\end_inset + + and +\begin_inset Formula $U_{2}$ +\end_inset + + uniformly distributed between 0 and 1 and return +\begin_inset Formula +\[ +\max\left\{ U_{1},-\frac{q}{2r}+\sqrt{\left(\frac{q}{2r}\right)^{2}-\frac{p}{r}+\frac{U_{2}}{r}}\right\} . +\] + +\end_inset + +Note that we take the +\begin_inset Quotes eld +\end_inset + + +\begin_inset Formula $+$ +\end_inset + + +\begin_inset Quotes erd +\end_inset + + sign in the solution to the quadratic equation to choose the solution in the right side of the parabola. + The method in the book is more efficient. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc7[20] +\end_layout + +\end_inset + +(A. + J. + Walker) Suppose we have a bunch of cubes of +\begin_inset Formula $k$ +\end_inset + + different colors, + say +\begin_inset Formula $n_{j}$ +\end_inset + + cubes of color +\begin_inset Formula $C_{j}$ +\end_inset + + for +\begin_inset Formula $1\leq j\leq k$ +\end_inset + +, + and we also have +\begin_inset Formula $k$ +\end_inset + + boxes +\begin_inset Formula $\{B_{1},\dots,B_{k}\}$ +\end_inset + + each of which can hold exactly +\begin_inset Formula $n$ +\end_inset + + cubes. + Furthermore +\begin_inset Formula $n_{1}+\dots+n_{k}=kn$ +\end_inset + +, + so the cubes will just fit into the boxes. + Prove (constructively) that there is always a way to put the cubes into the boxes so that each box contains at most two different colors of cubes; + in fact, + there is a way to do it so that, + wherever box +\begin_inset Formula $B_{j}$ +\end_inset + + contains two colors, + one of those colors is +\begin_inset Formula $C_{j}$ +\end_inset + +. + Show how to use this principle to compute the +\begin_inset Formula $P$ +\end_inset + + and +\begin_inset Formula $Y$ +\end_inset + + tables required in (3), + given a probability distribution +\begin_inset Formula $(p_{1},\dots,p_{k})$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We prove this by induction on +\begin_inset Formula $k$ +\end_inset + +. + For +\begin_inset Formula $k=1$ +\end_inset + + this is trivial. + For +\begin_inset Formula $k>1$ +\end_inset + +, + if there is a +\begin_inset Formula $j$ +\end_inset + + such that +\begin_inset Formula $n=n_{j}$ +\end_inset + +, + we pack the +\begin_inset Formula $n_{j}$ +\end_inset + + cubes of color +\begin_inset Formula $C_{j}$ +\end_inset + + into +\begin_inset Formula $B_{j}$ +\end_inset + +; + otherwise there exists +\begin_inset Formula $i$ +\end_inset + + and +\begin_inset Formula $j$ +\end_inset + + such that +\begin_inset Formula $n_{i}<n<n_{j}$ +\end_inset + +, + so we pack the +\begin_inset Formula $n_{i}$ +\end_inset + + cubes of color +\begin_inset Formula $C_{i}$ +\end_inset + + and also +\begin_inset Formula $n-n_{i}$ +\end_inset + + cubes of color +\begin_inset Formula $C_{j}$ +\end_inset + + into +\begin_inset Formula $B_{i}$ +\end_inset + +. + Either way we are left with +\begin_inset Formula $k-1$ +\end_inset + + colors and +\begin_inset Formula $k-1$ +\end_inset + + boxes. +\end_layout + +\begin_layout Standard +To construct the tables, + we note that this proof doesn't require +\begin_inset Formula $n$ +\end_inset + + and the +\begin_inset Formula $n_{j}$ +\end_inset + +s to be integers, + they can be arbitrary nonnegative nonnegative reals as long as the conditions are met, + so we can let +\begin_inset Formula $n=\frac{1}{k}$ +\end_inset + + and +\begin_inset Formula $n_{j}=p_{j}$ +\end_inset + + (the probability of event +\begin_inset Formula $x_{j}$ +\end_inset + +) for each +\begin_inset Formula $j$ +\end_inset + +. + Then, + if after proceeding as in this proof, + we find that +\begin_inset Formula $B_{i}$ +\end_inset + + has +\begin_inset Formula $p$ +\end_inset + + cubes of color +\begin_inset Formula $C_{i}$ +\end_inset + + and +\begin_inset Formula $n-p$ +\end_inset + + cubes of some other color +\begin_inset Formula $C_{j}$ +\end_inset + + (where +\begin_inset Formula $p\in[0,n]$ +\end_inset + +), + we set +\begin_inset Formula $P=pk$ +\end_inset + + and +\begin_inset Formula $Y=j$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc10[HM24] +\end_layout + +\end_inset + +Explain how to calculate auxiliary constants +\begin_inset Formula $P_{j}$ +\end_inset + +, + +\begin_inset Formula $Q_{j}$ +\end_inset + +, + +\begin_inset Formula $Y_{j}$ +\end_inset + +, + +\begin_inset Formula $Z_{j}$ +\end_inset + +, + +\begin_inset Formula $S_{j}$ +\end_inset + +, + +\begin_inset Formula $D_{j}$ +\end_inset + +, + +\begin_inset Formula $E_{j}$ +\end_inset + + so that Algorithm M delivers answers with the correct distribution. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Let +\begin_inset Formula $p_{1},\dots,p_{31}$ +\end_inset + + be the probabilities as in the text and +\begin_inset Formula $p_{0}=0$ +\end_inset + +. + We may calculate probabilities +\begin_inset Formula $p_{16},\dots,p_{30}$ +\end_inset + + by a numeral method like Simpson's rule, + and this gives us values that are all lower than +\begin_inset Formula $\frac{1}{32}$ +\end_inset + +. + +\end_layout + +\begin_layout Standard +First, + calculate +\begin_inset Formula $p_{1},\dots,p_{31}$ +\end_inset + + as defined in the text, + obtaining that +\begin_inset Formula $p_{16},\dots,p_{31}<\frac{1}{32}$ +\end_inset + + (we may use some numerical method like the Simpson's rule), + and set +\begin_inset Formula $p_{0}=0$ +\end_inset + +. + Then, + operate like in Exercise 7 for these probabilities to obtain tables +\begin_inset Formula $(P_{j},Y'_{j})_{j=0}^{31}$ +\end_inset + +, + ensuring that +\begin_inset Formula $p_{15},\dots,p_{31}$ +\end_inset + + are considered first so that all the +\begin_inset Formula $Y'_{j}\in\{1,\dots,15\}$ +\end_inset + +. + This gives us the +\begin_inset Formula $P_{j}$ +\end_inset + +, + and then we set +\begin_inset Formula $Y_{j}=\frac{Y'_{j}-1}{5}$ +\end_inset + + and +\begin_inset Formula $Z_{j}=\frac{1}{5(1-P_{j})}$ +\end_inset + + for +\begin_inset Formula $0\leq j\leq31$ +\end_inset + +. + We also set +\begin_inset Formula $S_{j}=\frac{j-1}{5}$ +\end_inset + + for +\begin_inset Formula $1\leq j\leq16$ +\end_inset + + and +\begin_inset Formula $Q_{j}=\frac{1}{5P_{j}}$ +\end_inset + + for +\begin_inset Formula $1\leq j\leq15$ +\end_inset + +. +\end_layout + +\begin_layout Standard +Now, + the wedge functions are +\begin_inset Formula +\[ +f_{j+15}(x)\coloneqq\sqrt{\frac{2}{\pi}}\left(\text{e}^{-x^{2}/2}-\text{e}^{-j^{2}/50}\right)\bigg/p_{j+15} +\] + +\end_inset + +for +\begin_inset Formula $1\leq j\leq15$ +\end_inset + +. + For +\begin_inset Formula $1\leq j\leq5$ +\end_inset + +, + the curve is concave, + so we set +\begin_inset Formula +\begin{align*} +b_{j} & =-f'_{j+15}(S_{j+1})=\frac{j}{5p_{j+15}}\sqrt{\frac{2}{\pi}}\text{e}^{-j^{2}/50}, & a_{j} & =f_{j+15}(S_{j}). +\end{align*} + +\end_inset + +For +\begin_inset Formula $6\leq j\leq15$ +\end_inset + + the curve is convex and we set +\begin_inset Formula $b_{j}=5f_{j+15}(S_{j})$ +\end_inset + + (the slope) and +\begin_inset Formula $a_{j}=f_{j+15}(x)+(x-S_{j})b$ +\end_inset + +, + where +\begin_inset Formula $x\in[S_{j},S_{j+1}]$ +\end_inset + + is such that +\begin_inset Formula $f'_{j+15}(x)=-b_{j}$ +\end_inset + +. + Now, +\begin_inset Formula +\begin{multline*} +f'_{j+15}(x)=-\sqrt{\frac{2}{\pi}}\frac{x\text{e}^{-x^{2}/2}}{p_{j+15}}=-\frac{5}{p_{j+15}}\sqrt{\frac{2}{\pi}}(\text{e}^{-(j-1)^{2}/50}-\text{e}^{-j^{2}/50})=-b_{j}\iff\\ +x\text{e}^{-x^{2}/2}=5(\text{e}^{-(j-1)^{2}/50}-\text{e}^{-j^{2}/50}). +\end{multline*} + +\end_inset + +We know this value exists by Lagrange's mean value theorem, + although we need to calculate it numerically (for example, + by Newton's method, + using that +\begin_inset Formula $\frac{\text{d}}{\text{d}x}(x\text{e}^{-x^{2}/2})=(1-x^{2})\text{e}^{-x^{2}/2}$ +\end_inset + +). + Then, + for for +\begin_inset Formula $1\leq j\leq15$ +\end_inset + +, + we set +\begin_inset Formula $D_{j+15}=a_{j}/b_{j}$ +\end_inset + + and +\begin_inset Formula $E_{j+15}=\sqrt{\frac{2}{\pi}}\frac{e^{-j^{2}/50}}{b_{j}p_{j+15}}$ +\end_inset + +, + so +\begin_inset Formula +\[ +E_{j+15}=\begin{cases} +\frac{5}{j}, & 1\leq j\leq5;\\ +\frac{5}{\text{e}^{(2j-1)/50}-1}, & 6\leq j\leq15. +\end{cases} +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset Note Note +status open + +\begin_layout Plain Layout +\begin_inset Note Comment +status open + +\begin_layout Plain Layout +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +use POSIX; +\end_layout + +\begin_layout Plain Layout + +\end_layout + +\begin_layout Plain Layout + +my (@D, + @E, + @P, + @Q, + @S, + @Y, + @Z); +\end_layout + +\begin_layout Plain Layout + +\end_layout + +\begin_layout Plain Layout + +sub normal { +\end_layout + +\begin_layout Plain Layout + + my $rand = rand; +\end_layout + +\begin_layout Plain Layout + + my $sign = POSIX::floor( $rand * 2 ); +\end_layout + +\begin_layout Plain Layout + + my $piece = POSIX::floor( $rand * 64 ) % 32; +\end_layout + +\begin_layout Plain Layout + + my $dev = ( $rand * 64 ) % 1; +\end_layout + +\begin_layout Plain Layout + + my $abs; +\end_layout + +\begin_layout Plain Layout + + if ( $dev >= $P[$piece] ) { +\end_layout + +\begin_layout Plain Layout + + $abs = $Y[$piece] + $dev * $Z[$piece]; +\end_layout + +\begin_layout Plain Layout + + } +\end_layout + +\begin_layout Plain Layout + + elsif ( $piece <= 15 ) { +\end_layout + +\begin_layout Plain Layout + + $abs = $S[$piece] + $dev * $Q[$piece]; +\end_layout + +\begin_layout Plain Layout + + } +\end_layout + +\begin_layout Plain Layout + + elsif ( $piece < 31 ) { +\end_layout + +\begin_layout Plain Layout + + $piece -= 16; +\end_layout + +\begin_layout Plain Layout + + my ( $u, + $v ); +\end_layout + +\begin_layout Plain Layout + + do { +\end_layout + +\begin_layout Plain Layout + + ( $u, + $v ) = ( rand, + rand ); +\end_layout + +\begin_layout Plain Layout + + ( $u, + $v ) = ( $v, + $u ) if $u > $v; +\end_layout + +\begin_layout Plain Layout + + $abs = $S[$piece] + $u / 5; +\end_layout + +\begin_layout Plain Layout + + } while ( $v < $D[$piece] +\end_layout + +\begin_layout Plain Layout + + || $v <= $u + +\end_layout + +\begin_layout Plain Layout + + $E[$piece] * ( exp( ( $S[ $piece + 1 ]**2 - $abs**2 ) / 2 ) - 1 ) ); +\end_layout + +\begin_layout Plain Layout + + } +\end_layout + +\begin_layout Plain Layout + + else { +\end_layout + +\begin_layout Plain Layout + + do { $abs = sqrt( 9 - 2 * log rand ) } while ( $abs * rand ) >= 3; +\end_layout + +\begin_layout Plain Layout + + } +\end_layout + +\begin_layout Plain Layout + + return $sign ? + -$abs : + $abs; +\end_layout + +\begin_layout Plain Layout + +} +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +local D = ... +\end_layout + +\begin_layout Plain Layout + +local E = ... +\end_layout + +\begin_layout Plain Layout + +local P = ... +\end_layout + +\begin_layout Plain Layout + +local Q = ... +\end_layout + +\begin_layout Plain Layout + +local S = ... +\end_layout + +\begin_layout Plain Layout + +local Y = ... +\end_layout + +\begin_layout Plain Layout + +local Z = ... +\end_layout + +\begin_layout Plain Layout + +\end_layout + +\begin_layout Plain Layout + +local function normal () +\end_layout + +\begin_layout Plain Layout + + local rand = math.random() +\end_layout + +\begin_layout Plain Layout + + local sign = math.floor(rand * 2) +\end_layout + +\begin_layout Plain Layout + + local piece = math.floor(rand * 64) % 32 +\end_layout + +\begin_layout Plain Layout + + local dev = (rand * 64) % 1 +\end_layout + +\begin_layout Plain Layout + + local abs +\end_layout + +\begin_layout Plain Layout + + if dev >= P[piece] then +\end_layout + +\begin_layout Plain Layout + + abs = Y[piece] + dev * Z[piece] +\end_layout + +\begin_layout Plain Layout + + elseif piece <= 15 then +\end_layout + +\begin_layout Plain Layout + + abs = S[piece] + dev * Q[piece] +\end_layout + +\begin_layout Plain Layout + + elseif piece < 31 then +\end_layout + +\begin_layout Plain Layout + + local u, + v +\end_layout + +\begin_layout Plain Layout + + repeat +\end_layout + +\begin_layout Plain Layout + + u, + v = math.random(), + math.random() +\end_layout + +\begin_layout Plain Layout + + if u > v then u, + v = v, + u end +\end_layout + +\begin_layout Plain Layout + + abs = S[piece-15] + u/5 +\end_layout + +\begin_layout Plain Layout + + until v >= D[piece-15] or +\end_layout + +\begin_layout Plain Layout + + v > u + E[piece-15] * (math.exp((S[piece-14]^2 - abs^2) / 2) - 1) +\end_layout + +\begin_layout Plain Layout + + else +\end_layout + +\begin_layout Plain Layout + + repeat +\end_layout + +\begin_layout Plain Layout + + abs = math.sqrt(9 - 2 * math.log(math.random())) +\end_layout + +\begin_layout Plain Layout + + until abs * rand >= 3 +\end_layout + +\begin_layout Plain Layout + + end +\end_layout + +\begin_layout Plain Layout + + if sign == 0 then return abs else return -abs end +\end_layout + +\begin_layout Plain Layout + +end +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +from math import exp, + floor, + log, + sqrt +\end_layout + +\begin_layout Plain Layout + +from random import random +\end_layout + +\begin_layout Plain Layout + +\end_layout + +\begin_layout Plain Layout + +D, + E, + P, + Q, + S, + Y, + Z = [], + [], + [], + [], + [], + [], + [] +\end_layout + +\begin_layout Plain Layout + +\end_layout + +\begin_layout Plain Layout + +\end_layout + +\begin_layout Plain Layout + +def normal(): +\end_layout + +\begin_layout Plain Layout + + rand = random() +\end_layout + +\begin_layout Plain Layout + + sign = floor(rand * 2) +\end_layout + +\begin_layout Plain Layout + + piece = floor(rand * 64) % 32 +\end_layout + +\begin_layout Plain Layout + + dev = (rand * 64) % 1 +\end_layout + +\begin_layout Plain Layout + + if dev >= P[piece]: +\end_layout + +\begin_layout Plain Layout + + result = Y[piece] + dev * Z[piece] +\end_layout + +\begin_layout Plain Layout + + elif piece <= 15: +\end_layout + +\begin_layout Plain Layout + + result = S[piece] + dev * Q[piece] +\end_layout + +\begin_layout Plain Layout + + elif piece < 31: +\end_layout + +\begin_layout Plain Layout + + piece = piece - 16 +\end_layout + +\begin_layout Plain Layout + + while True: +\end_layout + +\begin_layout Plain Layout + + u, + v = random(), + random() +\end_layout + +\begin_layout Plain Layout + + if u > v: +\end_layout + +\begin_layout Plain Layout + + u, + v = v, + u +\end_layout + +\begin_layout Plain Layout + + result = S[piece] + u/5 +\end_layout + +\begin_layout Plain Layout + + if v >= D[piece]: +\end_layout + +\begin_layout Plain Layout + + break +\end_layout + +\begin_layout Plain Layout + + if v < u + E[piece] * (exp((S[piece+1]**2 - abs**2)/2) - 1): +\end_layout + +\begin_layout Plain Layout + + break +\end_layout + +\begin_layout Plain Layout + + else: +\end_layout + +\begin_layout Plain Layout + + while True: +\end_layout + +\begin_layout Plain Layout + + result = sqrt(9 - 2*log(random())) +\end_layout + +\begin_layout Plain Layout + + if result * random() < 3: +\end_layout + +\begin_layout Plain Layout + + break +\end_layout + +\begin_layout Plain Layout + + if sign: +\end_layout + +\begin_layout Plain Layout + + result = -result +\end_layout + +\begin_layout Plain Layout + + return result +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc16[HM22] +\end_layout + +\end_inset + +(J. + H. + Ahrens.) Develop an algorithm for gamma deviates of order +\begin_inset Formula $a$ +\end_inset + + when +\begin_inset Formula $0<a<1$ +\end_inset + +, + using the rejection method with +\begin_inset Formula $cg(t)=t^{a-1}/\Gamma(a)$ +\end_inset + + for +\begin_inset Formula $0<t<1$ +\end_inset + +, + and with +\begin_inset Formula $cg(t)=\text{e}^{-t}/\Gamma(a)$ +\end_inset + + for +\begin_inset Formula $t\geq1$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +The density function for the gamma distribution is +\begin_inset Formula +\begin{align*} +f(x) & \coloneqq\frac{1}{\Gamma(a)}x^{a-1}\text{e}^{-x}, & x & \geq0. +\end{align*} + +\end_inset + +Let +\begin_inset Formula +\[ +g(t)\coloneqq\begin{cases} +t^{a-1}, & 0<t<1;\\ +\text{e}^{-t}, & t\geq1. +\end{cases} +\] + +\end_inset + +Then, +\begin_inset Formula +\begin{align*} +G_{0}(x)\coloneqq\int_{0}^{x}g(t)\text{d}t & =\begin{cases} +\int_{0}^{x}t^{a-1}\text{d}t=\left[\frac{t^{a}}{a}\right]_{t=0}^{x}=\frac{x^{a}}{a}, & 0<t<1;\\ +a^{-1}+\int_{1}^{x}\text{e}^{-t}\text{d}t=\frac{1}{a}-\left[\text{e}^{-t}\right]_{t=1}^{x}=a^{-1}+\text{e}^{-1}-\text{e}^{-x}, & t\geq1. +\end{cases} +\end{align*} + +\end_inset + +If +\begin_inset Formula $M\coloneqq\lim_{x\to\infty}G(x)=a^{-1}+\text{e}^{-1}$ +\end_inset + +, + the real probability distribution function is +\begin_inset Formula $G(x)\coloneqq G_{0}(x)/M$ +\end_inset + +. + Thus, + a possible method could be the following: + Generate to independent deviates +\begin_inset Formula $U$ +\end_inset + + and +\begin_inset Formula $V$ +\end_inset + + uniformly distributed between 0 and 1. + If +\begin_inset Formula $U<a^{-1}/M$ +\end_inset + +, + set +\begin_inset Formula $X\coloneqq\sqrt[a]{aMU}=\sqrt[a]{1+\frac{a}{\text{e}}}\sqrt[a]{U}$ +\end_inset + + and +\begin_inset Formula $Y\coloneqq\Gamma(a)f(X)/g(X)=\text{e}^{-X}$ +\end_inset + +. + Otherwise set +\begin_inset Formula $X\coloneqq-\ln M\cdot\ln(1-U)$ +\end_inset + + and +\begin_inset Formula $Y\coloneqq\Gamma(a)f(X)/g(X)=X^{a-1}$ +\end_inset + +. + If +\begin_inset Formula $V\geq Y$ +\end_inset + +, + reject +\begin_inset Formula $X$ +\end_inset + + and repeat all the steps. + Otherwise return +\begin_inset Formula $X$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc17[M24] +\end_layout + +\end_inset + +What is the +\emph on +distribution function +\emph default + +\begin_inset Formula $F(x)$ +\end_inset + + for the geometric distribution with probability +\begin_inset Formula $p$ +\end_inset + +? + What is the +\emph on +generating function +\emph default + +\begin_inset Formula $G(z)$ +\end_inset + +? + What are the mean and standard deviation of this distribution? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Formula +\[ +F(x)=P(X\leq x)=1-P(X>x)=1-P(X>\lfloor x\rfloor)=1-(1-p)^{\max\{\lfloor x\rfloor,0\}}. +\] + +\end_inset + +The generating function is +\begin_inset Formula +\[ +G(z)\coloneqq\sum_{k\geq1}(1-p)^{k-1}pz^{k}=zp\sum_{k\geq0}(1-p)^{k}z^{k}=\frac{zp}{1-(1-p)z}=\frac{zp}{1-qz}, +\] + +\end_inset + +where +\begin_inset Formula $q\coloneqq1-p$ +\end_inset + +. + Then +\begin_inset Formula +\begin{align*} +G'(z) & =\frac{p-pqz+pqz}{(1-qz)^{2}}=\frac{p}{(1-qz)^{2}}, & G''(z) & =-\frac{2pq}{(1-qz)^{3}}, +\end{align*} + +\end_inset + +so the mean is +\begin_inset Formula +\[ +G'(1)=\frac{p}{(1-q)^{2}}=\frac{p}{p^{2}}=\frac{1}{p}, +\] + +\end_inset + +and the variance is +\begin_inset Formula +\[ +G''(1)+G'(1)-G'(1)^{2}=-\frac{2pq}{(1-q)^{3}}+\frac{1}{p}-\frac{1}{p^{2}}=\frac{2q}{p^{2}}+\frac{1}{p}-\frac{1}{p^{2}}=\frac{2q+p-1}{p^{2}}=\frac{q}{p^{2}}, +\] + +\end_inset + +so the standard deviation is +\begin_inset Formula $\frac{\sqrt{q}}{p}$ +\end_inset + +. +\end_layout + +\end_body +\end_document diff --git a/vol2/3.4.2.lyx b/vol2/3.4.2.lyx new file mode 100644 index 0000000..8d59cc5 --- /dev/null +++ b/vol2/3.4.2.lyx @@ -0,0 +1,537 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 620 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass book +\begin_preamble +\input defs +\end_preamble +\use_default_options true +\maintain_unincluded_children no +\language english +\language_package default +\inputencoding utf8 +\fontencoding auto +\font_roman "default" "default" +\font_sans "default" "default" +\font_typewriter "default" "default" +\font_math "auto" "auto" +\font_default_family default +\use_non_tex_fonts false +\font_sc false +\font_roman_osf false +\font_sans_osf false +\font_typewriter_osf false +\font_sf_scale 100 100 +\font_tt_scale 100 100 +\use_microtype false +\use_dash_ligatures true +\graphics default +\default_output_format default +\output_sync 0 +\bibtex_command default +\index_command default +\float_placement class +\float_alignment class +\paperfontsize default +\spacing single +\use_hyperref false +\papersize default +\use_geometry false +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\cite_engine basic +\cite_engine_type default +\biblio_style plain +\use_bibtopic false +\use_indices false +\paperorientation portrait +\suppress_date false +\justification true +\use_refstyle 1 +\use_formatted_ref 0 +\use_minted 0 +\use_lineno 0 +\index Index +\shortcut idx +\color #008000 +\end_index +\secnumdepth 3 +\tocdepth 3 +\paragraph_separation indent +\paragraph_indentation default +\is_math_indent 0 +\math_numbering_side default +\quotes_style english +\dynamic_quotes 0 +\papercolumns 1 +\papersides 1 +\paperpagestyle default +\tablestyle default +\tracking_changes false +\output_changes false +\change_bars false +\postpone_fragile_content false +\html_math_output 0 +\html_css_as_file 0 +\html_be_strict false +\docbook_table_output 0 +\docbook_mathml_prefix 1 +\end_header + +\begin_body + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc3[22] +\end_layout + +\end_inset + +The +\begin_inset Formula $(t+1)$ +\end_inset + +st item in Algorithm S is selected with probability +\begin_inset Formula $(n-m)/(N-t)$ +\end_inset + +, + not +\begin_inset Formula $n/N$ +\end_inset + +, + yet the text claims that the sample is unbiased; + thus each item should be selected with the +\emph on +same +\emph default + probability. + How can both of these statements be true? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +This is because +\begin_inset Formula $\frac{n-m}{N-t}$ +\end_inset + + appears as a +\emph on +conditioned +\emph default + probability, + where the condition depends on +\begin_inset Formula $t$ +\end_inset + +. + The actual probability of choosing the +\begin_inset Formula $(t+1)$ +\end_inset + +st element is +\begin_inset Formula +\[ +\sum_{m=0}^{t}P(\{m\text{ elements have been chosen between }1\text{ and }t\})\frac{n-m}{N-t}. +\] + +\end_inset + +Let +\begin_inset Formula $P_{mt}$ +\end_inset + + be the probability described with words inside this formula. + For +\begin_inset Formula $m>t$ +\end_inset + + or +\begin_inset Formula $m<0$ +\end_inset + +, + this probability is obviously 0, + and for +\begin_inset Formula $t=0$ +\end_inset + +, + +\begin_inset Formula $P_{00}=1$ +\end_inset + +. + For +\begin_inset Formula $t\geq1$ +\end_inset + + and +\begin_inset Formula $0\leq m\leq t$ +\end_inset + +, + +\begin_inset Formula +\[ +P_{mt}=P_{m(t-1)}\left(1-\frac{n-m}{N-t+1}\right)+P_{(m-1)(t-1)}\frac{n-m+1}{N-t+1}. +\] + +\end_inset + +Note that, + by this formula, + +\begin_inset Formula $P_{(n-1)t}=0$ +\end_inset + + always, + since the second term is 0 and the first term is a multiple of +\begin_inset Formula $P_{(n-1)(t-1)}$ +\end_inset + +, + which is 0 by induction since +\begin_inset Formula $P_{(n-1)(-1)}=0$ +\end_inset + +. + Then, + by induction in +\begin_inset Formula $m$ +\end_inset + +, + +\begin_inset Formula $P_{mt}=0$ +\end_inset + + for any +\begin_inset Formula $m>n$ +\end_inset + +. +\end_layout + +\begin_layout Standard +Since the algorithm is said to be unbiased, + we would expect +\begin_inset Formula +\[ +P_{mt}=\frac{\binom{t}{m}\binom{N-t}{n-m}}{\binom{N}{n}}, +\] + +\end_inset + +that is, + the number of ways to choose +\begin_inset Formula $m$ +\end_inset + + elements among the first +\begin_inset Formula $t$ +\end_inset + + ones and +\begin_inset Formula $n-m$ +\end_inset + + elements among the rest, + divided by the total number of ways of choosing +\begin_inset Formula $n$ +\end_inset + + elements among +\begin_inset Formula $N$ +\end_inset + +. +\end_layout + +\begin_layout Standard +We prove this by induction. + For +\begin_inset Formula $t=0$ +\end_inset + + we have seen it already. + For +\begin_inset Formula $t>0$ +\end_inset + +, + if +\begin_inset Formula $m=0$ +\end_inset + +, +\begin_inset Formula +\[ +P_{0t}=P_{0(t-1)}\left(1-\frac{n}{N-t+1}\right)=\frac{\binom{N-t+1}{n}}{\binom{N}{n}}\frac{N-t-n+1}{N-t+1}=\frac{\binom{N-t}{n}}{\binom{N}{n}}, +\] + +\end_inset + +and if +\begin_inset Formula $m>0$ +\end_inset + +, +\begin_inset Formula +\begin{align*} +P_{mt} & =\frac{\binom{t-1}{m}\binom{N-t+1}{n-m}}{\binom{N}{n}}\frac{N-t-n+m+1}{N-t+1}+\frac{\binom{t-1}{m-1}\binom{N-t+1}{n-m+1}}{\binom{N}{n}}\frac{n-m+1}{N-t+1}=\\ + & =\frac{\binom{t-1}{m}\binom{N-t}{n-m}}{\binom{N}{n}}+\frac{\binom{t-1}{m-1}\binom{N-t}{n-m}}{\binom{N}{n}}=\frac{\binom{t}{m}\binom{N-t}{n-m}}{\binom{N}{n}}, +\end{align*} + +\end_inset + +where we make extensive use of Eq. + 1.2.6–(8). + Finally, + by Eq. + 1.2.6–(21), + the probability of choosing any given element is +\begin_inset Formula +\[ +\sum_{m=0}^{t}P_{mt}\frac{n-m}{N-t}=\frac{1}{\binom{N}{n}}\sum_{m=0}^{t}\binom{t}{m}\binom{N-1-t}{n-1-m}=\frac{\binom{N-1}{n-1}}{\binom{N}{n}}=\frac{\binom{N-1}{N-n}}{\binom{N}{N-n}}=\frac{n}{N}. +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc11[M25] +\end_layout + +\end_inset + +Let +\begin_inset Formula $p_{m}$ +\end_inset + + be the probability that exactly +\begin_inset Formula $m$ +\end_inset + + elements are put into the reservoir during the first pass of Algorithm R. + Determine the generating function +\begin_inset Formula $G(z)=\sum_{m}p_{m}z^{m}$ +\end_inset + +, + and find the mean and standard deviation. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Let +\begin_inset Formula $s_{k}\coloneqq P(\text{the }k\text{th element is copied to the reservoir})$ +\end_inset + +, + then +\begin_inset Formula $p_{m}$ +\end_inset + + is the sum across all subsets +\begin_inset Formula $\{x_{1},\dots,x_{m}\}\in\{1,\dots,N\}$ +\end_inset + + of +\begin_inset Formula $m$ +\end_inset + + elements, + +\begin_inset Formula $x_{1}<\dots<x_{m}$ +\end_inset + +, + of the product of the +\begin_inset Formula $s_{x_{i}}$ +\end_inset + + times the +\begin_inset Formula $(1-s_{j})$ +\end_inset + + for +\begin_inset Formula $j\in\{1,\dots N\}\setminus\{x_{1},\dots,x_{m}\}$ +\end_inset + +. + Rearranging terms we can see that +\begin_inset Formula +\[ +G(z)=\prod_{k=1}^{N}(s_{k}z+1-s_{k})=z^{n}\prod_{k=n+1}^{N}\left(\frac{nz}{k}+1-\frac{n}{k}\right)=z^{n}\prod_{k=n+1}^{N}\frac{n(z-1)+k}{k}. +\] + +\end_inset + +Let +\begin_inset Formula $F(z)\coloneqq\prod_{k=n+1}^{N}\frac{n(z-1)+k}{k}$ +\end_inset + +, + we have +\begin_inset Formula $F(1)=1$ +\end_inset + + and +\begin_inset Formula +\begin{align*} +\dot{F}(z) & =F(z)\sum_{k=n+1}^{N}\frac{n}{n(z-1)+k}, & \dot{F}(1) & =\sum_{k=n+1}^{N}\frac{n}{k}=n(H_{N}-H_{n});\\ +\ddot{F}(z) & =\frac{\dot{F}(z)^{2}}{F(z)}-F(z)\sum_{k=n+1}^{N}\frac{n^{2}}{(n(z-1)+k)^{2}}, & \ddot{F}(1) & =n^{2}\left((H_{N}-H_{n})^{2}-(H_{N}^{(2)}-H_{n}^{(2)})\right). +\end{align*} + +\end_inset + +Using this, +\begin_inset Formula +\begin{align*} +\dot{G}(z) & =nz^{n-1}F(z)+z^{n}\dot{F}(z),\\ +\ddot{G}(z) & =n(n-1)z^{n-2}F(z)+2nz^{n-1}\dot{F}(z)+z^{n}\ddot{F}(z), +\end{align*} + +\end_inset + +so +\begin_inset Formula +\begin{align*} +\text{mean}(G) & =\dot{G}(1)=n(1+H_{N}-H_{n});\\ +\text{var}(G) & =\ddot{G}(1)+\dot{G}(1)-\dot{G}(1)^{2}\\ + & =\cancel{n(n-1)}\cancel{+2n\dot{F}(1)}+\ddot{F}(1)\cancel{+n}+\dot{F}(1)\cancel{-n^{2}}-\dot{F}(1)^{2}\cancel{-2n\dot{F}(1)}\\ + & =n(H_{N}-H_{n})-n^{2}(H_{N}^{(2)}-H_{n}^{(2)}),\\ +\sigma(G) & =\sqrt{\text{var}(G)}=\sqrt{n(H_{N}-H_{n})-n^{2}(H_{N}^{(2)}-H_{n}^{(2)})}. +\end{align*} + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc16[M25] +\end_layout + +\end_inset + +Devise a way to compute a random sample of +\begin_inset Formula $n$ +\end_inset + + records from +\begin_inset Formula $N$ +\end_inset + +, + given +\begin_inset Formula $N$ +\end_inset + + and +\begin_inset Formula $n$ +\end_inset + +, + based on the idea of hashing (Section 6.4). + Your method should use +\begin_inset Formula $O(n)$ +\end_inset + + storage locations and an average of +\begin_inset Formula $O(n)$ +\end_inset + + units of time, + and it should present the sample as a sorted set of integers +\begin_inset Formula $1\leq X_{1}<X_{2}<\dots<X_{n}\leq N$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout +TODO Depends on Section 6.4. +\end_layout + +\end_inset + + +\end_layout + +\end_body +\end_document diff --git a/vol2/3.5.lyx b/vol2/3.5.lyx new file mode 100644 index 0000000..0268000 --- /dev/null +++ b/vol2/3.5.lyx @@ -0,0 +1,1191 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 620 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass book +\begin_preamble +\input defs +\end_preamble +\use_default_options true +\maintain_unincluded_children no +\language english +\language_package default +\inputencoding utf8 +\fontencoding auto +\font_roman "default" "default" +\font_sans "default" "default" +\font_typewriter "default" "default" +\font_math "auto" "auto" +\font_default_family default +\use_non_tex_fonts false +\font_sc false +\font_roman_osf false +\font_sans_osf false +\font_typewriter_osf false +\font_sf_scale 100 100 +\font_tt_scale 100 100 +\use_microtype false +\use_dash_ligatures true +\graphics default +\default_output_format default +\output_sync 0 +\bibtex_command default +\index_command default +\float_placement class +\float_alignment class +\paperfontsize default +\spacing single +\use_hyperref false +\papersize default +\use_geometry false +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\cite_engine basic +\cite_engine_type default +\biblio_style plain +\use_bibtopic false +\use_indices false +\paperorientation portrait +\suppress_date false +\justification true +\use_refstyle 1 +\use_formatted_ref 0 +\use_minted 0 +\use_lineno 0 +\index Index +\shortcut idx +\color #008000 +\end_index +\secnumdepth 3 +\tocdepth 3 +\paragraph_separation indent +\paragraph_indentation default +\is_math_indent 0 +\math_numbering_side default +\quotes_style english +\dynamic_quotes 0 +\papercolumns 1 +\papersides 1 +\paperpagestyle default +\tablestyle default +\tracking_changes false +\output_changes false +\change_bars false +\postpone_fragile_content false +\html_math_output 0 +\html_css_as_file 0 +\html_be_strict false +\docbook_table_output 0 +\docbook_mathml_prefix 1 +\end_header + +\begin_body + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc1[10] +\end_layout + +\end_inset + +Can a periodic sequence be equidistributed? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Not if it's a real sequence, + because the period must be finite and, + if +\begin_inset Formula $0\leq x_{1}<\dots<x_{t}\leq1$ +\end_inset + + are the numbers that appear in the period, + then +\begin_inset Formula $\text{Pr}(\frac{1}{3}(2x_{1}+x_{2})\leq x<\frac{1}{3}(x_{1}+2x_{2}))=0\neq\frac{1}{3}(x_{2}-x_{1})$ +\end_inset + + (a similar proof can be made for +\begin_inset Formula $t=1$ +\end_inset + +). + If it's an integer sequence it can happen; + for example for the +\begin_inset Formula $b$ +\end_inset + +-ary sequence with period +\begin_inset Formula $0,1,2,\dots,b-1$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc2[10] +\end_layout + +\end_inset + +Consider the periodic binary sequence 0, + 0, + 1, + 1, + 0, + 0, + 1, + 1, + +\begin_inset Formula $\dots$ +\end_inset + +. + Is it 1-distributed? + Is it 2-distributed? + Is it 3-distributed? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +It is clearly 1-distributed and 2-distributed, + but not 3-distributed because +\begin_inset Quotes eld +\end_inset + +111 +\begin_inset Quotes erd +\end_inset + + never appears. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc5[HM22] +\end_layout + +\end_inset + +Let +\begin_inset Formula $U_{n}=(2^{\lfloor\lg(n+1)\rfloor}/3)\bmod1$ +\end_inset + +. + What is +\begin_inset Formula $\text{Pr}(U_{n}<\frac{1}{2})$ +\end_inset + +? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We have +\begin_inset Formula $\lfloor\lg(n+1)\rfloor=0$ +\end_inset + + for +\begin_inset Formula $n=0$ +\end_inset + +; + 1 for +\begin_inset Formula $n=1,2$ +\end_inset + +; + 2 for +\begin_inset Formula $n=3,4,5,6$ +\end_inset + +, + 3 for +\begin_inset Formula $n=7,\dots,14$ +\end_inset + +, + etc., + so the sequence +\begin_inset Formula $(2^{\lfloor\lg(n+1)\rfloor})_{n}$ +\end_inset + + has 1 1's, + followed by 2 2's, + 4 4's, + 8 8's, + etc. + It is easy to prove by induction that, + when +\begin_inset Formula $k\in\mathbb{N}$ +\end_inset + + is even, + +\begin_inset Formula $2^{k}\equiv1\bmod3$ +\end_inset + +, + and when it's odd, + +\begin_inset Formula $2^{k}\equiv2\bmod3$ +\end_inset + +, + and so +\begin_inset Formula $U_{n}<\frac{1}{2}$ +\end_inset + + precisely when +\begin_inset Formula $\lfloor\lg(n+1)\rfloor$ +\end_inset + + is even, + which is when +\begin_inset Formula $2^{k}\equiv1\bmod3$ +\end_inset + +. +\end_layout + +\begin_layout Standard +If +\begin_inset Formula $\nu(n)=|\{m\leq n\mid U_{n}<\frac{1}{2}\}|$ +\end_inset + +, + then +\begin_inset Formula $\nu(n)/n$ +\end_inset + + clearly increases when +\begin_inset Formula $n$ +\end_inset + + is between +\begin_inset Formula $2^{2k}-1$ +\end_inset + + and +\begin_inset Formula $2^{2k+1}-1$ +\end_inset + +, + and it decreases between +\begin_inset Formula $2^{2k-1}-1$ +\end_inset + + and +\begin_inset Formula $2^{2k}-1$ +\end_inset + +, + for +\begin_inset Formula $k\in\mathbb{N}^{*}$ +\end_inset + +. + The limit exists if the subsequence made from these infinite local minima and the one made from these infinite local maxima both have a limit and these limits match. +\end_layout + +\begin_layout Standard +For the maxima, + +\begin_inset Formula $\nu(1)=1$ +\end_inset + +, + +\begin_inset Formula $\nu(7)=5$ +\end_inset + +, + +\begin_inset Formula $\nu(31)=21$ +\end_inset + +, + etc. + In general, + +\begin_inset Formula +\[ +\nu(2^{2k+1}-1)=\sum_{i=0}^{k}2^{2k}=\frac{1-4^{k+1}}{1-4}=\frac{4^{k+1}-1}{3}, +\] + +\end_inset + +so +\begin_inset Formula +\[ +\lim_{k}\frac{\nu(2^{2k+1}-1)}{2^{2k+1}-1}=\frac{\frac{4^{k+1}-1}{3}}{2\cdot4^{k}-1}=\frac{1}{3}\frac{4\cdot4^{k}-1}{2\cdot4^{k}-1}=\frac{2}{3}. +\] + +\end_inset + +For the minima, + +\begin_inset Formula $\nu(3)=1$ +\end_inset + +, + +\begin_inset Formula $\nu(15)=5$ +\end_inset + +, + etc., + and in general +\begin_inset Formula $\nu(2^{2k}-1)=\nu(2^{2k-1}-1)=\frac{4^{k}-1}{3}$ +\end_inset + +, + so +\begin_inset Formula +\[ +\lim_{k}\frac{\nu(2^{2k}-1)}{2^{2k}-1}=\frac{1}{3}\frac{4^{k}-1}{4^{k}-1}=\frac{1}{3}. +\] + +\end_inset + +Since +\begin_inset Formula $\frac{1}{3}\neq\frac{2}{3}$ +\end_inset + +, + this probability is undefined. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc10[HM22] +\end_layout + +\end_inset + +Where was the fact that +\begin_inset Formula $m$ +\end_inset + + divides +\begin_inset Formula $q$ +\end_inset + + used in the proof of Theorem C? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +This is used for the sums in the second page of proof, + when telling the range of +\begin_inset Formula $t$ +\end_inset + +. + In particular, + it is needed when evaluating the sum over +\begin_inset Formula $t$ +\end_inset + + in Equation (22). +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc11[M10] +\end_layout + +\end_inset + +Use Theorem C to prove that if a sequence +\begin_inset Formula $\langle U_{n}\rangle$ +\end_inset + + is +\begin_inset Formula $\infty$ +\end_inset + +-distributed, + so is the subsequence +\begin_inset Formula $\langle U_{2n}\rangle$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Since it's +\begin_inset Formula $\infty$ +\end_inset + +-distributed, + it's also +\begin_inset Formula $(2,2k)$ +\end_inset + +-distributed for all +\begin_inset Formula $k\in\mathbb{N}^{*}$ +\end_inset + +, + so +\begin_inset Formula $\text{Pr}(u_{1}\leq U_{2n}<v_{1},\dots,u_{2k}\leq U_{2n+2k-1}<v_{2k})=(v_{1}-u_{1})\cdots(v_{k}-u_{k})$ +\end_inset + + for any +\begin_inset Formula $u_{1},v_{1},\dots,u_{k},v_{k}\in[0,1)$ +\end_inset + + with each +\begin_inset Formula $u_{i}<v_{i}$ +\end_inset + +, + and in particular, + if we let +\begin_inset Formula $u_{2},u_{4},\dots,u_{2k}=0$ +\end_inset + + and +\begin_inset Formula $v_{2},v_{4},\dots,v_{2k}=1$ +\end_inset + + we get the formula that shows that +\begin_inset Formula $\langle U_{2n}\rangle$ +\end_inset + + is +\begin_inset Formula $k$ +\end_inset + +-distributed. + And since this +\begin_inset Formula $k$ +\end_inset + + is arbitrary, + +\begin_inset Formula $\langle U_{2n}\rangle$ +\end_inset + + is +\begin_inset Formula $\infty$ +\end_inset + +-distributed. + Note that this argument applies to any +\begin_inset Formula $\langle U_{mn+j}\rangle$ +\end_inset + + with +\begin_inset Formula $m\in\mathbb{N}^{*}$ +\end_inset + + and +\begin_inset Formula $j\in\mathbb{N}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc18[HM22] +\end_layout + +\end_inset + +Prove that if +\begin_inset Formula $U_{0},U_{1},\dots$ +\end_inset + + is +\begin_inset Formula $k$ +\end_inset + +-distributed, + so is the sequence +\begin_inset Formula $V_{0},V_{1},\dots$ +\end_inset + + where +\begin_inset Formula $V_{n}=\lfloor nU_{n}\rfloor/n$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Take any +\begin_inset Formula $u_{1},v_{1},\dots,u_{k},v_{k}\in[0,1)$ +\end_inset + + such that each +\begin_inset Formula $u_{i}<v_{i}$ +\end_inset + +. + If +\begin_inset Formula $u_{i}\leq V_{n}<v_{i}$ +\end_inset + +, + then +\begin_inset Formula $u_{i}-\frac{1}{n}\leq U_{n}<v_{i}+\frac{1}{n}$ +\end_inset + +, + so if +\begin_inset Formula $S(n)\coloneqq\{\forall i,u_{i}\leq V_{n+i}<v_{i}\}$ +\end_inset + +, + then +\begin_inset Formula +\begin{align*} +\overline{\text{Pr}}(S(n)) & \leq\text{Pr}\left(\forall i,u_{i}-\frac{1}{n+i}\leq U_{n+i}<v_{i}+\frac{1}{n+i}\right)\\ + & \leq\text{Pr}\left(\forall i,u_{i}-\frac{1}{n}\leq U_{n+i}<v_{i}+\frac{1}{n}\right)\\ + & \leq\text{Pr}\left(\forall i,u_{i}-\frac{1}{n_{0}}\leq U_{n+i}<v_{i}+\frac{1}{n_{0}}\right) +\end{align*} + +\end_inset + +for any +\begin_inset Formula $n_{0}\in\mathbb{N}$ +\end_inset + +, + since the first finitely many terms of the sequence +\begin_inset Quotes eld +\end_inset + +don't matter, +\begin_inset Quotes erd +\end_inset + + and since +\begin_inset Formula $n_{0}$ +\end_inset + + is arbitrary, + taking limits on it we see that +\begin_inset Formula $\overline{\text{Pr}}(S(n))\leq\text{Pr}(\forall i,u_{i}\leq U_{n+i}<v_{i})=\prod_{i}(v_{i}-u_{i})$ +\end_inset + +. + Similarly, + if +\begin_inset Formula $u_{i}+\frac{1}{n}\leq U_{n}<v_{i}-\frac{1}{n}$ +\end_inset + +, + then +\begin_inset Formula $u_{i}\leq V_{n}<v_{i}$ +\end_inset + +, + so +\begin_inset Formula +\[ +\underline{\text{Pr}}(S(n))\geq\text{Pr}\left(\forall i,u_{i}+\frac{1}{n}\leq U_{n+i}<v_{i}+\frac{1}{n}\right)\geq\text{Pr}\left(\forall i,u_{i}+\frac{1}{n_{0}}\leq U_{n+i}<v_{i}-\frac{1}{n_{0}}\right), +\] + +\end_inset + +this time taking +\begin_inset Formula $n_{0}$ +\end_inset + + such that +\begin_inset Formula $\frac{1}{n_{0}}\leq v_{i}-u_{i}$ +\end_inset + + for every +\begin_inset Formula $i$ +\end_inset + +. + Again we reach the conclusion that +\begin_inset Formula $\underline{\text{Pr}}(S(n))\geq\prod_{i}(v_{i}-u_{i})$ +\end_inset + +. + We get the result by the same argument used at the end of Theorem A. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc28[HM21] +\end_layout + +\end_inset + +Use the sequence (11) to construct a +\begin_inset Formula $[0..1)$ +\end_inset + + sequence that is 3-distributed, + for which +\begin_inset Formula $\text{Pr}(U_{2n}\geq\frac{1}{2})=\frac{3}{4}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Let +\begin_inset Formula $(W_{n})_{n}$ +\end_inset + + be an +\begin_inset Formula $\infty$ +\end_inset + +-distributed real-valued sequence, + and let +\begin_inset Formula $(X_{n})_{n}$ +\end_inset + + be the 3-distributed binary sequence from (11), + then +\begin_inset Formula $(U_{n}\coloneqq\frac{1}{2}(W_{n}+1-X_{n}))_{n}$ +\end_inset + + satisfies the properties. + For if +\begin_inset Formula $0\leq u_{i}<v_{i}<1$ +\end_inset + +, + +\begin_inset Formula $i\in\{1,2,3\}$ +\end_inset + +, + and if we assume that, + for each +\begin_inset Formula $i$ +\end_inset + +, + +\begin_inset Formula $v_{i}\geq\frac{1}{2}$ +\end_inset + + implies +\begin_inset Formula $u_{i}\geq\frac{1}{2}$ +\end_inset + + (so the +\begin_inset Quotes eld +\end_inset + +rectangle +\begin_inset Quotes erd +\end_inset + + is contained in one quadrant), + then +\begin_inset Formula $u_{i}\leq U_{n}<v_{i}$ +\end_inset + + if, + and only if, + +\begin_inset Formula $\lfloor2u_{i}\rfloor=\lfloor2U_{i}\rfloor=1-X_{n}$ +\end_inset + + and +\begin_inset Formula $2u_{i}\bmod1\leq2U_{n}\bmod1=W_{n}\leq2v_{i}$ +\end_inset + +. + Since +\begin_inset Formula $W_{n}$ +\end_inset + + is +\begin_inset Formula $(16,3)$ +\end_inset + +-distributed, + the triplets +\begin_inset Formula $(W_{n},W_{n+1},W_{n+2})$ +\end_inset + + starting at positions where +\begin_inset Formula $(X_{n},X_{n+1},X_{n+2})$ +\end_inset + + has a given value have the same density as those starting at positions where it has any other value, + so +\begin_inset Formula +\begin{multline*} +\text{Pr}(\forall i,u_{i}\leq U_{n}<v_{i})=\text{Pr}(\forall i,\lfloor2u_{i}\rfloor=1-X_{n})\text{Pr}(\forall i,2u_{i}\bmod1\leq W_{n}\leq2v_{i}\bmod1)=\\ +=\frac{1}{8}\prod_{i}(2v_{i}-2u_{i})=\prod_{i}(v_{i}-u_{i}) +\end{multline*} + +\end_inset + +and the sequence is 3-distributed (the cases where some +\begin_inset Formula $\lfloor2u_{i}\rfloor\neq\lfloor2v_{i}\rfloor$ +\end_inset + + can be split into cases where this is not the case). + In addition, + +\begin_inset Formula $\text{Pr}(U_{2n}\geq\frac{1}{2})=\text{Pr}(X_{2n}=0)=\frac{3}{4}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc34[M25] +\end_layout + +\end_inset + +Define subsequence rules +\begin_inset Formula ${\cal R}_{1}$ +\end_inset + +, + +\begin_inset Formula ${\cal R}_{2}$ +\end_inset + +, + +\begin_inset Formula ${\cal R}_{3}$ +\end_inset + +, + ... + such that Algorithm W can be used with these rules to give an effective algorithm to construct a +\begin_inset Formula $[0..1)$ +\end_inset + + sequence satisfying Definition R1. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Note Greyedout +status open + +\begin_layout Plain Layout +(I had to look up the solution.) +\end_layout + +\end_inset + +The +\begin_inset Quotes eld +\end_inset + +algorithm +\begin_inset Quotes erd +\end_inset + + gives us a potentially infinite amount of sequences +\begin_inset Formula $\langle U_{n}\rangle{\cal R}_{k}$ +\end_inset + + that are 1-distributed, + so we may encode the properties that we want to check for in the value +\begin_inset Formula $k$ +\end_inset + +. + Specifically, + we want to check that, + for an increasing sequence of bases +\begin_inset Formula $(b_{n})_{n}$ +\end_inset + +, + +\begin_inset Formula $k\in\mathbb{N}^{*}$ +\end_inset + +, + and +\begin_inset Formula $a_{1},\dots,a_{k}\in\{0,\dots,b-1\}$ +\end_inset + +, + +\begin_inset Formula $U_{n-k}=a_{k},\dots,U_{n-1}=a_{1}$ +\end_inset + +, + so if, + for example, + +\begin_inset Formula $k=10^{b}10^{a_{1}}10^{a_{2}}1\cdots10a^{j}$ +\end_inset + + with each +\begin_inset Formula $a_{i}<b$ +\end_inset + +, + we may set +\begin_inset Formula ${\cal R}_{k}(x_{0},\dots,x_{n-1})=1$ +\end_inset + + if, + and only if, + +\begin_inset Formula $\lfloor bU_{n-1}\rfloor=a_{1}\land\dots\land\lfloor bU_{n-k}\rfloor=a_{k}$ +\end_inset + +. + For every other value of +\begin_inset Formula $k$ +\end_inset + +, + we may as well set +\begin_inset Formula ${\cal R}_{k}\equiv1$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset Note Note +status open + +\begin_layout Plain Layout +TODO 44 ( +\begin_inset Formula $<$ +\end_inset + +4pp., + +\begin_inset Formula $<$ +\end_inset + +1:53) +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc44[16] +\end_layout + +\end_inset + +(I. + J. + Good.) Can a valid table of random digits contain just one misprint? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Yes; + for example, + both 23456782019372837458 and 23456782019372837459 are random. + Of course, + this is not true for any misprint, + as then all numbers would be random. + For example, + 23456782019372828221 is random but 23456782019372828222 isn't, + as it contains too many 2's. + This has been calculated with the following (terrible) code: +\end_layout + +\begin_layout Standard +\begin_inset listings +lstparams "language=Python,numbers=left,basicstyle={\footnotesize\sffamily},breaklines=true" +inline false +status open + +\begin_layout Plain Layout + +import math +\end_layout + +\begin_layout Plain Layout + +\end_layout + +\begin_layout Plain Layout + +def israndom(digs): +\end_layout + +\begin_layout Plain Layout + + N = len(digs) +\end_layout + +\begin_layout Plain Layout + + dev = math.sqrt(N) +\end_layout + +\begin_layout Plain Layout + + for k in range(0, + math.floor(math.log10(N)) + 1): +\end_layout + +\begin_layout Plain Layout + + pos = 10**k +\end_layout + +\begin_layout Plain Layout + + expect = N/pos +\end_layout + +\begin_layout Plain Layout + + for ss in range(pos, + 2*pos): +\end_layout + +\begin_layout Plain Layout + + sb = str(ss)[1:] +\end_layout + +\begin_layout Plain Layout + + amt = len([n for n in range(len(digs)) if digs[n:n+k] == sb]) +\end_layout + +\begin_layout Plain Layout + + if abs(amt-expect) > dev: +\end_layout + +\begin_layout Plain Layout + + print( +\begin_inset Quotes eld +\end_inset + +FAIL +\begin_inset Quotes erd +\end_inset + +, + digs, + sb) +\end_layout + +\begin_layout Plain Layout + + return False +\end_layout + +\begin_layout Plain Layout + + return True +\end_layout + +\begin_layout Plain Layout + +\end_layout + +\begin_layout Plain Layout + +for x in range(123456782019372800000, + 123456790000000000000): +\end_layout + +\begin_layout Plain Layout + + if israndom(str(x)[1:]): +\end_layout + +\begin_layout Plain Layout + + print(str(x)[1:]) +\end_layout + +\end_inset + + +\end_layout + +\end_body +\end_document diff --git a/vol2/3.6.lyx b/vol2/3.6.lyx new file mode 100644 index 0000000..8eaaa14 --- /dev/null +++ b/vol2/3.6.lyx @@ -0,0 +1,496 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 620 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass book +\begin_preamble +\input defs +\end_preamble +\use_default_options true +\maintain_unincluded_children no +\language english +\language_package default +\inputencoding utf8 +\fontencoding auto +\font_roman "default" "default" +\font_sans "default" "default" +\font_typewriter "default" "default" +\font_math "auto" "auto" +\font_default_family default +\use_non_tex_fonts false +\font_sc false +\font_roman_osf false +\font_sans_osf false +\font_typewriter_osf false +\font_sf_scale 100 100 +\font_tt_scale 100 100 +\use_microtype false +\use_dash_ligatures true +\graphics default +\default_output_format default +\output_sync 0 +\bibtex_command default +\index_command default +\float_placement class +\float_alignment class +\paperfontsize default +\spacing single +\use_hyperref false +\papersize default +\use_geometry false +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\cite_engine basic +\cite_engine_type default +\biblio_style plain +\use_bibtopic false +\use_indices false +\paperorientation portrait +\suppress_date false +\justification true +\use_refstyle 1 +\use_formatted_ref 0 +\use_minted 0 +\use_lineno 0 +\index Index +\shortcut idx +\color #008000 +\end_index +\secnumdepth 3 +\tocdepth 3 +\paragraph_separation indent +\paragraph_indentation default +\is_math_indent 0 +\math_numbering_side default +\quotes_style english +\dynamic_quotes 0 +\papercolumns 1 +\papersides 1 +\paperpagestyle default +\tablestyle default +\tracking_changes false +\output_changes false +\change_bars false +\postpone_fragile_content false +\html_math_output 0 +\html_css_as_file 0 +\html_be_strict false +\docbook_table_output 0 +\docbook_mathml_prefix 1 +\end_header + +\begin_body + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc2[15] +\end_layout + +\end_inset + +some people have been afraid that computers will someday take over the world; + but they are reassured by the statement that a machine cannot do anything really new, + since it is only obeying the commands of its master, + the programmer. + Lady Lovelace wrote in 1844, + +\begin_inset Quotes eld +\end_inset + +The Analytical Engine has no pretensions to +\emph on +originate +\emph default + anything. + It can do +\emph on +whatever we know how to order it +\emph default + to perform. +\begin_inset Quotes erd +\end_inset + + Her statement has been elaborated further by many philosophers. + Discuss this topic, + with random number generators in mind. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +While it is true that a machine cannot do anything that a programmer doesn't tell it to do, + there are a number of caveats here. + First is that the programmer, + or their boss, + may not have other people's best interests in mind. + Another one is that what the programmer tells the machine to do is not the same thing as what they +\emph on +expects +\emph default + them to do; + the software may have bugs, + although the bugs are unlikely to make the computer take over the world. + Finally, + if a random number generator is being used, + the programmer is telling the machine to do one of a number of actions, + chosen with some given distribution, + without telling it which one to choose. + These actions are typically limited to a given scope, + and the programmer still controls the family of actions that the machine may take. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc11[M25] +\end_layout + +\end_inset + +Assuming that floating point arithmetic on numbers of type +\family typewriter +double +\family default + is properly rounded in the sense of Section 4.2.2 (hence exact when the values are suitably restricted), + convert the C routines +\emph on +ran_array +\emph default + and +\emph on +ran_start +\emph default + to similar programs that deliver double-precision random fractions in the range +\begin_inset Formula $[0..1)$ +\end_inset + +, + instead of 30-bit integers. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Technically this does the work: +\begin_inset listings +lstparams "language=C,numbers=left,basicstyle={\small\sffamily},breaklines=true" +inline false +status open + +\begin_layout Plain Layout + +#include <math.h> +\end_layout + +\begin_layout Plain Layout + +\end_layout + +\begin_layout Plain Layout + +static double ran_u[KK]; +\end_layout + +\begin_layout Plain Layout + +\end_layout + +\begin_layout Plain Layout + +void ranf_array(double out[], + size_t n) +\end_layout + +\begin_layout Plain Layout + +{ +\end_layout + +\begin_layout Plain Layout + + size_t i, + j; +\end_layout + +\begin_layout Plain Layout + + assert(n >= KK); +\end_layout + +\begin_layout Plain Layout + + for (j = 0; + j < KK; + j++) +\end_layout + +\begin_layout Plain Layout + + out[j] = ran_u[j]; +\end_layout + +\begin_layout Plain Layout + + for (; + j < n; + j++) +\end_layout + +\begin_layout Plain Layout + + out[j] = fmod(1. + + out[j-KK] - out[j-LL], + 1.); +\end_layout + +\begin_layout Plain Layout + + for (i = 0; + i < LL; + i++, + j++) +\end_layout + +\begin_layout Plain Layout + + ran_u[i] = fmod(1. + + out[j-KK] - out[j-LL], + 1.); +\end_layout + +\begin_layout Plain Layout + + for (; + i < KK; + i++, + j++) +\end_layout + +\begin_layout Plain Layout + + ran_u[i] = fmod(1. + + out[j-KK] - ran_x[j-LL], + 1.); +\end_layout + +\begin_layout Plain Layout + +} +\end_layout + +\begin_layout Plain Layout + +\end_layout + +\begin_layout Plain Layout + +void ranf_start(long seed) +\end_layout + +\begin_layout Plain Layout + +{ +\end_layout + +\begin_layout Plain Layout + + ranf_start(seed); +\end_layout + +\begin_layout Plain Layout + + for (size_t i = 0; + i < KK; + i++) +\end_layout + +\begin_layout Plain Layout + + ran_u[i] = (double)ran_x[i] / MM; +\end_layout + +\begin_layout Plain Layout + +} +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc12[M21] +\end_layout + +\end_inset + +What random number generator would be suitable for a minicomputer that does arithmetic only on integers in the range +\begin_inset Formula $[-32768..32767]$ +\end_inset + +? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We could use one of the generators with very large moduli from exercise 3.2.1.1–14. + We could also use running generators like the one in the text +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc15[25] +\end_layout + +\end_inset + +Write C code that makes it convenient to generate the random integers obtained from +\emph on +ran_array +\emph default + by discarding all but the first 100 of every 1009 elements, + as recommended in the text. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset listings +lstparams "language=C,numbers=left,basicstyle={\normalsize\sffamily},breaklines=true" +inline false +status open + +\begin_layout Plain Layout + +long next() +\end_layout + +\begin_layout Plain Layout + +{ +\end_layout + +\begin_layout Plain Layout + + static long buf[1009], + next = 100; +\end_layout + +\begin_layout Plain Layout + + if (next == 100) { +\end_layout + +\begin_layout Plain Layout + + ran_array(buf, + sizeof(buf) / sizeof(buf[0])); +\end_layout + +\begin_layout Plain Layout + + next = 0; +\end_layout + +\begin_layout Plain Layout + + } +\end_layout + +\begin_layout Plain Layout + + return buf[next++]; +\end_layout + +\begin_layout Plain Layout + +} +\end_layout + +\end_inset + + +\end_layout + +\end_body +\end_document diff --git a/vol2/4.1.lyx b/vol2/4.1.lyx new file mode 100644 index 0000000..b68ec0b --- /dev/null +++ b/vol2/4.1.lyx @@ -0,0 +1,1922 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 620 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass book +\begin_preamble +\input defs +\end_preamble +\use_default_options true +\maintain_unincluded_children no +\language english +\language_package default +\inputencoding utf8 +\fontencoding auto +\font_roman "default" "default" +\font_sans "default" "default" +\font_typewriter "default" "default" +\font_math "auto" "auto" +\font_default_family default +\use_non_tex_fonts false +\font_sc false +\font_roman_osf false +\font_sans_osf false +\font_typewriter_osf false +\font_sf_scale 100 100 +\font_tt_scale 100 100 +\use_microtype false +\use_dash_ligatures true +\graphics default +\default_output_format default +\output_sync 0 +\bibtex_command default +\index_command default +\float_placement class +\float_alignment class +\paperfontsize default +\spacing single +\use_hyperref false +\papersize default +\use_geometry false +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\cite_engine basic +\cite_engine_type default +\biblio_style plain +\use_bibtopic false +\use_indices false +\paperorientation portrait +\suppress_date false +\justification true +\use_refstyle 1 +\use_formatted_ref 0 +\use_minted 0 +\use_lineno 0 +\index Index +\shortcut idx +\color #008000 +\end_index +\secnumdepth 3 +\tocdepth 3 +\paragraph_separation indent +\paragraph_indentation default +\is_math_indent 0 +\math_numbering_side default +\quotes_style english +\dynamic_quotes 0 +\papercolumns 1 +\papersides 1 +\paperpagestyle default +\tablestyle default +\tracking_changes false +\output_changes false +\change_bars false +\postpone_fragile_content false +\html_math_output 0 +\html_css_as_file 0 +\html_be_strict false +\docbook_table_output 0 +\docbook_mathml_prefix 1 +\end_header + +\begin_body + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc2[24] +\end_layout + +\end_inset + +Consider the following four number systems: +\end_layout + +\begin_layout Enumerate +binary (signed magnitude); +\end_layout + +\begin_layout Enumerate +negabinary (radix +\begin_inset Formula $-2$ +\end_inset + +); +\end_layout + +\begin_layout Enumerate +balanced ternary; + and +\end_layout + +\begin_layout Enumerate +radix +\begin_inset Formula $b=\frac{1}{10}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +Use each of these four number systems to express each of the following three numbers: +\end_layout + +\begin_layout Enumerate +\begin_inset Formula $-49$ +\end_inset + +; +\end_layout + +\begin_layout Enumerate +\begin_inset Formula $-3\frac{1}{7}$ +\end_inset + + (show the repeating cycle); +\end_layout + +\begin_layout Enumerate +\begin_inset Formula $\pi$ +\end_inset + + (to a few significant figures). +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Enumerate +\begin_inset Formula $-49\to-110001$ +\end_inset + +. + Multiplying by 2, + +\begin_inset Formula $\frac{1}{7}\to\frac{2}{7}\to\frac{4}{7}\to1+\frac{1}{7}$ +\end_inset + +, + so +\begin_inset Formula $-3\frac{1}{7}\to-11.\overbrace{001}$ +\end_inset + +. + Finally, + +\begin_inset Formula $\pi\to11.00100100001111...$ +\end_inset + + +\end_layout + +\begin_layout Enumerate +The trick is to express the number in binary and, + for the odd positions (the ones where +\begin_inset Formula $(-2)^{k}$ +\end_inset + + is negative), + add 1 to the part of the number on the right, + because we are subtracting +\begin_inset Formula $2^{k}$ +\end_inset + + instead of adding so we compensate for that. + For negative numbers, + we represent them in two's complement before this change, + effectively adding +\begin_inset Formula $2^{M}$ +\end_inset + + for some large +\begin_inset Formula $M$ +\end_inset + +, + and after it we drop that upper bit to subtract +\begin_inset Formula $2^{M}$ +\end_inset + +. + Thus +\begin_inset Formula $-49\to...111001111\to11010011$ +\end_inset + +, + +\begin_inset Formula $-3\frac{1}{7}\to...1100.\overbrace{110110}\to1101.\overbrace{001011}$ +\end_inset + +, + +\begin_inset Formula $\pi\to111.01100100010000...$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +We proceed as in the text: + +\begin_inset Formula +\begin{align*} +-49 & \to-1211\to...11102200\to\overline{1}11\overline{1}\overline{1};\\ +-3\frac{1}{7} & \to-10.\overbrace{010212}\to\dots1101.\overbrace{100122}\to\overline{1}0.\overbrace{0\overline{1}\overline{1}011};\\ +\pi & \to10.010211012\dots\to...1121.122022201\dots\to10.011\overline{1}111\overline{1}0\dots. +\end{align*} + +\end_inset + + +\end_layout + +\begin_layout Enumerate +This is like the decimal system but backwards, + so +\begin_inset Formula $-49\to-9.4$ +\end_inset + +, + +\begin_inset Formula $-3\frac{1}{7}\to-\overbrace{758241}3$ +\end_inset + +, + +\begin_inset Formula $\pi\to...51413$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc5[00] +\end_layout + +\end_inset + +Explain why a negative integer in nines' complement notation has a representation in ten's complement notation that is always one greater, + if the representations are regarded as positive. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Ten's complement of a negative number +\begin_inset Formula $s$ +\end_inset + + is +\begin_inset Formula $10^{M}+s$ +\end_inset + +, + for a suitably large integer +\begin_inset Formula $M$ +\end_inset + +, + while nines' complement is +\begin_inset Formula $(10^{M}-1)+s$ +\end_inset + +, + so the ten's complement is one greater. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc8[M10] +\end_layout + +\end_inset + +Prove Eq. + (5). +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +The part at the left is +\begin_inset Formula $\sum_{j}a_{j}b^{j}$ +\end_inset + +, + while the part at the right is +\begin_inset Formula $\sum_{j}A_{j}b^{kj}$ +\end_inset + +, + but +\begin_inset Formula $A_{j}=\sum_{i=0}^{k-1}a_{kj+i}b^{i}$ +\end_inset + +, + so this is +\begin_inset Formula +\[ +\sum_{j}A_{j}b^{kj}=\sum_{j}\sum_{i=0}^{k-1}(a_{kj+i}b^{i})b^{kj}=\sum_{j}\sum_{i=0}^{k-1}(a_{kj+i}b^{kj+i})=\sum_{j}a_{j}b^{j}. +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc9[15] +\end_layout + +\end_inset + +Change the following +\emph on +octal +\emph default + numbers to +\emph on +hexadecimal +\emph default + notation, + using the hexadecimal digits +\family typewriter +0 +\family default +, + +\family typewriter +1 +\family default +, + ..., + +\family typewriter +9 +\family default +, + +\family typewriter +A +\family default +, + +\family typewriter +B +\family default +, + +\family typewriter +C +\family default +, + +\family typewriter +D +\family default +, + +\family typewriter +E +\family default +, + +\family typewriter +F +\family default +: + 12; + 5655; + 2550276; + 76545336; + 3726755. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We use Eq. + (5) with base 2. +\end_layout + +\begin_layout Standard +\align center +\begin_inset Tabular +<lyxtabular version="3" rows="6" columns="3"> +<features tabularvalignment="middle"> +<column alignment="right" valignment="top"> +<column alignment="right" valignment="top"> +<column alignment="right" valignment="top"> +<row> +<cell alignment="right" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +Octal +\end_layout + +\end_inset +</cell> +<cell alignment="right" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +Binary +\end_layout + +\end_inset +</cell> +<cell alignment="right" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +Hexadecimal +\end_layout + +\end_inset +</cell> +</row> +<row> +<cell alignment="right" valignment="top" topline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +12 +\end_layout + +\end_inset +</cell> +<cell alignment="right" valignment="top" topline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +1 010 +\end_layout + +\end_inset +</cell> +<cell alignment="right" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +A +\end_layout + +\end_inset +</cell> +</row> +<row> +<cell alignment="right" valignment="top" topline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +5655 +\end_layout + +\end_inset +</cell> +<cell alignment="right" valignment="top" topline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +101 110 101 101 +\end_layout + +\end_inset +</cell> +<cell alignment="right" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +BAD +\end_layout + +\end_inset +</cell> +</row> +<row> +<cell alignment="right" valignment="top" topline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +2550276 +\end_layout + +\end_inset +</cell> +<cell alignment="right" valignment="top" topline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +10 101 101 000 010 111 110 +\end_layout + +\end_inset +</cell> +<cell alignment="right" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +AD0BE +\end_layout + +\end_inset +</cell> +</row> +<row> +<cell alignment="right" valignment="top" topline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +76545336 +\end_layout + +\end_inset +</cell> +<cell alignment="right" valignment="top" topline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +111 110 101 100 101 011 011 110 +\end_layout + +\end_inset +</cell> +<cell alignment="right" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +FACADE +\end_layout + +\end_inset +</cell> +</row> +<row> +<cell alignment="right" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +3726755 +\end_layout + +\end_inset +</cell> +<cell alignment="right" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +11 111 010 110 111 101 101 +\end_layout + +\end_inset +</cell> +<cell alignment="right" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +FADED +\end_layout + +\end_inset +</cell> +</row> +</lyxtabular> + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset Note Comment +status open + +\begin_layout Plain Layout +Is this what academics do when they get bored? +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc13[M21] +\end_layout + +\end_inset + +In the decimal system there are some numbers with two infinite decimal expansions; + for example, + +\begin_inset Formula $2.3599999...=2.3600000...$ +\end_inset + +. + Does the +\emph on +negadecimal +\emph default + (base +\begin_inset Formula $-10$ +\end_inset + +) system have unique expansions, + or are there real numbers with two different infinite expansions in this base also? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +There are real numbers with two different infinite expansions: + +\begin_inset Formula +\[ +\tfrac{1}{11}=0.090909...=(0.090909...)_{-10}=(1.909090...)_{-10}. +\] + +\end_inset + +Effectively, + +\begin_inset Formula $(0.090909...)_{-10}=\sum_{k\geq1}9\cdot(-10)^{-2k}=9\sum_{k\geq1}100^{-k}=9\frac{\frac{1}{100}}{\frac{99}{100}}=\frac{1}{11}$ +\end_inset + +, + but +\begin_inset Formula $(1.909090...)_{-10}=1+\sum_{k\geq1}9\cdot(-10)^{-2k+1}=1-90\sum_{k\geq1}100^{-k}=1-90\frac{1}{99}=1-\frac{10}{11}=\frac{1}{11}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc19[23] +\end_layout + +\end_inset + +(David W. + Matula.) Let +\begin_inset Formula $D$ +\end_inset + + be a set of +\begin_inset Formula $b$ +\end_inset + + integers, + containing exactly one solution to the congruence +\begin_inset Formula $x\equiv j\pmod b$ +\end_inset + + for +\begin_inset Formula $0\leq j<b$ +\end_inset + +. + Prove that all integers (positive, + negative, + or zero) can be represented in the form +\begin_inset Formula $m=(a_{n}\dots a_{0})_{b}$ +\end_inset + +, + where all the +\begin_inset Formula $a_{j}$ +\end_inset + + are in +\begin_inset Formula $D$ +\end_inset + +, + if and only if all integers in the range +\begin_inset Formula $l\leq m\leq u$ +\end_inset + + can be so represented, + where +\begin_inset Formula $l=-\max\{a\mid a\in D\}/(b-1)$ +\end_inset + + and +\begin_inset Formula $u=-\min\{a\mid a\in D\}/(b-1)$ +\end_inset + +. + For example, + +\begin_inset Formula $D=\{-1,0,\dots,b-2\}$ +\end_inset + + satisfies the conditions for all +\begin_inset Formula $b\geq3$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +For the statement to make sense, + we need +\begin_inset Formula $b\geq2$ +\end_inset + +. +\end_layout + +\begin_layout Itemize +\begin_inset Argument item:1 +status open + +\begin_layout Plain Layout +\begin_inset Formula $\implies]$ +\end_inset + + +\end_layout + +\end_inset + +Obvious. +\end_layout + +\begin_layout Itemize +\begin_inset Argument item:1 +status open + +\begin_layout Plain Layout +\begin_inset Formula $\impliedby]$ +\end_inset + + +\end_layout + +\end_inset + +Take an arbitrary +\begin_inset Formula $m\in\mathbb{Z}$ +\end_inset + +. + If +\begin_inset Formula $l\leq m\leq u$ +\end_inset + +, + we are done. + Otherwise, + let +\begin_inset Formula $q$ +\end_inset + + and +\begin_inset Formula $r$ +\end_inset + + be the quotient and remainder of dividing +\begin_inset Formula $m$ +\end_inset + + by +\begin_inset Formula $b$ +\end_inset + +, + and let +\begin_inset Formula $x\in D$ +\end_inset + + be such that +\begin_inset Formula $x\equiv r\pmod b$ +\end_inset + +. + Then write +\begin_inset Formula $x$ +\end_inset + + and, + if +\begin_inset Formula $k\in\mathbb{Z}$ +\end_inset + + is such that +\begin_inset Formula $x=kb+r$ +\end_inset + +, + write the number +\begin_inset Formula $q-k$ +\end_inset + + to the right of the +\begin_inset Formula $x$ +\end_inset + + we just wrote by applying this same process. +\end_layout + +\begin_deeper +\begin_layout Standard +We have to prove that this algorithm terminates. + First we note that there exists at least an integer between +\begin_inset Formula $l$ +\end_inset + + and +\begin_inset Formula $u$ +\end_inset + +, + because there are +\begin_inset Formula $b$ +\end_inset + + integers in +\begin_inset Formula $D$ +\end_inset + + and so the maximum and minimum must differ by at least +\begin_inset Formula $b-1$ +\end_inset + +, + and so +\begin_inset Formula $u-l\geq1$ +\end_inset + +. + This means that necessarily +\begin_inset Formula $l\leq0$ +\end_inset + + and +\begin_inset Formula $u\geq0$ +\end_inset + +, + for if +\begin_inset Formula $l>0$ +\end_inset + +, + then all numbers in +\begin_inset Formula $D$ +\end_inset + + are negative, + but the integers between +\begin_inset Formula $l$ +\end_inset + + and +\begin_inset Formula $u$ +\end_inset + + are positive so they couldn't be represented in the given form, +\begin_inset Formula $\#$ +\end_inset + + and a similar thing would happen if +\begin_inset Formula $u<0$ +\end_inset + +. + Now, + in the algorithm above, + +\begin_inset Formula $q-k=\lfloor\frac{m}{b}\rfloor-k=\frac{m-r}{b}-\frac{x-r}{b}=\frac{m-x}{b}$ +\end_inset + +. + With this, + if +\begin_inset Formula $m>u$ +\end_inset + +, + then +\begin_inset Formula $m(b-1)>-\min D$ +\end_inset + +, + but and therefore +\begin_inset Formula +\[ +m-(q-k)=m-\frac{m-x}{b}=\frac{m(b-1)+x}{b}>\frac{-\min D+\min D}{b}=0, +\] + +\end_inset + +so +\begin_inset Formula $q-k<m$ +\end_inset + +, + and +\begin_inset Formula +\[ +m+(q-k)=\frac{m(b+1)-x}{b}>m-\frac{\max D}{b}\geq m+l, +\] + +\end_inset + +so +\begin_inset Formula $q-k\geq l$ +\end_inset + +. + This means that, + on each step, + +\begin_inset Formula $m$ +\end_inset + + is smaller by at least 1, + but it doesn't become smaller than +\begin_inset Formula $l$ +\end_inset + +, + so it eventually reaches the interval +\begin_inset Formula $[l,u]$ +\end_inset + + in at most +\begin_inset Formula $|m-u|$ +\end_inset + + steps. + And if +\begin_inset Formula $m<l$ +\end_inset + +, + then +\begin_inset Formula $m(b-1)<-\max D$ +\end_inset + +, + so +\begin_inset Formula +\[ +m-(q-k)=\frac{m(b-1)+x}{b}<\frac{-\max D+\max D}{b}=0, +\] + +\end_inset + +so +\begin_inset Formula $q-k>m$ +\end_inset + +, + and +\begin_inset Formula +\[ +m+(q-k)=\frac{m(b+1)-x}{b}<m-\frac{\min D}{b}\leq m+u, +\] + +\end_inset + + so +\begin_inset Formula $q-k\leq u$ +\end_inset + +, + and a similar reasoning applies. +\end_layout + +\end_deeper +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc21[M22] +\end_layout + +\end_inset + +(C. + E. + Shannon.) Can every real number (positive, + negative, + or zero) be expressed in a +\begin_inset Quotes eld +\end_inset + +balanced decimal +\begin_inset Quotes erd +\end_inset + + system, + that is, + in the form +\begin_inset Formula $\sum_{k\leq n}a_{k}10^{k}$ +\end_inset + +, + for some integer +\begin_inset Formula $n$ +\end_inset + + and some sequence +\begin_inset Formula $a_{n},a_{n-1},a_{n-2},\dots$ +\end_inset + +, + where each +\begin_inset Formula $a_{k}$ +\end_inset + + is one of the ten numbers +\begin_inset Formula $\{-4\frac{1}{2},-3\frac{1}{2},-2\frac{1}{2},-1\frac{1}{2},-\frac{1}{2},\frac{1}{2},1\frac{1}{2},2\frac{1}{2},3\frac{1}{2},4\frac{1}{2}\}$ +\end_inset + +? + (Although zero is not one of the allowed digits, + we implicitly assume that +\begin_inset Formula $a_{n+1},a_{n+2},\dots$ +\end_inset + + are zero.) Find all representations of zero in this number system, + and find all representations of unity. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Yes, + we can do something similar to the construction of balanced ternary. + First, + we add +\begin_inset Formula $5\cdot10^{n+1}$ +\end_inset + + to the number, + and then we subtract +\begin_inset Formula $4\frac{1}{2}$ +\end_inset + + from each digit from the +\begin_inset Formula $(n+1)$ +\end_inset + +st to the right. +\end_layout + +\begin_layout Standard +For a sum in the given form to be 0, + +\begin_inset Formula $a_{n}10^{n}$ +\end_inset + + must equal +\begin_inset Formula $-\sum_{k<n}a_{k}10^{k}$ +\end_inset + +. + The biggest value we can write as +\begin_inset Formula $\sum_{k<n}a_{k}10^{k}$ +\end_inset + + is +\begin_inset Formula $5\cdot10^{n-1}=10^{n}/2$ +\end_inset + +, + which we can only reach if all those +\begin_inset Formula $a_{k}=4\frac{1}{2}$ +\end_inset + +, + and the smallest is +\begin_inset Formula $-10^{n}/2$ +\end_inset + +, + where all the +\begin_inset Formula $a_{k}=-4\frac{1}{2}$ +\end_inset + +, + so the representations are +\begin_inset Quotes eld +\end_inset + + +\begin_inset Formula $-\frac{1}{2},4\frac{1}{2},4\frac{1}{2},4\frac{1}{2},\dots$ +\end_inset + + +\begin_inset Quotes erd +\end_inset + + and +\begin_inset Quotes eld +\end_inset + + +\begin_inset Formula $\frac{1}{2},-4\frac{1}{2},-4\frac{1}{2},-4\frac{1}{2},\dots$ +\end_inset + + +\begin_inset Quotes erd +\end_inset + +, + with the decimal point in any arbitrary position. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +begin{sloppypar} +\end_layout + +\end_inset + +To get one, + we need +\begin_inset Formula $\frac{1}{2}+\frac{1}{2}$ +\end_inset + + or +\begin_inset Formula $1\frac{1}{2}-\frac{1}{2}$ +\end_inset + +, + so either +\begin_inset Quotes eld +\end_inset + + +\begin_inset Formula $\frac{1}{2};4\frac{1}{2},\dots,4\frac{1}{2},\dots$ +\end_inset + + +\begin_inset Quotes erd +\end_inset + + or +\begin_inset Quotes eld +\end_inset + + +\begin_inset Formula $1\frac{1}{2};-4\frac{1}{2},\dots,-4\frac{1}{2},\dots$ +\end_inset + + +\begin_inset Quotes erd +\end_inset + +, + or +\begin_inset Quotes eld +\end_inset + + +\begin_inset Formula $\frac{1}{2},-4\frac{1}{2},\dots,-4\frac{1}{2},-3\frac{1}{2},-4\frac{1}{2},\dots,-4\frac{1}{2},\dots$ +\end_inset + + +\begin_inset Quotes erd +\end_inset + + or +\begin_inset Quotes eld +\end_inset + + +\begin_inset Formula $\frac{1}{2},-4\frac{1}{2},\dots,-4\frac{1}{2};4\frac{1}{2},\dots,4\frac{1}{2},\dots$ +\end_inset + + +\begin_inset Quotes erd +\end_inset + +, + which stem from representing +\begin_inset Formula $\frac{1}{2}$ +\end_inset + + and +\begin_inset Formula $1\frac{1}{2}$ +\end_inset + + in a way similar to the one used to represent the zero above. + Here the semicolon represents the radix point. + The most significant digit must be positive and to the left of the radix point, + and we can use this fact to show that these are all the ways that the number 1 can be represented in this system. +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +end{sloppypar} +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc28[M24] +\end_layout + +\end_inset + +Show that every nonzero complex number of the form +\begin_inset Formula $a+b\text{i}$ +\end_inset + + where +\begin_inset Formula $a$ +\end_inset + + and +\begin_inset Formula $b$ +\end_inset + + are integers has a unique +\begin_inset Quotes eld +\end_inset + +revolving binary representation +\begin_inset Quotes erd +\end_inset + + +\begin_inset Formula +\[ +(1+\text{i})^{e_{0}}+\text{i}(1+\text{i})^{e_{1}}-(1+\text{i})^{e_{2}}-\text{i}(1+\text{i})^{e_{3}}+\dots+\text{i}^{t}(1+\text{i})^{e_{t}}, +\] + +\end_inset + +where +\begin_inset Formula $e_{0}<e_{1}<\dots<e_{t}$ +\end_inset + +. + (Compare with exercise 27.) +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +First we show that such representation exists by providing an algorithm for getting it from a number +\begin_inset Formula $c\in\mathbb{Z}+\text{i}\mathbb{Z}$ +\end_inset + +: +\end_layout + +\begin_layout Enumerate +[Initialize.] Set +\begin_inset Formula $s\gets0$ +\end_inset + + and +\begin_inset Formula $e\gets0$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +\begin_inset CommandInset label +LatexCommand label +name "enu:e4128b" + +\end_inset + +[Case +\begin_inset Formula $(1+\text{i})^{0}$ +\end_inset + +.] If +\begin_inset Formula $\text{Re}c$ +\end_inset + + is odd and +\begin_inset Formula $\text{Im}c$ +\end_inset + + is even, + or vice versa, + write down +\begin_inset Formula $\text{i}^{s}(1+\text{i})^{e}$ +\end_inset + + and set +\begin_inset Formula $s\gets s+1$ +\end_inset + + and +\begin_inset Formula $c\gets-\text{i}(c-1)$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +\begin_inset CommandInset label +LatexCommand label +name "enu:e4128c" + +\end_inset + +[Case +\begin_inset Formula $(1+\text{i})^{1}$ +\end_inset + +.] If +\begin_inset Formula $\text{Re}c$ +\end_inset + + is odd [if, + and only if, + +\begin_inset Formula $\text{Im}c$ +\end_inset + + is odd,] write down +\begin_inset Formula $\text{i}^{s}(1+\text{i})^{e+1}$ +\end_inset + + and set +\begin_inset Formula $s\gets s+1$ +\end_inset + + and +\begin_inset Formula $c\gets-\text{i}(c-1-\text{i})$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +\begin_inset CommandInset label +LatexCommand label +name "enu:e4128d" + +\end_inset + +[Iterate.] If +\begin_inset Formula $c\neq0$ +\end_inset + +, + set +\begin_inset Formula $e\gets e+2$ +\end_inset + + and +\begin_inset Formula $c\gets\frac{c}{2\text{i}}$ +\end_inset + + and go back to step +\begin_inset CommandInset ref +LatexCommand ref +reference "enu:e4128b" +plural "false" +caps "false" +noprefix "false" +nolink "false" + +\end_inset + +. +\end_layout + +\begin_layout Standard +The algorithm always maintains the invariant that +\begin_inset Formula $c_{0}=w+\text{i}^{s}(1+\text{i})^{e}c$ +\end_inset + +, + where +\begin_inset Formula $c_{0}$ +\end_inset + + is the original value of +\begin_inset Formula $c$ +\end_inset + + and +\begin_inset Formula $w$ +\end_inset + + is the sum of the terms that have been written, + so when it finishes, + +\begin_inset Formula $w=c_{0}$ +\end_inset + +, + and it's trivial to see that +\begin_inset Formula $w$ +\end_inset + + is a revolving binary representation. + To see that the algorithm terminates, + we see that, + after each iteration, + +\begin_inset Formula $c$ +\end_inset + + has a smaller magnitude except if originally +\begin_inset Formula $c=-1,-\text{i},-1-\text{i}$ +\end_inset + +, + but in these cases the iteration after that will lower the magnitude of +\begin_inset Formula $c$ +\end_inset + +, + preventing an infinite loop: +\begin_inset Formula +\begin{align*} +-1 & \overset{\eqref{enu:e4128b}}{\to}2\text{i}\overset{\eqref{enu:e4128d}}{\to}1, & -\text{i} & \overset{\eqref{enu:e4128b}}{\to}\text{i}-1\overset{\eqref{enu:e4128c}}{\to}2\text{i}\overset{\eqref{enu:e4128d}}{\to}1, & -1-\text{i} & \overset{\eqref{enu:e4128c}}{\to}2\text{i}-2\overset{\eqref{enu:e4128d}}{\to}\text{i}+1. +\end{align*} + +\end_inset + + +\end_layout + +\begin_layout Standard +For the uniqueness, + let +\begin_inset Formula $\sum_{k=0}^{n}\text{i}^{k}(1+\text{i})^{e_{k}}=\sum_{j=0}^{m}\text{i}^{j}(1+\text{i})^{f_{j}}$ +\end_inset + + ( +\begin_inset Formula $n,m,e_{k},f_{j}\in\mathbb{N}$ +\end_inset + +, + +\begin_inset Formula $e_{0}<\dots<e_{n}$ +\end_inset + +, + +\begin_inset Formula $f_{0}<\dots<f_{m}$ +\end_inset + +) be two different representations of the same number, + and let +\begin_inset Formula $s\leq m,n$ +\end_inset + + be the first index where they differ (let's say +\begin_inset Formula $e_{s}<f_{s}$ +\end_inset + +). + Then we may remove all terms before +\begin_inset Formula $s$ +\end_inset + + in both representations and divide each remaining term by +\begin_inset Formula $\text{i}^{s}(1+\text{i})^{e_{s}}$ +\end_inset + +. + But then, + the second representation is a multiple of +\begin_inset Formula $(1+\text{i})^{\min\{e_{s}+1,f_{s}\}}$ +\end_inset + + in +\begin_inset Formula $\mathbb{Z}+\text{i}\mathbb{Z}$ +\end_inset + + but the first one isn't. +\begin_inset Formula $\#$ +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc34[22] +\end_layout + +\end_inset + +(G. + W. + Reitweisner, + 1960.) Explain how to represent a given integer +\begin_inset Formula $n$ +\end_inset + + in the form +\begin_inset Formula $(\dots a_{2}a_{1}a_{0})_{2}$ +\end_inset + +, + where each +\begin_inset Formula $a_{j}$ +\end_inset + + is +\begin_inset Formula $-1$ +\end_inset + +, + 0, + or 1, + using the fewest nonzero digits. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +If +\begin_inset Formula $n=0$ +\end_inset + +, + we just write 0. + If +\begin_inset Formula $n>0$ +\end_inset + +, + we take +\begin_inset Formula $k\in\mathbb{N}$ +\end_inset + + such that +\begin_inset Formula $|2^{k}-n|$ +\end_inset + + is minimum, + write a 1 at position +\begin_inset Formula $k$ +\end_inset + +, + and then write +\begin_inset Formula $n-2^{k}$ +\end_inset + + on the +\begin_inset Formula $k$ +\end_inset + + positions to the right. + If +\begin_inset Formula $n<0$ +\end_inset + +, + we do the same except that first we write +\begin_inset Formula $\overline{1}$ +\end_inset + + instead of 1. +\end_layout + +\begin_layout Standard +Now we prove that this in fact results in the representation fewest number of nonzero digits. + We only need to prove it for positive +\begin_inset Formula $n$ +\end_inset + +. +\end_layout + +\begin_layout Standard +Now, + if +\begin_inset Formula $n=2^{k}$ +\end_inset + + or +\begin_inset Formula $3\cdot2^{k}$ +\end_inset + + for some +\begin_inset Formula $k\in\mathbb{N}$ +\end_inset + +, + the statement is trivial. + Otherwise, + if +\begin_inset Formula $2^{k}<n<2^{k+1}$ +\end_inset + + for some +\begin_inset Formula $k\in\mathbb{N}$ +\end_inset + +, + we operate by induction. + First note that, + for such +\begin_inset Formula $n$ +\end_inset + +, + +\begin_inset Formula $k\geq2$ +\end_inset + +, + and that all possible representations start with a 1 at position +\begin_inset Formula $k$ +\end_inset + + or +\begin_inset Formula $k+1$ +\end_inset + +. +\end_layout + +\begin_layout Standard +If +\begin_inset Formula $n<3\cdot2^{k-1}$ +\end_inset + +, + let +\begin_inset Formula $\sigma(s)$ +\end_inset + + be the minimum number of nonzero digits in a representation of +\begin_inset Formula $s$ +\end_inset + +, + then if we start with a 1 at position +\begin_inset Formula $k$ +\end_inset + + we would have a minimum of +\begin_inset Formula $1+\sigma(n-2^{k})$ +\end_inset + + nonzero digits, + whereas if we start at position +\begin_inset Formula $k+1$ +\end_inset + + we would have a minimum of +\begin_inset Formula $1+\sigma(2^{k+1}-n)$ +\end_inset + +. + Let +\begin_inset Formula $t\coloneqq2^{k+1}-n>2^{k-1}$ +\end_inset + +, + +\begin_inset Formula $t$ +\end_inset + + would need to have its most significant digit in position +\begin_inset Formula $k$ +\end_inset + + or +\begin_inset Formula $k-1$ +\end_inset + +, + but any representation of +\begin_inset Formula $t$ +\end_inset + + that starts at position +\begin_inset Formula $k$ +\end_inset + + can be converted into one of +\begin_inset Formula $2^{k}-n$ +\end_inset + + by removing the 1 at that position, + and any one starting at position +\begin_inset Formula $k-1$ +\end_inset + + can be converted into one of +\begin_inset Formula $2^{k}-n$ +\end_inset + + by swapping the sign in that position, + so in general +\begin_inset Formula $\sigma(t)=\sigma(2^{k+1}-n)\geq\sigma(2^{k}-n)=\sigma(n-2^{k})$ +\end_inset + +. +\end_layout + +\begin_layout Standard +A similar argument shows that, + if +\begin_inset Formula $n>3\cdot2^{k-1}$ +\end_inset + +, + then +\begin_inset Formula $\sigma(n-2^{k})\geq\sigma(2^{k+1}-n)$ +\end_inset + +. +\end_layout + +\end_body +\end_document diff --git a/vol2/index.lyx b/vol2/index.lyx new file mode 100644 index 0000000..816a76b --- /dev/null +++ b/vol2/index.lyx @@ -0,0 +1,1394 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 620 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass book +\begin_preamble +\input{../defs} + +\makeatletter +\newcommand{\biggg}{\bBigg@\thr@@} +\newcommand{\Biggg}{\bBigg@{3.5}} +\makeatother +\end_preamble +\use_default_options true +\maintain_unincluded_children no +\language english +\language_package default +\inputencoding utf8 +\fontencoding auto +\font_roman "default" "default" +\font_sans "default" "default" +\font_typewriter "default" "default" +\font_math "auto" "auto" +\font_default_family default +\use_non_tex_fonts false +\font_sc false +\font_roman_osf false +\font_sans_osf false +\font_typewriter_osf false +\font_sf_scale 100 100 +\font_tt_scale 100 100 +\use_microtype true +\use_dash_ligatures true +\graphics default +\default_output_format default +\output_sync 0 +\bibtex_command default +\index_command default +\float_placement class +\float_alignment class +\paperfontsize 10 +\spacing single +\use_hyperref true +\pdf_bookmarks true +\pdf_bookmarksnumbered false +\pdf_bookmarksopen false +\pdf_bookmarksopenlevel 1 +\pdf_breaklinks false +\pdf_pdfborder false +\pdf_colorlinks false +\pdf_backref false +\pdf_pdfusetitle true +\papersize custom +\use_geometry true +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\cite_engine basic +\cite_engine_type default +\biblio_style plain +\use_bibtopic false +\use_indices false +\paperorientation portrait +\suppress_date false +\justification true +\use_refstyle 1 +\use_formatted_ref 0 +\use_minted 0 +\use_lineno 0 +\index Index +\shortcut idx +\color #008000 +\end_index +\paperwidth 198mm +\paperheight 297mm +\leftmargin 23mm +\topmargin 33mm +\rightmargin 43mm +\bottommargin 66mm +\secnumdepth 3 +\tocdepth 3 +\paragraph_separation indent +\paragraph_indentation default +\is_math_indent 0 +\math_numbering_side default +\quotes_style english +\dynamic_quotes 0 +\papercolumns 1 +\papersides 2 +\paperpagestyle fancy +\tablestyle default +\listings_params "basicstyle={\ttfamily}" +\tracking_changes false +\output_changes false +\change_bars false +\postpone_fragile_content false +\html_math_output 0 +\html_css_as_file 0 +\html_be_strict false +\docbook_table_output 0 +\docbook_mathml_prefix 1 +\end_header + +\begin_body + +\begin_layout Title +Exercises on +\emph on +The Art Of Computer Programming +\emph default + +\begin_inset Newline newline +\end_inset + + +\size larger +Volume 2: + Seminumerical Algorithms +\begin_inset Newline newline +\end_inset + +Third Edition +\end_layout + +\begin_layout Author +Juan Marín Noguera +\end_layout + +\begin_layout Standard +\begin_inset CommandInset toc +LatexCommand tableofcontents + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset Note Note +status open + +\begin_layout Plain Layout +Equivalent page size can be obtained with the following layouts (in mm): +\end_layout + +\begin_layout Plain Layout +\begin_inset Tabular +<lyxtabular version="3" rows="3" columns="7"> +<features tabularvalignment="middle"> +<column alignment="center" valignment="top"> +<column alignment="center" valignment="top"> +<column alignment="center" valignment="top"> +<column alignment="center" valignment="top"> +<column alignment="center" valignment="top"> +<column alignment="center" valignment="top"> +<column alignment="center" valignment="top"> +<row> +<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +Height +\end_layout + +\end_inset +</cell> +<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +Width +\end_layout + +\end_inset +</cell> +<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +Top +\end_layout + +\end_inset +</cell> +<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +Bottom +\end_layout + +\end_inset +</cell> +<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +Inner +\end_layout + +\end_inset +</cell> +<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +Outer +\end_layout + +\end_inset +</cell> +<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +Recommended headers +\end_layout + +\end_inset +</cell> +</row> +<row> +<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +297 +\end_layout + +\end_inset +</cell> +<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +198 +\end_layout + +\end_inset +</cell> +<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +33 +\end_layout + +\end_inset +</cell> +<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +66 +\end_layout + +\end_inset +</cell> +<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +23 +\end_layout + +\end_inset +</cell> +<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +43 +\end_layout + +\end_inset +</cell> +<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +Fancy +\end_layout + +\end_inset +</cell> +</row> +<row> +<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +210 +\end_layout + +\end_inset +</cell> +<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +140 +\end_layout + +\end_inset +</cell> +<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +4 +\end_layout + +\end_inset +</cell> +<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +8 +\end_layout + +\end_inset +</cell> +<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +3 +\end_layout + +\end_inset +</cell> +<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +5 +\end_layout + +\end_inset +</cell> +<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> +\begin_inset Text + +\begin_layout Plain Layout +Empty +\end_layout + +\end_inset +</cell> +</row> +</lyxtabular> + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +The first one follows Tschichold's canon except for +\begin_inset Formula $\unit[1]{mm}$ +\end_inset + + given to the inner margin from the outer one to account for a minimal folding. + The golden ratio resulted in way too narrow pages on A5 paper. +\end_layout + +\begin_layout Plain Layout +Proposed notation for in-progress: +\end_layout + +\begin_layout Plain Layout +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +atom = ( +\begin_inset Quotes eld +\end_inset + +A +\begin_inset Quotes erd +\end_inset + +| +\begin_inset Quotes erd +\end_inset + +R +\begin_inset Quotes erd +\end_inset + +) ?( +\begin_inset Quotes eld +\end_inset + +B +\begin_inset Quotes erd +\end_inset + +| +\begin_inset Quotes erd +\end_inset + +M +\begin_inset Quotes erd +\end_inset + +) (( +\begin_inset Quotes eld +\end_inset + +0 +\begin_inset Quotes erd +\end_inset + +.. +\begin_inset Quotes erd +\end_inset + +4 +\begin_inset Quotes erd +\end_inset + +) ( +\begin_inset Quotes eld +\end_inset + +0 +\begin_inset Quotes erd +\end_inset + +.. +\begin_inset Quotes erd +\end_inset + +9 +\begin_inset Quotes erd +\end_inset + +) / +\begin_inset Quotes eld +\end_inset + +@ +\begin_inset Quotes erd +\end_inset + +) / 1DIGIT *DIGIT / *1(1DIGIT *DIGIT) +\begin_inset Quotes eld +\end_inset + +.. +\begin_inset Quotes erd +\end_inset + + *1(1DIGIT *DIGIT) +\end_layout + +\begin_layout Plain Layout + +base = atom / +\begin_inset Quotes eld +\end_inset + +( +\begin_inset Quotes eld +\end_inset + + progress +\begin_inset Quotes eld +\end_inset + +) +\begin_inset Quotes erd +\end_inset + + +\end_layout + +\begin_layout Plain Layout + +intersection = atom / intersection +\begin_inset Quotes eld +\end_inset + +* +\begin_inset Quotes erd +\end_inset + + atom +\end_layout + +\begin_layout Plain Layout + +progress = intersection / progress ( +\begin_inset Quotes eld +\end_inset + ++ +\begin_inset Quotes erd +\end_inset + +/ +\begin_inset Quotes erd +\end_inset + +- +\begin_inset Quotes erd +\end_inset + +) intersection +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +An +\family typewriter +atom +\family default + represents all/recommended exercises, + optionally excluding M or HM/excluding HM, + and up to the given difficulty level/all difficulty levels, + or else a single exercise with the given number, + or a range of exercises (both ends inclusive). + Then +\family typewriter +* +\family default + is used for intersection, + +\family typewriter ++ +\family default + for union, + and +\family typewriter +- +\family default + for set difference. +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +setcounter{chapter}{2} +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Chapter +Random Numbers +\end_layout + +\begin_layout Section +Introduction +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "3.1.lyx" +literal "false" + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout + +\family typewriter +A10+R25+16 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Section +Generating Uniform Random Numbers +\end_layout + +\begin_layout Subsection +The Linear Congruential Method +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "3.2.1.lyx" +literal "false" + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout + +\family typewriter +A10+R25 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsubsection +Choice of modulus +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "3.2.1.1.lyx" +literal "false" + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout + +\family typewriter +A10+R25 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsubsection +Choice of multiplier +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "3.2.1.2.lyx" +literal "false" + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout + +\family typewriter +A10+R25 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsubsection +Potency +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "3.2.1.3.lyx" +literal "false" + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout + +\family typewriter +A10+R25 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsection +Other Methods +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "3.2.2.lyx" +literal "false" + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout + +\family typewriter +A10+R25 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Section +Statistical Tests +\end_layout + +\begin_layout Subsection +General Test Procedures for Studying Random Data +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "3.3.1.lyx" +literal "false" + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout + +\family typewriter +A10+R25 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsection +Empirical Tests +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "3.3.2.lyx" +literal "false" + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout + +\family typewriter +A10+R25 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsection +Theoretical Tests +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "3.3.3.lyx" +literal "false" + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout + +\family typewriter +A10+R25 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsection +The Spectral Test +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "3.3.4.lyx" +literal "false" + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout + +\family typewriter +A10+R25 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Section +Other Types of Random Quantities +\end_layout + +\begin_layout Subsection +Numerical Distributions +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "3.4.1.lyx" +literal "false" + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout + +\family typewriter +A10+R25 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsection +Random Sampling and Shuffling +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "3.4.2.lyx" +literal "false" + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout + +\family typewriter +A10+R25-16 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Section +What Is a Random Sequence? +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "3.5.lyx" +literal "false" + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout + +\family typewriter +A10+R25 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Section +Summary +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "3.6.lyx" +literal "false" + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout + +\family typewriter +A10+R25 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Chapter +Arithmetic +\end_layout + +\begin_layout Section +Positional Number Systems +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "4.1.lyx" +literal "false" + +\end_inset + + +\end_layout + +\begin_layout Section +Floating Point Arithmetic +\end_layout + +\begin_layout Subsection +Single-Precision Calculations +\end_layout + +\begin_layout Subsection +Accuracy of Floating Point Arithmetic +\end_layout + +\begin_layout Subsection +Double-Precision Calculations +\end_layout + +\begin_layout Standard +\begin_inset Note Note +status open + +\begin_layout Plain Layout +7+0; + 5 (0:28) -> 3d, + -1/3 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsection +Distribution of Floating Point Numbers +\end_layout + +\begin_layout Standard +\begin_inset Note Note +status open + +\begin_layout Plain Layout +10+2; + 5, + 13, + 17 (0:58) -> 5d +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Section +Multiple-Precision Arithmetic +\end_layout + +\begin_layout Subsection +The Classical Algorithms +\end_layout + +\begin_layout Standard +\begin_inset Note Note +status open + +\begin_layout Plain Layout +16+4; + 6, + 9, + 11, + 14, + 16, + 19, + 21, + 22, + 30, + 37, + 43 (2:58) -> 12d, + -2/3 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsection +Modular Arithmetic +\end_layout + +\begin_layout Standard +\begin_inset Note Note +status open + +\begin_layout Plain Layout +8+1; + 5, + 7, + 12, + 13 (1:13) -> 4d +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsection +How Fast Can We Multiply? +\end_layout + +\begin_layout Standard +\begin_inset Note Note +status open + +\begin_layout Plain Layout +22+3; + 16, + 19 (0:56) -> 10d, + -2/3 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Section +Radix Conversion +\end_layout + +\begin_layout Standard +\begin_inset Note Note +status open + +\begin_layout Plain Layout +9+2; + 1, + 3, + 12, + 13, + 19 (2:22) -> 8d, + -2/3 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Section +Rational Arithmetic +\end_layout + +\begin_layout Subsection +Fractions +\end_layout + +\begin_layout Standard +\begin_inset Note Note +status open + +\begin_layout Plain Layout +3+1; + 5, + 6, + 8 (0:42) -> 2d, + -2/3 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsection +The Greatest Common Divisor +\end_layout + +\begin_layout Standard +\begin_inset Note Note +status open + +\begin_layout Plain Layout +19+4; + 8, + 10, + 14, + 16, + 17, + 18, + 23, + 40 (3:19) -> 13d, + -1/3 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsection +Analysis of Euclid's Algorithm +\end_layout + +\begin_layout Standard +\begin_inset Note Note +status open + +\begin_layout Plain Layout +17+6; + 1, + 17, + 39, + 50 (1:42) -> 9d, + -2/3 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsection +Factoring into Primes +\end_layout + +\begin_layout Standard +\begin_inset Note Note +status open + +\begin_layout Plain Layout +32+6; + 1, + 8, + 18, + 19, + 24, + 26, + 32, + 35 (3:17) -> 17d +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Section +Polynomial Arithmetic +\end_layout + +\begin_layout Standard +\begin_inset Note Note +status open + +\begin_layout Plain Layout +2+0; + 1, + 4, + 5 (0:31) -> 2d, + -1/3 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsection +Division of Polynomials +\end_layout + +\begin_layout Standard +\begin_inset Note Note +status open + +\begin_layout Plain Layout +15+4; + 1, + 3, + 7, + 8, + 12, + 16, + 18 (2:08) -> 9d, + -1/3 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsection +Factorization of Polynomials +\end_layout + +\begin_layout Standard +\begin_inset Note Note +status open + +\begin_layout Plain Layout +17+5; + 1, + 2, + 10, + 12, + 18, + 22, + 34, + 40 (3:22) -> 13d, + -2/3 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsection +Evaluation of Powers +\end_layout + +\begin_layout Standard +\begin_inset Note Note +status open + +\begin_layout Plain Layout +21+4; + 3, + 5, + 9, + 10, + 12, + 24, + 26, + 36, + 39, + 40 (3:37) -> 14d, + -2/3 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsection +Evaluation of Polynomials +\end_layout + +\begin_layout Standard +\begin_inset Note Note +status open + +\begin_layout Plain Layout +29+10; + 2, + 19, + 20, + 24, + 26, + 29, + 33, + 35, + 44, + 45, + 49, + 51, + 70 (5:24) -> 20d +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Section +Manipulation of Power Series +\end_layout + +\begin_layout Standard +\begin_inset Note Note +status open + +\begin_layout Plain Layout +8+5; + 1, + 4, + 5, + 6, + 8, + 11, + 17 (1:59) -> 7d, + -1/3 +\end_layout + +\end_inset + + +\end_layout + +\end_body +\end_document |
