From 4f670b750af5c11e1eac16d9cd8556455f89f46a Mon Sep 17 00:00:00 2001 From: Juan Marín Noguera Date: Fri, 16 May 2025 22:18:44 +0200 Subject: Changed layout for more manageable volumes --- vol1/0.lyx | 172 +++ vol1/1.1.lyx | 550 +++++++ vol1/1.2.1.lyx | 1705 ++++++++++++++++++++++ vol1/1.2.10.lyx | 1006 +++++++++++++ vol1/1.2.11.1.lyx | 556 +++++++ vol1/1.2.11.2.lyx | 440 ++++++ vol1/1.2.11.3.lyx | 241 +++ vol1/1.2.2.lyx | 1329 +++++++++++++++++ vol1/1.2.3.lyx | 1732 ++++++++++++++++++++++ vol1/1.2.4.lyx | 2433 +++++++++++++++++++++++++++++++ vol1/1.2.5.lyx | 1097 ++++++++++++++ vol1/1.2.6.lyx | 3599 +++++++++++++++++++++++++++++++++++++++++++++ vol1/1.2.7.lyx | 572 ++++++++ vol1/1.2.8.lyx | 1852 +++++++++++++++++++++++ vol1/1.2.9.lyx | 846 +++++++++++ vol1/1.3.1.lyx | 2356 ++++++++++++++++++++++++++++++ vol1/1.3.2.lyx | 3414 +++++++++++++++++++++++++++++++++++++++++++ vol1/1.3.3.lyx | 1630 +++++++++++++++++++++ vol1/1.4.1.lyx | 403 +++++ vol1/1.4.2.lyx | 465 ++++++ vol1/1.4.3.1.lyx | 334 +++++ vol1/1.4.3.2.lyx | 294 ++++ vol1/1.4.4.lyx | 4213 +++++++++++++++++++++++++++++++++++++++++++++++++++++ vol1/2.1.lyx | 568 ++++++++ vol1/2.2.1.lyx | 910 ++++++++++++ vol1/2.2.2.lyx | 563 +++++++ vol1/2.2.3.lyx | 1685 +++++++++++++++++++++ vol1/2.2.4.lyx | 644 ++++++++ vol1/2.2.5.lyx | 606 ++++++++ vol1/2.2.6.lyx | 577 ++++++++ vol1/2.3.1.lyx | 1075 ++++++++++++++ vol1/2.3.2.lyx | 1316 +++++++++++++++++ vol1/2.3.3.lyx | 2031 ++++++++++++++++++++++++++ vol1/2.3.4.1.lyx | 760 ++++++++++ vol1/2.3.4.2.lyx | 859 +++++++++++ vol1/2.3.4.3.lyx | 508 +++++++ vol1/2.3.4.4.lyx | 750 ++++++++++ vol1/2.3.4.5.lyx | 443 ++++++ vol1/2.3.4.6.lyx | 224 +++ vol1/2.3.5.lyx | 199 +++ vol1/2.3.lyx | 884 +++++++++++ vol1/2.4.lyx | 387 +++++ vol1/2.5.lyx | 1706 ++++++++++++++++++++++ vol1/index.lyx | 1835 +++++++++++++++++++++++ 44 files changed, 49769 insertions(+) create mode 100644 vol1/0.lyx create mode 100644 vol1/1.1.lyx create mode 100644 vol1/1.2.1.lyx create mode 100644 vol1/1.2.10.lyx create mode 100644 vol1/1.2.11.1.lyx create mode 100644 vol1/1.2.11.2.lyx create mode 100644 vol1/1.2.11.3.lyx create mode 100644 vol1/1.2.2.lyx create mode 100644 vol1/1.2.3.lyx create mode 100644 vol1/1.2.4.lyx create mode 100644 vol1/1.2.5.lyx create mode 100644 vol1/1.2.6.lyx create mode 100644 vol1/1.2.7.lyx create mode 100644 vol1/1.2.8.lyx create mode 100644 vol1/1.2.9.lyx create mode 100644 vol1/1.3.1.lyx create mode 100644 vol1/1.3.2.lyx create mode 100644 vol1/1.3.3.lyx create mode 100644 vol1/1.4.1.lyx create mode 100644 vol1/1.4.2.lyx create mode 100644 vol1/1.4.3.1.lyx create mode 100644 vol1/1.4.3.2.lyx create mode 100644 vol1/1.4.4.lyx create mode 100644 vol1/2.1.lyx create mode 100644 vol1/2.2.1.lyx create mode 100644 vol1/2.2.2.lyx create mode 100644 vol1/2.2.3.lyx create mode 100644 vol1/2.2.4.lyx create mode 100644 vol1/2.2.5.lyx create mode 100644 vol1/2.2.6.lyx create mode 100644 vol1/2.3.1.lyx create mode 100644 vol1/2.3.2.lyx create mode 100644 vol1/2.3.3.lyx create mode 100644 vol1/2.3.4.1.lyx create mode 100644 vol1/2.3.4.2.lyx create mode 100644 vol1/2.3.4.3.lyx create mode 100644 vol1/2.3.4.4.lyx create mode 100644 vol1/2.3.4.5.lyx create mode 100644 vol1/2.3.4.6.lyx create mode 100644 vol1/2.3.5.lyx create mode 100644 vol1/2.3.lyx create mode 100644 vol1/2.4.lyx create mode 100644 vol1/2.5.lyx create mode 100644 vol1/index.lyx (limited to 'vol1') diff --git a/vol1/0.lyx b/vol1/0.lyx new file mode 100644 index 0000000..a56b5a7 --- /dev/null +++ b/vol1/0.lyx @@ -0,0 +1,172 @@ +#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[00] +\end_layout + +\end_inset + +What does the rating +\begin_inset Quotes eld +\end_inset + + +\emph on +M20 +\emph default + +\begin_inset Quotes erd +\end_inset + + mean? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +A mathematically oriented, + medium difficulty exercise. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc2[10] +\end_layout + +\end_inset + +Of what value can the exercises in a textbook be to the reader? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +It helps to internalize contents by applying them. +\end_layout + +\end_body +\end_document diff --git a/vol1/1.1.lyx b/vol1/1.1.lyx new file mode 100644 index 0000000..9644d3b --- /dev/null +++ b/vol1/1.1.lyx @@ -0,0 +1,550 @@ +#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 + +The text showed how to interchange the values of variables +\begin_inset Formula $m$ +\end_inset + + and +\begin_inset Formula $n$ +\end_inset + +, + using the replacement notation, + by setting +\begin_inset Formula $t\gets m$ +\end_inset + +, + +\begin_inset Formula $m\gets n$ +\end_inset + +, + +\begin_inset Formula $n\gets t$ +\end_inset + +. + Show how the values of the +\emph on +four +\emph default + variables +\begin_inset Formula $(a,b,c,d)$ +\end_inset + + can be rearranged to +\begin_inset Formula $(b,c,d,a)$ +\end_inset + + by a sequence of replacements. + In other words, + the new value of +\begin_inset Formula $a$ +\end_inset + + is to be the original value of +\begin_inset Formula $b$ +\end_inset + +, + etc. + Try to use the minimum number of replacements. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Formula $t\gets a,a\gets b,b\gets c,c\gets d,d\gets t$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc5[12] +\end_layout + +\end_inset + +Show that the +\begin_inset Quotes eld +\end_inset + +Procedure for Reading This Set of Books +\begin_inset Quotes erd +\end_inset + + that appears in the preface actually fails to be a genuine algorithm on at least three of our five counts! + Also mention some differences in format between it and Algorithm E. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +It fails on finiteness (it doesn't have an ending condition), + definiteness (the instructions are not unambiguous), + and effectiveness (solving the Fermat's theorem on the exercises is not +\begin_inset Quotes eld +\end_inset + +sufficiently basic that it can be done exactly and in a finite length of time +\begin_inset Quotes erd +\end_inset + +), + and it may have no output (although, + this time, + this is the output). + It also doesn't have a header, + an ending mark, + or a letter prefix on the steps. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc7[HM21] +\end_layout + +\end_inset + +Let +\begin_inset Formula $U_{m}$ +\end_inset + + be the average number of times that step E1 is executed in Algorithm E, + if +\begin_inset Formula $m$ +\end_inset + + is known and +\begin_inset Formula $n$ +\end_inset + + is allowed to range over all positive integers. + Show that +\begin_inset Formula $U_{m}$ +\end_inset + + is well defined. + Is +\begin_inset Formula $U_{m}$ +\end_inset + + in any way related to +\begin_inset Formula $T_{m}$ +\end_inset + +? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +On average, + it will be the case that +\begin_inset Formula $n>m$ +\end_inset + +, + so after one step, + the two numbers will exchange positions and, + after two steps, + we'll have the same value for +\begin_inset Formula $m$ +\end_inset + + but +\begin_inset Formula $n$ +\end_inset + + will be the remainder of the original values of +\begin_inset Formula $n$ +\end_inset + + and +\begin_inset Formula $m$ +\end_inset + +, + which is uniformly distributed on the integers between +\begin_inset Formula $0$ +\end_inset + + and +\begin_inset Formula $m-1$ +\end_inset + +. + This means +\begin_inset Formula $U_{m}$ +\end_inset + + is two plus the average number of times that E1 is executed if +\begin_inset Formula $m$ +\end_inset + + is known and +\begin_inset Formula $0\leq n0,n>0,T=0$ +\end_inset + +. +\begin_inset Quotes erd +\end_inset + + The additional condition +\begin_inset Quotes eld +\end_inset + + +\begin_inset Formula $T=1$ +\end_inset + + +\begin_inset Quotes erd +\end_inset + + should similarly be appended to +\begin_inset Formula $A2$ +\end_inset + +. + Show how to append additional conditions to the assertions in such a way that any one of +\begin_inset Formula $A1,A2,\dots,A6$ +\end_inset + + implies +\begin_inset Formula $T\leq3n$ +\end_inset + +, + and such that the inductive proof can still be carried out. + (Hence the computation must terminate in at most +\begin_inset Formula $3n$ +\end_inset + + steps.) +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +At +\begin_inset Formula $A3$ +\end_inset + +, + we append +\begin_inset Formula $T\leq3(n-r)-1$ +\end_inset + +. + From +\begin_inset Formula $A2$ +\end_inset + +, + we have +\begin_inset Formula $T=2$ +\end_inset + +, + and since +\begin_inset Formula $c=m>0$ +\end_inset + + and +\begin_inset Formula $d=n>0$ +\end_inset + +, + we have +\begin_inset Formula $rn-r$ +\end_inset + + and +\begin_inset Formula $T\leq3(n-d)+2\leq3(n-r)-3+2=3(n-r)-1$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc15[HM28] +\end_layout + +\end_inset + +( +\emph on +Generalized induction. +\emph default +) The text shows how to prove statements +\begin_inset Formula $P(n)$ +\end_inset + + that depend on a single integer +\begin_inset Formula $n$ +\end_inset + +, + but it does not describe how to prove statements +\begin_inset Formula $P(m,n)$ +\end_inset + + depending on two integers. + In these circumstances a proof is often given by some sort of +\begin_inset Quotes eld +\end_inset + +double induction, +\begin_inset Quotes erd +\end_inset + + which frequently seems confusing. + Actually, + there is an important principle more general than simple induction that applies not only in this case but also to situations in which statements are to be proved about uncountable sets— +for example, + +\begin_inset Formula $P(x)$ +\end_inset + + for all real +\begin_inset Formula $x$ +\end_inset + +. + This general principle is called +\emph on +well-ordering +\emph default +. +\end_layout + +\begin_layout Standard +Let +\begin_inset Quotes eld +\end_inset + + +\begin_inset Formula $\prec$ +\end_inset + + +\begin_inset Quotes erd +\end_inset + + be a relation on a set +\begin_inset Formula $S$ +\end_inset + +, + satisfying the following properties: +\end_layout + +\begin_layout Enumerate +Given +\begin_inset Formula $x$ +\end_inset + +, + +\begin_inset Formula $y$ +\end_inset + +, + and +\begin_inset Formula $z$ +\end_inset + + in +\begin_inset Formula $S$ +\end_inset + +, + if +\begin_inset Formula $x\prec y$ +\end_inset + + and +\begin_inset Formula $y\prec z$ +\end_inset + +, + then +\begin_inset Formula $x\prec z$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Given +\begin_inset Formula $x$ +\end_inset + + and +\begin_inset Formula $y$ +\end_inset + + in +\begin_inset Formula $S$ +\end_inset + +, + exactly one of the following three possibilities is true: + +\begin_inset Formula $x\prec y$ +\end_inset + +, + +\begin_inset Formula $x=y$ +\end_inset + +, + or +\begin_inset Formula $y\prec x$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +If +\begin_inset Formula $A$ +\end_inset + + is any nonempty subset of +\begin_inset Formula $S$ +\end_inset + +, + there is an element +\begin_inset Formula $x$ +\end_inset + + in +\begin_inset Formula $A$ +\end_inset + + with +\begin_inset Formula $x\preceq y$ +\end_inset + + (that is, + +\begin_inset Formula $x\prec y$ +\end_inset + + or +\begin_inset Formula $x=y$ +\end_inset + +) for all +\begin_inset Formula $y$ +\end_inset + + in +\begin_inset Formula $A$ +\end_inset + +. +\end_layout + +\begin_layout Standard +This relation is said to be a well-ordering of +\begin_inset Formula $S$ +\end_inset + +. + For example, + it is clear that the positive integers are well-ordered by the ordinary +\begin_inset Quotes eld +\end_inset + +less than +\begin_inset Quotes erd +\end_inset + + relation, + +\begin_inset Formula $<$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Show that the set of +\emph on +all +\emph default + integers is not well-ordered by +\begin_inset Formula $<$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Define a well-ordering relation on the set of all integers. +\end_layout + +\begin_layout Enumerate +Is the set of all nonnegative real numbers well-ordered by +\begin_inset Formula $<$ +\end_inset + +? +\end_layout + +\begin_layout Enumerate +\begin_inset CommandInset label +LatexCommand label +name "enu:Lexicographic-order" + +\end_inset + +( +\emph on +Lexicographic order. +\emph default +) Let +\begin_inset Formula $S$ +\end_inset + + be well-ordered by +\begin_inset Formula $\prec$ +\end_inset + +, + and for +\begin_inset Formula $n>0$ +\end_inset + +, + let +\begin_inset Formula $T_{n}$ +\end_inset + + be the set of +\begin_inset Formula $n$ +\end_inset + +-tuples +\begin_inset Formula $(x_{1},x_{2},\dots,x_{n})$ +\end_inset + + of elements +\begin_inset Formula $x_{j}$ +\end_inset + + in +\begin_inset Formula $S$ +\end_inset + +. + Define +\begin_inset Formula $(x_{1},x_{2},\dots,x_{n})\prec(y_{1},y_{2},\dots,y_{n})$ +\end_inset + + if there is some +\begin_inset Formula $k$ +\end_inset + +, + +\begin_inset Formula $1\leq k\leq n$ +\end_inset + +, + such that +\begin_inset Formula $x_{j}=y_{j}$ +\end_inset + + for +\begin_inset Formula $1\leq j0$ +\end_inset + +, + or +\begin_inset Formula $|a|<|b|$ +\end_inset + + so +\begin_inset Formula $|a|<|b|\leq|c|$ +\end_inset + +. + In both cases, + +\begin_inset Formula $a\prec c$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +If +\begin_inset Formula $x\neq y$ +\end_inset + +, + then either +\begin_inset Formula $|x|=|y|$ +\end_inset + + so it must be +\begin_inset Formula $x\prec y$ +\end_inset + + if +\begin_inset Formula $y<0$ +\end_inset + + or +\begin_inset Formula $y\prec x$ +\end_inset + + if +\begin_inset Formula $y>0$ +\end_inset + +, + +\begin_inset Formula $|x|<|y|$ +\end_inset + + so that +\begin_inset Formula $x\prec y$ +\end_inset + +, + or +\begin_inset Formula $|y|>|x|$ +\end_inset + + so that +\begin_inset Formula $y\prec x$ +\end_inset + +. + It's clear that +\begin_inset Formula $x\prec y$ +\end_inset + + implies +\begin_inset Formula $x\neq y$ +\end_inset + + and +\begin_inset Formula $y\nprec x$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Let +\begin_inset Formula $S\subseteq\mathbb{Z}$ +\end_inset + + be nonempty, + then we can find the minimum element of +\begin_inset Formula $S$ +\end_inset + + by looking at the elements of +\begin_inset Formula $S$ +\end_inset + + with minimal absolute value, + which form a finite, + nonempty subset. +\end_layout + +\end_deeper +\begin_layout Enumerate +No, + as the nonempty subset +\begin_inset Formula $\{x\in\mathbb{R}:x>0\}$ +\end_inset + + doesn't have a first element: + for each +\begin_inset Formula $x>0$ +\end_inset + +, + +\begin_inset Formula $\frac{x}{2}1$ +\end_inset + +, + +\begin_inset Formula +\[ +p_{n0}=\frac{1}{n}p_{(n-1)(-1)}+\frac{n-1}{n}p_{(n-1)0}=\frac{n-1}{n}p_{(n-1)0}=\dots=\frac{n-1}{n}\frac{n-2}{n-1}\cdots\frac{1}{2}p_{10}=\frac{1}{n}, +\] + +\end_inset + +so in general the probability that step M4 is never run (which happens when +\begin_inset Formula $a_{n}$ +\end_inset + + is already the maximum value) is +\begin_inset Formula $p_{n0}=\frac{1}{n}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc4[M10] +\end_layout + +\end_inset + +Give an explicit, + closed formula for the values of +\begin_inset Formula $p_{nk}$ +\end_inset + + in the coin-tossing experiment, + Eq. + (17). +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Formula $p_{nk}=\binom{n}{k}p^{k}q^{n-k}$ +\end_inset + +. + To show that this derives from Eq. + (17), + we see that, + when +\begin_inset Formula $n=0$ +\end_inset + +, + +\begin_inset Formula $p_{0k}=\delta_{k0}$ +\end_inset + +, + matching the formula, + and then, + by induction, +\begin_inset Formula +\[ +p_{nk}=pp_{n-1,k-1}+qp_{n-1,k}=\binom{n-1}{k-1}p^{k}q^{n-k}+\binom{n-1}{k}p^{k}q^{n-k}=\binom{n}{k}p^{k}q^{n-k}. +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc8[M20] +\end_layout + +\end_inset + +Suppose that each +\begin_inset Formula $X[k]$ +\end_inset + + is taken at random from a set of +\begin_inset Formula $M$ +\end_inset + + distinct elements, + so that each of the +\begin_inset Formula $M^{n}$ +\end_inset + + possible choices for +\begin_inset Formula $X[1],X[2],\dots,X[n]$ +\end_inset + + is considered equally likely. + What is the probability that all the +\begin_inset Formula $X[k]$ +\end_inset + + will be distinct? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We need calculate the number of choices out of those +\begin_inset Formula $M^{n}$ +\end_inset + + that do not repeat numbers. + These choices can be considered as taking a subset of +\begin_inset Formula $n$ +\end_inset + + elements from those +\begin_inset Formula $M$ +\end_inset + + (if +\begin_inset Formula $n>M$ +\end_inset + + then we must necessarily repeat) and then ordering them somehow, + so the total number of choices is +\begin_inset Formula $\binom{M}{n}n!$ +\end_inset + +, + and the probability is +\begin_inset Formula +\[ +\frac{\binom{M}{n}n!}{M^{n}}=\frac{M(M-1)\cdots(M-n+1)}{M^{n}}=\frac{M^{\underline{n}}}{M^{n}}. +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc11[M15] +\end_layout + +\end_inset + +What happens to the semi-invariants of a distribution if we change +\begin_inset Formula $G(z)$ +\end_inset + + to +\begin_inset Formula $F(z)=z^{n}G(z)$ +\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 $H(z)\coloneqq z^{n}$ +\end_inset + +, + then +\begin_inset Formula $h(t)\coloneqq\ln H(\text{e}^{t})=\ln\text{e}^{nt}=nt$ +\end_inset + +, + so +\begin_inset Formula $\dot{h}(t)=n$ +\end_inset + + and +\begin_inset Formula $\ddot{h}(t)=\dddot{h}(t)=\dots=0$ +\end_inset + +. + Therefore +\begin_inset Formula +\begin{align*} +\kappa_{1} & =\dot{h}(0)=n; & \kappa_{n} & =h^{(n)}(0)=0, & n & >1. +\end{align*} + +\end_inset + +Thus, + by Theorem A, + the mean increases by +\begin_inset Formula $n$ +\end_inset + + and all the other semi-invariants stay the same. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc20[M22] +\end_layout + +\end_inset + +Suppose we want to calculate +\begin_inset Formula $\max\{|a_{1}-b_{1}|,|a_{2}-b_{2}|,\dots,|a_{n}-b_{n}|\}$ +\end_inset + + when +\begin_inset Formula $b_{1}\leq b_{2}\leq\dots\leq b_{n}$ +\end_inset + +. + Show that it is sufficient to calculate +\begin_inset Formula $\max\{m_{\text{L}},m_{\text{R}}\}$ +\end_inset + +, + where +\begin_inset Formula +\begin{align*} +m_{\text{L}} & =\max\{a_{k}-b_{k}\mid a_{k}\text{ is a left-to-right maximum of }a_{1}a_{2}\cdots a_{n}\},\\ +m_{\text{R}} & =\max\{b_{k}-a_{k}\mid a_{k}\text{ is a right-to-left minimum of }a_{1}a_{2}\cdots a_{n}\}. +\end{align*} + +\end_inset + +(Thus, + if the +\begin_inset Formula $a$ +\end_inset + +'s are in random order, + the number of +\begin_inset Formula $k$ +\end_inset + +'s for which a subtraction must be performed is only about +\begin_inset Formula $2\ln n$ +\end_inset + +.) +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We interpret the concepts of +\begin_inset Quotes eld +\end_inset + +directional +\begin_inset Quotes erd +\end_inset + + maximum and minimum as meaning that +\begin_inset Formula $a_{k}\geq a_{k-1},\dots,a_{1}$ +\end_inset + + or that +\begin_inset Formula $a_{k}\leq a_{k+1},\dots,a_{n}$ +\end_inset + +, + respectively. + Then, + if +\begin_inset Formula $a_{j}$ +\end_inset + + is not a left-to-right maximum, + there is a +\begin_inset Formula $ka_{j}$ +\end_inset + + and therefore +\begin_inset Formula $a_{k}-b_{k}>a_{j}-b_{j}$ +\end_inset + + (as +\begin_inset Formula $b_{k}\leq b_{j}$ +\end_inset + +), + so +\begin_inset Formula $a_{j}-b_{j}$ +\end_inset + + is not a maximum of +\begin_inset Formula $\{a_{k}-b_{k}\}$ +\end_inset + +. + Similarly, + if +\begin_inset Formula $a_{j}$ +\end_inset + + is not a right-to-left minimum, + there is a +\begin_inset Formula $k>j$ +\end_inset + + with +\begin_inset Formula $a_{k}b_{j}-a_{j}$ +\end_inset + +. + +\end_layout + +\begin_layout Standard +Thus +\begin_inset Formula $m_{\text{L}}=\max\{a_{k}-b_{k}\}$ +\end_inset + + and +\begin_inset Formula $m_{\text{R}}=\max\{b_{k}-a_{k}\}$ +\end_inset + +. + Since at least one of them is non-negative, + +\begin_inset Formula $\max\{m_{\text{L}},m_{\text{R}}\}$ +\end_inset + + is also non-negative and it is therefore +\begin_inset Formula $|a_{k}-b_{k}|$ +\end_inset + + for some +\begin_inset Formula $k$ +\end_inset + +, + and it is no lower than any +\begin_inset Formula $|a_{j}-b_{j}|$ +\end_inset + + as those are either +\begin_inset Formula $a_{j}-b_{j}$ +\end_inset + + or +\begin_inset Formula $b_{j}-a_{j}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc21[HM21] +\end_layout + +\end_inset + +Let +\begin_inset Formula $X$ +\end_inset + + be the number of heads that occur when a random coin is flipped +\begin_inset Formula $n$ +\end_inset + + times, + with generating function (18). + Use (25) to prove that +\begin_inset Formula +\[ +\text{Pr}(X\geq n(p+\epsilon))\leq\text{e}^{-\epsilon^{2}n/(2q)} +\] + +\end_inset + +when +\begin_inset Formula $\epsilon\geq0$ +\end_inset + +, + and obtain a similar estimate for +\begin_inset Formula $\text{Pr}(X\leq n(p-\epsilon))$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +First, + we tackle the edge cases. + If +\begin_inset Formula $n=0$ +\end_inset + +, + then +\begin_inset Formula $X=0$ +\end_inset + + and +\begin_inset Formula $\text{Pr}(X\geq0)\leq1$ +\end_inset + + trivially, + so we may consider +\begin_inset Formula $n>0$ +\end_inset + +. + If +\begin_inset Formula $p=0$ +\end_inset + +, + then +\begin_inset Formula $\text{Pr}(X=0)=1$ +\end_inset + + and +\begin_inset Formula $\text{Pr}(X\geq n\epsilon)\leq\text{e}^{-\epsilon^{2}n/2}$ +\end_inset + + trivially, + so we may consider +\begin_inset Formula $p>0$ +\end_inset + +. + Finally, + if +\begin_inset Formula $\epsilon>q$ +\end_inset + + then +\begin_inset Formula $\text{Pr}(X\geq n(p+\epsilon))=0\leq\text{e}^{-\epsilon^{2}n/(2q)}$ +\end_inset + + and if +\begin_inset Formula $\epsilon=q$ +\end_inset + + then +\begin_inset Formula $\text{Pr}(X\geq n)=p^{n}\leq(\text{e}^{-q})^{n}\leq\text{e}^{-qn/2}$ +\end_inset + +, + using the fact that +\begin_inset Formula $t\leq\text{e}^{t-1}$ +\end_inset + + for every +\begin_inset Formula $t\in\mathbb{R}$ +\end_inset + +, + so we may consider +\begin_inset Formula $\epsilon0$ +\end_inset + +. +\end_layout + +\begin_layout Standard +Now let +\begin_inset Formula $r=n(p+\epsilon)$ +\end_inset + +. + Then +\begin_inset Formula $\text{Pr}(X\geq n(p+\epsilon))\leq x^{-n(p+\epsilon)}(q+px)^{n}$ +\end_inset + +, + and we just need to find +\begin_inset Formula $x\geq1$ +\end_inset + + such that +\begin_inset Formula +\[ +\ln(q+px)-(p+\epsilon)\ln x\leq-\frac{\epsilon^{2}}{2q}. +\] + +\end_inset + + +\begin_inset Note Greyedout +status open + +\begin_layout Plain Layout +(I had to look at the solution, + esp. + for the right value of +\begin_inset Formula $x$ +\end_inset + +.) +\end_layout + +\end_inset + + If +\begin_inset Formula $x\coloneqq\frac{p+\epsilon}{p}\frac{q}{q-\epsilon}$ +\end_inset + +, + we have +\begin_inset Formula +\begin{multline*} +\ln(q+px)-(p+\epsilon)\ln x=\ln\left(q+(p+\epsilon)\frac{q}{q-\epsilon}\right)-(p+\epsilon)\ln\left(\frac{p+\epsilon}{p}\frac{q}{q-\epsilon}\right)=\\ +=\ln q-\ln(q-\epsilon)-(p+\epsilon)(\ln q-\ln(q-\epsilon)+\ln(p+\epsilon)-\ln p)=\\ +=(q-\epsilon)\ln\frac{q}{q-\epsilon}-(p+\epsilon)\ln\frac{p+\epsilon}{p}, +\end{multline*} + +\end_inset + +where we are assuming that +\begin_inset Formula $\epsilonr_{0}$ +\end_inset + +, + this fraction is less than 1. +\end_layout + +\end_body +\end_document diff --git a/vol1/1.2.11.1.lyx b/vol1/1.2.11.1.lyx new file mode 100644 index 0000000..daa07e2 --- /dev/null +++ b/vol1/1.2.11.1.lyx @@ -0,0 +1,556 @@ +#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 +\use_default_options true +\maintain_unincluded_children no +\language american +\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 true +\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 Note Note +status open + +\begin_layout Plain Layout +TODO 1, + 2, + 4, + 6, + 11, + 13 (1 p.) (est. + 0:21:19) +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc1[HM01] +\end_layout + +\end_inset + +What is +\begin_inset Formula $\lim_{n\to\infty}O(n^{-1/3})$ +\end_inset + +? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +0. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc2[M10] +\end_layout + +\end_inset + +Mr. + B. + C. + Dull obtained astonishing results by using the +\begin_inset Quotes eld +\end_inset + +self-evident +\begin_inset Quotes erd +\end_inset + + formula +\begin_inset Formula $O(f(n))-O(f(n))=0$ +\end_inset + +. + What was his mistake, + and what should the right-hand side of his formula has been? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Formula $O(f(n))$ +\end_inset + + is a set of functions, + not a single function, + so the two +\begin_inset Formula $O(f(n))$ +\end_inset + + do not cancel out (for example, + the first +\begin_inset Formula $O(f(n))$ +\end_inset + + could represent +\begin_inset Formula $f(n)$ +\end_inset + + and the second one could be 0). + The right hand side should be another +\begin_inset Formula $O(f(n))$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc4[M15] +\end_layout + +\end_inset + +Give an asymptotic expansion of +\begin_inset Formula $n(\sqrt[n]{a}-1)$ +\end_inset + +, + if +\begin_inset Formula $a>0$ +\end_inset + +, + to terms +\begin_inset Formula $O(1/n^{3})$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We can do this by considering the function in terms of +\begin_inset Formula $x\coloneqq\frac{1}{n}$ +\end_inset + +, + which would be +\begin_inset Formula $\frac{1}{x}(a^{x}-1)$ +\end_inset + +. + Then +\begin_inset Formula $a^{x}=\text{e}^{x\ln a}=1+x\ln a+\frac{1}{2}x^{2}\ln^{2}a+\frac{1}{6}x^{3}\ln^{3}a+O(x^{4}\ln^{4}a)$ +\end_inset + +, + so +\begin_inset Formula +\[ +a^{x}-1=x\ln a+\frac{x^{2}\ln^{2}a}{2}+\frac{x^{3}\ln^{3}a}{6}+O(x^{4})=\frac{\ln a}{n}+\frac{\ln^{2}a}{2n^{2}}+\frac{\ln^{3}a}{6n^{3}}+O(n^{-4}) +\] + +\end_inset + +and finally +\begin_inset Formula +\[ +n(\sqrt[n]{a}-1)=\ln a+\frac{\ln^{2}a}{2n}+\frac{\ln^{3}a}{6n^{2}}+O(n^{-3}). +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc6[M20] +\end_layout + +\end_inset + +What is wrong with the following arguments? + +\begin_inset Quotes eld +\end_inset + +Since +\begin_inset Formula $n=O(n)$ +\end_inset + +, + and +\begin_inset Formula $2n=O(n)$ +\end_inset + +, + ..., + we have +\begin_inset Formula +\[ +\sum_{k=1}^{n}kn=\sum_{k=1}^{n}O(n)=O(n^{2}).\text{''} +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +The second expression does not make sense. + It is a sum of +\begin_inset Formula $n$ +\end_inset + + functions each of which has +\begin_inset Formula $n$ +\end_inset + + as a parameter, + but if +\begin_inset Formula $n$ +\end_inset + + is a parameter, + it cannot be an +\begin_inset Quotes eld +\end_inset + +external +\begin_inset Quotes erd +\end_inset + + parameter of the function represented by +\begin_inset Formula $O(n)$ +\end_inset + + as well. + In this case, + it is invalid to move the big O inside the sum as the range of the sum depends on +\begin_inset Formula $n$ +\end_inset + + and so does the domain of values +\begin_inset Formula $k$ +\end_inset + + can take, + so +\begin_inset Formula $k$ +\end_inset + +, + which depends on +\begin_inset Formula $n$ +\end_inset + +, + cannot be treated like a constant. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc11[M11] +\end_layout + +\end_inset + +Explain why Eq. + (18) is true. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +The first identity is because +\begin_inset Formula $\sqrt[n]{n}=\text{e}^{\ln\sqrt[n]{n}}=\text{e}^{\ln n^{1/n}}=\text{e}^{\ln n/n}$ +\end_inset + +, + taking the power +\begin_inset Formula $1/n$ +\end_inset + + out of the logarithm. + The second identity is a direct application of Eq. + (12), + using that +\begin_inset Formula $\ln n/n\to0$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc13[M10] +\end_layout + +\end_inset + +Prove or disprove: + +\begin_inset Formula $g(n)=\Omega(f(n))$ +\end_inset + + if and only if +\begin_inset Formula $f(n)=O(g(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 Formula $g(n)=\Omega(f(n))$ +\end_inset + + if and only if there exist +\begin_inset Formula $n_{0}$ +\end_inset + + and +\begin_inset Formula $L$ +\end_inset + + such that +\begin_inset Formula $|g(n)|\geq L|f(n)|$ +\end_inset + + for each +\begin_inset Formula $n\geq n_{0}$ +\end_inset + +, + but this is the same as saying that, + for all such +\begin_inset Formula $n$ +\end_inset + +, + +\begin_inset Formula $|f(n)|\leq\frac{1}{L}|g(n)|$ +\end_inset + +, + which is to say that +\begin_inset Formula $f(n)=O(g(n))$ +\end_inset + +. + Since arguably this +\begin_inset Formula $L$ +\end_inset + + must be positive (otherwise the statement is trivial), + taking +\begin_inset Formula $\frac{1}{L}$ +\end_inset + + is valid, + and likewise, + if +\begin_inset Formula $|f(n)|\leq M|g(n)|$ +\end_inset + + for each +\begin_inset Formula $n\geq n_{0}$ +\end_inset + + and some +\begin_inset Formula $M$ +\end_inset + +, + we can always make this +\begin_inset Formula $M$ +\end_inset + + positive to make the reverse argument. +\end_layout + +\end_body +\end_document diff --git a/vol1/1.2.11.2.lyx b/vol1/1.2.11.2.lyx new file mode 100644 index 0000000..cd12585 --- /dev/null +++ b/vol1/1.2.11.2.lyx @@ -0,0 +1,440 @@ +#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 +\use_default_options true +\maintain_unincluded_children no +\language american +\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 true +\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 +rexerc4[HM20] +\end_layout + +\end_inset + +( +\emph on +Sums of powers. +\emph default +) When +\begin_inset Formula $f(x)=x^{m}$ +\end_inset + +, + the high-order derivatives of +\begin_inset Formula $f$ +\end_inset + + are all zero, + so Euler's summation formula gives an +\emph on +exact +\emph default + value for the sum +\begin_inset Formula +\[ +S_{m}(n)=\sum_{0\leq km$ +\end_inset + +, + +\begin_inset Formula $f^{(k)}(x)\equiv0$ +\end_inset + +. + Using Euler's summation formula, + when +\begin_inset Formula $m\geq1$ +\end_inset + +, +\begin_inset Formula +\[ +S_{m}(n)=\sum_{0\leq ky$ +\end_inset + +, + based on the decimal representation. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We say that +\begin_inset Formula $x=y$ +\end_inset + + if +\begin_inset Formula $m=n$ +\end_inset + + and +\begin_inset Formula $d_{k}=e_{k}$ +\end_inset + + for all +\begin_inset Formula $k$ +\end_inset + +, + and that +\begin_inset Formula $x0$ +\end_inset + +, + then +\begin_inset Formula $f(x)\leq0$ +\end_inset + +. + We have +\begin_inset Formula +\[ +f'(x)=\frac{1}{n\sqrt[n]{1+x}}-\frac{1}{n}=\frac{1}{n}\left(\frac{1}{\sqrt[n]{1+x}-1}\right), +\] + +\end_inset + +but since +\begin_inset Formula $\sqrt[n]{1+x}>1$ +\end_inset + + for +\begin_inset Formula $x>0$ +\end_inset + +, + we have +\begin_inset Formula $f'(x)<0$ +\end_inset + + and +\begin_inset Formula $f$ +\end_inset + + is strictly decreasing on +\begin_inset Formula $(0,+\infty)$ +\end_inset + +. + Since +\begin_inset Formula $f(0)=0$ +\end_inset + +, + this proves the result. +\end_layout + +\begin_layout Enumerate +It's clear that +\begin_inset Formula $b^{n+d_{1}/10+\dots+d_{k}/10^{k}}\leq b^{n+1}$ +\end_inset + +, + and then, + taken +\begin_inset Formula $x=b-1>0$ +\end_inset + + and +\begin_inset Formula $n=10^{k}$ +\end_inset + +, + we have +\begin_inset Formula $\sqrt[10^{k}]{1+b-1}=b^{1/10^{k}}\leq(b-1)/10^{k}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc15[10] +\end_layout + +\end_inset + +Prove or disprove: +\begin_inset Formula +\begin{align*} +\log_{b}x/y & =\log_{b}x-\log_{b}y, & \text{if }x,y & >0. +\end{align*} + +\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 $\alpha:=\log_{b}x$ +\end_inset + + and +\begin_inset Formula $\beta:=\log_{b}y$ +\end_inset + +, + we have +\begin_inset Formula +\[ +\frac{b^{\alpha}}{b^{\beta}}=b^{\alpha}b^{-\beta}=b^{\alpha-\beta}, +\] + +\end_inset + +and taking logarithms, + we get +\begin_inset Formula $\log_{b}\frac{b^{\alpha}}{b^{\beta}}=\log_{b}\frac{x}{y}=\log_{b}b^{\alpha-\beta}=\alpha-\beta=\log_{b}x-\log_{b}y.$ +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc16[00] +\end_layout + +\end_inset + +How can +\begin_inset Formula $\log_{10}x$ +\end_inset + + be expressed in terms of +\begin_inset Formula $\ln x$ +\end_inset + + and +\begin_inset Formula $\ln10$ +\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 $\log_{10}x=\frac{\log_{e}x}{\log_{e}10}=\frac{\ln x}{\ln10}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc17[05] +\end_layout + +\end_inset + +What is +\begin_inset Formula $\lg32$ +\end_inset + +? + +\begin_inset Formula $\log_{\pi}\pi$ +\end_inset + +? + +\begin_inset Formula $\ln e$ +\end_inset + +? + +\begin_inset Formula $\log_{b}1$ +\end_inset + +? + +\begin_inset Formula $\log_{b}(-1)$ +\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 $\lg32=5$ +\end_inset + +, + +\begin_inset Formula $\log_{\pi}\pi=1$ +\end_inset + +, + +\begin_inset Formula $\ln e=1$ +\end_inset + +, + +\begin_inset Formula $\log_{b}1=0$ +\end_inset + +. + As for +\begin_inset Formula $\log_{b}(-1)$ +\end_inset + +, + it would be an +\begin_inset Formula $x$ +\end_inset + + such that +\begin_inset Formula $b^{x}=-1$ +\end_inset + +, + which is not a real number most of the time. + As a complex number, + it would be +\begin_inset Formula $\log_{b}(-1)=\frac{\ln(-1)}{\ln b}=\frac{i\pi}{\ln b}$ +\end_inset + +, + since +\begin_inset Formula $e^{i\pi}=-1$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc18[10] +\end_layout + +\end_inset + +Prove or disprove: + +\begin_inset Formula $\log_{8}x=\frac{1}{2}\lg x$ +\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 $\log_{8}x=\frac{\lg x}{\lg8}$ +\end_inset + +, + but +\begin_inset Formula $\lg8=3\neq2$ +\end_inset + +, + so this is false in the general case (this is only true when +\begin_inset Formula $x=1$ +\end_inset + +). +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc19[20] +\end_layout + +\end_inset + +If +\begin_inset Formula $n$ +\end_inset + + is an integer whose decimal representation is 14 digits long, + will the value of +\begin_inset Formula $n$ +\end_inset + + fit in a computer word with a capacity of 47 bits and a sign bit? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +The number of possibilities for a number with up to 14 digits is +\begin_inset Formula $10^{14}$ +\end_inset + +, + and the number for 47 bits is +\begin_inset Formula $2^{47}\approx1.3\cdot2^{14}$ +\end_inset + +, + so it would fit. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc20[10] +\end_layout + +\end_inset + +Is there any simple relation between +\begin_inset Formula $\log_{10}2$ +\end_inset + + and +\begin_inset Formula $\log_{2}10$ +\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 $\log_{10}2=\frac{\log_{2}2}{\log_{2}10}=\frac{1}{\log_{2}10}$ +\end_inset + +, + so +\begin_inset Formula $\log_{10}2\log_{2}10=1$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc22[20] +\end_layout + +\end_inset + +(R. + W. + Hamming.) Prove that +\begin_inset Formula +\[ +\lg x\approx\ln x+\log_{10}x, +\] + +\end_inset + +with less than +\begin_inset Formula $\unit[1]{\%}$ +\end_inset + + error! + (Thus a table of natural logarithms and of common logarithms can be used to get approximate values of binary logarithms as well.) +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Formula +\[ +\ln x+\log_{10}x=\frac{\lg x}{\lg e}+\frac{\lg x}{\lg10}=\lg x\left(\frac{1}{\lg e}+\frac{1}{\lg10}\right)\cong0.994\lg x\approx\lg x, +\] + +\end_inset + +and this gives us about +\begin_inset Formula $\unit[0.6]{\%}$ +\end_inset + + error. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc27[M25] +\end_layout + +\end_inset + +Consider the method for calculating +\begin_inset Formula $\log_{10}x$ +\end_inset + + discussed in the text. + Let +\begin_inset Formula $x'_{k}$ +\end_inset + + denote the computed approximation to +\begin_inset Formula $x_{k}$ +\end_inset + +, + determined as follows: + +\begin_inset Formula $x(1-\delta)\leq10^{n}x'_{0}\leq x(1+\epsilon)$ +\end_inset + +; + and in the determination of +\begin_inset Formula $x'_{k}$ +\end_inset + + by Eqs. + (18), + the quantity +\begin_inset Formula $y_{k}$ +\end_inset + + is used in place of +\begin_inset Formula $(x'_{k-1})^{2}$ +\end_inset + +, + where +\begin_inset Formula $(x'_{k-1})^{2}(1-\delta)\leq y_{k}\leq(x'_{k-1})^{2}(1+\epsilon)$ +\end_inset + + and +\begin_inset Formula $1\leq y_{k}<100$ +\end_inset + +. + Here +\begin_inset Formula $\delta$ +\end_inset + + and +\begin_inset Formula $\epsilon$ +\end_inset + + are small constants that reflect the upper and lower errors due to rounding or truncation. + If +\begin_inset Formula $\log^{\prime}x$ +\end_inset + + denotes the result of the calculations, + show that after +\begin_inset Formula $k$ +\end_inset + + steps we have +\begin_inset Formula +\[ +\log_{10}x+2\log_{10}(1-\delta)-1/2^{k}<\log^{\prime}x\leq\log_{10}x+2\log_{10}(1+\epsilon). +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We first prove by induction that +\begin_inset Formula +\[ +x^{2^{k}}(1-\delta)^{2^{k+1}-1}\leq10^{2^{k}(n+b_{1}/2+\dots+b_{k}/2^{k})}x'_{k}\leq x^{2^{k}}(1+\epsilon)^{2^{k+1}-1}. +\] + +\end_inset + +For +\begin_inset Formula $k=0$ +\end_inset + +, + we have +\begin_inset Formula $x(1-\delta)\leq10^{n}x'_{0}\leq x(1+\epsilon)$ +\end_inset + +, + which is given. + If this holds up to a certain +\begin_inset Formula $k$ +\end_inset + +, + then if +\begin_inset Formula $(x'_{k})^{2}<10$ +\end_inset + +, + we have +\begin_inset Formula $b_{k+1}=0$ +\end_inset + +, + +\begin_inset Formula $(1-\delta)(x'_{k})^{2}\leq x'_{k+1}\leq(1+\epsilon)(x'_{k})^{2}$ +\end_inset + + and +\begin_inset Formula +\begin{eqnarray*} +x^{2^{k+1}}(1-\delta)^{2^{k+2}-1} & = & (x^{2^{k+1}}(1-\delta)^{2^{k+1}-1})^{2}(1-\delta)\\ + & \leq & (10^{2^{k}(n+b_{1}/2+\dots+b_{k}/2^{k})}x'_{k})^{2}(1-\delta)\\ + & \leq & 10^{2^{k+1}(n+b_{1}/2+\dots+b_{k}/2^{k}+b_{k+1}/2^{k+1})}x'_{k+1}\\ + & \leq & (10^{2^{k}(n+b_{1}/2+\dots+b_{k}/2^{k})}x'_{k})^{2}(1+\epsilon)\\ + & \leq & (x^{2^{k}}(1+\epsilon)^{2^{k+1}-1})^{2}(1+\epsilon)=x^{2^{k+1}}(1+\epsilon)^{2^{k+2}-1}. +\end{eqnarray*} + +\end_inset + +If +\begin_inset Formula $(x'_{k})^{2}\geq10$ +\end_inset + +, + we have +\begin_inset Formula $b_{k+1}=1$ +\end_inset + +, + +\begin_inset Formula $(1-\delta)(x'_{k})^{2}\leq10x'_{k+1}\leq(1+\epsilon)(x'_{k})^{2}$ +\end_inset + + and +\begin_inset Formula +\begin{eqnarray*} +x^{2^{k+1}}(1-\delta)^{2^{k+2}-1} & \leq & (10^{2^{k}(n+b_{1}/2+\dots+b_{k}/2^{k})}x'_{k})^{2}(1-\delta)\\ + & \leq & 10^{2^{k+1}(n+b_{1}/2+\dots+b_{k}/2^{k})}10x'_{k+1}\\ + & = & 10^{2^{k+1}(n+b_{1}/2+\dots+b_{k}/2^{k}+b_{k+1}/2^{k+1})}x'_{k+1}\\ + & \leq & (10^{2^{k}(n+b_{1}/2+\dots+b_{k}/2^{k})}x'_{k})^{2}(1+\epsilon)\\ + & \leq & x^{2^{k+1}}(1+\epsilon)^{2^{k+2}-1}. +\end{eqnarray*} + +\end_inset + +Then, + by taking logarithms on the expression, + we get +\begin_inset Formula +\[ +2^{k}\log x+(2^{k+1}-1)\log(1-\delta)\leq2^{k}\log^{\prime}x+\log x'_{k}\leq2^{k}\log x+(2^{k+1}-1)\log(1+\epsilon). +\] + +\end_inset + +Finally, + subtracting +\begin_inset Formula $\log x'_{k}$ +\end_inset + + from all sides, + using that +\begin_inset Formula $-1<-\log(1-\delta)-\log x'_{k}=-\log(x'_{k}(1-\delta))$ +\end_inset + +, + because +\begin_inset Formula $x'_{k}(1-\delta)<10$ +\end_inset + +, + using that +\begin_inset Formula $-\log(1+\epsilon)-\log x'_{k}=-\log(x'_{k}(1+\epsilon))\leq0$ +\end_inset + +, + because +\begin_inset Formula $x'_{k}(1+\epsilon)\geq1$ +\end_inset + +, + and dividing everything by +\begin_inset Formula $2^{k}$ +\end_inset + +, + we get +\begin_inset Formula +\[ +\log x+2\log(1-\delta)-\frac{1}{2^{k}}<\log^{\prime}x\leq\log x+2\log(1+\epsilon), +\] + +\end_inset + +which is precisely what we wanted to prove. +\end_layout + +\end_body +\end_document diff --git a/vol1/1.2.3.lyx b/vol1/1.2.3.lyx new file mode 100644 index 0000000..0648fc2 --- /dev/null +++ b/vol1/1.2.3.lyx @@ -0,0 +1,1732 @@ +#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[10] +\end_layout + +\end_inset + +The text says that +\begin_inset Formula $a_{1}+a_{2}+\dots+a_{0}=0$ +\end_inset + +. + What then, + is +\begin_inset Formula $a_{2}+\dots+a_{0}$ +\end_inset + +? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We could set that to be +\begin_inset Formula $-a_{1}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc2[01] +\end_layout + +\end_inset + +What does the notation +\begin_inset Formula $\sum_{1\leq j\leq n}a_{j}$ +\end_inset + + mean, + if +\begin_inset Formula $n=3.14$ +\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 $a_{1}+a_{2}+a_{3}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc3[13] +\end_layout + +\end_inset + +Without using the +\begin_inset Formula $\sum$ +\end_inset + +-notation, + write out the equivalent of +\begin_inset Formula +\[ +\sum_{0\leq n\leq5}\frac{1}{2n+1}, +\] + +\end_inset + +and also the equivalent of +\begin_inset Formula +\[ +\sum_{0\leq n^{2}\leq5}\frac{1}{2n^{2}+1}. +\] + +\end_inset + +Explain why the two results are different, + in spite of rule (b). +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Formula +\begin{eqnarray*} +\sum_{0\leq n\leq5}\frac{1}{2n+1} & = & \frac{1}{1}+\frac{1}{3}+\frac{1}{5}+\frac{1}{7}+\frac{1}{9}+\frac{1}{11},\\ +\sum_{0\leq n^{2}\leq5}\frac{1}{2n^{2}+1} & = & \frac{1}{9}+\frac{1}{3}+\frac{1}{1}+\frac{1}{3}+\frac{1}{9}, +\end{eqnarray*} + +\end_inset + +as the integers with +\begin_inset Formula $0\leq n^{2}\leq5$ +\end_inset + + are +\begin_inset Formula $\{-2,-1,0,1,2\}$ +\end_inset + +. + Rule (b) states that a permutation of the integers satisfying the condition doesn't alter the result, + but because +\begin_inset Formula $n\mapsto n^{2}$ +\end_inset + + is not a permutation of such +\emph on +integers +\emph default +, + the rule doesn't apply. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc4[10] +\end_layout + +\end_inset + +Without using the +\begin_inset Formula $\sum$ +\end_inset + +-notation, + write out the equivalent of each side of Eq. + (10) as a sum of sums for the case +\begin_inset Formula $n=3$ +\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 $a_{11}+a_{21}+a_{22}+a_{31}+a_{32}+a_{33}=a_{11}+a_{21}+a_{31}+a_{22}+a_{32}+a_{33}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc5[HM20] +\end_layout + +\end_inset + +Prove that rule (a) is valid for arbitrary infinite series, + provided that the series converge. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Since infinite series are defined for cases where the total number of nonzero elements is at most countable, + we might assume that the series are indexed by positive integers. + Thus, + we'd have to prove that +\begin_inset Formula +\[ +\left(\sum_{i=1}^{\infty}a_{i}\right)\left(\sum_{j=1}^{\infty}b_{j}\right)=\sum_{i=1}^{\infty}\sum_{j=1}^{\infty}a_{i}b_{j}, +\] + +\end_inset + +assuming that the relevant series converge. + We have +\end_layout + +\begin_layout Standard +\begin_inset Formula +\[ +\left(\sum_{i=0}^{\infty}a_{i}\right)\left(\sum_{j=0}^{\infty}b_{j}\right)=\sum_{i=0}^{\infty}\left(a_{i}\sum_{j=0}^{\infty}b_{j}\right)=\sum_{i=0}^{\infty}\sum_{j=0}^{\infty}b_{j}, +\] + +\end_inset + +by entering the second series as a constant into the first series (because it converges) and then entering the element of the first series, + considered as a constant, + into the inner series. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc9[05] +\end_layout + +\end_inset + +Is the derivation of Eq. + (14) valid even if +\begin_inset Formula $n=-1$ +\end_inset + +? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +The result is +\begin_inset Formula +\[ +\sum_{0\leq j\leq-1}ax^{j}=0=a\left(\frac{1-x^{0}}{1-x}\right), +\] + +\end_inset + +which is correct. + However, + the derivation is not correct as the rule (d) cannot be applied, + because the applications in the derivation assume +\begin_inset Formula $n\geq0$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc10[05] +\end_layout + +\end_inset + +Is the derivation of Eq. + (14) valid even if +\begin_inset Formula $n=-2$ +\end_inset + +? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +No (see previous exercise). +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc11[03] +\end_layout + +\end_inset + +What should the right-hand side of Eq. + (14) be if +\begin_inset Formula $x=1$ +\end_inset + +? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Mere substitution in the original formula yields an undefined result, + but it's clear that +\begin_inset Formula +\[ +\sum_{0\leq j\leq n}a\cdot1^{j}=\sum_{0\leq j\leq n}a=(n+1)a. +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc12[10] +\end_layout + +\end_inset + +What is +\begin_inset Formula $1+\frac{1}{7}+\frac{1}{49}+\frac{1}{343}+\dots+\left(\frac{1}{7}\right)^{n}$ +\end_inset + +? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +By Eq. + (14), + this is +\begin_inset Formula +\[ +\sum_{k=0}^{n}\left(\frac{1}{7}\right)^{k}=\left(\frac{1-\left(\frac{1}{7}\right)^{n+1}}{1-\frac{1}{7}}\right)=\frac{1-\left(\frac{1}{7}\right)^{n+1}}{\frac{6}{7}}=\frac{7}{6}\left(1-\frac{1}{7^{n+1}}\right). +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc13[10] +\end_layout + +\end_inset + +Using Eq. + (15) and assuming that +\begin_inset Formula $m\leq n$ +\end_inset + +, + evaluate +\begin_inset Formula $\sum_{j=m}^{n}j$ +\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 Standard +\begin_inset Formula +\begin{multline*} +\sum_{m\leq j\leq n}j=\sum_{m\leq j+m\leq n}(j+m)=\sum_{0\leq j\leq n-m}(m+j)=\\ +=m(n-m+1)+\frac{1}{2}(n-m)(n-m+1)=\frac{1}{2}(n(n+1)-m(m-1)). +\end{multline*} + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc14[11] +\end_layout + +\end_inset + +Using the result of the previous exercise, + evaluate +\begin_inset Formula $\sum_{j=m}^{n}\sum_{k=r}^{s}jk$ +\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 +\begin{multline*} +\sum_{j=m}^{n}\sum_{k=r}^{s}jk=\left(\sum_{j=m}^{n}j\right)\left(\sum_{k=r}^{s}k\right)=\\ +=\frac{1}{4}(n(n+1)-m(m-1))(s(s+1)-r(r-1)). +\end{multline*} + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc15[M22] +\end_layout + +\end_inset + +Compute the sum +\begin_inset Formula $1\times2+2\times2^{2}+3\times2^{3}+\dots+n\times2^{n}$ +\end_inset + + for small values of +\begin_inset Formula $n$ +\end_inset + +. + Do you see the pattern developing in these numbers? + If not, + discover it by manipulations similar to those leading up to Eq. + (14). +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Let +\begin_inset Formula $\tau(n)$ +\end_inset + + be such a such sum +\begin_inset Formula +\begin{align*} +\tau(1) & =2, & \tau(2) & =2+8=10, & \tau(3) & =10+24=34,\\ +\tau(4) & =34+64=98, & \tau(5) & =98+160=258, & & \dots +\end{align*} + +\end_inset + + +\end_layout + +\begin_layout Standard +Now, +\begin_inset Formula +\begin{align*} +\tau(n) & =\sum_{1\leq k\leq n}k2^{k} & & \text{by definition}\\ + & =\sum_{0\leq k\leq n-1}(k+1)2^{k+1} & & \text{by rule (b)}\\ + & =2\sum_{0\leq k\leq n-1}(k+1)2^{k} & & \text{by a special case of (a)}\\ + & =2\left(\sum_{0\leq k\leq n-1}k2^{k}+\sum_{0\leq k\leq n-1}2^{k}\right) & & \text{by rule (c)}\\ + & =2\left(\sum_{0\leq k\leq n}k2^{k}-n2^{n}+(2^{n}-1)\right) & & \text{by rule (d) and Eq. (14)}\\ + & =2\left(\sum_{1\leq k\leq n}k2^{k}-n2^{n}+(2^{n}-1)\right) & & \text{by rule (d)} +\end{align*} + +\end_inset + + +\end_layout + +\begin_layout Standard +This means +\begin_inset Formula $\tau(n)=2(\tau(n)-n2^{n}+2^{n}-1)=2\tau(n)-n2^{n+1}+2^{n+1}-2$ +\end_inset + +, + so +\begin_inset Formula +\[ +\tau(n)=n2^{n+1}-2^{n+1}+2=(n-1)2^{n+1}+2. +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc17[M00] +\end_layout + +\end_inset + +Let +\begin_inset Formula $S$ +\end_inset + + be a set of integers. + What is +\begin_inset Formula $\sum_{j\in S}1$ +\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 $|S|$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc20[25] +\end_layout + +\end_inset + +Dr. + I. + J. + Matrix has observed a remarkable sequence of formulas: +\begin_inset Formula +\begin{align*} +9\times1+2 & =11, & 9\times12+3 & =111,\\ +9\times123+4 & =1111, & 9\times1234+5 & =11111. +\end{align*} + +\end_inset + + +\end_layout + +\begin_layout Enumerate +Write the good doctor's great discovery in terms of the +\begin_inset Formula $\sum$ +\end_inset + +-notation. +\end_layout + +\begin_layout Enumerate +Your answer to part (a) undoubtedly involves the number 10 as base of the decimal system; + generalize this formula so that you get a formula that will perhaps work in any base +\begin_inset Formula $b$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Prove your formula from part (b) by using formulas derived in the text or in exercise 16 above. +\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 +\begin_inset Formula $n\geq1$ +\end_inset + +, + +\begin_inset Formula +\[ +9\sum_{j=0}^{n-1}10^{j}(n-j)+n+1=\sum_{j=0}^{n}10^{j}. +\] + +\end_inset + + +\end_layout + +\begin_layout Enumerate +\begin_inset Formula +\[ +(b-1)\sum_{j=0}^{n-1}b^{j}(n-j)+n+1=\sum_{j=0}^{n}b^{j}. +\] + +\end_inset + + +\end_layout + +\begin_layout Enumerate +We have +\begin_inset Formula +\begin{eqnarray*} +\sum_{j=0}^{n-1}b^{j}(n-j) & = & n\sum_{j=0}^{n-1}b^{j}-\sum_{j=0}^{n-1}jb^{j}\\ + & = & n\frac{1-b^{n}}{1-b}-\frac{(n-1)b^{n+1}-nb^{n}+b}{(b-1)^{2}}\\ + & = & n\frac{b^{n}-1}{b-1}-\frac{(n-1)b^{n+1}-nb^{n}+b}{(b-1)^{2}}, +\end{eqnarray*} + +\end_inset + +so +\begin_inset Formula +\begin{align*} + & (b-1)\sum_{j=0}^{n-1}b^{j}(n-j)+n+1\\ + & =n(b^{n}-1)-\frac{(n-1)b^{n+1}-nb^{n}+b}{b-1}+n+1\\ + & =\frac{n(b^{n}-1)(b-1)-(n-1)b^{n+1}+nb^{n}-b+n(b-1)+b-1}{b-1}\\ + & =\frac{nb^{n+1}-nb^{n}-nb+n-nb^{n+1}+b^{n+1}+nb^{n}-b+nb-n+b-1}{b-1}\\ + & =\frac{b^{n+1}-1}{b-1}=\frac{1-b^{n+1}}{b-1}=\sum_{j=0}^{n}b^{j}. +\end{align*} + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc21[M25] +\end_layout + +\end_inset + +Derive rule (d) from (8) and (17). +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Formula +\begin{multline*} +\sum_{R(j)}a_{j}+\sum_{S(j)}a_{j}=\sum_{j}a_{j}[R(j)]+\sum_{j}a_{j}[S(j)]=\sum_{j}a_{j}([R(j)]+[S(j)])=\\ +\sum_{j}a_{j}([R(j)\lor S(j)]+[R(j)\land S(j)])=\sum_{R(j)\lor S(j)}a_{j}+\sum_{R(j)\land S(j)}a_{j}. +\end{multline*} + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc22[20] +\end_layout + +\end_inset + +State the appropriate analogs of Eqs. + (5), + (7), + (8), + and (11) for +\emph on +products +\emph default + instead of sums. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Formula +\begin{align*} +\prod_{R(i)}a_{i} & =\prod_{R(j)}a_{j}=\prod_{R(p(j))}a_{p(j)}, & \prod_{R(i)}\prod_{S(j)}a_{ij} & =\prod_{S(j)}\prod_{R(i)}a_{ij},\\ +\prod_{R(i)}b_{i}c_{i} & =\prod_{R(i)}b_{i}+\prod_{R(i)}c_{i}, & \prod_{R(j)}a_{j}\prod_{S(j)}a_{j} & =\prod_{R(j)\lor S(j)}a_{j}\prod_{R(j)\land S(j)}a_{j}. +\end{align*} + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc23[10] +\end_layout + +\end_inset + +Explain why it is a good idea to define +\begin_inset Formula $\sum_{R(j)}a_{j}$ +\end_inset + + and +\begin_inset Formula $\prod_{R(j)}a_{j}$ +\end_inset + + as zero and one, + respectively, + when no integers satisfy +\begin_inset Formula $R(j)$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Zero and one are the neutral terms for sum and product, + respectively, + so by defining it this way, + rule (d) (among others) applies independently of whether there are integers satisfying the properties or not. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc25[15] +\end_layout + +\end_inset + +Consider the following derivation; + is anything amiss? +\begin_inset Formula +\[ +\left(\sum_{i=1}^{n}a_{i}\right)\left(\sum_{j=1}^{n}\frac{1}{a_{j}}\right)=\sum_{1\leq i\leq n}\sum_{1\leq j\leq n}\frac{a_{i}}{a_{j}}=\sum_{1\leq i\leq n}\sum_{1\leq i\leq n}\frac{a_{i}}{a_{i}}=\sum_{i=1}^{n}1=n. +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +First, + the change of variable on the second equality is invalid since it changes to a bound variable, + not to a free variable. + Second, + it then converts the double summation into a single summation, + which is invalid too. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc29[M30] +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Enumerate +Express +\begin_inset Formula $\sum_{i=0}^{n}\sum_{j=0}^{i}\sum_{k=0}^{j}a_{i}a_{j}a_{k}$ +\end_inset + + in terms of the multiple-sum notation explained at the end of the section. +\end_layout + +\begin_layout Enumerate +Express the same sum in terms of +\begin_inset Formula $\sum_{i=0}^{n}a_{i}$ +\end_inset + +, + +\begin_inset Formula $\sum_{i=0}^{n}a_{i}^{2}$ +\end_inset + +, + and +\begin_inset Formula $\sum_{i=0}^{n}a_{i}^{3}$ +\end_inset + + [see Eq. + (13)]. +\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 +\[ +\sum_{0\leq k\leq j\leq i\leq n}a_{i}a_{j}a_{k}. +\] + +\end_inset + + +\end_layout + +\begin_deeper +\begin_layout Standard +\noindent +We have +\begin_inset Formula +\begin{align*} +S & :=\sum_{i=0}^{n}\sum_{j=0}^{i}\sum_{k=0}^{j}a_{i}a_{j}a_{k}=\sum_{i=0}^{n}\sum_{j=0}^{i}\sum_{k=j}^{i}a_{i}a_{j}a_{k}\\ + & =\sum_{i=0}^{n}\sum_{j=i}^{n}\sum_{k=0}^{i}a_{i}a_{j}a_{k}=\sum_{i=0}^{n}\sum_{j=0}^{i}\sum_{k=i}^{n}a_{i}a_{j}a_{k}\\ + & =\sum_{i=0}^{n}\sum_{j=i}^{n}\sum_{k=i}^{j}a_{i}a_{j}a_{k}=\sum_{i=0}^{n}\sum_{j=i}^{n}\sum_{k=j}^{n}a_{i}a_{j}a_{k}. +\end{align*} + +\end_inset + +Thus, +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +bgroup +\backslash +small +\end_layout + +\end_inset + + +\begin_inset Formula +\begin{eqnarray*} +6S & = & \sum_{i=0}^{n}\sum_{j=0}^{i}\left(\sum_{k=0}^{j}a_{i}a_{j}a_{k}+\sum_{k=j}^{i}a_{i}a_{j}a_{k}+\sum_{k=i}^{n}a_{i}a_{j}a_{k}\right)\\ + & & +\sum_{i=0}^{n}\sum_{j=i}^{n}\left(\sum_{k=0}^{i}a_{i}a_{j}a_{k}+\sum_{k=i}^{j}a_{i}a_{j}a_{k}+\sum_{i=j}^{n}a_{i}a_{j}a_{k}\right)\\ + & = & \sum_{i=0}^{n}\left(\sum_{j=0}^{i}\left(\sum_{k=0}^{n}a_{i}a_{j}a_{k}+a_{i}a_{j}^{2}+a_{i}^{2}a_{j}\right)+\sum_{j=i}^{n}\left(\sum_{k=0}^{n}a_{i}a_{j}a_{k}+a_{i}a_{j}^{2}+a_{j}^{2}a_{i}\right)\right)\\ + & = & \sum_{i=0}^{n}\left(\sum_{j=0}^{n}\left(\sum_{k=0}^{n}a_{i}a_{j}a_{k}+a_{i}a_{j}^{2}+a_{i}^{2}a_{j}\right)+\sum_{k=0}^{n}a_{i}^{2}a_{k}+a_{i}^{3}+a_{i}^{3}\right)\\ + & = & \sum_{i=0}^{n}\sum_{j=0}^{n}\sum_{k=0}^{n}a_{i}a_{j}a_{k}+\sum_{i=0}^{n}\sum_{j=0}^{n}a_{i}a_{j}^{2}+\sum_{i=0}^{n}\sum_{j=0}^{n}a_{i}^{2}a_{j}+\sum_{i=0}^{n}\sum_{k=0}^{n}a_{i}^{2}a_{k}+2\sum_{i=0}^{n}a_{i}^{3}\\ + & = & \left(\sum_{i=0}^{n}a_{i}\right)^{3}+\left(\sum_{i=0}^{n}a_{i}\right)\left(\sum_{i=0}^{n}a_{i}^{2}\right)+\left(\sum_{i=0}^{n}a_{i}^{2}\right)\left(\sum_{i=0}^{n}a_{i}\right)\\ + & & +\left(\sum_{i=0}^{n}a_{i}^{2}\right)\left(\sum_{i=0}^{n}a_{i}\right)+2\sum_{i=0}^{n}a_{i}^{3}\\ + & = & \left(\sum_{i=0}^{n}a_{i}\right)^{3}+3\left(\sum_{i=0}^{n}a_{i}\right)\left(\sum_{i=0}^{n}a_{i}^{2}\right)+2\left(\sum_{i=0}^{n}a_{i}^{3}\right). +\end{eqnarray*} + +\end_inset + + +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +egroup +\end_layout + +\end_inset + +This means +\begin_inset Formula +\[ +S=\frac{1}{6}\left(\sum_{i=0}^{n}a_{i}\right)^{3}+\frac{1}{2}\left(\sum_{i=0}^{n}a_{i}\right)\left(\sum_{i=0}^{n}a_{i}^{2}\right)+\frac{1}{3}\left(\sum_{i=0}^{n}a_{i}^{3}\right). +\] + +\end_inset + + +\end_layout + +\end_deeper +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc30[M23] +\end_layout + +\end_inset + +(J. + Binet, + 1812.) Without using induction, + prove the identity +\begin_inset Formula +\[ +\left(\sum_{j=1}^{n}a_{j}x_{j}\right)\left(\sum_{j=1}^{n}b_{j}y_{j}\right)=\left(\sum_{j=1}^{n}a_{j}y_{j}\right)\left(\sum_{j=1}^{n}b_{j}x_{j}\right)+\sum_{1\leq j1$ +\end_inset + +, + assuming this holds for +\begin_inset Formula $n-1$ +\end_inset + +, + subtracting from each row the previous one multiplied by +\begin_inset Formula $x_{1}$ +\end_inset + +, + expanding by cofactors, + factoring out, + and applying the induction hypothesis, + we have +\begin_inset Formula +\begin{eqnarray*} +\left|\begin{array}{cccc} +x_{1} & x_{2} & \cdots & x_{n}\\ +x_{1}^{2} & x_{2}^{2} & \cdots & x_{n}^{2}\\ +\vdots & \vdots & & \vdots\\ +x_{1}^{n} & x_{2}^{n} & \cdots & x_{n}^{n} +\end{array}\right| & = & \left|\begin{array}{cccc} +x_{1} & x_{2} & \cdots & x_{n}\\ +0 & x_{2}(x_{2}-x_{1}) & \cdots & x_{n}(x_{n}-x_{1})\\ +\vdots & \vdots & & \vdots\\ +0 & x_{2}^{n-1}(x_{2}-x_{1}) & \cdots & x_{n}^{n-1}(x_{n}-x_{1}) +\end{array}\right|\\ + & = & x_{1}\left|\begin{array}{ccc} +x_{2}(x_{2}-x_{1}) & \cdots & x_{n}(x_{n}-x_{1})\\ +\vdots & & \vdots\\ +x_{2}^{n-1}(x_{2}-x_{1}) & \cdots & x_{n}^{n-1}(x_{n}-x_{1}) +\end{array}\right|\\ + & = & x_{1}(x_{2}-x_{1})\cdots(x_{n}-x_{1})\left|\begin{array}{ccc} +x_{2} & \cdots & x_{n}\\ +\vdots & & \vdots\\ +x_{2}^{n-1} & \cdots & x_{n}^{n-1} +\end{array}\right|\\ + & = & x_{1}\prod_{2\leq j\leq n}(x_{j}-x_{1})\prod_{2\leq j\leq n}x_{j}\prod_{2\leq i1$ +\end_inset + + and that the hypothesis holds for +\begin_inset Formula $n-1$ +\end_inset + +. + Multiplying each row +\begin_inset Formula $i$ +\end_inset + + by +\begin_inset Formula $\frac{x_{1}+y_{1}}{x_{i}+y_{1}}$ +\end_inset + + times the first row, + we get +\begin_inset Formula +\begin{multline*} +\left|\begin{array}{cccc} +\frac{1}{x_{1}+y_{1}} & \frac{1}{x_{1}+y_{2}} & \cdots & \frac{1}{x_{1}+y_{n}}\\ +\frac{1}{x_{2}+y_{1}} & \frac{1}{x_{2}+y_{2}} & \cdots & \frac{1}{x_{2}+y_{n}}\\ +\vdots & \vdots & & \vdots\\ +\frac{1}{x_{n}+y_{1}} & \frac{1}{x_{n}+y_{2}} & \cdots & \frac{1}{x_{n}+y_{n}} +\end{array}\right|=\\ +=\left|\begin{array}{cccc} +\frac{1}{x_{1}+y_{1}} & \frac{1}{x_{1}+y_{2}} & \cdots & \frac{1}{x_{1}+y_{n}}\\ +0 & \frac{1}{x_{2}+y_{2}}-\frac{x_{1}+y_{1}}{(x_{1}+y_{2})(x_{2}+y_{1})} & \cdots & \frac{1}{x_{2}+y_{n}}-\frac{x_{1}+y_{1}}{(x_{1}+y_{n})(x_{2}+y_{1})}\\ +\vdots & \vdots & & \vdots\\ +0 & \frac{1}{x_{n}+y_{2}}-\frac{x_{1}+y_{1}}{(x_{1}+y_{2})(x_{n}+y_{1})} & \cdots & \frac{1}{x_{n}+y_{n}}-\frac{x_{1}+y_{1}}{(x_{1}+y_{n})(x_{n}+y_{1})} +\end{array}\right|=\\ +=\frac{1}{x_{1}+y_{1}}\left|\begin{array}{ccc} +\frac{1}{x_{2}+y_{2}}-\frac{x_{1}+y_{1}}{(x_{1}+y_{2})(x_{2}+y_{1})} & \cdots & \frac{1}{x_{2}+y_{n}}-\frac{x_{1}+y_{1}}{(x_{1}+y_{n})(x_{2}+y_{1})}\\ +\vdots & & \vdots\\ +\frac{1}{x_{n}+y_{2}}-\frac{x_{1}+y_{1}}{(x_{1}+y_{2})(x_{n}+y_{1})} & \cdots & \frac{1}{x_{n}+y_{n}}-\frac{x_{1}+y_{1}}{(x_{1}+y_{n})(x_{n}+y_{1})} +\end{array}\right|. +\end{multline*} + +\end_inset + +Now, +\begin_inset Formula +\begin{multline*} +\frac{1}{x_{i}+y_{j}}-\frac{x_{1}+y_{1}}{(x_{1}+y_{j})(x_{i}+y_{1})}=\frac{(x_{1}+y_{j})(x_{i}+y_{1})-(x_{1}+y_{1})(x_{i}+y_{j})}{(x_{i}+y_{j})(x_{1}+y_{j})(x_{i}+y_{1})}=\\ +=\frac{1}{x_{i}+y_{j}}\frac{x_{1}y_{1}+x_{i}y_{j}-x_{1}y_{j}-x_{i}y_{1}}{(x_{1}+y_{j})(x_{i}+y_{1})}=\frac{1}{x_{i}+y_{j}}\frac{(x_{i}-x_{1})(y_{j}-y_{1})}{(x_{1}+y_{j})(x_{i}+y_{1})}, +\end{multline*} + +\end_inset + +so +\begin_inset Formula +\begin{multline*} +\left|\begin{array}{cccc} +\frac{1}{x_{1}+y_{1}} & \frac{1}{x_{1}+y_{2}} & \cdots & \frac{1}{x_{1}+y_{n}}\\ +\frac{1}{x_{2}+y_{1}} & \frac{1}{x_{2}+y_{2}} & \cdots & \frac{1}{x_{2}+y_{n}}\\ +\vdots & \vdots & & \vdots\\ +\frac{1}{x_{n}+y_{1}} & \frac{1}{x_{n}+y_{2}} & \cdots & \frac{1}{x_{n}+y_{n}} +\end{array}\right|=\\ +=\frac{1}{x_{1}+y_{1}}\left|\begin{array}{ccc} +\frac{1}{x_{2}+y_{2}}\frac{(x_{2}-x_{1})(y_{2}-y_{1})}{(x_{1}+y_{2})(x_{2}+y_{1})} & \cdots & \frac{1}{x_{2}+y_{n}}\frac{(x_{2}-x_{1})(y_{n}-y_{1})}{(x_{1}+y_{n})(x_{2}+y_{1})}\\ +\vdots & & \vdots\\ +\frac{1}{x_{n}+y_{2}}\frac{(x_{n}-x_{1})(y_{2}-y_{1})}{(x_{1}+y_{2})(x_{n}+y_{1})} & \cdots & \frac{1}{x_{n}+y_{n}}\frac{(x_{n}-x_{1})(y_{n}-y_{1})}{(x_{1}+y_{n})(x_{n}+y_{1})} +\end{array}\right|=\\ +=\frac{1}{x_{1}+y_{1}}\prod_{i=2}^{n}\frac{x_{i}-x_{1}}{x_{i}+y_{1}}\prod_{j=2}^{n}\frac{y_{j}-y_{1}}{x_{1}+y_{j}}\left|\begin{array}{ccc} +\frac{1}{x_{2}+y_{2}} & \cdots & \frac{1}{x_{2}+y_{n}}\\ +\vdots & & \vdots\\ +\frac{1}{x_{n}+y_{2}} & \cdots & \frac{1}{x_{n}+y_{n}} +\end{array}\right|=\\ +=\frac{\prod_{j=2}^{n}(x_{j}-x_{1})(y_{j}-y_{1})}{(x_{1}+y_{1})\prod_{i=2}^{n}(x_{j}+y_{1})\prod_{j=2}^{n}(x_{1}+y_{j})}\frac{\prod_{2\leq in\#$ +\end_inset + +. +\end_layout + +\begin_layout Description +\begin_inset Formula $2\implies3]$ +\end_inset + + Multiply the inequality by +\begin_inset Formula $-1$ +\end_inset + + and add +\begin_inset Formula $x+n$ +\end_inset + + to each member. +\end_layout + +\begin_layout Description +\begin_inset Formula $3\implies1]$ +\end_inset + + +\begin_inset Formula $n\leq x$ +\end_inset + + and any +\begin_inset Formula $m\in\mathbb{Z}$ +\end_inset + + with +\begin_inset Formula $m\leq x$ +\end_inset + + has +\begin_inset Formula $m0$ +\end_inset + +. + Show that if +\begin_inset Formula $(x-z)/y$ +\end_inset + + is an integer and if +\begin_inset Formula $0\leq z1$ +\end_inset + + are necessary and sufficient to guarantee that +\begin_inset Formula $\lfloor\log_{b}x\rfloor=\left\lfloor \log_{b}\lfloor x\rfloor\right\rfloor $ +\end_inset + + for all real +\begin_inset Formula $x\geq1$ +\end_inset + +? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +It happens if and only if +\begin_inset Formula $b\in\mathbb{Z}$ +\end_inset + +. + To prove this, + observe that, + since the logarithm in base +\begin_inset Formula $b>1$ +\end_inset + + is strictly increasing, + +\begin_inset Formula $\log_{b}\lfloor x\rfloor<\log_{b}x$ +\end_inset + +, + so +\begin_inset Formula $\lfloor\log_{b}x\rfloor\neq\left\lfloor \log_{b}\lfloor x\rfloor\right\rfloor $ +\end_inset + + if and only if +\begin_inset Formula $\left\lfloor \log_{b}\lfloor x\rfloor\right\rfloor <\lfloor\log_{b}x\rfloor$ +\end_inset + +, + that is, + if there exists an integer +\begin_inset Formula $k$ +\end_inset + + (namely +\begin_inset Formula $\lfloor\log_{b}x\rfloor$ +\end_inset + +) such that +\begin_inset Formula $\log_{b}\lfloor x\rfloor0$ +\end_inset + +, + prove that +\begin_inset Formula +\[ +\lfloor(x+m)/n\rfloor=\left\lfloor (\lfloor x\rfloor+m)/n\right\rfloor +\] + +\end_inset + +for all real +\begin_inset Formula $x$ +\end_inset + +. + (When +\begin_inset Formula $m=0$ +\end_inset + +, + we have an important special case.) Does an analogous result hold for the ceiling function? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Clearly +\begin_inset Formula $\left\lfloor \frac{\lfloor x\rfloor+m}{n}\right\rfloor \leq\left\lfloor \frac{x+m}{n}\right\rfloor $ +\end_inset + +. + If this inequality were strict, + however, + there would be an integer +\begin_inset Formula $k$ +\end_inset + + such that +\begin_inset Formula $\frac{\lfloor x\rfloor+m}{n}e_{2}>\dots>e_{r}\geq0$ +\end_inset + +. + Show that +\begin_inset Formula $n!$ +\end_inset + + is divisible by +\begin_inset Formula $2^{n-r}$ +\end_inset + + but not by +\begin_inset Formula $2^{n-r+1}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +This is exactly to say that, + for +\begin_inset Formula $p=2$ +\end_inset + +, + +\begin_inset Formula $\mu=n-r$ +\end_inset + +. + But +\begin_inset Formula $r$ +\end_inset + + is the sum of all bits of +\begin_inset Formula $n$ +\end_inset + + in base 2, + so by Exercise 12, + +\begin_inset Formula $\mu=\frac{1}{2-1}(n-r)=n-r$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc12[M22] +\end_layout + +\end_inset + +(A. + Legendre, + 1808.) Generalizing the result of the previous exercise, + let +\begin_inset Formula $p$ +\end_inset + + be a prime number, + and let the representation of +\begin_inset Formula $n$ +\end_inset + + in the +\begin_inset Formula $p$ +\end_inset + +-ary number system be +\begin_inset Formula $n=a_{k}p^{k}+a_{k-1}p^{k-1}+\dots+a_{1}p+a_{0}$ +\end_inset + +. + Express the number +\begin_inset Formula $\mu$ +\end_inset + + of Eq. + (8) in a simple formula involving +\begin_inset Formula $n$ +\end_inset + +, + +\begin_inset Formula $p$ +\end_inset + +, + and +\begin_inset Formula $a$ +\end_inset + +'s. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +The question makes sense for +\begin_inset Formula $n\in\mathbb{N}^{*}$ +\end_inset + +. + Then, + given that the previous exercise showed that, + for +\begin_inset Formula $p=2$ +\end_inset + +, + +\begin_inset Formula $\mu=n-r$ +\end_inset + +, + where +\begin_inset Formula $r\coloneqq|\{k\in\mathbb{N}\mid a_{k}\neq0\}|=\sum_{k}a_{k}$ +\end_inset + +, + a guess is that +\begin_inset Formula $\mu=n-\sum_{k}a_{k}$ +\end_inset + + for any other positive prime integer +\begin_inset Formula $p$ +\end_inset + + as well, + that is, + +\begin_inset Formula $n-\mu=\sum_{k}a_{k}$ +\end_inset + +. + To prove this, +\begin_inset Formula +\[ +\mu=\sum_{j\geq1}\left\lfloor \frac{n}{p^{j}}\right\rfloor =\sum_{j=1}^{k}\sum_{i=j}^{k}a_{i}p^{i-j}=\sum_{1\leq j\leq i\leq k}a_{i}p^{i-j}=\sum_{i=1}^{k}a_{i}\left(\sum_{j=0}^{i-1}p^{j}\right)=\sum_{i=1}^{k}\frac{a_{i}(p^{i}-1)}{p-1}, +\] + +\end_inset + +where the latter identity is because of the cyclotomic formula. + Then, +\begin_inset Formula +\begin{align*} +\sum_{i=1}^{k}\frac{a_{i}(p^{i}-1)}{p-1} & =\frac{1}{p-1}\left(\sum_{i=1}^{k}a_{i}p^{i}-\sum_{i=1}^{k}a_{i}\right)=\frac{1}{p-1}\left((n-a_{0})-\sum_{i\geq1}a_{i}\right)\\ + & =\frac{1}{p-1}\left(n-\sum_{i\geq0}a_{i}\right). +\end{align*} + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc22[HM20] +\end_layout + +\end_inset + +Try to put yourself in Euler's place, + looking for a way to generalize +\begin_inset Formula $n!$ +\end_inset + + to noninteger values of +\begin_inset Formula $n$ +\end_inset + +. + Since +\begin_inset Formula $(n+\frac{1}{2})!/n!$ +\end_inset + + times +\begin_inset Formula $((n+\frac{1}{2})+\frac{1}{2})!/(n+\frac{1}{2})!$ +\end_inset + + equals +\begin_inset Formula $(n+1)!/n!=n+1$ +\end_inset + +, + it seems natural that +\begin_inset Formula $(n+\frac{1}{2})!/n!$ +\end_inset + + should be approximately +\begin_inset Formula $\sqrt{n}$ +\end_inset + +. + Similarly, + +\begin_inset Formula $(n+\frac{1}{3})!/n!$ +\end_inset + + should be +\begin_inset Formula $\approx\sqrt[3]{n}$ +\end_inset + +. + Invent a hypothesis about the ratio +\begin_inset Formula $(n+x)!/n!$ +\end_inset + + as +\begin_inset Formula $n$ +\end_inset + + approaches infinity. + Is your hypothesis correct when +\begin_inset Formula $x$ +\end_inset + + is an integer? + Does it tell anything about the appropriate value of +\begin_inset Formula $x!$ +\end_inset + + when +\begin_inset Formula $x$ +\end_inset + + is not an integer? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +The previous examples show +\begin_inset Formula $\frac{(n+\frac{1}{m})!}{n!}\approx\sqrt[m]{n}=n^{\frac{1}{m}}$ +\end_inset + +, + which is to say that +\begin_inset Formula $\frac{(n+x)!}{n!}\approx n^{x}$ +\end_inset + + for +\begin_inset Formula $x=\frac{1}{m}$ +\end_inset + +. + As +\begin_inset Formula $n$ +\end_inset + + gets bigger, + the approximation should probably be more accurate for the same value of +\begin_inset Formula $x$ +\end_inset + +, + so we could see that +\begin_inset Formula $(n+x)!\approx n^{x}n!$ +\end_inset + +. + For a non-negative integer +\begin_inset Formula $x$ +\end_inset + +, + +\begin_inset Formula $(n+x)!=(n+1)\cdots(n+x)\cdot n!$ +\end_inset + +, + so as +\begin_inset Formula $n$ +\end_inset + + gets bigger the approximation is more and more precise, + and in fact, +\begin_inset Formula +\[ +\lim_{n}\frac{n^{x}n!}{(n+x)!}=\lim_{n}\frac{n^{x}}{(n+1)\cdots(n+x)}=\lim_{n}\prod_{k=1}^{x}\frac{n}{n+k}=1. +\] + +\end_inset + +Multiplying by +\begin_inset Formula $x!$ +\end_inset + +, +\begin_inset Formula +\[ +x!=\lim_{n}\frac{n^{x}x!n!}{(n+x)!}=\lim_{n}(n^{x}n!)\frac{x!}{(n+x)!}=\lim_{n}\frac{n^{x}n!}{(x+1)\cdots(x+n)}, +\] + +\end_inset + +which is Euler's factorial formula. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc24[HM21] +\end_layout + +\end_inset + +Prove the handy inequalities +\begin_inset Formula +\begin{align*} +\frac{n^{n}}{\text{e}^{n-1}} & \leq n!\leq\frac{n^{n+1}}{\text{e}^{n-1}}, & \text{integer }n & \geq1. +\end{align*} + +\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 +(Looking at the answers.) +\end_layout + +\end_inset + +We have +\begin_inset Formula +\begin{align*} +\frac{n^{n}}{n!} & =\prod_{k=1}^{n}\frac{n}{k}=\prod_{k=1}^{n-1}\frac{n}{k}=\prod_{k=1}^{n-1}\prod_{j=k}^{n-1}\frac{j+1}{j}=\prod_{1\leq k\leq j + + + + + + + + + + + + + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $r$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\binom{r}{0}$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\binom{r}{1}$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\binom{r}{2}$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\binom{r}{3}$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\binom{r}{4}$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\binom{r}{5}$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\binom{r}{6}$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\binom{r}{7}$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\binom{r}{8}$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\binom{r}{9}$ +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $-3$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $-3$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $6$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $-10$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $15$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $-21$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $28$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $-36$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $45$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $-55$ +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $-2$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $-2$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $3$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $-4$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $5$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $-6$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $7$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $-8$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $9$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $-10$ +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $-1$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $-1$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $1$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $-1$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $-1$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $-1$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $-1$ +\end_inset + + +\end_layout + +\end_inset + + + + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc8[00] +\end_layout + +\end_inset + +What property of Pascal's triangle is reflected in the +\begin_inset Quotes eld +\end_inset + +symmetry condition, +\begin_inset Quotes erd +\end_inset + + Eq. + (6)? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +The symmetry of each row +\begin_inset Formula $r$ +\end_inset + + with center in +\begin_inset Formula $k=\frac{r}{2}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc9[01] +\end_layout + +\end_inset + +What is the value of +\begin_inset Formula $\binom{n}{n}$ +\end_inset + +? + (Consider all integers +\begin_inset Formula $n$ +\end_inset + +.) +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +For +\begin_inset Formula $n\geq0$ +\end_inset + +, + +\begin_inset Formula $\binom{n}{n}=\frac{n!}{n!1!}=1$ +\end_inset + +. + For +\begin_inset Formula $n<0$ +\end_inset + +, + by definition +\begin_inset Formula $\binom{n}{n}=0$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc10[M25] +\end_layout + +\end_inset + +If +\begin_inset Formula $p$ +\end_inset + + is prime, + show that: +\end_layout + +\begin_layout Enumerate +\begin_inset Formula $\binom{n}{p}\equiv\left\lfloor \frac{n}{p}\right\rfloor \pmod p$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +\begin_inset Formula $\binom{p}{k}\equiv0\pmod p$ +\end_inset + +, + for +\begin_inset Formula $1\leq k\leq p-1$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +\begin_inset Formula $\binom{p-1}{k}\equiv(-1)^{k}\pmod p$ +\end_inset + +, + for +\begin_inset Formula $0\leq k\leq p-1$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +\begin_inset Formula $\binom{p+1}{k}\equiv0\pmod p$ +\end_inset + +, + for +\begin_inset Formula $2\leq k\leq p-1$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +(É. + Lucas, + 1877.) +\begin_inset Formula +\[ +\binom{n}{k}\equiv\binom{\lfloor n/p\rfloor}{\lfloor k/p\rfloor}\binom{n\bmod p}{k\bmod p}\pmod p. +\] + +\end_inset + + +\end_layout + +\begin_layout Enumerate +If the representations of +\begin_inset Formula $n$ +\end_inset + + and +\begin_inset Formula $k$ +\end_inset + + in the +\begin_inset Formula $p$ +\end_inset + +-ary number system are +\begin_inset Formula +\begin{eqnarray*} +\begin{array}{rlc} +n & = & a_{r}p^{r}+\dots+a_{1}p+a_{0},\\ +k & = & b_{r}p^{r}+\dots+b_{1}p+b_{0}, +\end{array} & \text{then} & \binom{n}{k}\equiv\binom{a_{r}}{b_{r}}\cdots\binom{a_{1}}{b_{1}}\binom{a_{0}}{b_{0}}\pmod p. +\end{eqnarray*} + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We assume +\begin_inset Formula $n\in\mathbb{Z}$ +\end_inset + + and +\begin_inset Formula $k\in\mathbb{N}$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Using part 5, +\begin_inset Formula +\[ +\binom{n}{p}\equiv\binom{\lfloor n/p\rfloor}{\lfloor p/p\rfloor}\binom{n\bmod p}{p\bmod p}=\binom{\lfloor n/p\rfloor}{1}\binom{n\bmod p}{0}=\left\lfloor \frac{n}{p}\right\rfloor \cdot1. +\] + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout +\begin_inset Note Comment +status open + +\begin_layout Plain Layout +Since we know +\begin_inset Formula $\binom{n}{p}=\frac{n(n-1)\cdots(n-p+1)}{1\cdot2\cdot\cdots\cdot p}\in\mathbb{Z}$ +\end_inset + + (because of the addition formula), + and since +\begin_inset Formula $p$ +\end_inset + + appears once in the denominator, + there must be a +\begin_inset Formula $k\in\{0,\dots,p-1\}$ +\end_inset + + such that +\begin_inset Formula $p\mid n-k$ +\end_inset + +, + and it obviously must be unique. + It's then easy to see that +\begin_inset Formula $\lfloor\frac{n}{p}\rfloor=\frac{n-k}{p}$ +\end_inset + +, + and so +\begin_inset Formula +\[ +\binom{n}{p}\equiv\left\lfloor \frac{n}{p}\right\rfloor \frac{n(n-1)\cdots(n-k+1)(n-k-1)\cdots(n-p+1)}{1\cdot2\cdots(p-1)}\pmod p. +\] + +\end_inset + +Let us call +\begin_inset Formula $b$ +\end_inset + + the numerator in the fraction of the above formula, + we just need to prove that +\begin_inset Formula $\frac{b}{(p-1)!}\equiv1\pmod p$ +\end_inset + +, + which by rule 1.2.4–C is equivalent to +\begin_inset Formula $b\equiv(p-1)!\bmod p!$ +\end_inset + +. + Since +\begin_inset Formula $b$ +\end_inset + + is a multiple of +\begin_inset Formula $(p-1)!$ +\end_inset + + (otherwise +\begin_inset Formula $\binom{n}{p}$ +\end_inset + + would be an integer), + +\begin_inset Formula $b\equiv0\equiv(p-1)!\bmod(p-1)!$ +\end_inset + +, + and since +\begin_inset Formula $\{(n-j)\bmod p\}_{0\leq j0. +\end{array}\right. +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc39[M10] +\end_layout + +\end_inset + +What is the sum +\begin_inset Formula $\sum_{k}\stirla nk$ +\end_inset + + of the numbers in each row of Stirling's first triangle? + What is the sum of these numbers with alternating signs? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We can use Equation 44: +\end_layout + +\begin_layout Standard +\begin_inset Formula +\begin{multline*} +\sum_{k}\stirla nk=(-1)^{-n}\sum_{k}(-1)^{n-k}\stirla nk(-1)^{k}=(-1)^{n}(-1)^{\underline{n}}=\\ +=(-1)^{n}(-1)(-2)\cdots(-n)=n!, +\end{multline*} + +\end_inset + + +\begin_inset Formula +\[ +\sum_{k}\stirla nk(-1)^{k}=\sum_{k}\stirla nk(-1)^{-k}=(-1)^{-n}\sum_{k}(-1)^{n-k}\stirla nk1^{k}=(-1)^{n}1^{\underline{n}}=\delta_{n0}-\delta_{n1}. +\] + +\end_inset + +The first equation makes sense, + as it is the number of permutations of +\begin_inset Formula $n$ +\end_inset + + symbols irrespective of the number +\begin_inset Formula $k$ +\end_inset + + of cycles. + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc42[HM10] +\end_layout + +\end_inset + +Express the binomial coefficient +\begin_inset Formula $\binom{r}{k}$ +\end_inset + + in terms of the beta function defined above. + (This gives us a way to extend the definition to all real values of +\begin_inset Formula $k$ +\end_inset + +.) +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +For integers +\begin_inset Formula $r\geq0$ +\end_inset + + and +\begin_inset Formula $k\neq0$ +\end_inset + +, + +\begin_inset Formula +\[ +\binom{r}{k}=\frac{r!}{k!(r-k)!}=\frac{\Gamma(r+1)}{\Gamma(k+1)\Gamma(r-k)}=\frac{\Gamma(r+1)}{k\Gamma(k)\Gamma(r-k+1)}=(kB(k,r-k+1))^{-1}. +\] + +\end_inset + +We can extend this function to the points where it is not defined by taking limits. +\end_layout + +\begin_layout Standard +We are not required to evaluate the domain of this function, + but we have to see that it matches our definition for +\begin_inset Formula $r\in\mathbb{R}$ +\end_inset + + and +\begin_inset Formula $k\in\mathbb{Z}$ +\end_inset + +. + For +\begin_inset Formula $k\in\mathbb{N}$ +\end_inset + +, + we first see that +\begin_inset Formula +\begin{multline*} +\lim_{(x,y)\to(r,k)}\frac{\Gamma(x-y+1)}{\Gamma(x-k+1)}=\lim_{(x,y)\to(r,k)}\frac{\lim_{m}\frac{m^{x-y}m!}{(x-y+1)\cdots(x-y+m)}}{\lim_{m}\frac{m^{x-k}m!}{(x-k+1)\cdots(x-k+m)}}=\\ +=\lim_{(x,y)\to(r,k)}\lim_{m}m^{k-y}\prod_{i=1}^{m}\frac{x+m-y}{x+m-k}=1, +\end{multline*} + +\end_inset + +where I don't remember enough of my calculus lessons to know why the last step is correct but it has to do with exchanging limits. + With this, + if we successively apply the fact that +\begin_inset Formula $\Gamma(x+1)=x\Gamma(x)$ +\end_inset + +, + +\begin_inset Formula +\begin{multline*} +\lim_{(x,y)\to(r,k)}\frac{\Gamma(x+1)}{y\Gamma(y)\Gamma(x-y+1)}=\lim_{(x,y)\to(r,k)}\frac{x(x-1)\cdots(x-k+1)}{y\Gamma(y)\frac{\Gamma(x-y+1)}{\Gamma(x-k+1)}}=\\ +=\frac{r(r-1)\cdots(r-k+1)}{k!}. +\end{multline*} + +\end_inset + +If +\begin_inset Formula $k\in\mathbb{Z}^{-}$ +\end_inset + +, + for +\begin_inset Formula $r\notin\mathbb{Z}^{-}$ +\end_inset + +, + +\begin_inset Formula $\Gamma(r+1)$ +\end_inset + + is bounded in an open set around +\begin_inset Formula $(r,k)$ +\end_inset + +, + and since +\begin_inset Formula $\Gamma$ +\end_inset + + is continuous and has no zeros, + the denominator tends to infinity, + so the corresponding limit correctly evaluates to 0. + If +\begin_inset Formula $k,r\in\mathbb{Z}^{-}$ +\end_inset + + I can't find if the value is defined, + but if it is then its value is 0. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc44[HM20] +\end_layout + +\end_inset + +Using the generalized binomial coefficient suggested in exercise 42, + show that +\begin_inset Formula +\[ +\binom{r}{1/2}=2^{2r+1}\bigg/\binom{2r}{r}\pi. +\] + +\end_inset + + +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +From the definition, +\begin_inset Formula +\[ +\binom{r}{\frac{1}{2}}=\frac{1}{\frac{1}{2}B(\frac{1}{2},r+\frac{1}{2})}=\frac{2\Gamma(r+1)}{\Gamma(\frac{1}{2})\Gamma(r+\frac{1}{2})}. +\] + +\end_inset + +Now, + we know +\begin_inset Formula $\frac{\sqrt{\pi}}{2}=(\frac{1}{2})!=\frac{1}{2}\Gamma(\frac{1}{2})$ +\end_inset + +, + so +\begin_inset Formula $\Gamma(\frac{1}{2})=\sqrt{\pi}$ +\end_inset + + and +\begin_inset Formula +\[ +\binom{r}{\frac{1}{2}}=\frac{2r!}{\sqrt{\pi}(r-\frac{1}{2})(r-\frac{3}{2})\cdots(\frac{1}{2})\sqrt{\pi}}=\frac{2r!2^{r}}{\pi(2r-1)(2r-3)\cdots1}. +\] + +\end_inset + +We see that +\begin_inset Formula $(2r)!=((2r)(2r-2)\cdots2)((2r-1)(2r-3)\cdots1)$ +\end_inset + +. + We already have the second factor, + and the first one is precisely +\begin_inset Formula $2^{r}r!$ +\end_inset + +, + so we multiply both numerator and denominator by this factor to get that +\begin_inset Formula +\[ +\binom{r}{\frac{1}{2}}=\frac{2r!2^{r}2^{r}r!}{\pi(2r)!}=\frac{2^{2r+1}}{\binom{2r}{r}\pi}. +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc46[M21] +\end_layout + +\end_inset + +Using Stirling's approximation, + Eq. + 1.2.5–(7), + find an approximate value of +\begin_inset Formula $\binom{x+y}{y}$ +\end_inset + +, + assuming that both +\begin_inset Formula $x$ +\end_inset + + and +\begin_inset Formula $y$ +\end_inset + + are large. + In particular, + find the approximate size of +\begin_inset Formula $\binom{2n}{n}$ +\end_inset + + when +\begin_inset Formula $n$ +\end_inset + + is large. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +For large +\begin_inset Formula $x$ +\end_inset + + and +\begin_inset Formula $y$ +\end_inset + +, +\begin_inset Formula +\begin{multline*} +\binom{x+y}{y}=\frac{(x+y)!}{x!y!}\approx\frac{\sqrt{2\pi(x+y)}\left(\frac{x+y}{\text{e}}\right)^{x+y}}{\sqrt{2\pi x}\sqrt{2\pi y}\left(\frac{x}{\text{e}}\right)^{x}\left(\frac{y}{\text{e}}\right)^{y}}=\sqrt{\frac{x+y}{2\pi xy}}\left(\frac{(x+y)^{x+y}}{x^{x}y^{y}}\right)=\\ +=\frac{(x+y)^{x+y+\nicefrac{1}{2}}}{\sqrt{2\pi}x^{x+\nicefrac{1}{2}}y^{y+\nicefrac{1}{2}}}=\sqrt{\frac{1}{2\pi}\left(\frac{1}{x}+\frac{1}{y}\right)}\left(1+\frac{y}{x}\right)^{x}\left(1+\frac{x}{y}\right)^{y}. +\end{multline*} + +\end_inset + +Then, + for large +\begin_inset Formula $n$ +\end_inset + +, +\begin_inset Formula +\[ +\binom{2n}{n}=\frac{(2n)^{2n+\nicefrac{1}{2}}}{\sqrt{2\pi}n^{2n+1}}=\frac{2^{2n}\sqrt{2}n^{2n}\sqrt{n}}{\sqrt{2\pi}n^{2n}n}=\frac{4^{n}}{\sqrt{\pi n}}. +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc48[M25] +\end_layout + +\end_inset + +Show that +\begin_inset Formula +\[ +\sum_{k\geq0}\binom{n}{k}\frac{(-1)^{k}}{k+x}=\frac{n!}{x(x+1)\cdots(x+n)}=\frac{1}{x\binom{n+x}{n}}, +\] + +\end_inset + +if the denominators are not zero. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +The second equality is obvious. + For the first one, + since the way the formula is written assumes +\begin_inset Formula $n\in\mathbb{N}$ +\end_inset + +, + we can prove this by induction. + For +\begin_inset Formula $n=0$ +\end_inset + +, +\begin_inset Formula +\[ +\sum_{k\geq0}\binom{0}{k}\frac{(-1)^{k}}{k+x}=\frac{1}{x}=\frac{0!}{x}. +\] + +\end_inset + +For +\begin_inset Formula $n>0$ +\end_inset + +, +\begin_inset Formula +\begin{multline*} +\sum_{k\geq0}\binom{n}{k}\frac{(-1)^{k}}{k+x}=\sum_{k\geq0}\binom{n-1}{k}\frac{(-1)^{k}}{k+x}+\sum_{k\geq0}\binom{n-1}{k-1}\frac{(-1)^{k}}{k+x}=\\ +=\sum_{k\geq0}\binom{n-1}{k}\frac{(-1)^{k}}{k+x}+\sum_{k\geq0}\binom{n-1}{k}\frac{(-1)^{k+1}}{k+1+x}=\frac{1}{x\binom{n-1+x}{n-1}}-\frac{1}{(x+1)\binom{n+x}{n-1}}=\\ +=\frac{(n-1)!}{x(x+1)\cdots(x+n-1)}-\frac{(n-1)!}{(x+1)(x+2)\cdots(x+n)}=\frac{(n-1)!((\cancel{x+}n)\cancel{-x})}{x(x+1)\cdots(x+n)}. +\end{multline*} + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc57[M22] +\end_layout + +\end_inset + +Show that the coefficient +\begin_inset Formula $a_{m}$ +\end_inset + + in Stirling's attempt at generalizing the factorial function, + Eq. + 1.2.5–(12), + is +\begin_inset Formula +\[ +\frac{(-1)^{m}}{m!}\sum_{k\geq1}(-1)^{k}\binom{m-1}{k-1}\ln k. +\] + +\end_inset + +Also find +\begin_inset Formula $q$ +\end_inset + +-nomial generalizations of the fundamental identities (17) and (21). +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +The sum in Stirling's attempt is +\begin_inset Formula +\begin{eqnarray*} +S_{n} & = & \sum_{k\geq0}a_{k+1}\prod_{j=0}^{k}(n-j)=\sum_{m\geq1}a_{m}\prod_{j=0}^{m-1}(n-j)\\ + & = & \sum_{m\geq1}\frac{(-1)^{m}}{m!}\left(\sum_{k\geq1}(-1)^{k}\binom{m-1}{k-1}\ln k\right)\prod_{j=0}^{m-1}(n-j)\\ + & = & \sum_{k\geq1}\left(\sum_{m\geq1}(-1)^{m+k}\binom{n}{m}\binom{m-1}{k-1}\right)\ln k. +\end{eqnarray*} + +\end_inset + +There are several things happening in the last line. + First, + note that both sums are bounded, + for +\begin_inset Formula $m$ +\end_inset + + must be at most +\begin_inset Formula $n$ +\end_inset + + because otherwise the product would contain a factor +\begin_inset Formula $n-n=0$ +\end_inset + +, + and +\begin_inset Formula $k$ +\end_inset + + must be lower than +\begin_inset Formula $m$ +\end_inset + +, + and therefore lower than +\begin_inset Formula $n$ +\end_inset + +, + because otherwise the factor +\begin_inset Formula $\binom{m-1}{k-1}$ +\end_inset + + would be 0. + This allows us to swap the sums and extract a factor that only depends on +\begin_inset Formula $k$ +\end_inset + +. + Moreover, +\begin_inset Formula +\[ +\frac{\prod_{j=0}^{m-1}(n-j)}{m!}=\frac{\prod_{j=1}^{m}(n-j+1)}{\prod_{j=1}^{m}j}=\binom{n}{m}. +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +Let +\begin_inset Formula $A_{k}$ +\end_inset + + be the value of the inner sum for a given +\begin_inset Formula $k$ +\end_inset + +, + we know that +\begin_inset Formula $A_{k}=0$ +\end_inset + + for +\begin_inset Formula $k>n$ +\end_inset + +, + and if we prove that +\begin_inset Formula $A_{k}=1$ +\end_inset + + for +\begin_inset Formula $k\leq n$ +\end_inset + +, + we would have +\begin_inset Formula +\[ +S_{n}=\sum_{k=1}^{n}\ln k=\ln\prod_{k=1}^{n}k=\ln n! +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +Now, + we have +\begin_inset Formula +\begin{align*} +A_{k} & =\sum_{m\geq1}(-1)^{m+k}\binom{n}{m}\binom{m-1}{k-1}\\ + & =\sum_{m}(-1)^{m+k}\binom{n}{m}\binom{m-1}{k-1}-(-1)^{k}\binom{-1}{k-1} & (*)\\ + & =\sum_{m}(-1)^{n-m-k}\binom{n}{n-m}\binom{n-m-1}{k-1}+1 & (**)\\ + & =-\sum_{m}(-1)^{n-m}\binom{n}{m}\binom{k-1-n+m}{k-1}+1 & \text{Rules B, G}\\ + & =-\binom{k-1-n}{k-1-n}+1=1, & \text{Eq. (23)} +\end{align*} + +\end_inset + +where in +\begin_inset Formula $(*)$ +\end_inset + + we expand the domain of +\begin_inset Formula $m$ +\end_inset + + to all integers and subtract the case when +\begin_inset Formula $m=0$ +\end_inset + + to compensate for that (this is the only nonzero term that wasn't considered already) and in +\begin_inset Formula $(**)$ +\end_inset + + we change +\begin_inset Formula $m$ +\end_inset + + to +\begin_inset Formula $n-m$ +\end_inset + +. +\end_layout + +\begin_layout Standard +For the second part of the exercise, + we start by writing the identities (17) and (21) in +\begin_inset Formula $q$ +\end_inset + +-nomial notation. + For (17), + this would be +\begin_inset Formula +\begin{eqnarray*} +\binom{r}{k,r-k}=(-1)^{k}\binom{k-r-1}{k,-r-1}, & \text{ or } & \binom{a+b}{a,b}=(-1)^{a}\binom{-b-1}{a,-(a+b)-1}. +\end{eqnarray*} + +\end_inset + +That is, + this allows us to change the sum on top to something resembling just one of the numbers that were on the bottom part. + To generalize this, +\begin_inset Formula +\begin{align*} +\binom{k_{1}+\dots+k_{m}}{k_{1},\dots,k_{m}} & =\binom{k_{1}+k_{2}}{k_{1}}\cdots\binom{k_{1}+\dots+k_{m}}{k_{1}+\dots+k_{m-1}}\\ + & =(-1)^{k_{1}+\dots+k_{m-1}}\binom{k_{1}+k_{2}}{k_{1}}\cdots\binom{k_{1}+\dots+k_{m-1}}{k_{1}+\dots+k_{m-2}}\binom{-k_{m}-1}{k_{1}+\dots+k_{m-1}}\\ + & =(-1)^{k_{1}+\dots+k_{m-1}}\binom{-k_{m}-1}{k_{1},\dots,k_{m-1},-(k_{1}+\dots+k_{m})-1}. +\end{align*} + +\end_inset + +We are abusing notation here, + since the book only defines multinomial coefficients for +\begin_inset Formula $k_{i}\geq0$ +\end_inset + +, + but we can define them for any +\begin_inset Formula $k_{i}\in\mathbb{Z}$ +\end_inset + + by using the property that relates them to binomial coefficients, + at the cost of symmetry with respect to the order of the +\begin_inset Formula $k_{i}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +For (21), + this would be +\begin_inset Formula +\[ +\sum_{k}\binom{r}{k,r-k}\binom{s}{n-k,s-n+k}=\binom{r+s}{n,r+s-n}. +\] + +\end_inset + +That is, + in this case we would add up all the numbers on each component. + This clearly holds if we place +\begin_inset Formula $k,r-k$ +\end_inset + + and +\begin_inset Formula $n-k,s-n+k$ +\end_inset + + as the two last components of the multinomial coefficient. + There must be a better (less silly) generalization but I've already spent way too much time in this exercise. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc60[M23] +\end_layout + +\end_inset + +We have seen that +\begin_inset Formula $\binom{n}{k}$ +\end_inset + + is the number of combinations of +\begin_inset Formula $n$ +\end_inset + + things, + +\begin_inset Formula $k$ +\end_inset + + at a time, + namely the number of ways to choose +\begin_inset Formula $k$ +\end_inset + + different things out of a set of +\begin_inset Formula $n$ +\end_inset + +. + The +\emph on +combinations with repetitions +\emph default + are similar to ordinary combinations, + except that we may choose each object any number of times. + Thus, + the list (1) would be extended to include also +\begin_inset Formula $aaa$ +\end_inset + +, + +\begin_inset Formula $aab$ +\end_inset + +, + +\begin_inset Formula $aac$ +\end_inset + +, + +\begin_inset Formula $aad$ +\end_inset + +, + +\begin_inset Formula $aae$ +\end_inset + +, + +\begin_inset Formula $abb$ +\end_inset + +, + etc., + if we were considering combinations with repetition. + How many +\begin_inset Formula $k$ +\end_inset + +-combinations of +\begin_inset Formula $n$ +\end_inset + + objects are there, + if repetition is allowed? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We can draw a bijection between +\begin_inset Formula $k$ +\end_inset + +-combinations of +\begin_inset Formula $\{1,\dots,n\}$ +\end_inset + + with repetition and +\begin_inset Formula $k$ +\end_inset + +-combinations of +\begin_inset Formula $\{1,\dots,n+k-1\}$ +\end_inset + + without repetition by the following assignment: +\begin_inset Formula +\begin{eqnarray*} +1\leq a_{1}\leq a_{2}\leq\dots\leq a_{k}\leq n & \mapsto & 1\leq a_{1}\ln n$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +\begin_inset Formula $H_{n}>\ln n+\gamma$ +\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 +False, + since +\begin_inset Formula $H_{2}=\frac{3}{2}>1>\ln2$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +True, + because the next one is true. +\end_layout + +\begin_layout Enumerate +True. + If this wasn't true for some number +\begin_inset Formula $n$ +\end_inset + +, + then it would be +\begin_inset Formula +\[ +0\geq H_{n}-(\ln n+\gamma)>\frac{1}{2n}-\frac{1}{12n^{2}}+\frac{1}{12n^{4}}-\frac{1}{252n^{6}}, +\] + +\end_inset + +but +\begin_inset Formula $\frac{1}{2n}>\frac{1}{12n^{2}}$ +\end_inset + + and +\begin_inset Formula $\frac{1}{12n^{4}}>\frac{1}{252n^{6}}$ +\end_inset + + for any +\begin_inset Formula $n\geq1\#$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc9[M18] +\end_layout + +\end_inset + +Theorem A applies only when +\begin_inset Formula $x>0$ +\end_inset + +; + what is the value of the sum considered when +\begin_inset Formula $x=-1$ +\end_inset + +? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Using Equation 1.2.6(18) in +\begin_inset Formula $(*)$ +\end_inset + + and Exercise 1.2.6–48 in +\begin_inset Formula $(**)$ +\end_inset + +, +\begin_inset Formula +\begin{multline*} +\sum_{k=1}^{n}\binom{n}{k}(-1)^{k}H_{k}=\sum_{1\leq j\leq k\leq n}\binom{n}{k}(-1)^{k}\frac{1}{j}=\sum_{j=1}^{n}\frac{1}{j}\sum_{k=j}^{n}\binom{n}{k}(-1)^{k}=\\ +=(-1)^{n}\sum_{j=1}^{n}\frac{1}{j}\sum_{k=0}^{n-j}\binom{n}{k}(-1)^{k}\overset{(*)}{=}(-1)^{\cancel{n}}\sum_{j=1}^{n}\frac{1}{j}(-1)^{\cancel{n}-j}\binom{n-1}{n-j}=\\ +=\sum_{j=0}^{n}\frac{1}{j+1}(-1)^{-j-1}\binom{n-1}{n-j-1}=-\sum_{j=0}^{n-1}\frac{(-1)^{j}}{j+1}\binom{n-1}{j}\overset{(**)}{=}\frac{1}{\binom{n}{n-1}}=-\frac{1}{n}. +\end{multline*} + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc11[M21] +\end_layout + +\end_inset + +Using summation by parts, + evaluate +\begin_inset Formula +\[ +\sum_{10}$ +\end_inset + +, +\begin_inset Formula +\[ +\frac{\Gamma'(n)}{\Gamma(n)}=\lim_{m}(\ln m-H_{n+m}+H_{n-1})=H_{n-1}-\gamma, +\] + +\end_inset + +and we can define +\begin_inset Formula +\[ +H_{x}\coloneqq\frac{\Gamma'(x+1)}{\Gamma(x+1)}+\gamma +\] + +\end_inset + +for any +\begin_inset Formula $x\in\mathbb{C}$ +\end_inset + + where this expression is defined or can be extended by continuity. +\end_layout + +\end_body +\end_document diff --git a/vol1/1.2.8.lyx b/vol1/1.2.8.lyx new file mode 100644 index 0000000..23e44dc --- /dev/null +++ b/vol1/1.2.8.lyx @@ -0,0 +1,1852 @@ +#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 +\usepackage{amsmath} +\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 answer to Leonardo Fibonacci's original problem: + How many pairs of rabbits are present after a year? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +After one month there are +\begin_inset Formula $F_{3}=2$ +\end_inset + + pairs of rabbits, + after two months there are +\begin_inset Formula $F_{4}=3$ +\end_inset + +, + etc., + therefore after a year there are +\begin_inset Formula $F_{14}=377$ +\end_inset + + pairs of rabbits. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc2[20] +\end_layout + +\end_inset + +In view of Eq. + (15), + what is the approximate value of +\begin_inset Formula $F_{1000}$ +\end_inset + +? + (Use logarithms found in Appendix A.) +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Formula +\begin{align*} +F_{1000} & \approx\frac{\phi^{1000}}{\sqrt{5}}=\frac{10^{\log\phi^{1000}}}{\sqrt{5}}=\frac{10^{1000(\ln\phi/\ln10)}}{\sqrt{5}}\cong\frac{10^{1000\cdot0.48121...\cdot0.43429...}}{2.23606...}\cong\frac{10^{208.9876..}}{2.23606...}\\ + & \cong\frac{10^{0.9876}}{2.23606}\cdot10^{208}\cong4.3\cdot10^{208}. +\end{align*} + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc4[14] +\end_layout + +\end_inset + +Find all +\begin_inset Formula $n$ +\end_inset + + for which +\begin_inset Formula $F_{n}=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 Formula $F_{0}=0$ +\end_inset + +, + +\begin_inset Formula $F_{1}=1$ +\end_inset + +. + Then +\begin_inset Formula $F_{2}=1$ +\end_inset + +, + +\begin_inset Formula $F_{3}=2$ +\end_inset + +, + +\begin_inset Formula $F_{4}=3$ +\end_inset + +, + +\begin_inset Formula $F_{5}=5$ +\end_inset + +, + and from here +\begin_inset Formula $F_{n}$ +\end_inset + + grows strictly faster than +\begin_inset Formula $n$ +\end_inset + + so there are no more such numbers. + Thus only 0, + 1, + and 5 meet this condition. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc7[15] +\end_layout + +\end_inset + +If +\begin_inset Formula $n$ +\end_inset + + is not a prime number, + +\begin_inset Formula $F_{n}$ +\end_inset + + is not a prime number (with one exception). + Prove this and find the exception. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +The exception is +\begin_inset Formula $F_{4}=3$ +\end_inset + +. + For the general rule, + let +\begin_inset Formula $r,s\in\mathbb{Z}$ +\end_inset + + with +\begin_inset Formula $r\geq3$ +\end_inset + + and +\begin_inset Formula $s\geq2$ +\end_inset + +, + by Eq. + (6), +\end_layout + +\begin_layout Standard +\begin_inset Formula +\begin{align*} +F_{rs} & =F_{r+r(s-1)}=F_{r(s-1)}F_{r+1}+F_{r(s-1)-1}F_{r}=F_{r}(F_{r(s-1)}+F_{r(s-1)-1})+F_{r-1}F_{r(s-1)}\\ + & =F_{r}\left(F_{r(s-1)+1}+F_{r-1}{\textstyle \frac{F_{r(s-1)}}{F_{r}}}\right), +\end{align*} + +\end_inset + +where the fraction in the last part is an integer. + If +\begin_inset Formula $r>2$ +\end_inset + +, + then +\begin_inset Formula $F_{r}>1$ +\end_inset + + and, + since +\begin_inset Formula $F_{r(s-1)+1}>1$ +\end_inset + +, + we have a decomposition of +\begin_inset Formula $F_{rs}$ +\end_inset + + as a compound number. + Every compound number other than 4 can be expressed as a product of integers +\begin_inset Formula $rs$ +\end_inset + + with +\begin_inset Formula $r\geq3$ +\end_inset + + and +\begin_inset Formula $s\geq2$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc13[M22] +\end_layout + +\end_inset + +Express the following sequences in terms of the Fibonacci numbers, + when +\begin_inset Formula $r$ +\end_inset + +, + +\begin_inset Formula $s$ +\end_inset + +, + and +\begin_inset Formula $c$ +\end_inset + + are given constants: +\end_layout + +\begin_layout Enumerate +\begin_inset Formula $a_{0}=r$ +\end_inset + +, + +\begin_inset Formula $a_{1}=s$ +\end_inset + +; + +\begin_inset Formula $a_{n+2}=a_{n+1}+a_{n}$ +\end_inset + +, + for +\begin_inset Formula $n\geq0$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +\begin_inset Formula $b_{0}=0$ +\end_inset + +, + +\begin_inset Formula $b_{1}=1$ +\end_inset + +; + +\begin_inset Formula $b_{n+2}=b_{n+1}+b_{n}+c$ +\end_inset + +, + for +\begin_inset Formula $n\geq0$ +\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 +We have +\begin_inset Formula +\[ +\binom{a_{n+1}}{a_{n}}=\begin{pmatrix}1 & 1\\ +1 & 0 +\end{pmatrix}\begin{pmatrix}a_{n}\\ +a_{n-1} +\end{pmatrix}=\dots=\begin{pmatrix}1 & 1\\ +1 & 0 +\end{pmatrix}^{n}\begin{pmatrix}s\\ +r +\end{pmatrix}=\begin{pmatrix}F_{n+1}s+F_{n}r\\ +F_{n}s+F_{n-1}r +\end{pmatrix}, +\] + +\end_inset + +so in general +\begin_inset Formula $a_{n}=F_{n-1}r+F_{n}s$ +\end_inset + +, + using the convention that +\begin_inset Formula $F_{-1}=1$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +We have +\begin_inset Formula +\[ +\begin{pmatrix}b_{n+1}\\ +b_{n}\\ +1 +\end{pmatrix}=\begin{pmatrix}1 & 1 & c\\ +1 & 0 & 0\\ +0 & 0 & 1 +\end{pmatrix}\begin{pmatrix}b_{n}\\ +b_{n-1}\\ +1 +\end{pmatrix}=\dots=\begin{pmatrix}1 & 1 & c\\ +1 & 0 & 0\\ +0 & 0 & 1 +\end{pmatrix}^{n}\begin{pmatrix}1\\ +0\\ +1 +\end{pmatrix}. +\] + +\end_inset + +By playing a bit with this matrix, + we come to the conclusion that +\begin_inset Formula +\[ +\begin{pmatrix}1 & 1 & c\\ +1\\ + & & 1 +\end{pmatrix}^{n}=\begin{pmatrix}F_{n+1} & F_{n} & (F_{n+2}-1)c\\ +F_{n} & F_{n-1} & (F_{n+1}-1)c\\ + & & 1 +\end{pmatrix} +\] + +\end_inset + +and therefore +\begin_inset Formula +\[ +b_{n}=F_{n}+(F_{n+1}-1)c. +\] + +\end_inset + +For +\begin_inset Formula $n=0$ +\end_inset + + and +\begin_inset Formula $n=1$ +\end_inset + +, + this is easy to check. + For +\begin_inset Formula $n\geq2$ +\end_inset + +, +\begin_inset Formula +\[ +b_{n}=b_{n-1}+b_{n-2}+c=F_{n-1}+(F_{n}-1)c+F_{n-2}+(F_{n-1}-1)c+c=F_{n}+(F_{n+1}-1)c. +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc16[M20] +\end_layout + +\end_inset + +Fibonacci numbers appear implicitly in Pascal's triangle if it is viewed from the right angle. + Show that the following sum of binomial coefficients is a Fibonacci number: +\begin_inset Formula +\[ +\sum_{k=0}^{n}\binom{n-k}{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 by induction that this sum is precisely +\begin_inset Formula $F_{n+1}$ +\end_inset + +. + For +\begin_inset Formula $n=0$ +\end_inset + + and +\begin_inset Formula $n=1$ +\end_inset + +, + this is a simple check. + For +\begin_inset Formula $n>1$ +\end_inset + +, +\begin_inset Formula +\begin{align*} +\sum_{k=0}^{n}\binom{n-k}{k} & =\sum_{k=0}^{n}\binom{n-k-1}{k}+\sum_{k=0}^{n}\binom{n-k-1}{k-1}\\ + & =\sum_{k=0}^{n}\binom{n-k-1}{k}+\sum_{k=-1}^{n-1}\binom{n-k-2}{k}\\ + & =\sum_{k=0}^{n-1}\binom{(n-1)-k}{k}+\sum_{k=0}^{n-2}\binom{(n-2)-k}{k}=F_{n}+F_{n-1}=F_{n+1}. +\end{align*} + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc22[M20] +\end_layout + +\end_inset + +Show that +\begin_inset Formula $\sum_{k}\binom{n}{k}F_{m+k}$ +\end_inset + + is a Fibonacci number. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We prove by induction on +\begin_inset Formula $n$ +\end_inset + + that this sum is +\begin_inset Formula $F_{m+2n}$ +\end_inset + +. + For +\begin_inset Formula $n=0$ +\end_inset + + and +\begin_inset Formula $n=1$ +\end_inset + +, + this is a simple check. + For +\begin_inset Formula $n>1$ +\end_inset + +, +\begin_inset Formula +\begin{align*} +\sum_{k}\binom{n}{k}F_{m+k} & =\sum_{k}\binom{n-1}{k}F_{m+k}+\sum_{k}\binom{n-1}{k-1}F_{m+k}\\ + & =F_{m+2(n-1)}+\sum_{k}\binom{n-1}{k}F_{m+1+k}\\ + & =F_{m+2(n-1)}+F_{m+1+2(n-1)}=F_{m+2+2(n-1)}=F_{m+2n}. +\end{align*} + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc26[M20] +\end_layout + +\end_inset + +Using the previous exercise, + show that +\begin_inset Formula $F_{p}=5^{(p-1)/2}\pmod p$ +\end_inset + + if +\begin_inset Formula $p$ +\end_inset + + is an odd prime. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +The previous exercise tells us that +\begin_inset Formula +\[ +2^{n}F_{n}=2\sum_{k\text{ odd}}\binom{n}{k}5^{(k-1)/2}. +\] + +\end_inset + +Now, + if +\begin_inset Formula $n=p$ +\end_inset + + is prime, + +\begin_inset Formula $\binom{p}{k}=\frac{p(p-1)\cdots(p-k+1)}{1\cdots k}$ +\end_inset + + is a multiple of +\begin_inset Formula $p$ +\end_inset + + for +\begin_inset Formula $k\in\{1,\dots,p-1\}$ +\end_inset + +, + and +\begin_inset Formula $k=0$ +\end_inset + + is not odd, + so +\begin_inset Formula +\[ +2^{p-1}F_{p}=\sum_{k\text{ odd}}\binom{p}{k}5^{(k-1)/2}\equiv\binom{p}{p}5^{(p-1)/2}=5^{(p-1)/2}\pmod p, +\] + +\end_inset + +but by Fermat's theorem, + +\begin_inset Formula $2^{p-1}\equiv1\pmod p$ +\end_inset + +, + so this simplifies to the desired result. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc29[M23] +\end_layout + +\end_inset + +( +\emph on +Fibonomial coefficients. +\emph default +) Édouard Lucas defined the quantities +\begin_inset Formula +\[ +\binom{n}{k}_{{\cal F}}=\frac{F_{n}F_{n-1}\cdots F_{n-k+1}}{F_{k}F_{k-1}\cdots F_{1}}=\prod_{j=1}^{k}\left(\frac{F_{n-k+j}}{F_{j}}\right) +\] + +\end_inset + +in a manner analogous to binomial coefficients. +\end_layout + +\begin_layout Enumerate +Make a table of +\begin_inset Formula $\binom{n}{k}_{{\cal F}}$ +\end_inset + + for +\begin_inset Formula $0\leq k\leq n\leq6$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Show that +\begin_inset Formula $\binom{n}{k}_{{\cal F}}$ +\end_inset + + is always an integer because we have +\begin_inset Formula +\[ +\binom{n}{k}_{{\cal F}}=F_{k-1}\binom{n-1}{k}_{{\cal F}}+F_{n-k+1}\binom{n-1}{k-1}_{{\cal F}}. +\] + +\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 Note Note +status open + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\end_layout + +\begin_deeper +\begin_layout Standard +\align center +\begin_inset Tabular + + + + + + + + + + + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $n$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\binom{n}{0}$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\binom{n}{1}$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\binom{n}{2}$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\binom{n}{3}$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\binom{n}{4}$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\binom{n}{5}$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\binom{n}{6}$ +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +0 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +2 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +3 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +2 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +2 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +4 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +3 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +6 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +3 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +5 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +5 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +15 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +15 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +5 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +6 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +8 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +40 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +60 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +40 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +8 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + + + +\end_inset + + +\end_layout + +\end_deeper +\begin_layout Enumerate +We have +\begin_inset Formula +\begin{multline*} +F_{k-1}\binom{n-1}{k}_{{\cal F}}+F_{n-k+1}\binom{n-1}{k-1}_{{\cal F}}=\\ +=F_{k-1}\prod_{j=1}^{k}\frac{F_{n-k+j-1}}{F_{j}}+F_{n-k+1}\prod_{j=1}^{k-1}\frac{F_{n-k+j}}{F_{j}}=\\ +=\frac{1}{F_{k}}\left(\prod_{j=1}^{k-1}\frac{F_{n-k+j}}{F_{j}}\right)(F_{k-1}F_{n-k}+F_{n-k+1}F_{k}), +\end{multline*} + +\end_inset + +where the last identity is better read backwards, + and by Eq. + (6), +\begin_inset Formula +\[ +F_{n}=F_{(n-k)+k}=F_{k}F_{n-k+1}+F_{k-1}F_{n-k}, +\] + +\end_inset + +so the above simplifies precisely to +\begin_inset Formula $\binom{n}{k}_{{\cal F}}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc34[M24] +\end_layout + +\end_inset + +( +\emph on +The Fibonacci number system. +\emph default +) Let the notation +\begin_inset Formula $k\gg m$ +\end_inset + + mean that +\begin_inset Formula $k\geq m+2$ +\end_inset + +. + Show that every positive integer +\begin_inset Formula $n$ +\end_inset + + has a +\emph on +unique +\emph default + representation +\begin_inset Formula $n=F_{k_{1}}+F_{k_{2}}+\dots+F_{k_{r}}$ +\end_inset + +, + where +\begin_inset Formula $k_{1}\gg k_{2}\gg\cdots\gg k_{r}\gg0$ +\end_inset + +. +\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\leq3$ +\end_inset + +, + this is easy to check. + Otherwise, + let +\begin_inset Formula $k$ +\end_inset + + be the greatest number such that +\begin_inset Formula $n\geq F_{k}$ +\end_inset + +. + If +\begin_inset Formula $n=F_{k}$ +\end_inset + +, + we're done. + Otherwise +\begin_inset Formula $n>3$ +\end_inset + + and +\begin_inset Formula $k\geq4$ +\end_inset + +, + and +\begin_inset Formula $n-F_{k}F_{j_{1}}\geq2$ +\end_inset + +, + and we want to prove that +\begin_inset Formula +\[ +F_{j_{2}}+\dots+F_{j_{s}}\leq F_{j_{1}-2}+\dots+F_{\lfloor j_{1}\bmod2\rfloor+2}\leq F_{j_{1}-1}\leq F_{k_{1}}-F_{j_{1}}. +\] + +\end_inset + +The first inequality comes from the highest value that +\begin_inset Formula $F_{j_{2}}+\dots+F_{j_{s}}$ +\end_inset + + could possibly have, + and the last one from the highest value that +\begin_inset Formula $F_{j_{1}}+F_{j_{1}-1}$ +\end_inset + + could. + For the middle one we use induction. + For +\begin_inset Formula $j_{1}\in\{2,3\}$ +\end_inset + +, + the left hand side is 0. + Otherwise +\begin_inset Formula +\[ +F_{j_{1}-2}+F_{j_{1}-4}+\dots+F_{\lfloor j_{1}\bmod2\rfloor+2}\leq F_{j_{1}-2}+F_{j_{1}-3}=F_{j_{1}-1}. +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc41[M25] +\end_layout + +\end_inset + +(Yuri Matiyasevich, + 1990.) Let +\begin_inset Formula $f(x)=\lfloor x+\phi^{-1}\rfloor$ +\end_inset + +. + Prove that if +\begin_inset Formula $n=F_{k_{1}}+\dots+F_{k_{r}}$ +\end_inset + + is the representation of +\begin_inset Formula $n$ +\end_inset + + in the Fibonacci number system of exercise 34, + then +\begin_inset Formula $F_{k_{1}+1}+\dots+F_{k_{r}+1}=f(\phi n)$ +\end_inset + +. + Find a similar formula for +\begin_inset Formula $F_{k_{1}-1}+\dots+F_{k_{r}-1}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Using that each +\begin_inset Formula $F_{k_{i}}=\frac{1}{\sqrt{5}}(\phi^{k_{i}}+\hat{\phi}^{k_{i}})$ +\end_inset + +, + let +\begin_inset Formula $m\coloneqq F_{k_{1}+1}+\dots+F_{k_{r}+1}$ +\end_inset + +, + since +\begin_inset Formula $m\in\mathbb{Z}$ +\end_inset + +, +\begin_inset Formula +\begin{align*} +f(\phi n)-m & =\left\lfloor \frac{1}{\sqrt{5}}\left(\sum_{i}\phi^{k_{i}+1}+\sum_{i}\hat{\phi}^{k_{i}-1}\right)-\hat{\phi}\right\rfloor -\frac{1}{\sqrt{5}}\left(\sum_{i}\phi^{k_{i}+1}-\sum_{i}\hat{\phi}^{k_{i}+1}\right)\\ + & =\left\lfloor \frac{1}{\sqrt{5}}\sum_{i}(\hat{\phi}^{k_{i}-1}+\hat{\phi}^{k_{i}+1})-\hat{\phi}\right\rfloor =\left\lfloor \frac{1+\hat{\phi}^{2}}{\sqrt{5}}\sum_{i}\hat{\phi}^{k_{i}-1}-\hat{\phi}\right\rfloor . +\end{align*} + +\end_inset + +Here, + when +\begin_inset Formula $k_{i}$ +\end_inset + + is even, + +\begin_inset Formula $\hat{\phi}^{k_{i}-1}$ +\end_inset + + is negative, + and when it's odd, + +\begin_inset Formula $\hat{\phi}^{k_{i}-1}$ +\end_inset + + is positive, + so the value of this sum is strictly lower than +\begin_inset Formula $\sum_{k\geq1}\hat{\phi}^{2k}=\frac{\hat{\phi}^{2}}{1-\hat{\phi}^{2}}$ +\end_inset + +, + and strictly greater than +\begin_inset Formula $\sum_{k\geq1}\hat{\phi}^{2k-1}=\frac{\hat{\phi}}{1-\hat{\phi}^{2}}$ +\end_inset + +. + Now, + +\begin_inset Formula $\hat{\phi}^{2}=\frac{1}{4}(1-\sqrt{5})^{2}=\frac{1}{4}(6-2\sqrt{5})=\frac{1}{2}(3-\sqrt{5})$ +\end_inset + +, + so +\begin_inset Formula $1-\hat{\phi}^{2}=\frac{1}{2}(2-3+\sqrt{5})=-\frac{1}{2}(1-\sqrt{5})=-\hat{\phi}$ +\end_inset + + and therefore the lower bound of what is inside the brackets above is +\begin_inset Formula +\[ +\frac{1+\hat{\phi}^{2}}{\sqrt{5}}\frac{\hat{\phi}}{1-\hat{\phi}^{2}}-\hat{\phi}=-\frac{1+\hat{\phi}^{2}}{\sqrt{5}}-\hat{\phi}=-\frac{5-\sqrt{5}}{2\sqrt{5}}-\frac{1-\sqrt{5}}{2}=-\frac{5-\sqrt{5}+\sqrt{5}-5}{2\sqrt{5}}=0, +\] + +\end_inset + +and the upper bound is +\begin_inset Formula +\[ +-\hat{\phi}\frac{1+\hat{\phi}^{2}}{\sqrt{5}}-\hat{\phi}=-\hat{\phi}\left(\frac{5-\sqrt{5}}{2\sqrt{5}}+1\right)=-\hat{\phi}\left(\frac{5+\sqrt{5}}{2\sqrt{5}}\right)=-\hat{\phi}\phi=1, +\] + +\end_inset + +and since these bounds are never reached, + the property has been proven. + A similar argument can be made to prove that +\begin_inset Formula $F_{k_{1}-1}+\dots+F_{k_{r}-1}=f(n/\phi)$ +\end_inset + +. +\end_layout + +\end_body +\end_document diff --git a/vol1/1.2.9.lyx b/vol1/1.2.9.lyx new file mode 100644 index 0000000..6bc6c57 --- /dev/null +++ b/vol1/1.2.9.lyx @@ -0,0 +1,846 @@ +#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 +\use_default_options true +\maintain_unincluded_children no +\language american +\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 true +\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[M13] +\end_layout + +\end_inset + +Prove Eq. + (11). +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Formula +\[ +\left(\sum_{n\geq0}\frac{a_{n}}{n!}z^{n}\right)\left(\sum_{m\geq0}\frac{b_{m}}{m!}z^{m}\right)=\sum_{n\geq0}\left(\sum_{k}\frac{a_{k}b_{n-k}}{k!(n-k)!}\right)z^{n}=\sum_{n\geq0}\frac{1}{n!}\left(\sum_{k}\binom{n}{k}a_{k}b_{n-k}\right)z^{n}. +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc4[M01] +\end_layout + +\end_inset + +Explain why Eq. + (19) is a special case of Eq. + (21). +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Just set +\begin_inset Formula $t=0$ +\end_inset + +, + then +\begin_inset Formula $x=1+z$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc6[HM15] +\end_layout + +\end_inset + +Find the generating function for +\begin_inset Formula +\[ +\left\langle \sum_{0n$ +\end_inset + + are null. + Now, + +\begin_inset Formula $[z^{n-k}](1+z)^{2n-2k}=[z^{n}](z^{k}(1+z)^{2n-2k})$ +\end_inset + +, + so this is +\begin_inset Formula +\[ +S\coloneqq[z^{n}](1+z)^{2n}\sum_{k}[w^{k}](1-2w)^{n}\left(\frac{z}{(1+z)^{2}}\right)^{k}=[z^{n}](1+z)^{2n}\left(1-\frac{2z}{(1+z)^{2}}\right)^{n}, +\] + +\end_inset + +where we evaluating the sum by taking +\begin_inset Formula $\frac{z}{(1+z)^{2}}$ +\end_inset + + as the argument of the generating function in +\begin_inset Formula $w$ +\end_inset + +. + Then, + we simplify to get +\begin_inset Formula +\[ +S=[z^{n}]\left(\left((1+z)^{2}(1-\nicefrac{2z}{(1+z)^{2}})\right)^{n}\right)=[z^{n}]\left((1+z^{2})^{n}\right)=\binom{n}{\nicefrac{n}{2}}[n\text{ even}]. +\] + +\end_inset + + +\end_layout + +\end_body +\end_document diff --git a/vol1/1.3.1.lyx b/vol1/1.3.1.lyx new file mode 100644 index 0000000..22c5cb2 --- /dev/null +++ b/vol1/1.3.1.lyx @@ -0,0 +1,2356 @@ +#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 +\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 Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc1[00] +\end_layout + +\end_inset + +If +\family typewriter +MIX +\family default + were a ternary (base 3) computer, + how many +\begin_inset Quotes eld +\end_inset + +trits +\begin_inset Quotes erd +\end_inset + + would there be per byte? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +The only power of 3 between 64 and 100 is +\begin_inset Formula $3^{4}=81$ +\end_inset + +, + so there would be 4 trits. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc2[02] +\end_layout + +\end_inset + +If a value to be represented within +\family typewriter +MIX +\family default + may get as large as 99999999, + how many adjacent bytes should be used to contain this quantity. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Since +\begin_inset Formula $\lg99999999\in(26,27)$ +\end_inset + +, + we'd need 27 bits, + so 5 bytes. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc3[02] +\end_layout + +\end_inset + +Give the partial field specifications, + +\begin_inset Formula $(L:R)$ +\end_inset + +, + for the (a) address field, + (b) index field, + (c) field field, + and (d) operation code field for a +\family typewriter +MIX +\family default + instruction. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Formula $(0:2)$ +\end_inset + +, + +\begin_inset Formula $(3:3)$ +\end_inset + +, + +\begin_inset Formula $(4:4)$ +\end_inset + +, + and +\begin_inset Formula $(5:5)$ +\end_inset + +, + respectively. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc4[00] +\end_layout + +\end_inset + +The last example in (5) is ` +\family typewriter +LDA -2000,4 +\family default +'. + How can this be legitimate, + in view of the fact that memory addresses should not be negative? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Because we're assuming that +\family typewriter +r4 +\family default + is at least 2000. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc5[10] +\end_layout + +\end_inset + +What symbolic notation, + analogous to (4), + corresponds to (6) if (6) is regarded as a +\family typewriter +MIX +\family default + instruction? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\family typewriter +DIV -80,3 +\family default +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc6[10] +\end_layout + +\end_inset + +Assume that location 3000 contains +\end_layout + +\begin_layout Standard +\align center +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +mixbox{ +\backslash +byte+ +\backslash +byte5 +\backslash +byte1 +\backslash +twobytes{200} +\backslash +byte{15}} +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +What is the result of the following instructions? + (State if any of them are undefined or only partially defined.) +\end_layout + +\begin_layout Enumerate + +\family typewriter +LDAN 3000 +\family default +; +\end_layout + +\begin_layout Enumerate + +\family typewriter +LD2N 3000(3:4) +\family default +; +\end_layout + +\begin_layout Enumerate + +\family typewriter +LDX 3000(1:3) +\family default +; +\end_layout + +\begin_layout Enumerate + +\family typewriter +LD6 3000 +\family default +; +\end_layout + +\begin_layout Enumerate + +\family typewriter +LDXN 3000(0:0) +\family default +. +\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 +Set A to +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +mixbox{ +\backslash +byte- +\backslash +byte5 +\backslash +byte1 +\backslash +twobytes{200} +\backslash +byte{15}} +\end_layout + +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Set I2 to +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +mixsmbox{ +\backslash +byte- +\backslash +twobytes{200}} +\end_layout + +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Set X to +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +mixbox{ +\backslash +byte+ +\backslash +byte0 +\backslash +byte0 +\backslash +byte5 +\backslash +byte1 +\backslash +byte?} +\end_layout + +\end_inset + + (the last byte is undefined). +\end_layout + +\begin_layout Enumerate +Undefined. +\end_layout + +\begin_layout Enumerate +Set X to +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +mixbox{ +\backslash +byte- +\backslash +byte0 +\backslash +byte0 +\backslash +byte0 +\backslash +byte0 +\backslash +byte0} +\end_layout + +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc9[15] +\end_layout + +\end_inset + +List all the +\family typewriter +MIX +\family default + operators that can possibly affect the setting of the overflow toggle. + (Don not include floating point operators.) +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\family typewriter +ADD +\family default +, + +\family typewriter +SUB +\family default +, + +\family typewriter +DIV +\family default +, + +\family typewriter +INCA +\family default +, + +\family typewriter +INCX +\family default +, + +\family typewriter +DECA +\family default +, + +\family typewriter +DECX +\family default +, + +\family typewriter +NUM +\family default +, + +\family typewriter +JOV +\family default +, + +\family typewriter +JNOV +\family default +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc11[15] +\end_layout + +\end_inset + +List all the +\family typewriter +MIX +\family default + operators that can possibly affect the setting of rI1. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\family typewriter +MOVE +\family default +, + +\family typewriter +LD1 +\family default +, + +\family typewriter +LD1N +\family default +, + +\family typewriter +INC1 +\family default +, + +\family typewriter +DEC1 +\family default +, + +\family typewriter +ENT1 +\family default +, + +\family typewriter +ENN1 +\family default +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc12[10] +\end_layout + +\end_inset + +Find a single instruction that has the effect of multiplying the current contents of rI3 by two and leaving the result in rI3. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\family typewriter +INC3 0,3 +\family default +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc13[10] +\end_layout + +\end_inset + +Suppose location 1000 contains the instruction ` +\family typewriter +JOV 1001 +\family default +'. + This instruction turns off the overflow toggle if it is on (and the next instruction executed will be in location 1001, + in any case). + If this instruction were changed to ` +\family typewriter +JNOV 1001 +\family default +', + would there be any difference? + What if it were changed to ` +\family typewriter +JOV 1000 +\family default +' or ` +\family typewriter +JNOV 1000 +\family default +'? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +There wouldn't be any difference after changing it to ` +\family typewriter +JNOV 1001 +\family default +' aside from the contents of register J. + If it's changed to ` +\family typewriter +JOV 1000 +\family default +', + the only difference would be the timing, + but if it's changed to ` +\family typewriter +JNOV 1000 +\family default +', + an infinite loop would occur if the overflow toggle wasn't previously on. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc15[10] +\end_layout + +\end_inset + +How many +\emph on +alphameric characters +\emph default + are there in a typewriter or paper-tape block? + in a card-reader or card-punch block? + in a +\nospellcheck on +line-printer +\nospellcheck default + block? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +70 characters in a typewriter or paper-tape block, + 80 in a card-reader or card-punch block, + and 120 in a line-printer block. + This is because each word can hold up to 5 characters. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc18[22] +\end_layout + +\end_inset + +After the following +\begin_inset Quotes eld +\end_inset + +number one +\begin_inset Quotes erd +\end_inset + + program has been executed, + what changes to registers, + toggles, + and memory have taken place? + (For example, + what is the setting of rI1? + of rX? + of the overflow an comparison indicators? +\end_layout + +\begin_layout Standard +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +STZ 1 +\end_layout + +\begin_layout Plain Layout + +ENNX 1 +\end_layout + +\begin_layout Plain Layout + +STX 1(0:1) +\end_layout + +\begin_layout Plain Layout + +SLAX 1 +\end_layout + +\begin_layout Plain Layout + +ENNA 1 +\end_layout + +\begin_layout Plain Layout + +INCX 1 +\end_layout + +\begin_layout Plain Layout + +ENT1 1 +\end_layout + +\begin_layout Plain Layout + +SRC 1 +\end_layout + +\begin_layout Plain Layout + +ADD 1 +\end_layout + +\begin_layout Plain Layout + +DEC1 -1 +\end_layout + +\begin_layout Plain Layout + +STZ 1 +\end_layout + +\begin_layout Plain Layout + +CMPA 1 +\end_layout + +\begin_layout Plain Layout + +MOVE -1,1(1) +\end_layout + +\begin_layout Plain Layout + +NUM 1 +\end_layout + +\begin_layout Plain Layout + +CHAR 1 +\end_layout + +\begin_layout Plain Layout + +HLT 1 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Assuming the program doesn't start at 0000, + the result is: +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +soffsets +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset Tabular + + + + + + +\begin_inset Text + +\begin_layout Plain Layout +Position +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Content +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset space ~ +\end_inset + +Address 1 +\begin_inset space ~ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +byte0 +\backslash +byte0 +\backslash +byte0 +\backslash +byte0 +\backslash +byte0 +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset space ~ +\end_inset + +Address 2 +\begin_inset space ~ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +byte0 +\backslash +byte0 +\backslash +byte0 +\backslash +byte0 +\backslash +byte0 +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset space ~ +\end_inset + +rX +\begin_inset space ~ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte- +\backslash +byte{31} +\backslash +byte{30} +\backslash +byte{30} +\backslash +byte{30} +\backslash +byte{30} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset space ~ +\end_inset + +rA +\begin_inset space ~ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte- +\backslash +byte{30} +\backslash +byte{30} +\backslash +byte{30} +\backslash +byte{30} +\backslash +byte{30} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\end_inset + + +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +hfil{} +\end_layout + +\end_inset + + +\begin_inset Tabular + + + + + + +\begin_inset Text + +\begin_layout Plain Layout +Position +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Content +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset space ~ +\end_inset + +rI1 +\begin_inset space ~ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +byte0 +\backslash +byte2 +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset space ~ +\end_inset + +Overflow +\begin_inset space ~ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +ON +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset space ~ +\end_inset + +Comparison +\begin_inset space ~ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +EQUAL +\end_layout + +\end_inset + + + + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +eoffsets +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc19[14] +\end_layout + +\end_inset + +What is the execution time of the program in the preceding exercise, + not counting the +\family typewriter +HLT +\family default + instruction? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +42 units of time. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc21[24] +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Enumerate +Can the J-register ever be zero? +\end_layout + +\begin_layout Enumerate +Write a program that, + given a number +\begin_inset Formula $N$ +\end_inset + + in rI4, + sets register J equal to +\begin_inset Formula $N$ +\end_inset + +, + assuming that +\begin_inset Formula $0 JMP 3006] +\end_layout + +\begin_layout Plain Layout + +STA -1,4 +\end_layout + +\begin_layout Plain Layout + +JMP -1,4 +\end_layout + +\begin_layout Plain Layout + +STX -1,4 ; + position 3006 +\end_layout + +\begin_layout Plain Layout + +HLT +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc22[28] +\end_layout + +\end_inset + +Location 2000 contains an integer number, + +\begin_inset Formula $X$ +\end_inset + +. + Write two programs that compute +\begin_inset Formula $X^{13}$ +\end_inset + + and halt with the result in register +\begin_inset Formula $A$ +\end_inset + +. + One program should use the minimum number of +\family typewriter +MIX +\family default + memory locations; + the other should require the minimum execution time possible. + Assume that +\begin_inset Formula $X^{13}$ +\end_inset + + fits into a single word. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Minimum time, + since the conditions imply +\begin_inset Formula $|X|\leq5$ +\end_inset + +: +\end_layout + +\begin_layout Standard +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +LD1 2000 +\end_layout + +\begin_layout Plain Layout + +LDA 3500,1 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +Then at positions 3495 to 3505 we'd have a table of precomputed results. + This uses a total of 2 words for the instructions and 11 words for the table. +\end_layout + +\begin_layout Standard +Minimum number of memory locations, + assuming the program starts at position 0: +\end_layout + +\begin_layout Standard +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +LDA 2000 +\end_layout + +\begin_layout Plain Layout + +ENT1 12 +\end_layout + +\begin_layout Plain Layout + +MUL 2000 +\end_layout + +\begin_layout Plain Layout + +SLAX 5 +\end_layout + +\begin_layout Plain Layout + +DEC1 1 +\end_layout + +\begin_layout Plain Layout + +J1NZ 2 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +This uses a total of 6 words for the instructions but no additional memory. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc25[30] +\end_layout + +\end_inset + +Suppose that the manufacturer of +\family typewriter +MIX +\family default + wishes to come out with a more powerful computer ( +\begin_inset Quotes eld +\end_inset + +Mixmaster +\begin_inset Quotes erd +\end_inset + +?), + and he wants to convince as many people as possible of those people now owning a +\family typewriter +MIX +\family default + computer to invest in the more expensive machine. + He wants to design this new hardware to be an +\emph on +extension +\emph default + of +\family typewriter +MIX +\family default +, + in the sense that all programs correctly written for +\family typewriter +MIX +\family default + will work on the new machines without change. + Suggest desirable things that could be incorporated in this extension. + (For example, + can you make better use of the I-field of an instruction?) +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Some of the ways that +\family typewriter +MIX +\family default + could be extended would be: +\end_layout + +\begin_layout Enumerate +Make the machine work faster through pipelining and other techniques. +\end_layout + +\begin_layout Enumerate +Allocate additional memory. + A way to do this would be to expand the size of the index registers to be one full word, + allowing for +\begin_inset Formula $\unit[1]{Gword}$ +\end_inset + + (equivalent to +\begin_inset Formula $\unit[4]{GB}$ +\end_inset + + by modern standards). + Then we'd have 8 full-word registers, + a bare minimum for modern processors. +\end_layout + +\begin_layout Enumerate +For normal instructions, + instead of having the I-field specify a range, + it could be used to specify which of the six fields are being used, + since we are warrantied at least six bits, + allocating the corresponding floating point instructions in the F-field value that doesn't select any of the fields (the null value). + For compatibility, + we can't use the trivial binary representation for this, + so we have to use a non-trivial mapping. +\end_layout + +\begin_layout Enumerate +Many more floating-point instructions could be allocated in the null value of the I-field, + such as square root, + sine, + cosine, + etc. + These could be allocated on instruction code 5 (special). +\end_layout + +\begin_layout Enumerate +8-bit compatibility would be desirable, + but on a binary +\family typewriter +MIX +\family default +, + we only have 31 bits per word. + One way to achieve compatibility is to add an extra bit per word that's not used by legacy +\family typewriter +MIX +\family default + programs and extend the F-field in the following way: + if the value in the field is at least 48, + we take the 4 least significant bits and divide that into two groups: + one for the lower part of the range,which would be specified in bytes, + and one for the upper part. + +\end_layout + +\begin_deeper +\begin_layout Standard +This would allow operating on bytes, + and it would be incompatible with the previous proposal to extend the F-field. + For other values of the I-field, + the extra bit would be ignored. +\end_layout + +\end_deeper +\begin_layout Enumerate +In the case the 8-bit compatibility is implemented, + it'd be nice to have a way to address individual bytes and half-words without case distinctions or code modifications. + This could be done with a special value 6 (half-word) and 7 (byte) for the F-field in load and store instructions, + which would use the full 32-bits of the specified index register. +\end_layout + +\begin_layout Enumerate +Values 7 and 8 for the I-field could be used to mean registers A and X. +\end_layout + +\begin_layout Enumerate +Values 16 to 24 for the I-field could be used for register to register arithmetic. + Then the I-field minus 16 would be the destination operand and the source operand would be the one specified by the first part of the address with the fields given by the second part, + with the same format than an F-field. +\end_layout + +\begin_layout Enumerate +Memory protection and memory management could be implemented by changing the F-field of the +\family typewriter +NOP +\family default + operation, + with the instructions shown in table +\begin_inset CommandInset ref +LatexCommand ref +reference "fig:e13125" +plural "false" +caps "false" +noprefix "false" +nolink "false" + +\end_inset + +. +\end_layout + +\begin_deeper +\begin_layout Standard +\begin_inset Float figure +placement document +alignment document +wide false +sideways false +status open + +\begin_layout Plain Layout +\begin_inset Tabular + + + + + + + +\begin_inset Text + +\begin_layout Plain Layout +Name +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +F +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Description +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +PSET +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Set the beginning of the privileged section to +\begin_inset Formula $M$ +\end_inset + +. + By default, + it's 0. + When an exception occurs, + A is saved to the first word in the privileged section, + the next word contains the reason of the exception, + the next contains a pointer to the instruction that was being run and the next contains the start of the exception-processing code, + to be run in privileged mode. + Exceptions are disabled by default. +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +PGET +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +2 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Copy the address of the privileged section start to rI1. +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +PUSR +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +3 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Change to user (non-privileged) mode; + jump to +\begin_inset Formula $M$ +\end_inset + + and set J to 0. +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +VCAL +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +4 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Change to kernel (privileged) code; + like an exception, + with the reason being 0 in 0:0. +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +VSET +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +5 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Enable virtual memory, + switch to the page table +\begin_inset Formula $M$ +\end_inset + + and flush the TLB. + Virtual memory addresses are 12-12-10 and each word in a table contains the address (1:4), + an enable/disable flag (0:0), + and read-write permissions (least significant 2 bits on 4:4), + plus anything the OS wants to put in 5:5. + When a page fault occurs, + an exception happens with reason 1 in 0:0. + Changes in an active page mapping have unspecified behavior when trying to access a page that depends on that before flushing the TLB. +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +VFLS +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +6 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Flush the TLB. + The I-field must be 0. +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +VDIS +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +7 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Disable virtual memory and jump to +\begin_inset Formula $M$ +\end_inset + +. +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +EINT +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +8 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Enable/disable interrupts for the device in the I-field, + depending on whether the sign is positive or negative. + Interrupts are exceptions with reason 3 in 0:0 and the device ID in 1:1. +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +AEX +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +9 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Enable/disable all exceptions, + depending on whether the sign is positive or negative. + The result of triggering an exception that's not an interrupt is unspecified. +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +WAIT +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +10 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Wait until some device is ready. +\end_layout + +\end_inset + + + + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Caption Standard + +\begin_layout Plain Layout +\begin_inset CommandInset label +LatexCommand label +name "fig:e13125" + +\end_inset + +System instructions for MIXMaster. +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +All of those instructions except +\family typewriter +VCAL +\family default + are illegal in user mode, + along with +\family typewriter +HLT +\family default +, + +\family typewriter +JBUS +\family default +, + +\family typewriter +IOC +\family default +, + +\family typewriter +IN +\family default +, + +\family typewriter +OUT +\family default +, + and +\family typewriter +JRED +\family default +. + Instructions that had unspecified behavior now cause an exception with type 4 in 0:0, + provided that exceptions are enabled. + Nonetheless, + the operating system is expected to treat those exceptions and act accordingly, + usually by checking for authorization and simulating the effects of the instructions as if they were system calls. +\end_layout + +\end_deeper +\begin_layout Enumerate +Bitwise operations and shifts could be added. +\end_layout + +\begin_layout Enumerate +An +\family typewriter +IOC +\family default + number could be used to return the number of bytes per chunk for a device, + and another number could be self-describing, + to tell the type of the device. + This would allow for more device types to be added, + such as USB, + Ethernet, + PCI, + video, + timer, + etc., + given a standard for differentiating those. +\end_layout + +\end_body +\end_document diff --git a/vol1/1.3.2.lyx b/vol1/1.3.2.lyx new file mode 100644 index 0000000..3e693ad --- /dev/null +++ b/vol1/1.3.2.lyx @@ -0,0 +1,3414 @@ +#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[00] +\end_layout + +\end_inset + +The text remarked that ` +\family typewriter +X EQU 1000 +\family default +' does not assemble any instruction that sets the value of a variable. + Suppose that you are writing a +\family typewriter +MIX +\family default + program in which the algorithm is supposed to set the value contained in certain memory cell (whose symbolic name is +\family typewriter +X +\family default +) equal to 1000. + How could you express this in +\family typewriter +MIXAL +\family default +? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +ENTA 1000 +\end_layout + +\begin_layout Plain Layout + +STA X +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc2[10] +\end_layout + +\end_inset + +Line 12 of program M says ` +\family typewriter +JMP * +\family default +', + where +\family typewriter +* +\family default + denotes the location of that line. + Why doesn't the program go into an infinite loop, + endlessly repeating this instruction? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Because, + at the entry point of the function, + the code self-modifies, + changing that instruction to a jump to the next instruction of the routine that called program M. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc3[23] +\end_layout + +\end_inset + +What is the effect of the following program, + if it is used in conjunction with Program M? +\end_layout + +\begin_layout Standard +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +START IN X+1(0) +\end_layout + +\begin_layout Plain Layout + + JBUS *(0) +\end_layout + +\begin_layout Plain Layout + + ENT1 100 +\end_layout + +\begin_layout Plain Layout + +1H JMP MAXIMUM +\end_layout + +\begin_layout Plain Layout + + LDX X,1 +\end_layout + +\begin_layout Plain Layout + + STA X,1 +\end_layout + +\begin_layout Plain Layout + + STX X,2 +\end_layout + +\begin_layout Plain Layout + + DEC1 1 +\end_layout + +\begin_layout Plain Layout + + J1P 1B +\end_layout + +\begin_layout Plain Layout + + OUT X+1(1) +\end_layout + +\begin_layout Plain Layout + + HLT +\end_layout + +\begin_layout Plain Layout + + END START +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +It reads 100 numbers from tape 0 and prints them sorted in nondecreasing order to tape 1. + It first reads the 100 numbers, + and then it finds the maximum of the elements, + exchanges it with the last element in the list and repeats that with the list made of of all the remaining elements. + Finally, + it outputs the result. + This is known as +\emph on +bubble sort +\emph default +, + the slowest sensible sorting algorithm, + with complexity +\begin_inset Formula $O(n^{2})$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc4[25] +\end_layout + +\end_inset + +Assemble Program P by hand. + (It won't take as long as you think.) What are the actual numerical contents of memory, + corresponding to that symbolic program? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +See figure +\begin_inset CommandInset ref +LatexCommand ref +reference "fig:e1234" +plural "false" +caps "false" +noprefix "false" +nolink "false" + +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset Float figure +placement document +alignment document +wide false +sideways false +status open + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +soffsets +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\align center +\begin_inset Tabular + + + + + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset space ~ +\end_inset + + +\family typewriter +3000 +\family default + +\begin_inset space ~ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes0 +\backslash +byte0 +\backslash +byte{18} +\backslash +byte{35} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3001 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes{2051} +\backslash +byte0 +\backslash +byte5 +\backslash +byte9 +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3002 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes{2050} +\backslash +byte0 +\backslash +byte5 +\backslash +byte{10} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3003 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes1 +\backslash +byte0 +\backslash +byte0 +\backslash +byte{49} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3004 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes{499} +\backslash +byte1 +\backslash +byte5 +\backslash +byte{26} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3005 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes{3016} +\backslash +byte0 +\backslash +byte1 +\backslash +byte{41} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3006 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes2 +\backslash +byte0 +\backslash +byte0 +\backslash +byte{50} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3007 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes2 +\backslash +byte0 +\backslash +byte2 +\backslash +byte{51} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3008 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes0 +\backslash +byte0 +\backslash +byte2 +\backslash +byte{48} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3009 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes0 +\backslash +byte2 +\backslash +byte2 +\backslash +byte{55} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3010 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte- +\backslash +twobytes1 +\backslash +byte3 +\backslash +byte5 +\backslash +byte4 +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3011 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes{3006} +\backslash +byte0 +\backslash +byte1 +\backslash +byte{47} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3012 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte- +\backslash +twobytes1 +\backslash +byte3 +\backslash +byte5 +\backslash +byte{56} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3013 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes1 +\backslash +byte0 +\backslash +byte0 +\backslash +byte{51} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3014 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes{3008} +\backslash +byte0 +\backslash +byte6 +\backslash +byte{39} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3015 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes{3003} +\backslash +byte0 +\backslash +byte0 +\backslash +byte{39} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3016 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes{1995} +\backslash +byte0 +\backslash +byte{18} +\backslash +byte{37} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3017 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes{2035} +\backslash +byte0 +\backslash +byte2 +\backslash +byte{52} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3018 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte- +\backslash +twobytes{50} +\backslash +byte0 +\backslash +byte2 +\backslash +byte{53} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3019 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes{501} +\backslash +byte0 +\backslash +byte0 +\backslash +byte{53} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\end_inset + + +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +hfil{} +\end_layout + +\end_inset + + +\begin_inset Tabular + + + + + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset space ~ +\end_inset + + +\family typewriter +3020 +\family default + +\begin_inset space ~ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte- +\backslash +twobytes1 +\backslash +byte5 +\backslash +byte5 +\backslash +byte8 +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3021 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes0 +\backslash +byte0 +\backslash +byte1 +\backslash +byte5 +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3022 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes0 +\backslash +byte4 +\backslash +byte{12} +\backslash +byte{31} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3023 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes1 +\backslash +byte0 +\backslash +byte1 +\backslash +byte{52} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3024 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes{50} +\backslash +byte0 +\backslash +byte1 +\backslash +byte{53} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3025 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes{3020} +\backslash +byte0 +\backslash +byte2 +\backslash +byte{45} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3026 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes0 +\backslash +byte4 +\backslash +byte{18} +\backslash +byte{37} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3027 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes{24} +\backslash +byte4 +\backslash +byte5 +\backslash +byte{12} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3028 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes{3019} +\backslash +byte0 +\backslash +byte0 +\backslash +byte{45} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +3029 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +twobytes0 +\backslash +byte0 +\backslash +byte2 +\backslash +byte5 +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +0000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +fivebytes2 +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +1995 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +byte6 +\backslash +byte9 +\backslash +byte{19} +\backslash +byte{22} +\backslash +byte{23} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +1996 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +byte0 +\backslash +byte6 +\backslash +byte9 +\backslash +byte{25} +\backslash +byte5 +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +1997 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +byte0 +\backslash +byte8 +\backslash +byte{24} +\backslash +byte{15} +\backslash +byte4 +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +1998 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +byte{19} +\backslash +byte5 +\backslash +byte4 +\backslash +byte0 +\backslash +byte{17} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +1999 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +byte{19} +\backslash +byte9 +\backslash +byte{14} +\backslash +byte5 +\backslash +byte{22} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +2024 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +fivebytes{2035} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +2049 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +fivebytes{2010} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +2050 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte+ +\backslash +fivebytes3 +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +2051 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +byte- +\backslash +fivebytes{499} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +eoffsets +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Caption Standard + +\begin_layout Plain Layout +\begin_inset CommandInset label +LatexCommand label +name "fig:e1234" + +\end_inset + +Machine code for Program P. +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc7[10] +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Enumerate +What is the meaning of ` +\family typewriter +4B +\family default +' in line 34 of Program P? +\end_layout + +\begin_layout Enumerate +What effect, + if any, + would be cause if the location of line 15 were changed to ` +\family typewriter +2H +\family default +' and the address of line 20 were changed to ` +\family typewriter +2B +\family default +'? +\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 references the address at line 29, + the first previous line with label ` +\family typewriter +4H +\family default +'. +\end_layout + +\begin_layout Enumerate +Line 14 would reference line 15 instead of line 25 and line 24 would reference line 15 instead of line 12. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc8[24] +\end_layout + +\end_inset + +What does the following program do? + (Do not run it on a computer, + figure it out by hand!) +\end_layout + +\begin_layout Standard +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +* MYSTERY PROGRAM +\end_layout + +\begin_layout Plain Layout + +BUF ORIG *+3000 +\end_layout + +\begin_layout Plain Layout + +1H ENT1 1 +\end_layout + +\begin_layout Plain Layout + + ENT2 0 +\end_layout + +\begin_layout Plain Layout + + LDX 4F +\end_layout + +\begin_layout Plain Layout + +2H ENT3 0,1 +\end_layout + +\begin_layout Plain Layout + +3H STZ BUF,2 +\end_layout + +\begin_layout Plain Layout + + INC2 1 +\end_layout + +\begin_layout Plain Layout + + DEC3 1 +\end_layout + +\begin_layout Plain Layout + + J3P 3B +\end_layout + +\begin_layout Plain Layout + + STX BUF,2 +\end_layout + +\begin_layout Plain Layout + + INC2 1 +\end_layout + +\begin_layout Plain Layout + + INC1 1 +\end_layout + +\begin_layout Plain Layout + + CMP1 =75= +\end_layout + +\begin_layout Plain Layout + + JL 2B +\end_layout + +\begin_layout Plain Layout + + ENN2 2400 +\end_layout + +\begin_layout Plain Layout + + OUT BUF+2400,2(18) +\end_layout + +\begin_layout Plain Layout + + INC2 24 +\end_layout + +\begin_layout Plain Layout + + J2N *-2 +\end_layout + +\begin_layout Plain Layout + + HLT +\end_layout + +\begin_layout Plain Layout + +4H ALF AAAAA +\end_layout + +\begin_layout Plain Layout + + END 1B +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +An analysis shows that the code is not self-modifying and that it's equivalent to the following pseudo-C: +\end_layout + +\begin_layout Standard +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +r2 = 0; +\end_layout + +\begin_layout Plain Layout + +x = * +\begin_inset Quotes erd +\end_inset + +AAAAA +\begin_inset Quotes erd +\end_inset + +; +\end_layout + +\begin_layout Plain Layout + +for (r1 = 1; + r1 < 75; + r1++) { +\end_layout + +\begin_layout Plain Layout + + for (or3m75 = 0; + or3m75 < r1; + or3m75++) +\end_layout + +\begin_layout Plain Layout + + *r2++ = 0; +\end_layout + +\begin_layout Plain Layout + + *r2++ = x; +\end_layout + +\begin_layout Plain Layout + +} +\end_layout + +\begin_layout Plain Layout + +for (f2i24p100 = 0; + r2i24p100 < 100; + r2i24p100++) +\end_layout + +\begin_layout Plain Layout + + write(PRINTER, + r2i24p100 * 24); +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +The program code begins at position 3000, + and the programs writes until position +\begin_inset Formula +\[ +(2+\dots+75)-1=(1+\dots+74)+74-1=\frac{74\cdot75}{2}+74-1=\frac{74\cdot77}{2}-1=2848, +\] + +\end_inset + +so the code is indeed not self-modifying. + For each iteration +\begin_inset Formula $i$ +\end_inset + + from 1 to 74, + the code stores +\begin_inset Formula $5i$ +\end_inset + + spaces and then 5 A's, + and then the code prints the first 12000 characters from those. +\end_layout + +\begin_layout Standard +As an aside, + the same effect can be obtained with the following actual C code, + provided there are no runtime errors: +\end_layout + +\begin_layout Standard +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +#include +\end_layout + +\begin_layout Plain Layout + +#include +\end_layout + +\begin_layout Plain Layout + +\end_layout + +\begin_layout Plain Layout + +int main() +\end_layout + +\begin_layout Plain Layout + +{ +\end_layout + +\begin_layout Plain Layout + + char buffer[15000]; +\end_layout + +\begin_layout Plain Layout + + int i, + j, + k = 0; +\end_layout + +\begin_layout Plain Layout + +\end_layout + +\begin_layout Plain Layout + + for (i = 1; + i < 75; + i++) { +\end_layout + +\begin_layout Plain Layout + + for (j = 0; + j < i; + j++) +\end_layout + +\begin_layout Plain Layout + + strcpy(buffer + 5*(k++), + " "); +\end_layout + +\begin_layout Plain Layout + + strcpy(buffer + 5*(k++), + "AAAAA"); +\end_layout + +\begin_layout Plain Layout + + } +\end_layout + +\begin_layout Plain Layout + + for (i = 0; + i < 100; + i++) { +\end_layout + +\begin_layout Plain Layout + + fwrite(buffer + 120*i, + 120, + 1, + stdout); +\end_layout + +\begin_layout Plain Layout + + putchar(' +\backslash +n'); +\end_layout + +\begin_layout Plain Layout + + } +\end_layout + +\begin_layout Plain Layout + + return 0; +\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 +rexerc9[25] +\end_layout + +\end_inset + +Location +\family typewriter +INST +\family default + contains a +\family typewriter +MIX +\family default + word that purportedly is a +\family typewriter +MIX +\family default + instruction. + Write a +\family typewriter +MIX +\family default + program that jumps to location +\family typewriter +GOOD +\family default + if the word has a valid C-field, + valid +\begin_inset Formula $\pm\text{AA}$ +\end_inset + +-field, + valid I-field, + and valid F-field, + according to Table 1.3.1–1; + your program should jump to location +\family typewriter +BAD +\family default + otherwise. + Remember that the test for a valid F-field depends on the C-field; + for example, + if +\begin_inset Formula $\text{C}=7$ +\end_inset + + ( +\family typewriter +MOVE +\family default +), + any F-field is acceptable, + but if +\begin_inset Formula $\text{C}=8$ +\end_inset + + ( +\family typewriter +LDA +\family default +), + the F-field must have the form +\begin_inset Formula $8L+R$ +\end_inset + + where +\begin_inset Formula $0\leq L\leq R\leq5$ +\end_inset + +. + The +\begin_inset Quotes eld +\end_inset + + +\begin_inset Formula $\pm\text{AA}$ +\end_inset + + +\begin_inset Quotes erd +\end_inset + +-field is to be considered valid +\emph on +unless +\emph default + C specifies an instruction requiring a memory address and +\begin_inset Formula $\text{I}=0$ +\end_inset + + and +\begin_inset Formula $\pm\text{AA}$ +\end_inset + + is not a valid memory address. +\end_layout + +\begin_layout Standard + +\emph on +Note +\emph default +: + Inexperienced programmers tend to tackle a problem like this by writing a long series of tests on the C-field, + such as ` +\family typewriter +LDA C +\family default +; + +\family typewriter +JAZ 1F +\family default +; + +\family typewriter +DECA 5 +\family default +; + +\family typewriter +JAN 2F +\family default +; + +\family typewriter +JAZ 3F +\family default +; + +\family typewriter +DECA 2 +\family default +; + +\family typewriter +JAN 4F +\family default +; + ...'. + This is +\emph on +not +\emph default + good practice! + The best way to make multiway decisions is to prepare an auxiliary +\emph on +table +\emph default + containing information that encapsulates the desired logic. + If there were, + for example, + a table of 64 entries, + we could write ` +\family typewriter +LD1 C +\family default +; + +\family typewriter +LD1 TABLE,1 +\family default +; + +\family typewriter +JMP 0,1 +\family default +'— +thereby jumping very speedily to the desired routine. + Other useful information can also be kept in such a table. + A tabular approach to the present problem makes the program only a little bit longer (including the table) and greatly increases its speed and flexibility. +\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 +inline false +status open + +\begin_layout Plain Layout + +ADDR EQU 0:2 +\end_layout + +\begin_layout Plain Layout + +INDEX EQU 3:3 +\end_layout + +\begin_layout Plain Layout + +FIELD EQU 4:4 +\end_layout + +\begin_layout Plain Layout + +CODE EQU 5:5 +\end_layout + +\begin_layout Plain Layout + + LD1 INST(CODE) +\end_layout + +\begin_layout Plain Layout + + LD3 INST(INDEX) ; + Load I-field +\end_layout + +\begin_layout Plain Layout + + ENTA -6,3 ; + Check if I-field > 6 +\end_layout + +\begin_layout Plain Layout + + JAP BAD +\end_layout + +\begin_layout Plain Layout + + J3NZ 2F ; + I-field nonzero, + skip AA test +\end_layout + +\begin_layout Plain Layout + + LDX TABLE,1(0:0) +\end_layout + +\begin_layout Plain Layout + + ENTX 1(5:5) ; + 1 when AA is address, + -1 otherwise +\end_layout + +\begin_layout Plain Layout + + JXN 2F +\end_layout + +\begin_layout Plain Layout + + LDA INST(ADDR) +\end_layout + +\begin_layout Plain Layout + + JAN BAD ; + Addr relevant, + index 0, + addr negative +\end_layout + +\begin_layout Plain Layout + +2H LDA INST(FIELD) ; + Field test: + dispatch +\end_layout + +\begin_layout Plain Layout + + LD1 TABLE,1(4:5) +\end_layout + +\begin_layout Plain Layout + + JMP 0,1 +\end_layout + +\begin_layout Plain Layout + +BOUND CMPA TABLE,1(3:3); + F-field in [0,CONTENTS(TABLE,1(3:3))] +\end_layout + +\begin_layout Plain Layout + + JL GOOD +\end_layout + +\begin_layout Plain Layout + + JMP BAD +\end_layout + +\begin_layout Plain Layout + +RANSX CMPA =6= ; + F-field in range or 6 +\end_layout + +\begin_layout Plain Layout + + JE GOOD +\end_layout + +\begin_layout Plain Layout + +RANGE SRAX 5 ; + rAX is the F-field +\end_layout + +\begin_layout Plain Layout + + DIV =8= ; + rA:rX is the F-field +\end_layout + +\begin_layout Plain Layout + + CMPA FIVE +\end_layout + +\begin_layout Plain Layout + + JG BAD +\end_layout + +\begin_layout Plain Layout + + CMPX FIVE +\end_layout + +\begin_layout Plain Layout + + JG BAD +\end_layout + +\begin_layout Plain Layout + + STA *+1(0:2) ; + rX -= rA +\end_layout + +\begin_layout Plain Layout + + DECX * +\end_layout + +\begin_layout Plain Layout + + JXN BAD ; + If rX < rA, + dat's bad +\end_layout + +\begin_layout Plain Layout + + JMP GOOD +\end_layout + +\begin_layout Plain Layout + +; + Format is Sign(0:0), + F-field test (4:5), + where Sign is +\end_layout + +\begin_layout Plain Layout + +; + positive iff the +/-AA field represents an address and +\end_layout + +\begin_layout Plain Layout + +; + F-field test jumps to GOOD if the F-field is valid for the +\end_layout + +\begin_layout Plain Layout + +; + given case or to BAD otherwise. + Fields 1:3 may contain +\end_layout + +\begin_layout Plain Layout + +; + specific information +\end_layout + +\begin_layout Plain Layout + +IODEV EQU 21(0:3),BOUND(4:5) ; + Field is I/O device +\end_layout + +\begin_layout Plain Layout + +JMPBY EQU 6(0:3),BOUND(4:5) ; + Field is Jx+ +\end_layout + +\begin_layout Plain Layout + +IMMAT EQU 4(0:3),BOUND(4:5) ; + Field is INCx/DECx/ENTx/ENNx +\end_layout + +\begin_layout Plain Layout + +TABLE CON -GOOD ; + NOP +\end_layout + +\begin_layout Plain Layout + + CON RANSX ; + ADD/FADD +\end_layout + +\begin_layout Plain Layout + + CON RANSX ; + SUB/FSUB +\end_layout + +\begin_layout Plain Layout + + CON RANSX ; + MUL/FMUL +\end_layout + +\begin_layout Plain Layout + + CON RANSX ; + DIV/FDIV +\end_layout + +\begin_layout Plain Layout + + CON -3(0:3),BOUND(4:5) ; + NUM/CHAR/HLT +\end_layout + +\begin_layout Plain Layout + + CON -6(0:3),BOUND(4:5) ; + SLA/SRA/SLAX/SRAX/SLC/SRC +\end_layout + +\begin_layout Plain Layout + + CON GOOD ; + MOVE +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + LDA +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + LD1 +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + LD2 +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + LD3 +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + LD4 +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + LD5 +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + LD6 +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + LDX +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + LDAN +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + LD1N +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + LD2N +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + LD3N +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + LD4N +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + LD5N +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + LD6N +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + LDXN +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + STA +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + ST1 +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + ST2 +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + ST3 +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + ST4 +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + ST5 +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + ST6 +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + STX +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + STJ +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + STZ +\end_layout + +\begin_layout Plain Layout + + CON IODEV ; + JBUS +\end_layout + +\begin_layout Plain Layout + + CON -IODEV ; + IOC +\end_layout + +\begin_layout Plain Layout + + CON IODEV ; + IN +\end_layout + +\begin_layout Plain Layout + + CON IODEV ; + OUT +\end_layout + +\begin_layout Plain Layout + + CON IODEV ; + JRED +\end_layout + +\begin_layout Plain Layout + + CON 10(0:3),BOUND(4:5) ; + JMP/JSJ/JOV/JNOV/* +\end_layout + +\begin_layout Plain Layout + + CON JMPBY ; + JA+ +\end_layout + +\begin_layout Plain Layout + + CON JMPBY ; + J1+ +\end_layout + +\begin_layout Plain Layout + + CON JMPBY ; + J2+ +\end_layout + +\begin_layout Plain Layout + + CON JMPBY ; + J3+ +\end_layout + +\begin_layout Plain Layout + + CON JMPBY ; + J4+ +\end_layout + +\begin_layout Plain Layout + + CON JMPBY ; + J5+ +\end_layout + +\begin_layout Plain Layout + + CON JMPBY ; + J6+ +\end_layout + +\begin_layout Plain Layout + + CON JMPBY ; + JX+ +\end_layout + +\begin_layout Plain Layout + + CON IMMAT ; + INCA/DECA/ENTA/ENNA +\end_layout + +\begin_layout Plain Layout + + CON IMMAT ; + INC1/... +\end_layout + +\begin_layout Plain Layout + + CON IMMAT ; + INC2/... +\end_layout + +\begin_layout Plain Layout + + CON IMMAT ; + INC3/... +\end_layout + +\begin_layout Plain Layout + + CON IMMAT ; + INC4/... +\end_layout + +\begin_layout Plain Layout + + CON IMMAT ; + INC5/... +\end_layout + +\begin_layout Plain Layout + + CON IMMAT ; + INC6/... +\end_layout + +\begin_layout Plain Layout + + CON IMMAT ; + INC7/... +\end_layout + +\begin_layout Plain Layout + + CON RANSX ; + CMPA/FCMP +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + CMP1 +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + CMP2 +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + CMP3 +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + CMP4 +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + CMP5 +\end_layout + +\begin_layout Plain Layout + + CON RANGE ; + CMP6 +\end_layout + +\begin_layout Plain Layout + + CON RANGe ; + CMPX +\end_layout + +\begin_layout Plain Layout + +FIVE CON 5 +\end_layout + +\end_inset + + +\end_layout + +\end_body +\end_document diff --git a/vol1/1.3.3.lyx b/vol1/1.3.3.lyx new file mode 100644 index 0000000..db7c653 --- /dev/null +++ b/vol1/1.3.3.lyx @@ -0,0 +1,1630 @@ +#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[02] +\end_layout + +\end_inset + +Consider the transformation of +\begin_inset Formula $\{0,1,2,3,4,5,6\}$ +\end_inset + + that replaces +\begin_inset Formula $x$ +\end_inset + + by +\begin_inset Formula $2x\bmod7$ +\end_inset + +. + Show that this transformation is a permutation, + and write it in cycle form. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Being a permutation follows from the fact that +\begin_inset Formula $\mathbb{Z}_{7}$ +\end_inset + + is a field. + In cycle form, + this would be +\begin_inset Formula $(1\,2\,4)(3\,6\,5)$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc2[10] +\end_layout + +\end_inset + +The text shows how we might set +\begin_inset Formula $(a,b,c,d,e,f)\to(c,d,f,b,e,a)$ +\end_inset + + by using a series of replacement operations ( +\begin_inset Formula $x\gets y$ +\end_inset + +) and one auxiliary variable +\begin_inset Formula $t$ +\end_inset + +. + Show how to do the job by using a series of +\emph on +exchange +\emph default + operations ( +\begin_inset Formula $x\leftrightarrow y$ +\end_inset + +) and no auxiliary variables. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Since the permutation such that +\begin_inset Formula $(a,b,c,d,e,f)\to(c,d,f,b,e,a)$ +\end_inset + + such that +\begin_inset Formula $x_{i}\to\sigma(x_{i})$ +\end_inset + + is +\begin_inset Formula $(a\,c\,f)(b\,d)$ +\end_inset + +, + we could use +\begin_inset Formula $a\leftrightarrow c,c\leftrightarrow f,b\leftrightarrow d$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc3[03] +\end_layout + +\end_inset + +Compute the product +\begin_inset Formula ${\small \begin{pmatrix}a & b & c & d & e & f\\ +b & d & c & a & f & e +\end{pmatrix}}\times{\small \begin{pmatrix}a & b & c & d & e & f\\ +c & d & f & b & e & a +\end{pmatrix}}$ +\end_inset + +, + and express the answer in two-line notation. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Formula +\[ +\begin{pmatrix}a & b & c & d & e & f\\ +d & b & f & c & a & e +\end{pmatrix}. +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc4[10] +\end_layout + +\end_inset + +Express +\begin_inset Formula $(a\,b\,d)(e\,f)(a\,c\,f)(b\,d)$ +\end_inset + + as a product of disjoint cycles. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Formula $(a\,d\,c\,f\,e)$ +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc5[M10] +\end_layout + +\end_inset + +Equation (3) shows several equivalent ways to express the same permutation in cycle form. + How many different ways of writing that permutation are possible, + if all singleton cycles are suppressed? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +There are 2 cycles which can be ordered in +\begin_inset Formula $2!=2$ +\end_inset + + different ways, + and since an +\begin_inset Formula $m$ +\end_inset + +-cycle can be written in +\begin_inset Formula $m$ +\end_inset + + different ways, + there are +\begin_inset Formula $2!\cdot2\cdot3=12$ +\end_inset + + possible ways to write the permutation in cycle form. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc7[10] +\end_layout + +\end_inset + +If Program A is presented with the input (6), + what are the quantities +\begin_inset Formula $X$ +\end_inset + +, + +\begin_inset Formula $Y$ +\end_inset + +, + +\begin_inset Formula $M$ +\end_inset + +, + +\begin_inset Formula $N$ +\end_inset + +, + +\begin_inset Formula $U$ +\end_inset + +, + and +\begin_inset Formula $V$ +\end_inset + + of (19)? + What is the time required by Program A, + excluding input-output? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Formula $X$ +\end_inset + + is the number of cards of input, + namely +\begin_inset Formula $\lceil30/24\rceil=2$ +\end_inset + + if no space is added; + then +\begin_inset Formula $Y=29$ +\end_inset + +. + +\begin_inset Formula $M=5$ +\end_inset + +, + the number of cycles in input, + and +\begin_inset Formula $N=7$ +\end_inset + +, + the number of different elements. + Then, + since the output is +\begin_inset Formula $(a\,d\,g)(c\,e\,b)(f)$ +\end_inset + +, + +\begin_inset Formula $U=3$ +\end_inset + +, + the number of cycles in the output, + and +\begin_inset Formula $V=1$ +\end_inset + +, + the number of singleton cycles. +\end_layout + +\begin_layout Standard +Then the time required, + excluding input-output, + is +\begin_inset Formula +\begin{multline*} +112NX+304X-2M-Y+11U+2V-11=\\ +=112\cdot7\cdot2+304\cdot2-2\cdot5-29+11\cdot3+2\cdot1-11=2161u. +\end{multline*} + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc8[23] +\end_layout + +\end_inset + +Would it be feasible to modify Algorithm B to go from left to right instead of from right to left through the input? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Yes, + if we're allowed to use an extra step for inverting the result. + For this algorithm, + we use an auxiliary table +\begin_inset Formula $U[1],\dots,U[n]$ +\end_inset + + where we obtain the inverse of the permutation. + We calculate it by noticing that +\begin_inset Formula $(a_{11}\,\dots\,a_{1m_{1}})\cdots(a_{k1}\,\cdots\,a_{km_{k}})=((a_{km_{k}}\,\dots\,a_{k1})\cdots(a_{1m_{1}}\,\dots\,a_{11}))^{-1}$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +\begin_inset Argument item:1 +status open + +\begin_layout Plain Layout + +\series bold +B1. +\end_layout + +\end_inset + +[Initialize.] Set +\begin_inset Formula $U[k]\to k$ +\end_inset + + for +\begin_inset Formula $1\leq k\leq n$ +\end_inset + +. + Also, + prepare to scan the input from left to right. +\end_layout + +\begin_layout Enumerate +\begin_inset Argument item:1 +status open + +\begin_layout Plain Layout + +\series bold +B2. +\end_layout + +\end_inset + +[Next element.] Examine the next element of the input. + If the input has been exhausted, + go to step B5. + If the element is a `(', + set +\begin_inset Formula $Z\gets0$ +\end_inset + + and repeat step B2; + if it is a `)', + go to B4. + Otherwise the element is +\begin_inset Formula $x_{i}$ +\end_inset + + for some +\begin_inset Formula $i$ +\end_inset + +, + go on to B'3. +\end_layout + +\begin_layout Enumerate +\begin_inset Argument item:1 +status open + +\begin_layout Plain Layout + +\series bold +B3. +\end_layout + +\end_inset + +[Change +\begin_inset Formula $U[i]$ +\end_inset + +.] Exchange +\begin_inset Formula $Z\leftrightarrow U[i]$ +\end_inset + +. + If this makes +\begin_inset Formula $U[i]=0$ +\end_inset + +, + set +\begin_inset Formula $j\gets i$ +\end_inset + +. + Return to step B2. +\end_layout + +\begin_layout Enumerate +\begin_inset Argument item:1 +status open + +\begin_layout Plain Layout + +\series bold +B4. +\end_layout + +\end_inset + +[Change +\begin_inset Formula $U[j]$ +\end_inset + +.] Set +\begin_inset Formula $U[j]\gets Z$ +\end_inset + +. + Return to step B2. +\end_layout + +\begin_layout Enumerate +\begin_inset Argument item:1 +status open + +\begin_layout Plain Layout + +\series bold +B5. +\end_layout + +\end_inset + +[Invert permutation.] For +\begin_inset Formula $1\leq k\leq n$ +\end_inset + +, + set +\begin_inset Formula $T[U[i]]\gets i$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc9[10] +\end_layout + +\end_inset + +Both Programs A and B accept the same input and give the answer in essentially the same form. + Is the output +\emph on +exactly +\emph default + the same under both programs? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +No. + For example, + for input (6), + Program A produces +\begin_inset Formula $(a\,d\,g)(c\,e\,b)(f)$ +\end_inset + + while Program B produces +\begin_inset Formula $(a\,d\,g)(b\,c\,e)(f)$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc13[M24] +\end_layout + +\end_inset + +Prove that Algorithm J is valid. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We prove it by induction. + Let +\begin_inset Formula $\sigma$ +\end_inset + + be the original permutation, + it's enough to show that, + when entering step J2, + or when exiting step J5, + for each +\begin_inset Formula $j\in\{1,\dots,n\}$ +\end_inset + +, + if +\begin_inset Formula $\sigma^{-1}(j)>m$ +\end_inset + +, + +\begin_inset Formula $X[j]=\sigma^{-1}(j)$ +\end_inset + +, + and otherwise +\begin_inset Formula $X[j]=-\sigma^{k+1}(j)$ +\end_inset + + where +\begin_inset Formula $k$ +\end_inset + + is the least nonnegative integer with +\begin_inset Formula $\sigma^{k}(j)\leq m$ +\end_inset + + (if there were no such number, + since +\begin_inset Formula $\sigma^{-1}(j)=\sigma^{p}(j)$ +\end_inset + + for some +\begin_inset Formula $p\geq0$ +\end_inset + +, + then it would be +\begin_inset Formula $\sigma^{-1}(j)>m$ +\end_inset + +). + +\end_layout + +\begin_layout Standard +If we enter J2 from J1, + every +\begin_inset Formula $X[j]<0$ +\end_inset + +, + every +\begin_inset Formula $j\leq m=n$ +\end_inset + +, + so +\begin_inset Formula $k=1$ +\end_inset + + and what we have to prove is that +\begin_inset Formula $X[j]=-\sigma(j)$ +\end_inset + +, + which obviously holds. + Now, + provided that this holds when we enter J2, + we have to show that it holds when we reach J5 and the proof is complete. +\end_layout + +\begin_layout Standard +After steps J2 and J3, + obviously the condition still holds. + After these steps, + +\begin_inset Formula $i=-\sigma(m)$ +\end_inset + + and +\begin_inset Formula $j$ +\end_inset + + is such that +\begin_inset Formula $i=X[j]$ +\end_inset + +. + We prove this by induction, + showing that, + after +\begin_inset Formula $k\geq1$ +\end_inset + + steps, + +\begin_inset Formula $i$ +\end_inset + + is either +\begin_inset Formula $-\sigma(m)<0$ +\end_inset + + or +\begin_inset Formula $\sigma^{-k}(m)>0$ +\end_inset + +, + and in the latter case, + +\begin_inset Formula $\sigma^{-k}(m),\sigma^{-k+1}(m),\dots,\sigma^{-1}(m)>m$ +\end_inset + +. +\end_layout + +\begin_layout Standard +After one iteration, + +\begin_inset Formula $i=X[m]$ +\end_inset + +; + if +\begin_inset Formula $i>0$ +\end_inset + +, + +\begin_inset Formula $i=\sigma^{-1}(m)>m$ +\end_inset + +; + otherwise +\begin_inset Formula $i=-\sigma^{p+1}(m)$ +\end_inset + +, + where +\begin_inset Formula $p$ +\end_inset + + is the least nonnegative integer with +\begin_inset Formula $\sigma^{p}(m)\leq m$ +\end_inset + +, + but since +\begin_inset Formula $p=0$ +\end_inset + +, + +\begin_inset Formula $i=-\sigma(m)$ +\end_inset + +. + Now assume that this still holds after +\begin_inset Formula $k$ +\end_inset + + iterations, + and that +\begin_inset Formula $i>0$ +\end_inset + + so there's a +\begin_inset Formula $(k+1)$ +\end_inset + +-th iteration. + Then +\begin_inset Formula $j=\sigma^{-k}(m)>0$ +\end_inset + + and we assign +\begin_inset Formula $X[j]$ +\end_inset + + to +\begin_inset Formula $i$ +\end_inset + +. + If +\begin_inset Formula $i>0$ +\end_inset + +, + +\begin_inset Formula $i=\sigma^{-1}(\sigma^{-k}(m))=\sigma^{-k-1}(m)>m$ +\end_inset + +; + otherwise +\begin_inset Formula $i=-\sigma^{p+1}(\sigma^{-k}(m))$ +\end_inset + +, + where +\begin_inset Formula $p$ +\end_inset + + is the least nonnegative integer with +\begin_inset Formula $\sigma^{p-k}(m)\leq m$ +\end_inset + +, + but +\begin_inset Formula $\sigma^{-k}(m),\dots,\sigma^{-1}(m)>m$ +\end_inset + + and +\begin_inset Formula $\sigma^{0}(m)=m$ +\end_inset + +, + so +\begin_inset Formula $p=k$ +\end_inset + + and +\begin_inset Formula $i=-\sigma^{k+1}(\sigma^{-k}(m))=-\sigma(m)$ +\end_inset + +. +\end_layout + +\begin_layout Standard +Now, + at the beginning of step J4, + +\begin_inset Formula $i=-\sigma(m)$ +\end_inset + + and +\begin_inset Formula $j$ +\end_inset + + is such that, + if +\begin_inset Formula $k$ +\end_inset + + is the least nonnegative integer with +\begin_inset Formula $\sigma^{k}(j)\leq m$ +\end_inset + +, + then +\begin_inset Formula $\sigma^{k+1}(j)=\sigma(m)$ +\end_inset + +. + Then the new value of +\begin_inset Formula $X[j]$ +\end_inset + + is +\begin_inset Formula $X[-i]=X[\sigma(m)]=-\sigma^{p+1}(m)$ +\end_inset + +, + where +\begin_inset Formula $p$ +\end_inset + + is the least positive integer with +\begin_inset Formula $\sigma^{p}(m)\leq m$ +\end_inset + +, + the new value of +\begin_inset Formula $X[-i]=X[\sigma(m)]$ +\end_inset + + is +\begin_inset Formula $m=\sigma^{-1}(\sigma(m))$ +\end_inset + + and the new value of +\begin_inset Formula $m$ +\end_inset + + is +\begin_inset Formula $m-1$ +\end_inset + +. + Since +\begin_inset Formula $\sigma^{-1}(\sigma(m))>m-1$ +\end_inset + +, + the condition holds for +\begin_inset Formula $X[\sigma(m)]=X[-i]$ +\end_inset + +:. + Also, + +\begin_inset Formula $X[j]=-\sigma^{p+1}(m)=-\sigma^{p+k+1}(j)$ +\end_inset + +, + +\begin_inset Formula $j,\sigma(j),\dots,\sigma^{k-1}(j),\sigma^{k}(j)=m,\sigma^{k+1}(j)=\sigma(m),\dots,\sigma^{p+k}(j)=\sigma^{p-1}(m)>m-1$ +\end_inset + +, + and because +\begin_inset Formula $\sigma^{p+k+1}(j)=\sigma^{p}(m)\leq m$ +\end_inset + +, + and +\begin_inset Formula $\sigma^{p}(m)\neq m$ +\end_inset + + because otherwise it would be either +\begin_inset Formula $p\leq k$ +\end_inset + + and +\begin_inset Formula $\sigma^{k-p}(j)=m\#$ +\end_inset + +, + or +\begin_inset Formula $p>k$ +\end_inset + + and +\begin_inset Formula $\sigma^{p}(j)=\sigma^{p-k}(m)=j\leq m\#$ +\end_inset + +, + then we have +\begin_inset Formula $\sigma^{p+k+1}(j)=\sigma^{p}(m)\leq m-1$ +\end_inset + +, + and the condition holds for +\begin_inset Formula $X[j]$ +\end_inset + +. +\end_layout + +\begin_layout Standard +Now the only thing left to prove is that step J3 always ends, + for which it suffices to prove that the cycle that +\begin_inset Formula $m$ +\end_inset + + is in contains an element +\begin_inset Formula $t$ +\end_inset + + with +\begin_inset Formula $X[t]<0$ +\end_inset + +, + which happens if and only if it contains a +\begin_inset Formula $t$ +\end_inset + + with +\begin_inset Formula $\sigma^{-1}(t)\leq m$ +\end_inset + +, + if and only if there's an element not greater than +\begin_inset Formula $m$ +\end_inset + +, + but +\begin_inset Formula $m$ +\end_inset + + is such an element. +\end_layout + +\begin_layout Standard +\begin_inset Note Note +status open + +\begin_layout Plain Layout +TODO 26, + 34 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc26[M24] +\end_layout + +\end_inset + +Extend the principle of inclusion and exclusion to obtain a formula for the number of elements that are in exactly +\begin_inset Formula $r$ +\end_inset + + of the subsets +\begin_inset Formula $S_{1},S_{2},\dots,S_{M}$ +\end_inset + +. + (The text considers only the case +\begin_inset Formula $r=0$ +\end_inset + +.) +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +For the sake of abbreviation, + let +\begin_inset Formula $E_{r}$ +\end_inset + + be the number of elements that are exactly in +\begin_inset Formula $r$ +\end_inset + + of the subsets and let +\begin_inset Formula +\[ +T_{r}\coloneqq\sum_{1\leq j_{1}<\dotsM$ +\end_inset + +, + +\begin_inset Formula $T_{r}=0$ +\end_inset + +. +\end_layout + +\begin_layout Standard +Obviously +\begin_inset Formula $E_{r}=0$ +\end_inset + + for +\begin_inset Formula $r>M$ +\end_inset + +, + and +\begin_inset Formula $E_{M}=T_{M}$ +\end_inset + +. + After calculating +\begin_inset Formula $E_{M-1}$ +\end_inset + + and +\begin_inset Formula $E_{M-2}$ +\end_inset + +, + we formulate the hypothesis that +\begin_inset Formula +\[ +E_{r}=\sum_{k=r}^{M}(-1)^{k-r}\binom{k}{r}T_{k} +\] + +\end_inset + +for +\begin_inset Formula $0\leq r\leq M$ +\end_inset + +, + which matches what we know about +\begin_inset Formula $E_{M}$ +\end_inset + + and +\begin_inset Formula $E_{0}$ +\end_inset + +. + We prove this by induction from +\begin_inset Formula $r=M$ +\end_inset + + to 0. + We have already established the base case. + For +\begin_inset Formula $r + + + + + +\begin_inset Text + +\begin_layout Plain Layout +Time +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Action +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +0 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +ASSIGN(BUF1) +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +1000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +RELEASE, + OUT BUF1 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +2000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +ASSIGN(BUF2) +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +3000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +RELEASE +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +4000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +ASSIGN(BUF3) +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +5000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +RELEASE +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +6000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +ASSIGN +\family default + (wait) +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +8500 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +BUF1 +\family default + assigned, + +\family typewriter +OUT BUF2 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +9500 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +RELEASE +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +10500 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +ASSIGN +\family default + (wait) +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +16000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +BUF2 +\family default + assigned, + +\family typewriter +OUT BUF3 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +23000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +RELEASE +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +23500 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +OUT BUF1 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +28000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +ASSIGN(BUF3) +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +31000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +OUT BUF2 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +35000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +RELEASE +\end_layout + +\end_inset + + + + +\end_inset + + +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +hfil +\end_layout + +\end_inset + + +\begin_inset Tabular + + + + + + +\begin_inset Text + +\begin_layout Plain Layout +Time +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Action +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +38500 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +OUT BUF3 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +40000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +ASSIGN(BUF1) +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +46000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Output stops. +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +47000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +RELEASE, + OUT BUF1 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +52000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +ASSIGN(BUF2) +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +54500 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Output stops. +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +59000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +RELEASE, + OUT BUF2 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +64000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +ASSIGN(BUF3) +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +65000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +RELEASE +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +66000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +ASSIGN(BUF1) +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +66500 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +OUT BUF3 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +68000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +RELEASE +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +69000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Computation stops. +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +74000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +OUT BUF1 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +81500 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Output stops. +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\end_inset + + +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +hfil +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +The total time required was therefore +\begin_inset Formula $\unit[81500]{u}$ +\end_inset + +; + the computer was idle from 6000–8500, + 10500–16000, + and 69000–81500, + or +\begin_inset Formula $\unit[20500]{u}$ +\end_inset + + altogether; + the output unit was idle from 0–1000, + 46000–47000, + and 54500–59000, + or +\begin_inset Formula $\unit[6500]{u}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +Make a time-action chart like the above for the same program, + assuming that there are only +\emph on +two +\emph default + buffers. +\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 Float figure +placement document +alignment document +wide false +sideways false +status open + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +begin{center} +\end_layout + +\begin_layout Plain Layout + + +\backslash +begin{tikzpicture} +\end_layout + +\begin_layout Plain Layout + + +\backslash +def +\backslash +sp{( +\backslash +linewidth)} +\end_layout + +\begin_layout Plain Layout + + +\backslash +def +\backslash +us{*1.0/900* +\backslash +sp} +\end_layout + +\begin_layout Plain Layout + + +\backslash +def +\backslash +tmw{75 +\backslash +us} +\end_layout + +\begin_layout Plain Layout + + +\backslash +def +\backslash +buff{*1.4} +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw[style=dotted] +\end_layout + +\begin_layout Plain Layout + + (0,2.6 +\backslash +buff) +\end_layout + +\begin_layout Plain Layout + + node[left,text width=1cm,align=center]{Com +\backslash +-puter} +\end_layout + +\begin_layout Plain Layout + + -- ++({ +\backslash +sp},0) +\end_layout + +\begin_layout Plain Layout + + (0,3.2 +\backslash +buff) +\end_layout + +\begin_layout Plain Layout + + node[left,text width=1cm,align=center]{Output unit} +\end_layout + +\begin_layout Plain Layout + + -- ++({ +\backslash +sp},0); +\end_layout + +\begin_layout Plain Layout + + +\backslash +fill[fill=green] +\end_layout + +\begin_layout Plain Layout + + (0,0) -- (0,2 +\backslash +buff) -- ({ +\backslash +sp},{2 +\backslash +buff}) -- ({ +\backslash +sp},0); +\end_layout + +\begin_layout Plain Layout + +% +\backslash +assignment{buffer}{tm_start}{tm_got}{tm_use}{tm_red} +\end_layout + +\begin_layout Plain Layout + +% Buffer number, + time of ASSIGN, + time when the buffer is +\end_layout + +\begin_layout Plain Layout + +% ready for use, + time of RELEASE, + time when output starts +\end_layout + +\begin_layout Plain Layout + + +\backslash +def +\backslash +assignment#1#2#3#4#5{ +\end_layout + +\begin_layout Plain Layout + + +\backslash +fill[fill=yellow] +\end_layout + +\begin_layout Plain Layout + + ({#3 +\backslash +us},{#1 +\backslash +buff}) -- ({#4 +\backslash +us},{#1 +\backslash +buff}) +\end_layout + +\begin_layout Plain Layout + + -- ++(0,-1 +\backslash +buff) -- ({#3 +\backslash +us},{(#1-1) +\backslash +buff}); +\end_layout + +\begin_layout Plain Layout + + +\backslash +fill[fill=red] +\end_layout + +\begin_layout Plain Layout + + ({#4 +\backslash +us},{#1 +\backslash +buff}) -- ({#5 +\backslash +us},{#1 +\backslash +buff}) +\end_layout + +\begin_layout Plain Layout + + -- ++({ +\backslash +tmw},{-1/6 +\backslash +buff}) -- ++({- +\backslash +tmw},{-1/6 +\backslash +buff}) +\end_layout + +\begin_layout Plain Layout + + -- ++({ +\backslash +tmw},{-1/6 +\backslash +buff}) -- ++({- +\backslash +tmw},{-1/6 +\backslash +buff}) +\end_layout + +\begin_layout Plain Layout + + -- ++({ +\backslash +tmw},{-1/6 +\backslash +buff}) -- ++({- +\backslash +tmw},{-1/6 +\backslash +buff}) +\end_layout + +\begin_layout Plain Layout + + -- ({#4 +\backslash +us},{(#1-1) +\backslash +buff}); +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw +\end_layout + +\begin_layout Plain Layout + + ({#2 +\backslash +us},{2.5 +\backslash +buff}) -- ++(0,{0.2 +\backslash +buff}) node[above]{A} +\end_layout + +\begin_layout Plain Layout + + ({#3 +\backslash +us},{2.6 +\backslash +buff}) -- ({#4 +\backslash +us},{2.6 +\backslash +buff}) +\end_layout + +\begin_layout Plain Layout + + ({#4 +\backslash +us},{2.7 +\backslash +buff}) -- ++(0,{-0.2 +\backslash +buff}) node[below]{R} +\end_layout + +\begin_layout Plain Layout + + ({#5 +\backslash +us},{3.1 +\backslash +buff}) -- ++(0,{0.2 +\backslash +buff}) node[above]{O} +\end_layout + +\begin_layout Plain Layout + + ({#5 +\backslash +us},{3.2 +\backslash +buff}) -- ++({75 +\backslash +us},0); +\end_layout + +\begin_layout Plain Layout + +} +\end_layout + +\begin_layout Plain Layout + + +\backslash +assignment1{0}{0}{10}{10} +\end_layout + +\begin_layout Plain Layout + + +\backslash +assignment2{20}{20}{30}{85} +\end_layout + +\begin_layout Plain Layout + + +\backslash +assignment1{40}{85}{95}{160} +\end_layout + +\begin_layout Plain Layout + + +\backslash +assignment2{105}{160}{170}{235} +\end_layout + +\begin_layout Plain Layout + + +\backslash +assignment1{180}{235}{305}{310} +\end_layout + +\begin_layout Plain Layout + + +\backslash +assignment2{355}{355}{425}{425} +\end_layout + +\begin_layout Plain Layout + + +\backslash +assignment1{475}{475}{545}{545} +\end_layout + +\begin_layout Plain Layout + + +\backslash +assignment2{595}{595}{665}{665} +\end_layout + +\begin_layout Plain Layout + + +\backslash +assignment1{715}{715}{725}{740} +\end_layout + +\begin_layout Plain Layout + + +\backslash +assignment2{735}{740}{760}{815} +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw +\end_layout + +\begin_layout Plain Layout + + (0,0) -- (0,2 +\backslash +buff) -- ({ +\backslash +sp},2 +\backslash +buff) -- ({ +\backslash +sp},0); +\end_layout + +\begin_layout Plain Layout + + +\backslash +def +\backslash +bufferlbl#1{ +\end_layout + +\begin_layout Plain Layout + + (0,{(#1-0.5) +\backslash +buff}) +\end_layout + +\begin_layout Plain Layout + + node[left,rotate=90,anchor=south]{Buffer #1} +\end_layout + +\begin_layout Plain Layout + + (0,{(#1-1) +\backslash +buff}) -- ++({ +\backslash +sp},0) +\end_layout + +\begin_layout Plain Layout + +} +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw +\backslash +bufferlbl1 +\backslash +bufferlbl2; +\end_layout + +\begin_layout Plain Layout + + +\backslash +def +\backslash +axis#1{({(1#1-1000) +\backslash +us},0) -- ++(0,-0.2) node[below,rotate=90,anchor=east]{#100}} +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw +\backslash +axis{000} +\backslash +axis{050} +\backslash +axis{100} +\backslash +axis{150} +\end_layout + +\begin_layout Plain Layout + + +\backslash +axis{200} +\backslash +axis{250} +\backslash +axis{300} +\backslash +axis{350} +\end_layout + +\begin_layout Plain Layout + + +\backslash +axis{400} +\backslash +axis{450} +\backslash +axis{500} +\backslash +axis{550} +\end_layout + +\begin_layout Plain Layout + + +\backslash +axis{600} +\backslash +axis{650} +\backslash +axis{700} +\backslash +axis{750} +\end_layout + +\begin_layout Plain Layout + + +\backslash +axis{800} +\backslash +axis{850} +\backslash +axis{900}; +\end_layout + +\begin_layout Plain Layout + + +\backslash +end{tikzpicture} +\end_layout + +\begin_layout Plain Layout + + +\backslash +end{center} +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Caption Standard + +\begin_layout Plain Layout +\begin_inset CommandInset label +LatexCommand label +name "fig:1.4.4-1" + +\end_inset + +Output with three buffers (see exercise 9). +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +We can do this graphically as shown in +\begin_inset CommandInset ref +LatexCommand formatted +reference "fig:1.4.4-1" +plural "false" +caps "false" +noprefix "false" +nolink "false" + +\end_inset + +, + giving us the following chart: +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +nopagebreak +\backslash +hfil +\end_layout + +\end_inset + + +\begin_inset Tabular + + + + + + +\begin_inset Text + +\begin_layout Plain Layout +Time +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Action +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +0 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +ASSIGN(BUF1) +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +1000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +RELEASE, + OUT BUF1 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +2000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +ASSIGN(BUF2) +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +3000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +RELEASE +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +4000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +ASSIGN +\family default + (wait) +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +8500 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +BUF1 +\family default + assigned, + +\family typewriter +OUT BUF2 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +9500 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +RELEASE +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +10500 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +ASSIGN +\family default + (wait) +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +16000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +BUF2 +\family default + assigned, + +\family typewriter +OUT BUF1 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +17000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +RELEASE +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +18000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +ASSIGN +\family default + (wait) +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +23500 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +BUF1 +\family default + assigned, + +\family typewriter +OUT BUF2 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +30500 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +RELEASE +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +31000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +OUT BUF1 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +35500 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +ASSIGN(BUF2) +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +38500 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Output stops. +\end_layout + +\end_inset + + + + +\end_inset + + +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +hfil +\end_layout + +\end_inset + + +\begin_inset Tabular + + + + + + +\begin_inset Text + +\begin_layout Plain Layout +Time +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Action +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +42500 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +RELEASE, + OUT BUF2 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +47500 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +ASSIGN(BUF1) +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +50000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Output stops. +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +54500 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +RELEASE, + OUT BUF1 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +59500 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +ASSIGN(BUF2) +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +62000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Output stops. +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +65500 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +RELEASE, + OUT BUF2 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +71500 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +ASSIGN(BUF1) +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +72500 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +RELEASE +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +73500 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +ASSIGN +\family default + (wait) +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +74000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +BUF2 +\family default + assigned, + +\family typewriter +OUT BUF1 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +76000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +RELEASE +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +77000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Computation stops. +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +81500 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +OUT BUF2 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +89000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Output stops. +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\end_inset + + +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +hfil +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc14[20] +\end_layout + +\end_inset + +Suppose the computational program does not alternate between +\family typewriter +ASSIGN +\family default + and +\family typewriter +RELEASE +\family default +, + but instead gives the sequence of actions +\family typewriter +...ASSIGN...ASSIGN...RELEASE...RELEASE +\family default +. + What effect does this have on the algorithms described in the text? + Is it possibly useful? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +It just means we would need at least two buffers or the program would stall. + It might be useful if the algorithm needs more data at a time than what fits in one buffer, + so that it doesn't have to copy the data elsewhere. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc15[22] +\end_layout + +\end_inset + +Write a complete +\family typewriter +MIX +\family default + program that copies 100 blocks from tape unit 0 to tape unit 1, + using just three buffers. + The program should be as fast as possible. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +The following programs have not been tested. + We need to use the buffers in a circle, + checking input and output in a loop to see if the devices are ready and if we can move to the next buffer. + The following program in pseudo-C might be illustrative: +\end_layout + +\begin_layout Standard +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +void aread(char *buf), + awrite(char *buf); + // IN, + OUT +\end_layout + +\begin_layout Plain Layout + +bool done_read(), + done_write(); + // JBUS/JRED +\end_layout + +\begin_layout Plain Layout + +char buf[3][100]; +\end_layout + +\begin_layout Plain Layout + +char *cin = buf[0], + *cout = buf[0], + *next(char *buf); +\end_layout + +\begin_layout Plain Layout + +int n = 100; + // Remaining blocks to input +\end_layout + +\begin_layout Plain Layout + +\end_layout + +\begin_layout Plain Layout + +aread(cin); +\end_layout + +\begin_layout Plain Layout + +while (1) { +\end_layout + +\begin_layout Plain Layout + + if (done_read() && next(cin) != cout) { +\end_layout + +\begin_layout Plain Layout + + if (--n == 0) +\end_layout + +\begin_layout Plain Layout + + break; +\end_layout + +\begin_layout Plain Layout + + cin = next(cin); +\end_layout + +\begin_layout Plain Layout + + aread(cin); +\end_layout + +\begin_layout Plain Layout + + } +\end_layout + +\begin_layout Plain Layout + + } +\end_layout + +\begin_layout Plain Layout + + if (done_write() && next(cout) != cin) { +\end_layout + +\begin_layout Plain Layout + + cout = next(cout); +\end_layout + +\begin_layout Plain Layout + + awrite(cout); +\end_layout + +\begin_layout Plain Layout + + } +\end_layout + +\begin_layout Plain Layout + +} +\end_layout + +\begin_layout Plain Layout + +do // Output remaining blocks +\end_layout + +\begin_layout Plain Layout + + awrite(cout = next(cout)); +\end_layout + +\begin_layout Plain Layout + +while (cout != cin); +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +We may translate this as follows: +\end_layout + +\begin_layout Standard +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + + IN BUF1(0) +\end_layout + +\begin_layout Plain Layout + + ENTA 100 +\end_layout + +\begin_layout Plain Layout + + ENT1 BUF1 ; + cin +\end_layout + +\begin_layout Plain Layout + + ENT2 BUF1 ; + cout +\end_layout + +\begin_layout Plain Layout + +READ JBUS WRITE(0) +\end_layout + +\begin_layout Plain Layout + + CMP2 100,1 +\end_layout + +\begin_layout Plain Layout + + JEQ WRITE +\end_layout + +\begin_layout Plain Layout + + DECA 1 +\end_layout + +\begin_layout Plain Layout + + JAZ EOUT +\end_layout + +\begin_layout Plain Layout + + LD1 100,1 +\end_layout + +\begin_layout Plain Layout + + IN 0,1(0) +\end_layout + +\begin_layout Plain Layout + +WRITE JBUS READ(1) +\end_layout + +\begin_layout Plain Layout + + CMP1 100,2 +\end_layout + +\begin_layout Plain Layout + + JEQ READ +\end_layout + +\begin_layout Plain Layout + + LD2 100,2 +\end_layout + +\begin_layout Plain Layout + + OUT 0,2(1) +\end_layout + +\begin_layout Plain Layout + + JMP READ +\end_layout + +\begin_layout Plain Layout + +EOUT LD2 100,2 +\end_layout + +\begin_layout Plain Layout + + CMP2 100,1 +\end_layout + +\begin_layout Plain Layout + + JAZ END +\end_layout + +\begin_layout Plain Layout + + OUT 0,2(1) +\end_layout + +\begin_layout Plain Layout + + JMP EOUT +\end_layout + +\begin_layout Plain Layout + +END HLT +\end_layout + +\begin_layout Plain Layout + +BUF1 ORIG *+100 +\end_layout + +\begin_layout Plain Layout + + CON BUF2 +\end_layout + +\begin_layout Plain Layout + +BUF2 ORIG *+100 +\end_layout + +\begin_layout Plain Layout + + CON BUF3 +\end_layout + +\begin_layout Plain Layout + +BUF3 ORIG *+100 +\end_layout + +\begin_layout Plain Layout + + CON BUF1 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +Now, + the behavior of this program is always the same: + first the input advances, + then the output advances, + and so on, + so we might do better (and with a lower chance of bugs) just by coding it manually and using the blocking properties of +\family typewriter +IN +\family default + and +\family typewriter +OUT +\family default + with respect to other operations in the same device: +\end_layout + +\begin_layout Standard +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + + IN BUF1(0) +\end_layout + +\begin_layout Plain Layout + +LOOP ENTA 33 +\end_layout + +\begin_layout Plain Layout + + IN BUF2(0) +\end_layout + +\begin_layout Plain Layout + + OUT BUF1(1) +\end_layout + +\begin_layout Plain Layout + + IN BUF3(0) +\end_layout + +\begin_layout Plain Layout + + OUT BUF2(1) +\end_layout + +\begin_layout Plain Layout + + IN BUF1(0) +\end_layout + +\begin_layout Plain Layout + + OUT BUF3(1) +\end_layout + +\begin_layout Plain Layout + + DECA 1 +\end_layout + +\begin_layout Plain Layout + + JANZ LOOP +\end_layout + +\begin_layout Plain Layout + + JBUS *(0) +\end_layout + +\begin_layout Plain Layout + + OUT BUF1(1) +\end_layout + +\begin_layout Plain Layout + + JBUS *(1) +\end_layout + +\begin_layout Plain Layout + + HLT +\end_layout + +\begin_layout Plain Layout + +BUF1 ORIG *+100 +\end_layout + +\begin_layout Plain Layout + +BUF2 ORIG *+100 +\end_layout + +\begin_layout Plain Layout + +BUF3 ORIG *+100 +\end_layout + +\end_inset + + +\end_layout + +\end_body +\end_document diff --git a/vol1/2.1.lyx b/vol1/2.1.lyx new file mode 100644 index 0000000..624d7cf --- /dev/null +++ b/vol1/2.1.lyx @@ -0,0 +1,568 @@ +#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[04] +\end_layout + +\end_inset + +In the situation depicted in (3), + what is the value of +\end_layout + +\begin_layout Enumerate + +\family typewriter +SUIT(NEXT(TOP)) +\family default +; +\end_layout + +\begin_layout Enumerate + +\family typewriter +NEXT(NEXT(NEXT(TOP))) +\family default +? +\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 +4. +\end_layout + +\begin_layout Enumerate +\begin_inset Formula $\Lambda$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc2[10] +\end_layout + +\end_inset + +The text points out that in many cases +\begin_inset Formula $\mathtt{CONTENTS(LOC(V))}=\mathtt{V}$ +\end_inset + +. + Under what conditions do we have +\begin_inset Formula $\mathtt{LOC(CONTENTS(V))}=\mathtt{V}$ +\end_inset + +? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\family typewriter +V +\family default + must be a valid memory address different from +\begin_inset Formula $\Lambda$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc5[21] +\end_layout + +\end_inset + +Give an algorithm that essentially undoes the effect of exercise 4: + Assuming that the pile is not empty and that its bottom card is face down, + your algorithm should remove the bottom card and make +\family typewriter +NEWCARD +\family default + link to it. + (This algorithm is sometimes called +\begin_inset Quotes eld +\end_inset + +cheating +\begin_inset Quotes erd +\end_inset + + in solitaire games.) +\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 +If +\begin_inset Formula $\mathtt{NEXT(TOP)}=\Lambda$ +\end_inset + +, + let +\begin_inset Formula $\mathtt{NEWCARD}\gets\mathtt{TOP}$ +\end_inset + +, + +\begin_inset Formula $\mathtt{TOP}\gets\Lambda$ +\end_inset + + and terminate. +\end_layout + +\begin_layout Enumerate +\begin_inset Formula $\mathtt{X}\gets\mathtt{TOP}$ +\end_inset + +, + +\begin_inset Formula $\mathtt{Y}\gets\mathtt{NEXT(TOP)}$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +If +\begin_inset Formula $\mathtt{NEXT(Y)}\neq\Lambda$ +\end_inset + +, + let +\begin_inset Formula $\mathtt{X}\gets\mathtt{Y}$ +\end_inset + +, + +\begin_inset Formula $\mathtt{Y}\gets\mathtt{NEXT(Y)}$ +\end_inset + + and repeat this step. +\end_layout + +\begin_layout Enumerate +Set +\begin_inset Formula $\mathtt{NEWCARD}\gets\mathtt{Y}$ +\end_inset + + and +\begin_inset Formula $\mathtt{NEXT(X)}\gets\Lambda$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc6[06] +\end_layout + +\end_inset + +In the playing card example, + suppose that +\family typewriter +CARD +\family default + is the name of a variable whose value is an entire node as in (6). + The operation +\begin_inset Formula $\mathtt{CARD}\gets\mathtt{NODE(TOP)}$ +\end_inset + + sets the fields of +\family typewriter +CARD +\family default + respectively equal to those of the top of the pile. + After this operation, + which of the following notations stands for the suit of the top card? +\end_layout + +\begin_layout Enumerate + +\family typewriter +SUIT(CARD) +\family default +; +\end_layout + +\begin_layout Enumerate + +\family typewriter +SUIT(LOC(CARD)) +\family default +; +\end_layout + +\begin_layout Enumerate + +\family typewriter +SUIT(CONTENTS(CARD)) +\family default +; +\end_layout + +\begin_layout Enumerate + +\family typewriter +SUIT(TOP) +\family default +? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +2 and 4. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc7[04] +\end_layout + +\end_inset + +In the text's example +\family typewriter +MIX +\family default + program, + (5), + the link variable +\family typewriter +TOP +\family default + is stored in the +\family typewriter +MIX +\family default + computer word whose assembly language name is +\family typewriter +TOP +\family default +. + Given the field structure (1), + which of the following sequences of code brings the quantity +\family typewriter +NEXT(TOP) +\family default + into register A? + Explain why the other sequence is incorrect. +\end_layout + +\begin_layout Enumerate + +\family typewriter +LDA TOP(NEXT) +\end_layout + +\begin_layout Enumerate + +\family typewriter +LD1 TOP +\begin_inset Newline newline +\end_inset + +LDA 0,1(NEXT) +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +2, + since the first loads the field +\family typewriter +NEXT +\family default + from the memory word +\family typewriter +TOP +\family default +, + that only contains the address, + instead of from the node that +\family typewriter +TOP +\family default + points to. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc8[18] +\end_layout + +\end_inset + +Write a +\family typewriter +MIX +\family default + program corresponding to steps B1–B3. +\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 +inline false +status open + +\begin_layout Plain Layout + +NEXT EQU 4:5 +\end_layout + +\begin_layout Plain Layout + +LLEN STJ CHECK +\end_layout + +\begin_layout Plain Layout + + ENTA 0 ; + B1 +\end_layout + +\begin_layout Plain Layout + + ENT1 TOP +\end_layout + +\begin_layout Plain Layout + +2H J1Z * ; + B2 +\end_layout + +\begin_layout Plain Layout + + INCA 1 ; + B3 +\end_layout + +\begin_layout Plain Layout + + LD1 0,1(NEXT) +\end_layout + +\begin_layout Plain Layout + + JMP 2B +\end_layout + +\end_inset + + +\end_layout + +\end_body +\end_document diff --git a/vol1/2.2.1.lyx b/vol1/2.2.1.lyx new file mode 100644 index 0000000..27287f7 --- /dev/null +++ b/vol1/2.2.1.lyx @@ -0,0 +1,910 @@ +#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[06] +\end_layout + +\end_inset + +An input-restricted deque is a linear list in which items may be inserted at one end but removed from either end; + clearly an input-restricted deque can operate either as a stack or as a queue, + if we consistently remove all items from one of the two ends. + Can an output-restricted deque also be operated either as a stack or as a queue? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Yes. + If output happens on the left, + we can use a deque as a queue by inserting on the right or as a stack by inserting on the left. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc2[15] +\end_layout + +\end_inset + +Imagine four railroad cars positioned on the input side of the track in Fig. + 1, + numbered 1, + 2, + 3, + and 4, + from left to right. + Suppose we perform the following sequence of operations (which is compatible with the direction of the arrows in the diagram and does not require cars to +\begin_inset Quotes eld +\end_inset + +jump over +\begin_inset Quotes erd +\end_inset + + other cars): + (i) move car 1 into the stack; + (ii) move car 2 into the stack; + (iii) move car 2 into the output; + (iv) move car 3 into the stack; + (v) move car 4 into the stack; + (vi) move car 4 into the output; + (vii) move car 3 into the output; + (viii) move car 1 into the output. +\end_layout + +\begin_layout Standard +As a result of these operations the original order of the cars, + +\begin_inset Formula $1\,2\,3\,4$ +\end_inset + +, + has been changed into +\begin_inset Formula $2\,4\,3\,1$ +\end_inset + +. + +\emph on +It is the purpose of this exercise and the following exercises to examine what permutations are obtainable in such a manner from stacks, + queues, + or deques. +\end_layout + +\begin_layout Standard +If there are six railroad cars numbered +\begin_inset Formula $1\,2\,3\,4\,5\,6$ +\end_inset + +, + can they be permuted into the order +\begin_inset Formula $3\,2\,5\,6\,4\,1$ +\end_inset + +? + Can they be permuted into the order +\begin_inset Formula $1\,5\,4\,6\,2\,3$ +\end_inset + +? + (In case it is possible, + show how to do it.) +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +For +\begin_inset Formula $3\,2\,5\,6\,4\,1$ +\end_inset + +, + we push 1, + push 2, + push 3, + pop 3, + pop 2, + push 4, + push 5, + pop 5, + push 6, + pop 6, + pop 4, + and pop 1. + We can't get the permutation +\begin_inset Formula $1\,5\,4\,6\,2\,3$ +\end_inset + +: + first, + we'd need to push 1 and pop it immediately since, + otherwise, + it couldn't be the first car to go out; + then we need to push trains 2 to 5 without popping anything before the 5, + so that no car is between the 1 and the 5, + but then we must pop 3 before popping 2, + so the order wouldn't be respected. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc5[M28] +\end_layout + +\end_inset + +Show that it is possible to obtain a permutation +\begin_inset Formula $p_{1}\,p_{2}\,\dots\,p_{n}$ +\end_inset + + from +\begin_inset Formula $1\,2\,\dots\,n$ +\end_inset + + using a stack if and only if there are no indices +\begin_inset Formula $ij$ +\end_inset + + such that +\begin_inset Formula $p_{j} 3 ---> 7 ---> 4 +\end_layout + +\begin_layout Plain Layout + + | | +\end_layout + +\begin_layout Plain Layout + + v | +\end_layout + +\begin_layout Plain Layout + + 9 ---> 5 | +\end_layout + +\begin_layout Plain Layout + + | | | +\end_layout + +\begin_layout Plain Layout + + v v v +\end_layout + +\begin_layout Plain Layout + + 2 ---> 8 ---> 6 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +Then we explore possibilities by following the idea in algorithm T but backtracking. + We suppress the arrows for compactness. +\end_layout + +\begin_layout Standard +\begin_inset Formula +\[ +\begin{array}{cccccc} +137492586 & 137495286 & 137924586 & 137925486 & 137925846 & 137942586\\ +137945286 & 137952486 & 137952846 & 137954286 & 139274586 & 139275486\\ +139275846 & 139724586 & 139725486 & 139725846 & 139742586 & 139745286\\ +139752486 & 139752846 & 139754286 & 192374586 & 192375486 & 192375846\\ +193274586 & 193275486 & 193275846 & 193724586 & 193725486 & 193725846\\ +193742586 & 193745286 & 193752486 & 193752846 & 193754286 & 912374586\\ +912375486 & 912375846 & 913274586 & 913275486 & 913275846 & 913724586\\ +913725486 & 913725846 & 913742586 & 913745286 & 913752486 & 913752846\\ +913754286 & 921374586 & 921375486 & 921375846 +\end{array} +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset Note Note +status open + +\begin_layout Plain Layout +TODO verify from here +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc17[21] +\end_layout + +\end_inset + + What output does Algorithm T produce if it is presented with the input (18)? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We follow the algorithm with the following table: +\end_layout + +\begin_layout Standard +\begin_inset Tabular + + + + + + + + + + + + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +0 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +2 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +3 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +4 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +5 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +6 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +7 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +8 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +9 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +QLINK +\family default +/ +\family typewriter +COUNT +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +9 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +7 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +2 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +5 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +8 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +0 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +4 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +6 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +3 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +TOP +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $3.$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $8.$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $7.$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $6.$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $8.$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\Lambda$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $4,5.$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $6.$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $5,2.$ +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +N: +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +0 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +F: +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +0 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +R: +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +6 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +P: +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\Lambda$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\end_inset + + +\end_layout + +\begin_layout Standard +To get the output +\begin_inset Formula $1\to9\to3\to2\to7\to4\to5\to8\to6(\to0)$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc20[24] +\end_layout + +\end_inset + +Algorithm T uses +\family typewriter +F +\family default +, + +\family typewriter +R +\family default +, + and the +\family typewriter +QLINK +\family default + table to obtain the effect of a queue that contains those nodes whose +\family typewriter +COUNT +\family default + field has become zero but whose successor relations have not yet been removed. + Could a stack be used for this purpose instead of a queue? + If so, + compare the resulting algorithm with Algorithm T. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Yes, + because those are nodes that we can already print next after the ones that we have already printed. + The differences would be: +\end_layout + +\begin_layout Enumerate +In T4, + we would do +\begin_inset Formula $\mathtt{T}\gets0$ +\end_inset + + and, + for each +\begin_inset Formula $1\leq k\leq n$ +\end_inset + + with +\begin_inset Formula $\mathtt{COUNT[}k\mathtt{]}=0$ +\end_inset + +, + +\begin_inset Formula $\mathtt{QLINK[}k\mathtt{]}\gets\mathtt{T}$ +\end_inset + + and +\begin_inset Formula $\mathtt{T}\gets k$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +In T5, + we would output the value of +\family typewriter +T +\family default + rather than +\family typewriter +F +\family default +, + and instead of +\begin_inset Formula $\mathtt{P}\gets\mathtt{TOP[F]}$ +\end_inset + + we would do +\begin_inset Formula $\mathtt{P}\gets\mathtt{TOP[T]}$ +\end_inset + +. + We would do +\begin_inset Formula $\mathtt{T}\gets\mathtt{QLINK[T]}$ +\end_inset + + right after T5 instead of doing T7. +\end_layout + +\begin_layout Enumerate +In T6, + the two assignments involving +\family typewriter +R +\family default + would instead be +\begin_inset Formula $\mathtt{QLINK[SUC(P)]}\gets\mathtt{T}$ +\end_inset + + and +\begin_inset Formula $\mathtt{T}\gets\mathtt{SUC(P)}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +Then we wouldn't need +\begin_inset Formula $\mathtt{QLINK[}0\mathtt{]}$ +\end_inset + +. + With input (18), + this would work as follows: +\end_layout + +\begin_layout Standard +\begin_inset Tabular + + + + + + + + + + + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +2 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +3 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +4 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +5 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +6 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +7 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +8 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +9 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +QLINK +\family default +/ +\family typewriter +COUNT +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +0 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +0 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +0 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +4 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +0 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +0 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +4 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +TOP +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $3.$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $8.$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $7.$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $6.$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $8.$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\Lambda$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $4,5.$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $6.$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $5,2.$ +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +N: +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +0 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +T: +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +0 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +P: +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\Lambda$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\end_inset + + +\end_layout + +\begin_layout Standard +Output: + +\begin_inset Formula $9\to2\to1\to3\to7\to5\to8\to4\to6(\to0)$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc29[21] +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Enumerate +\begin_inset CommandInset label +LatexCommand label +name "enu:e22429a" + +\end_inset + +Give an algorithm to +\begin_inset Quotes eld +\end_inset + +erase +\begin_inset Quotes erd +\end_inset + + an entire list like (1), + by putting all of its nodes on the +\family typewriter +AVAIL +\family default + stack, + given only the value of +\family typewriter +FIRST +\family default +. + The algorithm should operate as fast as possible. +\end_layout + +\begin_layout Enumerate +Repeat part +\begin_inset CommandInset ref +LatexCommand ref +reference "enu:e22429a" +plural "false" +caps "false" +noprefix "false" +nolink "false" + +\end_inset + + for a list like (12), + given the values of +\family typewriter +F +\family default + and +\family typewriter +R +\family default +. +\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 +If +\begin_inset Formula $\mathtt{FIRST}=\Lambda$ +\end_inset + +, + we don't have to do anything. + Otherwise, + let +\begin_inset Formula $\mathtt{P}\gets\mathtt{FIRST}$ +\end_inset + +, + if +\begin_inset Formula $\mathtt{LINK(P)}\neq\emptyset$ +\end_inset + + then +\begin_inset Formula $\mathtt{P}\gets\mathtt{LINK(P)}$ +\end_inset + + and repeat, + finally set +\begin_inset Formula $\mathtt{LINK(P)}\gets\mathtt{AVAIL}$ +\end_inset + + and +\begin_inset Formula $\mathtt{AVAIL}\gets\mathtt{FIRST}$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +Just set +\begin_inset Formula $\mathtt{LINK(R)}\gets\mathtt{AVAIL}$ +\end_inset + + and +\begin_inset Formula $\mathtt{AVAIL}\gets\mathtt{F}$ +\end_inset + +. + This works even if the queue is empty. +\end_layout + +\end_body +\end_document diff --git a/vol1/2.2.4.lyx b/vol1/2.2.4.lyx new file mode 100644 index 0000000..5445975 --- /dev/null +++ b/vol1/2.2.4.lyx @@ -0,0 +1,644 @@ +#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 +\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[20] +\end_layout + +\end_inset + +What does operation (3) do if +\begin_inset Formula $\mathtt{PTR}_{1}$ +\end_inset + + and +\begin_inset Formula $\mathtt{PTR}_{2}$ +\end_inset + + are both pointing to nodes in the +\emph on +same +\emph default + circular list? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +It splits the list into two parts; + the one that goes from the right of +\begin_inset Formula $\mathtt{PTR}_{1}$ +\end_inset + + to +\begin_inset Formula $\mathtt{PTR}_{2}$ +\end_inset + + is preserved but the other one becomes a memory leak. + If the two pointers are equal, + nothing happens, + just +\begin_inset Formula $\mathtt{PTR}_{2}$ +\end_inset + + is set to +\begin_inset Formula $\Lambda$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc5[21] +\end_layout + +\end_inset + +Design an algorithm that takes a circular list such as (1) and reverses the direction of all the arrows. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +This is similar to exercise 2.2.3.7. +\end_layout + +\begin_layout Enumerate +Set +\begin_inset Formula $\mathtt{P}\gets\Lambda$ +\end_inset + + and +\begin_inset Formula $\mathtt{C}\gets\mathtt{PTR}$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +If +\begin_inset Formula $\mathtt{C}\neq\Lambda$ +\end_inset + +, + set +\begin_inset Formula $\mathtt{N}\gets\mathtt{LINK(C)}$ +\end_inset + +, + +\begin_inset Formula $\mathtt{LINK(C)}\gets\mathtt{P}$ +\end_inset + +, + +\begin_inset Formula $\mathtt{P}\gets\mathtt{C}$ +\end_inset + +, + +\begin_inset Formula $\mathtt{C}\gets\mathtt{N}$ +\end_inset + +, + and repeat. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc7[10] +\end_layout + +\end_inset + +Why is it useful to assume that the +\family typewriter +ABC +\family default + fields of a polynomial list appear in decreasing order? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Many operations on polynomials require us to match monomials with equal exponents of the variables. + By having a total order on them it's easy to match these in linear time. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc8[10] +\end_layout + +\end_inset + +Why is it useful to have +\family typewriter +Q1 +\family default + trailing one step behind +\family typewriter +Q +\family default + in Algorithm A? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We need +\family typewriter +Q +\family default + to advance in order to check if the next monomial has greater, + lower, + or equal coefficient than the one pointed to by +\family typewriter +P +\family default +, + and if it's lower, + we need +\family typewriter +Q1 +\family default + to insert the one pointed to by +\family typewriter +P +\family default + right before the one pointed to by +\family typewriter +Q +\family default +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc9[23] +\end_layout + +\end_inset + +Would Algorithm A work properly if +\begin_inset Formula $\mathtt{P}=\mathtt{Q}$ +\end_inset + + (i.e., + both pointer variables point at the same polynomial)? + Would Algorithm M work properly if +\begin_inset Formula $\mathtt{P}=\mathtt{M}$ +\end_inset + +, + if +\begin_inset Formula $\mathtt{P}=\mathtt{Q}$ +\end_inset + +, + or if +\begin_inset Formula $\mathtt{M}=\mathtt{Q}$ +\end_inset + +? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Algorithm A would work properly, + doubling the polynomial being pointed to (this is assuming no coefficient is 0). + As for Algorithm M, + it would work for +\begin_inset Formula $\mathtt{P}=\mathtt{M}$ +\end_inset + + since they're not mutated. + If +\begin_inset Formula $\mathtt{P}=\mathtt{Q}$ +\end_inset + + it wouldn't work, + because if +\family typewriter +M +\family default + has more than one monomial then the addition of +\begin_inset Formula $\mathtt{P}$ +\end_inset + + times the second monomial or later (the second iteration of step M2) would add the wrong value to +\family typewriter +Q +\family default +. + If +\begin_inset Formula $\mathtt{M}=\mathtt{Q}$ +\end_inset + + it wouldn't work either as, + for example, + if initially +\begin_inset Formula $\mathtt{M}=\mathtt{Q}=1$ +\end_inset + + and +\begin_inset Formula $\mathtt{P}=-1$ +\end_inset + +, + then addition in the first iteration of M2 would free the current monomial pointed to by +\begin_inset Formula $\mathtt{M}$ +\end_inset + + and in the next iteration of M1, + +\begin_inset Formula $\mathtt{M}$ +\end_inset + + would point to free memory with unpredictable consequences. + In cases where the constant coefficient of +\family typewriter +P +\family default + is not +\begin_inset Formula $-1$ +\end_inset + +, + it amazingly works, + as writes to +\family typewriter +Q +\family default + are always behind where we read from +\family typewriter +M +\family default + when considering monomials of +\family typewriter +P +\family default + with positive degree and, + for the constant coefficient, + it writes to the same position where +\family typewriter +M +\family default + is but only to the +\family typewriter +COEF +\family default + field— +unless +\family typewriter +P +\family default + is +\begin_inset Formula $-1$ +\end_inset + + in which case the node pointed to by +\family typewriter +M +\family default + is freed. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc10[20] +\end_layout + +\end_inset + +The algorithms in this section assume that we are using three variables +\begin_inset Formula $x$ +\end_inset + +, + +\begin_inset Formula $y$ +\end_inset + +, + and +\begin_inset Formula $z$ +\end_inset + + in the polynomials, + and that their exponents individually never exceed +\begin_inset Formula $b-1$ +\end_inset + + (where +\begin_inset Formula $b$ +\end_inset + + is the byte size in +\family typewriter +MIX +\family default +'s case). + Suppose instead that we want to do addition and multiplication of polynomials in only one variable, + +\begin_inset Formula $x$ +\end_inset + +, + and to let its exponent take on values up to +\begin_inset Formula $b^{3}-1$ +\end_inset + +. + What changes should be made to Algorithms A and M? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +None, + as they work out of the box if we consider the +\family typewriter +ABC +\family default + field to hold a single coefficient. + The sums and comparisons made on this field in the algorithms are equally valid independently of which of the two interpretations we want to give to this field, + assuming no overflow. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc17[22] +\end_layout + +\end_inset + +What advantage is there in representing polynomials with a circular list as in this section, + instead of with a straight linear linked list terminated by +\begin_inset Formula $\Lambda$ +\end_inset + + as in the previous section? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Steps A2 and A5 don't need special cases to handle the end of a list, + only A3 does. + Other than that there's not much of a difference. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc18[25] +\end_layout + +\end_inset + +Devise a way to represent circular lists inside a computer in such a way that the list can be traversed efficiently in both directions, + yet only one link field is used per node. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +If the link field combines the location of the next and previous fields with some monoidal operation like XOR, + and we have an item +\begin_inset Formula $x_{i}$ +\end_inset + +, + then knowing the location of +\begin_inset Formula $x_{i+1}$ +\end_inset + + allows us to get the location of +\begin_inset Formula $x_{i-1}$ +\end_inset + + and vice versa, + so knowing the location of two consecutive items allows us to traverse the list in both directions. +\end_layout + +\end_body +\end_document diff --git a/vol1/2.2.5.lyx b/vol1/2.2.5.lyx new file mode 100644 index 0000000..6bf2b5b --- /dev/null +++ b/vol1/2.2.5.lyx @@ -0,0 +1,606 @@ +#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 +\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[22] +\end_layout + +\end_inset + +Explain why a list that is singly linked cannot allow efficient operation as a general deque; + the deletion of items can be done efficiently at only one end of a singly linked list. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +One could, + in fact, + implement it reasonably efficiently using the trick from Exercise 2.2.4.18. + If we assume a normal linked list, + however, + deletion of an element requires knowing the link to the previous element. + We know this for the head of the list, + as we just have to change the pointer to the head, + but we do not know it for the tail, + and if we cached a pointer to the second-to-last element to do this, + then we would need to update this pointer to point to the new second-to-last element, + whose address we cannot retrieve efficiently. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc3[22] +\end_layout + +\end_inset + +The elevator system described in the text uses three call variables, + +\family typewriter +CALLUP +\family default +, + +\family typewriter +CALLCAR +\family default +, + and +\family typewriter +CALLDOWN +\family default +, + for each floor, + representing buttons that have been pushed by the users in the system. + It is conceivable that the elevator actually needs only one or two binary variables for the call buttons on each floor, + instead of three. + Explain how an experimenter could push buttons in a certain sequence with this elevator system to +\emph on +prove +\emph default + that there are three independent binary variables for each floor (except the top and bottom floors). +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We need an experiment that proves that, + for any given floor that is not the top or bottom one, + the elevator behaves differently for each of the 8 possible combinations of the 3 buttons. +\end_layout + +\begin_layout Standard +Let us denote the states by the values of +\family typewriter +CALLUP +\family default +, + +\family typewriter +CALLCAR +\family default + and +\family typewriter +CALLDOWN +\family default + in sequence, + so for example only +\family typewriter +CALLUP +\family default + would be 100 and all buttons at once would be 111. +\end_layout + +\begin_layout Standard +We first note that the three buttons are not completely independent: + 101 and 111 are equal, + because the elevator would stop in both directions and then one of +\family typewriter +CALLUP +\family default + and +\family typewriter +CALLDOWN +\family default + is cleared at the same time as +\family typewriter +CALLCAR +\family default + is, + so there's no observable difference, + but this state and all others are pairwise different, + as we shall see. +\end_layout + +\begin_layout Standard +000 is trivially different from all the other states since, + if the elevator is in another floor, + any other combination would take it to our floor. + If the elevator is in the lower floor and we call 001 in the current and above floors, + it would go to the floor above and then to the current one, + the opposite of what would happen if in the current floor we would call any combination involving +\family typewriter +CALLUP +\family default + or +\family typewriter +CALLCAR +\family default +. + The opposite experiment (calling 100 in the current and below floors with the elevator in the one above, + and then changing what we call in the current floor) shows that 100 is also different from all the others. +\end_layout + +\begin_layout Standard +To see that 010 and 101 are different, + we press +\family typewriter +CALLCAR +\family default + in the current floor with the elevator in the one above and, + while it's going down, + press +\family typewriter +CALLUP +\family default + in the floor below and tell it to go two floors up. + Our design wouldn't stop in our floor when going up, + but it would if we had pressed both +\family typewriter +CALLUP +\family default + and +\family typewriter +CALLDOWN +\family default + since +\family typewriter +CALLUP +\family default + would still be 1 after stopping when going down. + Actually, + this shows that 010 and 011 are different from 101, + 110, + and 111, + and the opposite experiment shows that 010 and 110 are different from 101, + 011, + and 111. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc11[21] +\end_layout + +\end_inset + +( +\emph on +A sparse-update memory. +\emph default +) The following problem often arises in +\emph on +synchronous +\emph default + simulations: + The system has +\begin_inset Formula $n$ +\end_inset + + variables +\begin_inset Formula $\mathtt{V[}1\mathtt{]},\dots,\mathtt{V[}n\mathtt{]}$ +\end_inset + +, + and at every simulated step new values for some of them are calculated from the old values. + These calculations are assumed to be done +\begin_inset Quotes eld +\end_inset + +simultaneously +\begin_inset Quotes erd +\end_inset + + in the sense that the variables do not change to their new values until after all assignments have been made. + Thus, + the two statements +\begin_inset Formula +\begin{align*} +\mathtt{V[}1\mathtt{]} & \gets\mathtt{V[}2\mathtt{]} & & \text{and} & & \mathtt{V[}2\mathtt{]}\gets\mathtt{V[}1\mathtt{]} +\end{align*} + +\end_inset + +appearing at the same simulated time would interchange the values of +\begin_inset Formula $\mathtt{V[}1\mathtt{]}$ +\end_inset + + and +\begin_inset Formula $\mathtt{V[}2\mathtt{]}$ +\end_inset + +; + this is quite different from what would happen in a sequential calculation. +\end_layout + +\begin_layout Standard +The desired action can of course be simulated by keeping an additional table +\begin_inset Formula $\mathtt{NEWV[}1\mathtt{]},\dots,\mathtt{NEWV[}n\mathtt{]}$ +\end_inset + +. + Before each simulated step, + we could set +\begin_inset Formula $\mathtt{NEWV[}k\mathtt{]}\gets\mathtt{V[}k\mathtt{]}$ +\end_inset + + for +\begin_inset Formula $1\leq k\leq n$ +\end_inset + +, + then record all changes of +\begin_inset Formula $\mathtt{V[}k\mathtt{]}$ +\end_inset + + in +\begin_inset Formula $\mathtt{NEWV[}k\mathtt{]}$ +\end_inset + +, + and finally, + after the step we could set +\begin_inset Formula $\mathtt{V[}k\mathtt{]}\gets\mathtt{NEWV[}k\mathtt{]}$ +\end_inset + +, + +\begin_inset Formula $1\leq k\leq n$ +\end_inset + +. + But this +\begin_inset Quotes eld +\end_inset + +brute force +\begin_inset Quotes erd +\end_inset + + approach is not completely satisfactory, + for the following reasons: +\end_layout + +\begin_layout Enumerate +Often +\begin_inset Formula $n$ +\end_inset + + is very large, + but the number of variables changed per step is rather small. +\end_layout + +\begin_layout Enumerate +The variables are often not arranged in a nice table +\begin_inset Formula $\mathtt{V[}1\mathtt{]},\dots,\mathtt{V[}n\mathtt{]}$ +\end_inset + +, + but are scattered throughout memory in a rather chaotic fashion. +\end_layout + +\begin_layout Enumerate +This method does not detect the situation (usually an error in the model) when one variable is given two values in the same simulated stop. +\end_layout + +\begin_layout Enumerate +Assuming that the number of variables changed per step is rather small, + design an efficient algorithm that simulates the desired actions, + using two auxiliary tables +\begin_inset Formula $\mathtt{NEWV[}k\mathtt{]}$ +\end_inset + + and +\begin_inset Formula $\mathtt{LINK[}k\mathtt{]}$ +\end_inset + +, + +\begin_inset Formula $1\leq k\leq n$ +\end_inset + +. + If possible, + your algorithm should give an error stop if the same variables is being given two different values in the same step. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +The idea, + of course, + would be to make a linked list with the +\family typewriter +LINK +\family default + table. + If we assume the table is initially set to 0, + we could use +\begin_inset Formula $-1$ +\end_inset + + to signify the end of the linked list. +\end_layout + +\begin_layout Enumerate +[Initialize.] (This step only happens at the beginning of the simulation.) Set +\begin_inset Formula $\mathtt{LINK[}k\mathtt{]}\gets0$ +\end_inset + +, + +\begin_inset Formula $1\leq k\leq n$ +\end_inset + +, + +\begin_inset Formula $\mathtt{Q}\gets-1$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +\begin_inset CommandInset label +LatexCommand label +name "enu:25521b" + +\end_inset + +[Advance time.] Advance to the next step of the synchronous simulation. +\end_layout + +\begin_layout Enumerate +[Run the current state.] For each calculation that needs to be done, + if +\begin_inset Formula $k$ +\end_inset + + is the variable to be updated, + raise an error if +\begin_inset Formula $\mathtt{LINK[}k\mathtt{]}\neq0$ +\end_inset + +, + calculate the new value, + store it in +\begin_inset Formula $\mathtt{NEWV[}k\mathtt{]}$ +\end_inset + +, + set +\begin_inset Formula $\mathtt{LINK[}k\mathtt{]}\gets\mathtt{Q}$ +\end_inset + + and +\begin_inset Formula $\mathtt{Q}\gets k$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +[Update variables.] If +\begin_inset Formula $\mathtt{Q}>0$ +\end_inset + +, + set +\begin_inset Formula $\mathtt{V[Q]}\gets\mathtt{NEWV[Q]}$ +\end_inset + +, + +\begin_inset Formula $\mathtt{Q2}\gets\mathtt{LINK[Q]}$ +\end_inset + +, + +\begin_inset Formula $\mathtt{LINK[Q]}\gets0$ +\end_inset + +, + +\begin_inset Formula $\mathtt{Q}\gets\mathtt{LINK[Q]}$ +\end_inset + +, + and repeat this step. + Otherwise go to +\begin_inset CommandInset ref +LatexCommand ref +reference "enu:25521b" +plural "false" +caps "false" +noprefix "false" +nolink "false" + +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc12[22] +\end_layout + +\end_inset + +Why is it a good idea to use doubly linked lists instead of singly linked or sequential lists in the simulation program of this section? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +This is because we often delete nodes from the middle of the list without knowing the predecessor or successor, + like an user who was tired of waiting, + and doubly linked lists are the only kind that allows doing this efficiently. +\end_layout + +\end_body +\end_document diff --git a/vol1/2.2.6.lyx b/vol1/2.2.6.lyx new file mode 100644 index 0000000..56b0cdd --- /dev/null +++ b/vol1/2.2.6.lyx @@ -0,0 +1,577 @@ +#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 +\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 +rexerc[21] +\end_layout + +\end_inset + +Formulas (5) and (6) have been derived from the assumption that +\begin_inset Formula $0\leq\mathtt{I}_{r}\leq d_{r}$ +\end_inset + + for +\begin_inset Formula $1\leq r\leq k$ +\end_inset + +. + Give a general formula that applies to the case +\begin_inset Formula $l_{r}\leq\mathtt{I}_{r}\leq u_{r}$ +\end_inset + +, + where +\begin_inset Formula $l_{r}$ +\end_inset + + and +\begin_inset Formula $u_{r}$ +\end_inset + + are any lower and upper bounds on the dimensionality. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\begin_inset Formula +\begin{align*} +\mathtt{LOC(A[}\mathtt{I}_{1},\mathtt{I}_{2},\dots,\mathtt{I}_{k}\mathtt{])} & =\mathtt{LOC(A[}l_{1},l_{2},\dots,l_{k}\mathtt{])}+\sum_{1\leq r\leq k}a_{r}(\mathtt{I}_{r}-l_{r})=\\ + & =\left(\mathtt{LOC(A[}l_{1},l_{2},\dots,l_{k}\mathtt{])}-\sum_{1\leq r\leq k}a_{r}l_{r}\right)+\sum_{1\leq r\leq k}a_{r}\mathtt{I}_{r}, +\end{align*} + +\end_inset + +where +\begin_inset Formula +\[ +a_{r}=c\prod_{r + + + + + + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +P +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +NAME(P) +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +PARENT(P) +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +DELTA(P) +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +LBD(P) +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +UBD(P) +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\alpha$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +X +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\Lambda$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +0 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +0 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +10 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\beta$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +Y +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\Lambda$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +0 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +3 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +10 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\gamma$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +A +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\Lambda$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +0 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\delta$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +Z +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\Lambda$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +0 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $-2$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +0 +\end_layout + +\end_inset + + + + +\end_inset + + +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +vspace{4pt} +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +noindent +\end_layout + +\end_inset + +After the equivalences are processed, + the nodes might appear thus: +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +vspace{2pt} +\end_layout + +\end_inset + + +\begin_inset Newline newline +\end_inset + + +\begin_inset Tabular + + + + + + + + + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\text{\makebox[\widthof{\texttt{P}}][c]{\ensuremath{\alpha}}}$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\text{\makebox[\widthof{\texttt{NAME(P)}}][c]{\texttt{X}}}$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\text{\makebox[\widthof{\texttt{PARENT(P)}}][c]{\ensuremath{\Lambda}}}$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\text{\makebox[\widthof{\texttt{DELTA(P)}}][c]{\ensuremath{*}}}$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\text{\makebox[\widthof{\texttt{LBD(P)}}][c]{\ensuremath{-5}}}$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\text{\makebox[\widthof{\texttt{UBD(P)}}][c]{14}}$ +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\beta$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +Y +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\alpha$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +4 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $*$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $*$ +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\gamma$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +A +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\delta$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +0 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $*$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $*$ +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\delta$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\family typewriter +Z +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\alpha$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $-3$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $*$ +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $*$ +\end_inset + + +\end_layout + +\end_inset + + + + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +noindent +\end_layout + +\end_inset + +( +\begin_inset Quotes eld +\end_inset + + +\begin_inset Formula $*$ +\end_inset + + +\begin_inset Quotes erd +\end_inset + + denotes irrelevant information.) +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +end{samepage} +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +Design an algorithm that makes this transformation. + Assume that inputs to your algorithm have the form +\begin_inset Formula $(\mathtt{P},j,\mathtt{Q},k)$ +\end_inset + +, + denoting +\begin_inset Formula $\mathtt{X[}j\mathtt{]}\equiv\mathtt{Y[}k\mathtt{]}$ +\end_inset + +, + where +\begin_inset Formula $\mathtt{NAME(P)}=\text{``X''}$ +\end_inset + + and +\begin_inset Formula $\mathtt{NAME(Q)}=\text{``Y''}$ +\end_inset + +. + Be sure to check whether the equivalences are contradictory; + for example, + +\begin_inset Formula $\mathtt{X[}1\mathtt{]}\equiv\mathtt{Y[}2\mathtt{]}$ +\end_inset + + contradicts +\begin_inset Formula $\mathtt{X[}2\mathtt{]}\equiv\mathtt{Y[}1\mathtt{]}$ +\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 CommandInset label +LatexCommand label +name "enu:e23311a" + +\end_inset + +[Read input.] Read a line +\begin_inset Formula $(\mathtt{P},j,\mathtt{Q},k)$ +\end_inset + +, + but if there are no more lines, + terminate the algorithm. +\end_layout + +\begin_layout Enumerate +[Find roots.] If +\begin_inset Formula $\mathtt{PARENT(P)}\neq\Lambda$ +\end_inset + +, + set +\begin_inset Formula $j\gets j+\mathtt{DELTA(P)}$ +\end_inset + +, + +\begin_inset Formula $\mathtt{P}\gets\mathtt{PARENT(P)}$ +\end_inset + +, + and repeat this step. + If +\begin_inset Formula $\mathtt{PARENT(Q)}\neq\Lambda$ +\end_inset + +, + set +\begin_inset Formula $k\gets k+\mathtt{DELTA(Q)}$ +\end_inset + +, + +\begin_inset Formula $\mathtt{Q}\gets\mathtt{PARENT(Q)}$ +\end_inset + +, + and repeat this step. +\end_layout + +\begin_layout Enumerate +[Merge trees.] If +\begin_inset Formula $\mathtt{P}\neq\mathtt{Q}$ +\end_inset + +, + set +\begin_inset Formula $\mathtt{PARENT(P)}\gets\mathtt{Q}$ +\end_inset + + +\begin_inset Formula $\mathtt{DELTA(P)}\gets k-j$ +\end_inset + +, + +\begin_inset Formula $\mathtt{LBD(Q)}\gets\min\{\mathtt{LBD(Q)},\mathtt{LBD(P)}+\mathtt{DELTA(P)}\}$ +\end_inset + +, + +\begin_inset Formula $\mathtt{UBD(Q)}\gets\max\{\mathtt{UBD(Q)},\mathtt{UBD(P)}+\mathtt{DELTA(P)}\}$ +\end_inset + +. + Otherwise, + if +\begin_inset Formula $j\neq k$ +\end_inset + +, + notify a contradiction and terminate the algorithm. + Finally go to step +\begin_inset CommandInset ref +LatexCommand ref +reference "enu:e23311a" +plural "false" +caps "false" +noprefix "false" +nolink "false" + +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc17[25] +\end_layout + +\end_inset + +Algorithm F evaluates a +\begin_inset Quotes eld +\end_inset + +bottom-up +\begin_inset Quotes erd +\end_inset + + locally defined function, + namely, + one that should be evaluated at the children of a node before it is evaluated at the node. + A +\begin_inset Quotes eld +\end_inset + +top-down +\begin_inset Quotes erd +\end_inset + + locally defined function +\begin_inset Formula $f$ +\end_inset + + is one in which the value of +\begin_inset Formula $f$ +\end_inset + + at a node +\begin_inset Formula $x$ +\end_inset + + depends only on +\begin_inset Formula $x$ +\end_inset + + and the value of +\begin_inset Formula $f$ +\end_inset + + at the +\emph on +parent +\emph default + of +\begin_inset Formula $x$ +\end_inset + +. + Using an auxiliary stack, + design an algorithm analogous to Algorithm F that evaluates a +\begin_inset Quotes eld +\end_inset + +top-down +\begin_inset Quotes erd +\end_inset + + function +\begin_inset Formula $f$ +\end_inset + + at each node of a tree. + (Like Algorithm F, + your algorithm should work efficiently on trees that have been stored in +\emph on +postorder +\emph default + with degrees, + as in (9).) +\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 +[Initialize.] Set the stack to the single element +\begin_inset Formula $(\infty,\Lambda)$ +\end_inset + +, + and let +\family typewriter +P +\family default + point to the +\emph on +last +\emph default + ode of the forest in post-order. +\end_layout + +\begin_layout Enumerate +\begin_inset CommandInset label +LatexCommand label +name "enu:e23317b" + +\end_inset + +[Evaluate +\begin_inset Formula $f$ +\end_inset + +.] Let +\begin_inset Formula $(d,v)$ +\end_inset + + be the value at the top of the stack. + Evaluate +\begin_inset Formula $f(\mathtt{NODE(P)},v)$ +\end_inset + + and save the result as +\begin_inset Formula $\mathtt{VALUE(P)}$ +\end_inset + +. + Then push +\begin_inset Formula $(\mathtt{DEGREE(P)},\mathtt{VALUE(P)})$ +\end_inset + + to the stack. +\end_layout + +\begin_layout Enumerate +[Update the stack.] Pop the element +\begin_inset Formula $(p,v)$ +\end_inset + + from the stack. + If +\begin_inset Formula $p=0$ +\end_inset + +, + repeat this step. + Otherwise push +\begin_inset Formula $(p-1,v)$ +\end_inset + + into the stack. +\end_layout + +\begin_layout Enumerate +[Advance.] If +\family typewriter +P +\family default + is the first node in postorder, + terminate the algorithm. + Otherwise set +\family typewriter +P +\family default + to its predecessor in postorder and return to step +\begin_inset CommandInset ref +LatexCommand ref +reference "enu:e23317b" +plural "false" +caps "false" +noprefix "false" +nolink "false" + +\end_inset + +. +\end_layout + +\end_body +\end_document diff --git a/vol1/2.3.4.1.lyx b/vol1/2.3.4.1.lyx new file mode 100644 index 0000000..0eeec27 --- /dev/null +++ b/vol1/2.3.4.1.lyx @@ -0,0 +1,760 @@ +#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 +rexerc4[M20] +\end_layout + +\end_inset + +Let +\begin_inset Formula $G'$ +\end_inset + + be a finite free tree in which arrows have been drawn on its edges +\begin_inset Formula $e_{1},\dots,e_{n-1}$ +\end_inset + +; + let +\begin_inset Formula $E_{1},\dots,E_{n-1}$ +\end_inset + + be numbers satisfying Kirchhoff's law (1) in +\begin_inset Formula $G'$ +\end_inset + +. + Show that +\begin_inset Formula $E_{1}=\dots=E_{n-1}=0$ +\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 $n$ +\end_inset + +. + For +\begin_inset Formula $n=1$ +\end_inset + + it is trivial. + For +\begin_inset Formula $n>1$ +\end_inset + +, + there always exists a node of degree 1 (in an oriented tree, + this would be a leaf). + Let +\begin_inset Formula $e_{r}$ +\end_inset + + be the only edge connected to that node, + clearly +\begin_inset Formula $E_{r}=0$ +\end_inset + +, + so removing +\begin_inset Formula $e_{r}$ +\end_inset + + leaves us with an isolated node and a free tree of degree 0 which follows Kirchhoff's law and has +\begin_inset Formula $n-1$ +\end_inset + + nodes, + but then by the induction hypothesis all the other +\begin_inset Formula $E_{k}$ +\end_inset + + are also 0. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc8[M25] +\end_layout + +\end_inset + +When applying Kirchhoff's first law to program flow charts, + we usually are interested only in the +\emph on +vertex flows +\emph default + (the number of times each box of the flow chart is performed), + not the edge flows analyzed in the text. + For example, + in the graph of exercise 7, + the vertex flows are +\begin_inset Formula $A=E_{2}+E_{4}$ +\end_inset + +, + +\begin_inset Formula $B=E_{5}$ +\end_inset + +, + +\begin_inset Formula $C=E_{3}+E_{7}+E_{8}$ +\end_inset + +, + +\begin_inset Formula $D=E_{6}+E_{9}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +If we group some vertices together, + treating them as one +\begin_inset Quotes eld +\end_inset + +supervertex, +\begin_inset Quotes erd +\end_inset + + we can combine edge flows that correspond to the same vertex flow. + For example, + edges +\begin_inset Formula $e_{2}$ +\end_inset + + and +\begin_inset Formula $e_{4}$ +\end_inset + + can be combined in the flow chart above if we also put +\begin_inset Formula $B$ +\end_inset + + with +\begin_inset Formula $D$ +\end_inset + +: +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +begin{center} +\end_layout + +\begin_layout Plain Layout + + +\backslash +begin{tikzpicture}[node distance=2cm] +\end_layout + +\begin_layout Plain Layout + + +\backslash +node[circle,draw](Start){Start}; +\end_layout + +\begin_layout Plain Layout + + +\backslash +node[rectangle,draw,right of=Start](A){$A$}; +\end_layout + +\begin_layout Plain Layout + + +\backslash +node[rectangle,draw,right of=A](BD){$B,D$}; +\end_layout + +\begin_layout Plain Layout + + +\backslash +node[rectangle,draw,right of=BD](C){$C$}; +\end_layout + +\begin_layout Plain Layout + + +\backslash +node[circle,draw,right of=C](Stop){Stop}; +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw[->] (Start) -- node[above]{$e_1$} (A); +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw[->] (A) -- node[below]{$e_2+e_4$} (BD); +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw[->,transform canvas={yshift=2pt}] (BD)--node[above]{$e_5$}(C); +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw[->,transform canvas={yshift=-2pt}] (C)--node[below]{$e_7$}(BD); +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw[->] (C) -- node[above]{$e_8$} (Stop); +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw[->] (BD) to[bend right] node[below]{$e_9$} (Stop); +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw[->] (BD) to[loop below] node[left]{$e_6$} (BD); +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw[->] (C) to[bend right] node[above]{$e_3$} (A); +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw[->] (Stop) to[bend right] node[above]{$e_0$} (Start); +\end_layout + +\begin_layout Plain Layout + + +\backslash +end{tikzpicture} +\end_layout + +\begin_layout Plain Layout + + +\backslash +end{center} +\end_layout + +\end_inset + +(Here +\begin_inset Formula $e_{0}$ +\end_inset + + has also been added from Stop to Start, + as in the text.) Continuing this procedure, + we can combine +\begin_inset Formula $e_{3}+e_{7}$ +\end_inset + +, + then +\begin_inset Formula $(e_{3}+e_{7})+e_{8}$ +\end_inset + +, + then +\begin_inset Formula $e_{6}+e_{9}$ +\end_inset + +, + until we obtain the +\emph on +reduced flow chart +\emph default + having edges +\begin_inset Formula $s=e_{1}$ +\end_inset + +, + +\begin_inset Formula $a=e_{2}+e_{4}$ +\end_inset + +, + +\begin_inset Formula $b=e_{5}$ +\end_inset + +, + +\begin_inset Formula $c=e_{3}+e_{7}+e_{8}$ +\end_inset + +, + +\begin_inset Formula $d=e_{6}+e_{9}$ +\end_inset + +, + +\begin_inset Formula $t=e_{0}$ +\end_inset + +, + precisely one edge for each vertex in the original flow chart: +\begin_inset Formula $\text{}$ +\end_inset + + +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +begin{center} +\end_layout + +\begin_layout Plain Layout + + +\backslash +begin{tikzpicture}[node distance=3cm] +\end_layout + +\begin_layout Plain Layout + + +\backslash +node[circle,draw](S){Start}; +\end_layout + +\begin_layout Plain Layout + + +\backslash +node[rectangle,draw,right of=S](M){$A,B,D, +\backslash +text{Stop}$}; +\end_layout + +\begin_layout Plain Layout + + +\backslash +node[rectangle,draw,right of=M](C){$C$}; +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw[->,transform canvas={yshift=2pt}] (S) -- node[above]{$s$} (M); +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw[->,transform canvas={yshift=-2pt}] (M) -- node[below]{$t$} (S); +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw[->,transform canvas={yshift=2pt}] (M) -- node[above]{$b$} (C); +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw[->,transform canvas={yshift=-2pt}] (C) -- node[below]{$c$} (M); +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw[->] (M) to[out=120,in=60,looseness=4] node[left]{$a$ +\backslash + +\backslash + } (M); +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw[->] (M) to[out=300,in=240,looseness=4] node[right]{ +\backslash + $d$} (M); +\end_layout + +\begin_layout Plain Layout + + +\backslash +end{tikzpicture} +\end_layout + +\begin_layout Plain Layout + + +\backslash +end{center} +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +By construction, + Kirchhoff's law holds in this reduced flow chart. + The new edge flows are the vertex flows of the original; + hence the analysis in the text, + applied to the reduced flow chart, + shows how the original vertex flows depend on each other. +\end_layout + +\begin_layout Standard +Prove that this reduction process can be reversed, + in the sense that any set of flows +\begin_inset Formula $\{a,b,\dots\}$ +\end_inset + + satisfying Kirchhoff's law in the reduced flow chart can be +\begin_inset Quotes eld +\end_inset + +split up +\begin_inset Quotes erd +\end_inset + + into a set of edge flows +\begin_inset Formula $\{e_{0},e_{1},\dots\}$ +\end_inset + + in the original flow chart. + These flows +\begin_inset Formula $e_{j}$ +\end_inset + + satisfy Kirchhoff's law and combine to yield the given flows +\begin_inset Formula $\{a,b,\dots\}$ +\end_inset + +; + some of them might, + however, + be negative. + (Although the reduction procedure has been illustrated for only one particular flow chart, + your proof should be valid in general.) +\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, + this one is difficult.) +\end_layout + +\end_inset + + We only have to show that there exists an assignment in the original flowchart that produces any given set of flows in the reduced flowchart. +\end_layout + +\begin_layout Standard +Since we get from one to the other by reductions, + we only have to prove that we can reverse reductions. + In these reductions, + there are two arrows +\begin_inset Formula $e_{1}$ +\end_inset + + from vertex or supervertex +\begin_inset Formula $a$ +\end_inset + + to +\begin_inset Formula $b$ +\end_inset + + and +\begin_inset Formula $e_{2}$ +\end_inset + + from +\begin_inset Formula $a$ +\end_inset + + to +\begin_inset Formula $c$ +\end_inset + +, + to get an edge +\begin_inset Formula $f=e_{1}+e_{2}$ +\end_inset + + from +\begin_inset Formula $a$ +\end_inset + + to +\begin_inset Formula $b,c$ +\end_inset + +, + and reverting means recovering +\begin_inset Formula $e_{1}$ +\end_inset + + and +\begin_inset Formula $e_{2}$ +\end_inset + + from +\begin_inset Formula $f$ +\end_inset + + and the other edges. +\end_layout + +\begin_layout Standard +If +\begin_inset Formula $b=c$ +\end_inset + +, + we can just make up +\begin_inset Formula $e_{1}$ +\end_inset + + and set +\begin_inset Formula $e_{2}$ +\end_inset + + to +\begin_inset Formula $f-e_{1}$ +\end_inset + +. + If +\begin_inset Formula $a=b\neq c$ +\end_inset + +, + then +\begin_inset Formula $e_{2}$ +\end_inset + + must be such that Kirchhoff's law is preserved for +\begin_inset Formula $c$ +\end_inset + +, + and we can just set +\begin_inset Formula $e_{1}=f-e_{2}$ +\end_inset + +. + The situation +\begin_inset Formula $a=c\neq b$ +\end_inset + + is symmetrical. + Finally, + if the three nodes are distinct, + setting +\begin_inset Formula $e_{1}$ +\end_inset + + and +\begin_inset Formula $e_{2}$ +\end_inset + + such that they follow Kirchhoff's law for +\begin_inset Formula $b$ +\end_inset + + and +\begin_inset Formula $c$ +\end_inset + + makes +\begin_inset Formula $e_{1}+e_{2}$ +\end_inset + + follow Kirchhoff's law in +\begin_inset Formula $b,c$ +\end_inset + + in the reduced flowchart. +\end_layout + +\end_body +\end_document diff --git a/vol1/2.3.4.2.lyx b/vol1/2.3.4.2.lyx new file mode 100644 index 0000000..f1f1d4e --- /dev/null +++ b/vol1/2.3.4.2.lyx @@ -0,0 +1,859 @@ +#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 +rexerc4[M20] +\end_layout + +\end_inset + +The concept of +\emph on +topological sorting +\emph default + can be defined for any finite directed graph +\begin_inset Formula $G$ +\end_inset + + as a linear arrangement of the vertices +\begin_inset Formula $V_{1}V_{2}\dots V_{n}$ +\end_inset + + such that +\begin_inset Formula $\text{init}(e)$ +\end_inset + + precedes +\begin_inset Formula $\text{fin}(e)$ +\end_inset + + in the ordering for all arcs +\begin_inset Formula $e$ +\end_inset + + of +\begin_inset Formula $G$ +\end_inset + +. + (See Section 2.2.3, + Figs. + 6 and 7.) Not all finite directed graphs can be topologically sorted; + which ones can be? + (Use the terminology of this section to give the answer.) +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Only the ones with no directed cycles, + except possibly for cycles of length 1. + If +\begin_inset Formula $G$ +\end_inset + + has a cycle (of length 2 or more), + the nodes in the cycle cannot be topologically ordered; + otherwise the transitive closure of the edges of the graph is a partial ordering between the vertices, + so they can be topologically ordered. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc7[M22] +\end_layout + +\end_inset + +True or false: + A directed graph satisfying properties (a) and (b) of the definition of oriented tree, + and having no oriented cycles, + is an oriented tree. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +True for finite graphs. + If there were cycles, + they would be oriented because no vertex is the initial vertex of two arcs, + and a graph with no cycles and exactly one edge less than the number of vertices is a free tree. + Then the way to orient the edges such that (a) and (b) follow is unique, + which can be proved by induction on the distance of a node to the root, + and we know that this way follows (c). +\end_layout + +\begin_layout Standard +False for infinite graphs. + A graph whose vertices are +\begin_inset Formula $R,V_{1},V_{2},\dots,V_{n},\dots$ +\end_inset + + and whose edges are +\begin_inset Formula $V_{1}\to V_{2}\to V_{3}\to\dots$ +\end_inset + + follows (a) and (b) and has no cycles but it doesn't follow (c). +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc13[M24] +\end_layout + +\end_inset + +Prove that if +\begin_inset Formula $R$ +\end_inset + + is a root of a (possibly infinite) directed graph +\begin_inset Formula $G$ +\end_inset + +, + then +\begin_inset Formula $G$ +\end_inset + + contains an oriented subtree with the same vertices as +\begin_inset Formula $G$ +\end_inset + + and with root +\begin_inset Formula $R$ +\end_inset + +. + (As a consequence, + it is always possible to choose the free subtree in flow charts like Fig. + 32 of Section 2.3.4.1 so that it is actually an +\emph on +oriented +\emph default + subtree; + this would be the case in that diagram if we had selected +\begin_inset Formula $e''_{13}$ +\end_inset + +, + +\begin_inset Formula $e''_{19}$ +\end_inset + +, + +\begin_inset Formula $e_{20}$ +\end_inset + +, + and +\begin_inset Formula $e_{17}$ +\end_inset + + instead of +\begin_inset Formula $e'_{13}$ +\end_inset + +, + +\begin_inset Formula $e'_{19}$ +\end_inset + +, + +\begin_inset Formula $e_{23}$ +\end_inset + +, + and +\begin_inset Formula $e_{15}$ +\end_inset + +.) +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We prove by induction that there is a family of oriented subtrees +\begin_inset Formula $\{T_{n}\}_{n\geq0}$ +\end_inset + + of +\begin_inset Formula $G$ +\end_inset + + with root +\begin_inset Formula $R$ +\end_inset + + such that +\begin_inset Formula $T_{n}$ +\end_inset + + contains exactly all the vertices +\begin_inset Formula $V$ +\end_inset + + in +\begin_inset Formula $G$ +\end_inset + + such that there is an oriented path from +\begin_inset Formula $V$ +\end_inset + + to +\begin_inset Formula $R$ +\end_inset + + of length at most +\begin_inset Formula $n$ +\end_inset + + and, + furthermore, + +\begin_inset Formula $T_{n-1}\subseteq T_{n}$ +\end_inset + + for every +\begin_inset Formula $n\geq1$ +\end_inset + +. + It is easy to check that the union of this family of trees is a tree with all the vertices in +\begin_inset Formula $G$ +\end_inset + +. +\end_layout + +\begin_layout Standard +For +\begin_inset Formula $n=0$ +\end_inset + +, + we just take the trivial oriented tree, + which only contains +\begin_inset Formula $R$ +\end_inset + +. + For +\begin_inset Formula $n\geq1$ +\end_inset + +, + and for every node +\begin_inset Formula $V$ +\end_inset + + such that the shortest oriented path from +\begin_inset Formula $V$ +\end_inset + + to +\begin_inset Formula $R$ +\end_inset + + has length +\begin_inset Formula $n$ +\end_inset + +, + we choose one such path +\begin_inset Formula $VV_{1}\cdots V_{n-1}R$ +\end_inset + +, + which we can do for all such vertices because of the axiom of choice. + Since +\begin_inset Formula $V_{1}$ +\end_inset + + is in +\begin_inset Formula $T_{n-1}$ +\end_inset + +, + we just have to add +\begin_inset Formula $V$ +\end_inset + + and the arc +\begin_inset Formula $(V,V_{1})$ +\end_inset + + to +\begin_inset Formula $T_{n-1}$ +\end_inset + +, + for all such +\begin_inset Formula $V$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset Note Note +status open + +\begin_layout Plain Layout +TODO 16, + 24 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc16[M24] +\end_layout + +\end_inset + +In a popular solitaire game called +\begin_inset Quotes eld +\end_inset + +clock, +\begin_inset Quotes erd +\end_inset + + the 52 cards of an ordinary deck of playing cards are dealt face down into 13 piles of four each; + 12 piles are arranged in a circle like the 12 hours of a clock and the thirteenth pile goes in the center. + The solitaire game now proceeds by turning up the top card of the center pile, + and then if its face value is +\begin_inset Formula $k$ +\end_inset + +, + by placing it next to the +\begin_inset Formula $k$ +\end_inset + +th pile. + (The numbers +\begin_inset Formula $1,2,\dots,13$ +\end_inset + + are equivalent to +\begin_inset Formula $\text{A},2,\dots,10,\text{J},\text{Q},\text{K}$ +\end_inset + +.) Play continues by turning up the top card of the +\begin_inset Formula $k$ +\end_inset + +th pile and putting it next to +\emph on +its +\emph default + pile, + etc., + until we reach a point where we cannot continue since there are no more cards to turn up on the designated pile. + (The player has no choice in the game, + since the rules completely specify what to do.) The game is won if all cards are face up when the play terminates. +\end_layout + +\begin_layout Standard +Show that the game will be won if and only if the following directed graph is an oriented tree: + The vertices are +\begin_inset Formula $V_{1},V_{2},\dots,V_{13}$ +\end_inset + +; + the arcs are +\begin_inset Formula $e_{1},e_{2},\dots,e_{12}$ +\end_inset + +, + where +\begin_inset Formula $e_{j}$ +\end_inset + + goes from +\begin_inset Formula $V_{j}$ +\end_inset + + to +\begin_inset Formula $V_{k}$ +\end_inset + + if +\begin_inset Formula $k$ +\end_inset + + is the +\emph on +bottom +\emph default + card in pile +\begin_inset Formula $j$ +\end_inset + + after the deal. +\end_layout + +\begin_layout Standard +(In particular, + if the bottom card of pile +\begin_inset Formula $j$ +\end_inset + + is a +\begin_inset Quotes eld +\end_inset + + +\begin_inset Formula $j$ +\end_inset + + +\begin_inset Quotes erd +\end_inset + +, + for +\begin_inset Formula $j\neq13$ +\end_inset + +, + it is easy to see that the game is certainly lost, + since this card could never be turned up. + The result proved in this exercise gives a much faster way to play the game!) +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +First we note that this graph already follows conditions (a) and (b) of the definition of an oriented tree, + so it will be a tree if an only if +\begin_inset Formula $V_{13}$ +\end_inset + + is a root, + if and only if there are no cycles (see Exercise 7). + We also note that, + since there are only 4 cards of each denomination, + and we only take a card from a pile when we find its denomination except from one from +\begin_inset Formula $V_{13}$ +\end_inset + + at the start of the game, + the only case where we cannot continue is after finding the last card with face value K. +\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 + +Assume that the game is not an oriented tree, + then there is a cycle +\begin_inset Formula $V_{k_{1}}\cdots V_{k_{m}}$ +\end_inset + +. + We can assume that the +\begin_inset Formula $k_{1}$ +\end_inset + +th pile is the first whose bottom card we turn up. + Since clearly +\begin_inset Formula $k_{1}\neq13$ +\end_inset + +, + this means that we had already turned up all cards with denomination +\begin_inset Formula $k_{1}$ +\end_inset + +, + but we had not turned up +\begin_inset Formula $k_{m}\#$ +\end_inset + +. +\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 + +Assume we lost +\begin_inset CommandInset href +LatexCommand href +name "the game" +target "https://en.wikipedia.org/wiki/The_Game_(mind_game)" +literal "false" + +\end_inset + +, + which means that we have turned up all the cards with face value 13 and that, + furthermore, + we have turned up as many cards from the +\begin_inset Formula $k$ +\end_inset + +th pile as cards with face value +\begin_inset Formula $k$ +\end_inset + +. + This means that, + if +\begin_inset Formula +\[ +U\coloneqq\{V_{j}\mid\text{the }j\text{th pile's bottom card is down}\}, +\] + +\end_inset + +then +\begin_inset Formula $V_{13}\notin U$ +\end_inset + + and each vertex of +\begin_inset Formula $U$ +\end_inset + + has one outgoing edge that points to another vertex in +\begin_inset Formula $U$ +\end_inset + +, + as we have already turned up all the cards with face value +\begin_inset Formula $k$ +\end_inset + + for +\begin_inset Formula $V_{k}\notin U$ +\end_inset + +. + Thus +\begin_inset Formula $V_{13}$ +\end_inset + + is not a root. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc24[M20] +\end_layout + +\end_inset + +Let +\begin_inset Formula $G$ +\end_inset + + be a connected digraph with arcs +\begin_inset Formula $e_{0},e_{1},\dots,e_{m}$ +\end_inset + +. + Let +\begin_inset Formula $E_{0},E_{1},\dots,E_{m}$ +\end_inset + + be a set of positive integers that satisfy Kirchhoff's law for +\begin_inset Formula $G$ +\end_inset + +; + that is, + for each vertex +\begin_inset Formula $V$ +\end_inset + +, +\begin_inset Formula +\[ +\sum_{\text{init}(e_{j})=V}E_{j}=\sum_{\text{fin}(e_{j})=V}E_{j}. +\] + +\end_inset + +Assume further that +\begin_inset Formula $E_{0}=1$ +\end_inset + +. + Prove that there is an oriented walk in +\begin_inset Formula $G$ +\end_inset + + from +\begin_inset Formula $\text{init}(e_{0})$ +\end_inset + + such that edge +\begin_inset Formula $e_{j}$ +\end_inset + + appears exactly +\begin_inset Formula $E_{j}$ +\end_inset + + times, + for +\begin_inset Formula $1\leq j\leq m$ +\end_inset + +, + while edge +\begin_inset Formula $e_{0}$ +\end_inset + + does not appear. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We apply Theorem G to the graph whose vertices are those of +\begin_inset Formula $G$ +\end_inset + + and whose edges are the +\begin_inset Formula $e_{j}$ +\end_inset + + repeated +\begin_inset Formula $E_{j}$ +\end_inset + + times. + This is valid, + since we could as well place an intermediate vertex among each edge to avoid repeating edges, + and it would give us an Eulerian cycle in that graph that goes through +\begin_inset Formula $e_{0}$ +\end_inset + + once. + Coalescing the repeated edges into one gives us back graph +\begin_inset Formula $G$ +\end_inset + + and a cycle though +\begin_inset Formula $G$ +\end_inset + + that goes though edge +\begin_inset Formula $e_{j}$ +\end_inset + + exactly +\begin_inset Formula $E_{j}$ +\end_inset + + times, + and we just have to remove the only appearance of +\begin_inset Formula $e_{0}$ +\end_inset + +. +\end_layout + +\end_body +\end_document diff --git a/vol1/2.3.4.3.lyx b/vol1/2.3.4.3.lyx new file mode 100644 index 0000000..44b134e --- /dev/null +++ b/vol1/2.3.4.3.lyx @@ -0,0 +1,508 @@ +#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 Note Note +status open + +\begin_layout Plain Layout +TODO 1, + 3, + 6 (2pp., + 0:46) +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc1[M10] +\end_layout + +\end_inset + +The text refers to a set +\begin_inset Formula $S$ +\end_inset + + containing finite sequences of positive integers, + and states that this set is +\begin_inset Quotes eld +\end_inset + +essentially an oriented tree. +\begin_inset Quotes erd +\end_inset + + What is the root of this oriented tree, + and what are the arcs? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +The vertices are the elements of +\begin_inset Formula $S$ +\end_inset + +, + the root is +\begin_inset Formula $\emptyset$ +\end_inset + +, + and the arcs go from +\begin_inset Formula $(x_{1},\dots,x_{n})$ +\end_inset + + to +\begin_inset Formula $(x_{1},\dots,x_{n-1})$ +\end_inset + +, + for every +\begin_inset Formula $(x_{1},\dots,x_{n})\in S\setminus\{\emptyset\}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc3[M23] +\end_layout + +\end_inset + +If it is possible to tile the upper right quadrant of the plane when given an +\emph on +infinite +\emph default + set of tetrad types, + is it always possible to tile the whole plane? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +No. + For example, + our tiles might be of the form +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +begin{center} +\end_layout + +\begin_layout Plain Layout + + +\backslash +begin{tikzpicture} +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw (0,0) -- (0,2) -- (2,2) -- (2,0) -- (0,0) -- (2,2) +\end_layout + +\begin_layout Plain Layout + + (0,2) -- (2,0) +\end_layout + +\begin_layout Plain Layout + + (0.5,1) node{$n$} (1,0.5) node{$n$} +\end_layout + +\begin_layout Plain Layout + + (1.5,1) node{$n+1$} (1,1.5) node{$n+1$}; +\end_layout + +\begin_layout Plain Layout + + +\backslash +end{tikzpicture} +\end_layout + +\begin_layout Plain Layout + + +\backslash +end{center} +\end_layout + +\end_inset + +for +\begin_inset Formula $n\in\mathbb{N}$ +\end_inset + +. + Then in the +\begin_inset Formula $(x,y)$ +\end_inset + + square we might place the tile with +\begin_inset Formula $n=\max\{x,y\}$ +\end_inset + + and this would tile the upper right quadrant, + but there's obviously no way to tile the whole plane. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc6[M23] +\end_layout + +\end_inset + +(Otto Schreier.) In a famous paper, + B. + L. + van der Waerden proved the following theorem: +\end_layout + +\begin_layout Quote + +\shape slanted +If +\begin_inset Formula $k$ +\end_inset + + and +\begin_inset Formula $m$ +\end_inset + + are positive integers, + and if we have +\begin_inset Formula $k$ +\end_inset + + sets +\begin_inset Formula $S_{1},\dots,S_{k}$ +\end_inset + + of positive integers with every positive integer included in at least one of these sets, + then at least of the sets +\begin_inset Formula $S_{j}$ +\end_inset + + contains an arithmetic progression of length +\begin_inset Formula $m$ +\end_inset + +. +\end_layout + +\begin_layout Standard +(The latter statement means there exist integers +\begin_inset Formula $a$ +\end_inset + + and +\begin_inset Formula $\delta>0$ +\end_inset + + such that +\begin_inset Formula $a+\delta$ +\end_inset + +, + +\begin_inset Formula $a+2\delta$ +\end_inset + +, + ..., + +\begin_inset Formula $a+m\delta$ +\end_inset + + are all in +\begin_inset Formula $S_{j}$ +\end_inset + +.) If possible, + use this result and the infinity lemma to prove the following stronger statement: +\end_layout + +\begin_layout Quote + +\shape slanted +If +\begin_inset Formula $k$ +\end_inset + + and +\begin_inset Formula $m$ +\end_inset + + are positive integers, + there is a number +\begin_inset Formula $N$ +\end_inset + + such that if we have +\begin_inset Formula $k$ +\end_inset + + sets +\begin_inset Formula $S_{1},\dots,S_{k}$ +\end_inset + + of integers with every integer between 1 and +\begin_inset Formula $N$ +\end_inset + + included in at least one of these sets, + then at least one of the sets +\begin_inset Formula $S_{j}$ +\end_inset + + contains an arithmetic progression of length +\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 + +It is enough to prove it when the set that contains every integer between 1 and +\begin_inset Formula $N$ +\end_inset + + is +\begin_inset Formula $S_{1}$ +\end_inset + +. + We define a tree whose vertices are the tuples +\begin_inset Formula $(S_{1},\dots,S_{k})$ +\end_inset + + of finite sets of integers such that, + if +\begin_inset Formula $n=\max\bigcup_{i=1}^{k}S_{i}$ +\end_inset + +, + every positive integer up to +\begin_inset Formula $n$ +\end_inset + + is in one of the sets, + and such that no set contains an arithmetic progression of length +\begin_inset Formula $m$ +\end_inset + +. + The edges go from one such tuple to +\begin_inset Formula $(S_{1}\setminus\{n\},\dots,S_{k}\setminus\{n\})$ +\end_inset + +, + so the root is +\begin_inset Formula $(\emptyset,\dots,\emptyset)$ +\end_inset + + and +\begin_inset Formula $n$ +\end_inset + + is the height of the node in the tree. +\end_layout + +\begin_layout Standard +Since each vertex contains a finite number of children ( +\begin_inset Formula $2^{k}-1$ +\end_inset + +, + corresponding to the ways of adding the next number to one or more of the sets), + it follows that if this tree were infinite, + there would be an infinite path. + By van der Waerden theorem, + the component-wise union of this path would give us a tuple +\begin_inset Formula $(S_{1},\dots,S_{k})$ +\end_inset + + such that some +\begin_inset Formula $S_{j}$ +\end_inset + + contains an arithmetic progression of length +\begin_inset Formula $m$ +\end_inset + +, + so by construction one of the nodes in the path would follow this condition. +\begin_inset Formula $\#$ +\end_inset + + +\end_layout + +\begin_layout Standard +Thus the tree is finite and we just need to take +\begin_inset Formula $N$ +\end_inset + + as one plus the depth of the tree. +\end_layout + +\end_body +\end_document diff --git a/vol1/2.3.4.4.lyx b/vol1/2.3.4.4.lyx new file mode 100644 index 0000000..0172abf --- /dev/null +++ b/vol1/2.3.4.4.lyx @@ -0,0 +1,750 @@ +#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 +rexerc5[M25] +\end_layout + +\end_inset + +(A. + Cayley.) Let +\begin_inset Formula $c_{n}$ +\end_inset + + be the number of (unlabeled) oriented trees having +\begin_inset Formula $n$ +\end_inset + + leaves (namely, + vertices with in-degree zero) and having at least two subtrees at every other vertex. + Thus +\begin_inset Formula $c_{3}=2$ +\end_inset + +, + by virtue of the two trees +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +begin{center} +\end_layout + +\begin_layout Plain Layout + + +\backslash +def +\backslash +dot#1{node(#1){ +\backslash +textbullet}} +\end_layout + +\begin_layout Plain Layout + + +\backslash +begin{tikzpicture} +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw (0,1) +\backslash +dot R (-.5,0) +\backslash +dot A (0,0) +\backslash +dot B (.5,0) +\backslash +dot C +\end_layout + +\begin_layout Plain Layout + + (0,-1) node{}; +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw[->] (A) -> (R); +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw[->] (B) -> (R); +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw[->] (C) -> (R); +\end_layout + +\begin_layout Plain Layout + + +\backslash +end{tikzpicture} +\end_layout + +\begin_layout Plain Layout + + +\backslash +hfil +\end_layout + +\begin_layout Plain Layout + + +\backslash +begin{tikzpicture} +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw (0,1) +\backslash +dot R (-.5,0) +\backslash +dot A (.5,0) +\backslash +dot B +\end_layout + +\begin_layout Plain Layout + + (-1,-1) +\backslash +dot C (0,-1) +\backslash +dot D; +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw[->] (C) -> (A); +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw[->] (D) -> (A); +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw[->] (B) -> (R); +\end_layout + +\begin_layout Plain Layout + + +\backslash +draw[->] (A) -> (R); +\end_layout + +\begin_layout Plain Layout + + +\backslash +end{tikzpicture} +\end_layout + +\begin_layout Plain Layout + + +\backslash +end{center} +\end_layout + +\end_inset + +Find a formula analogous to (3) for the generating function +\begin_inset Formula +\[ +C(z)=\sum_{n}c_{n}z^{n}. +\] + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Every tree has at least one leaf, + so +\begin_inset Formula $c_{0}=0$ +\end_inset + +. + This includes subtrees, + so +\begin_inset Formula $c_{1}=1$ +\end_inset + + as, + if the root weren't also a leaf, + it would have at least two children and therefore two trees. + For +\begin_inset Formula $n>1$ +\end_inset + +, + the root has a tree and various subtrees. + Let +\begin_inset Formula $j_{k}$ +\end_inset + + be the number of subtrees with +\begin_inset Formula $k$ +\end_inset + + leaves, + +\begin_inset Formula $1\leq k0$ +\end_inset + + and +\begin_inset Formula $n\geq0$ +\end_inset + +. + (See a dictionary for the meaning of these terms in regard to family trees.) +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +It means that there exists a node +\begin_inset Formula $X'$ +\end_inset + + such that either +\begin_inset Formula $X$ +\end_inset + + is the +\begin_inset Formula $n$ +\end_inset + +th ancestor of +\begin_inset Formula $X'$ +\end_inset + + or vice versa (that is, + the ancestor +\begin_inset Formula $n$ +\end_inset + + levels below, + where for +\begin_inset Formula $n=0$ +\end_inset + + we would take +\begin_inset Formula $X'=X$ +\end_inset + +), + +\begin_inset Formula $X'$ +\end_inset + + and +\begin_inset Formula $Y$ +\end_inset + + are at the same level, + the +\begin_inset Formula $(m+1)$ +\end_inset + +th ancestor of +\begin_inset Formula $X'$ +\end_inset + + and +\begin_inset Formula $Y$ +\end_inset + + is the same, + and the +\begin_inset Formula $m$ +\end_inset + +th ancestor isn't. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc8[03] +\end_layout + +\end_inset + +What binary tree is not a tree? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +By the definitions in this book, + the empty binary tree. + Actually binary trees and trees are very separate concepts and therefore none is. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc9[00] +\end_layout + +\end_inset + +In the two binary trees of (1), + which node is the root ( +\begin_inset Formula $B$ +\end_inset + + or +\begin_inset Formula $A$ +\end_inset + +)? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +By the current conventions, + +\begin_inset Formula $A$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc13[10] +\end_layout + +\end_inset + +Suppose that node +\begin_inset Formula $X$ +\end_inset + + is numbered +\begin_inset Formula $a_{1}.a_{2}.\cdots.a_{k}$ +\end_inset + + in the Dewey decimal system; + what are the Dewey numbers of the nodes in the path from +\begin_inset Formula $X$ +\end_inset + + to the root (see exercise 3)? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +They would be +\begin_inset Formula $a_{1}.a_{2}.\cdots.a_{k};a_{1}.a_{2}.\cdots.a_{k-1};\dots;a_{1}.a_{2};a_{1}$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc15[20] +\end_layout + +\end_inset + +Invent a notation for the nodes of binary trees, + analogous to the Dewey decimal notation for nodes of trees. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We could call the root +\begin_inset Formula $\%$ +\end_inset + + and, + for a given nonempty node called +\begin_inset Formula $\lambda$ +\end_inset + + (a string), + its left child could be called +\begin_inset Formula $\lambda L$ +\end_inset + + and its right child +\begin_inset Formula $\lambda R$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc17[01] +\end_layout + +\end_inset + +If +\begin_inset Formula $Z$ +\end_inset + + stands for Fig. + 19 regarded as a forest, + what node is +\begin_inset Formula $\text{parent}(Z[1,2,2])$ +\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 $\text{parent}(Z[1,2,2])=\text{parent}(\text{children of node }1.2.2)=E$ +\end_inset + +. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc18[08] +\end_layout + +\end_inset + +In List (3), + what is +\begin_inset Formula $L[5,1,1]$ +\end_inset + +? + What is +\begin_inset Formula $L[3,1]$ +\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 $L[5,1,1]=(2)$ +\end_inset + +, + +\begin_inset Formula $L[3,1]$ +\end_inset + + doesn't exist. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc20[M21] +\end_layout + +\end_inset + +Define a +\emph on +0-2-tree +\emph default + as a tree in which each node has exactly zero or two children. + (Formally, + a 0-2-tree consists of a single node, + called its root, + plus 0 or 2 disjoint 0-2-trees.) Show that every 0-2-tree has an odd number of nodes; + and give a one-to-one correspondence between binary trees with +\begin_inset Formula $n$ +\end_inset + + nodes and (ordered) 0-2-trees with +\begin_inset Formula $2n+1$ +\end_inset + + nodes. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +We can prove that 0-2-trees have an odd number of nodes by induction on the depth of the tree: + for depth 0, + we just have one node with no children, + and for depth greater than 0, + we have the root and two children whose subtrees have each an odd number of nodes, + so the main tree also has an odd number of nodes. +\end_layout + +\begin_layout Standard +For the bijection, + an empty binary tree corresponds to a node with 0 children, + and any other binary tree corresponds to a node whose children are the left and right nodes. + This is clearly bijective, + and we can prove that the bijection sends binary trees with +\begin_inset Formula $n$ +\end_inset + + nodes to ordered 0-2-trees with +\begin_inset Formula $2n+1$ +\end_inset + + nodes by induction on +\begin_inset Formula $n$ +\end_inset + +. + For +\begin_inset Formula $n=0$ +\end_inset + +, + this is obvious; + for +\begin_inset Formula $n>0$ +\end_inset + +, + let +\begin_inset Formula $m$ +\end_inset + + be the number of nodes in the left subtree, + clearly +\begin_inset Formula $0\leq m\mathtt{L}$ +\end_inset + +, + so we could just do those instructions unconditionally, + then after removing the current stack item and before loading the next one we check if +\begin_inset Formula $\mathtt{L1}=\mathtt{L}$ +\end_inset + + and if so we go to A7, + then if +\begin_inset Formula $\mathtt{L1}\geq\mathtt{L}$ +\end_inset + + we repeat, + otherwise we report the error.) +\end_layout + +\begin_layout Standard +For this to work, + we have to get the stack empty by the time the algorithm finishes, + which we can do by setting +\begin_inset Formula $\mathtt{L}\gets0$ +\end_inset + + when the input is exhausted in step A2 and then terminate in step A7 when +\begin_inset Formula $\mathtt{L}=0$ +\end_inset + +. +\end_layout + +\end_body +\end_document diff --git a/vol1/2.5.lyx b/vol1/2.5.lyx new file mode 100644 index 0000000..11320d9 --- /dev/null +++ b/vol1/2.5.lyx @@ -0,0 +1,1706 @@ +#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 +rexerc5[18] +\end_layout + +\end_inset + +Suppose it is known that +\family typewriter +N +\family default + is always 100 or more in Algorithm A. + Would it be a good idea to set +\begin_inset Formula $c=100$ +\end_inset + + in the modified step +\begin_inset Formula $\text{A4}'$ +\end_inset + +? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +No, + because while we cannot use that storage +\emph on +right now +\emph default +, + it might be worth it after the next allocated block gets freed. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc6[23] +\end_layout + +\end_inset + +( +\emph on +Next fit. +\emph default +) After Algorithm A has been used repeatedly, + there will be a strong tendency for blocks of small +\family typewriter +SIZE +\family default + to remain at the front of the +\family typewriter +AVAIL +\family default + list, + so that it will often be necessary to search quite far into the list before finding a block of length +\family typewriter +N +\family default + or more. + For example, + notice how the size of the blocks essentially increases in Fig. + 42, + for both reserved and free blocks, + from the beginning of memory to the end. + (The +\family typewriter +AVAIL +\family default + list used while Fig. + 42 was being prepared was kept sorted by the order of location, + as required by Algorithm B.) Can you suggest a way to modify Algorithm A so that +\end_layout + +\begin_layout Enumerate +short blocks won't need to accumulate in a particular area, + and +\end_layout + +\begin_layout Enumerate +the +\family typewriter +AVAIL +\family default + list may still be kept in order of increasing memory locations, + for purposes of algorithms like Algorithm B? +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + +Yes, + we could arrange the free space as a circular list and start each search where the previous one left off. + In more precise terms, + in A1 we would change +\begin_inset Formula $\mathtt{Q}\gets\mathtt{LOC(AVAIL)}$ +\end_inset + + to +\begin_inset Formula $\mathtt{Q}\gets\mathtt{AVAIL}$ +\end_inset + +, + in A4 we would add +\begin_inset Formula $\mathtt{AVAIL}\gets\mathtt{Q}$ +\end_inset + +, + and the test in A2 would be +\begin_inset Formula $\mathtt{Q}=\mathtt{AVAIL}$ +\end_inset + + rather than +\begin_inset Formula $\mathtt{P}=\Lambda$ +\end_inset + + and it would be skipped in the first iteration. + Other algorithms that deal with memory management might need to be modified as well to avoid invalidating +\family typewriter +AVAIL +\family default +. + For example, + algorithm B would have to deal with this when freeing the block just before it. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +exerc7[10] +\end_layout + +\end_inset + +The example (1) shows that first-fit can sometimes be definitely superior to best-fit. + Give a similar example that shows a case where best-fit is superior to first-fit. +\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 +\align center +\begin_inset Tabular + + + + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\emph on +memory +\begin_inset Newline newline +\end_inset + +request +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\emph on +available areas, +\begin_inset Newline newline +\end_inset + +first-fit +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\emph on +available areas, +\begin_inset Newline newline +\end_inset + +best-fit +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +— + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1300, + 1200 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1300, + 1200 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +1100 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +200, + 1200 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1300, + 100 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +250 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +200, + 950 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +1050, + 100 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +1000 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +stuck +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +50, + 100 +\end_layout + +\end_inset + + + + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +rexerc12[20] +\end_layout + +\end_inset + +Modify Algorithm A so that it follows the boundary-tag conventions (7)–(9), + uses the modified step A4' described in the text, + and also incorporates the improvement of exercise 6. +\end_layout + +\begin_layout Standard +\begin_inset ERT +status open + +\begin_layout Plain Layout + + +\backslash +answer +\end_layout + +\end_inset + + +\series bold +Algorithm A' +\series default + ( +\emph on +Next-fit method with boundary-tag conventions +\emph default +). + Let the heap be stored as in (7)–(9), + +\begin_inset Formula $c$ +\end_inset + + be as in step A4' in the text, + and let +\family typewriter +PTR +\family default + be a variable whose value persists among runs of this algorithm and which starts with the value +\family typewriter +AVAIL +\family default +. + (We could just get rid of the list head in +\family typewriter +LOC(AVAIL) +\family default + and use this +\family typewriter +Q +\family default + instead of +\family typewriter +AVAIL +\family default +, + but let's follow convention (9).) For this algorithm +\begin_inset Formula $\mathtt{N}$ +\end_inset + + is two more than the number of words we want to allocate. +\end_layout + +\begin_layout Enumerate +\begin_inset Argument item:1 +status open + +\begin_layout Plain Layout + +\series bold +A1. +\end_layout + +\end_inset + +[Initialize.] Set +\begin_inset Formula $\mathtt{P}\gets\mathtt{PTR}$ +\end_inset + +. +\end_layout + +\begin_layout Enumerate +\begin_inset Argument item:1 +status open + +\begin_layout Plain Layout + +\series bold +A2. +\end_layout + +\end_inset + + +\begin_inset CommandInset label +LatexCommand label +name "enu:e2512b" + +\end_inset + +[Is +\family typewriter +SIZE +\family default + enough?] If +\begin_inset Formula $\mathtt{SIZE(P)}\geq\mathtt{N}$ +\end_inset + +, + go to +\begin_inset CommandInset ref +LatexCommand ref +reference "enu:e2512d" +plural "false" +caps "false" +noprefix "false" +nolink "false" + +\end_inset + +. +\end_layout + +\begin_layout Enumerate +\begin_inset Argument item:1 +status open + +\begin_layout Plain Layout + +\series bold +A3. +\end_layout + +\end_inset + +[End of list?] Set +\begin_inset Formula $\mathtt{P}\gets\mathtt{LINK(P)}$ +\end_inset + +. + If +\begin_inset Formula $\mathtt{P}=\mathtt{PTR}$ +\end_inset + +, + the algorithm terminates unsuccessfully; + there is no room for a block of +\family typewriter +N +\family default + consecutive blocks. + Otherwise go back to +\begin_inset CommandInset ref +LatexCommand ref +reference "enu:e2512b" +plural "false" +caps "false" +noprefix "false" +nolink "false" + +\end_inset + +. +\end_layout + +\begin_layout Enumerate +\begin_inset Argument item:1 +status open + +\begin_layout Plain Layout + +\series bold +A4. +\end_layout + +\end_inset + + +\begin_inset CommandInset label +LatexCommand label +name "enu:e2512d" + +\end_inset + +[Reserve +\family typewriter +N +\family default +.] Set +\begin_inset Formula $\mathtt{K}\gets\mathtt{SIZE(P)}-\mathtt{N}$ +\end_inset + +, + but if +\begin_inset Formula $\mathtt{K} + + + + + + + + + + +\begin_inset Text + +\begin_layout Plain Layout +Height +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Width +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Top +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Bottom +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Inner +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Outer +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Recommended headers +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +297 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +198 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +33 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +66 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +23 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +43 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Fancy +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +210 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +140 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +4 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +8 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +3 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +5 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Empty +\end_layout + +\end_inset + + + + +\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 Chapter* +Notes on the Exercises +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "0.lyx" +literal "true" + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout + +\family typewriter +A10+R30 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Chapter +Basic Concepts +\end_layout + +\begin_layout Section +Algorithms +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "1.1.lyx" +literal "true" + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout + +\family typewriter +A10+R30 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Section +Mathematical Preliminaries +\end_layout + +\begin_layout Subsection +Mathematical Induction +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "1.2.1.lyx" +literal "true" + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout + +\family typewriter +A10+R30 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsection +Numbers, + Powers, + and Logarithms +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "1.2.2.lyx" +literal "true" + +\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 +Sums and products +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "1.2.3.lyx" +literal "true" + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout + +\family typewriter +A10+R25+29 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsection +Integer Functions and Elementary Number Theory +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "1.2.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 Subsection +Permutations and Factorials +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "1.2.5.lyx" +literal "false" + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout + +\family typewriter +A10+R25+11 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsection +Binomial Coefficients +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "1.2.6.lyx" +literal "false" + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout + +\family typewriter +A10+R25+44 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsection +Harmonic Numbers +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "1.2.7.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 +Fibonacci Numbers +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "1.2.8.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 +Generating Functions +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "1.2.9.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 +Analysis of an Algorithm +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "1.2.10.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 +Asymptotic Representations +\end_layout + +\begin_layout Subsubsection +The +\begin_inset Formula $O$ +\end_inset + +-notation +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "1.2.11.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 +Euler's summation formula +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "1.2.11.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 +Some asymptotic calculations +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "1.2.11.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 Section + +\family typewriter +MIX +\end_layout + +\begin_layout Subsection +Description of +\family typewriter +MIX +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "1.3.1.lyx" +literal "true" + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout + +\family typewriter +A10+R25+22 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsection +The +\family typewriter +MIX +\family default + Assembly Language +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "1.3.2.lyx" +literal "true" + +\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 +Applications to permutations +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "1.3.3.lyx" +literal "true" + +\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 +Some Fundamental Programming Techniques +\end_layout + +\begin_layout Subsection +Subroutines +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "1.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 +Coroutines +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "1.4.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 +Interpretive Routines +\end_layout + +\begin_layout Subsubsection +A +\family typewriter +MIX +\family default + simulator +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "1.4.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 Subsubsection +Trace Routines +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "1.4.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 +Input and Output +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "1.4.4.lyx" +literal "false" + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout + +\family typewriter +A10+R25+4 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Section + +\family typewriter +MMIX +\end_layout + +\begin_layout Subsection +Description of +\family typewriter +MMIX +\end_layout + +\begin_layout Subsection +The +\family typewriter +MMIX +\family default + Assembly Language +\end_layout + +\begin_layout Section +Some Fundamental Programming Techniques ( +\family typewriter +MMIX +\family default +) +\end_layout + +\begin_layout Subsection +Subroutines +\end_layout + +\begin_layout Subsection +Coroutines +\end_layout + +\begin_layout Subsection +Interpretive Routines +\end_layout + +\begin_layout Chapter +Information Structures +\end_layout + +\begin_layout Section +Introduction +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "2.1.lyx" +literal "true" + +\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 +Linear lists +\end_layout + +\begin_layout Subsection +Stacks, + Queues, + and Deques +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "2.2.1.lyx" +literal "true" + +\end_inset + + +\begin_inset Note Note +status open + +\begin_layout Plain Layout + +\family typewriter +A10+R30 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsection +Sequential Allocation +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "2.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 Subsection +Linked Allocation +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "2.2.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 +Circular Lists +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "2.2.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 Subsection +\begin_inset CommandInset label +LatexCommand label +name "subsec:Doubly-Linked-Lists" + +\end_inset + +Doubly Linked Lists +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "2.2.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 Subsection +Arrays and Orthogonal Lists +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "2.2.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 Section +Trees +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "2.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 +Traversing Binary Trees +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "2.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 +Binary Tree Representation of Trees +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "2.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 +Other Representations of Trees +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "2.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 +Basic Mathematical Properties of Trees +\end_layout + +\begin_layout Subsubsection +Free trees +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "2.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 Subsubsection +Oriented trees +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "2.3.4.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 +The +\begin_inset Quotes eld +\end_inset + +infinity lemma +\begin_inset Quotes erd +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "2.3.4.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 Subsubsection +Enumeration of trees +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "2.3.4.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 Subsubsection +Path length +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "2.3.4.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 Subsubsection +History and bibliography +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "2.3.4.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 Subsection +Lists and Garbage Collection +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "2.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 +Multilinked Structures +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "2.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 +Dynamic Storage Allocation +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "2.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 + +\end_body +\end_document -- cgit v1.2.3