Compare commits
8 Commits
3bfaf915cf
...
46d44f41de
Author | SHA1 | Date | |
---|---|---|---|
46d44f41de | |||
2b621c94cf | |||
c417bdc6cf | |||
c2c7b28647 | |||
c27c875d98 | |||
cd72817bdf | |||
20e0c1a545 | |||
57cd8d63a8 |
@ -1,18 +1,3 @@
|
||||
% Copyright (C) 2023 Mark (mark@betalupi.com)
|
||||
%
|
||||
% This program is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% This program is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
\NeedsTeXFormat{LaTeX2e}
|
||||
\ProvidesClass{../../../lib/tex/ormc_handout}[2023/05/29 2.0.2 ORMC Handout]
|
||||
|
||||
|
@ -19,7 +19,7 @@ Only one of the following ISBNs is valid. Which one is it?
|
||||
|
||||
\begin{itemize}
|
||||
\item \texttt{0-134-54896-2}
|
||||
\item \texttt{0-895-77258-2}
|
||||
\item \texttt{0-895-77258-2} % oliver twist
|
||||
\end{itemize}
|
||||
|
||||
\begin{solution}
|
||||
@ -67,18 +67,19 @@ This is called a \textit{transposition error}.
|
||||
\vfill
|
||||
\pagebreak
|
||||
|
||||
\problem{}
|
||||
\definition{}
|
||||
ISBN-13 error checking is slightly different. Given a partial ISBN-13 $n_1 n_2 n_3 ... n_{12}$, the final digit is given by
|
||||
|
||||
$$
|
||||
n_{13} = \Biggr[ \sum_{i=1}^{12} n_i \times (2 + (-1)^i) \Biggl] \text{ mod } 10
|
||||
$$
|
||||
|
||||
\problem{}
|
||||
What is the last digit of the following ISBN-13? \par
|
||||
\texttt{978-0-380-97726-?}
|
||||
\texttt{978-030-7292-06*} % foundation
|
||||
|
||||
\begin{solution}
|
||||
The final digit is 0.
|
||||
The final digit is 3.
|
||||
\end{solution}
|
||||
|
||||
\vfill
|
||||
@ -127,7 +128,7 @@ Take a valid ISBN-13 and swap two adjacent digits. When will the result be a val
|
||||
\vfill
|
||||
|
||||
\problem{}<isbn-nocorrect>
|
||||
\texttt{978-0-08-2066-46-6} was a valid ISBN until I changed a single digit. \par
|
||||
\texttt{978-008-2066-466} was a valid ISBN until I changed a single digit. \par
|
||||
Can you find the digit I changed? Can you recover the original ISBN?
|
||||
|
||||
\begin{solution}
|
||||
|
@ -570,8 +570,45 @@ If we know which parity bits are inconsistent, how can we find where the error i
|
||||
\vfill
|
||||
|
||||
\problem{}<generalize-hamming>
|
||||
Can you generalize this system for messages of 4, 64, or 256 bits?
|
||||
Generalize this system for messages of 4, 64, or 256 bits. \par
|
||||
\begin{itemize}
|
||||
\item How does the resilience of this scheme change if we use a larger message size?
|
||||
\item How does the efficiency of this scheme change if we send larger messages?
|
||||
\end{itemize}
|
||||
|
||||
\vfill
|
||||
\pagebreak
|
||||
|
||||
|
||||
\definition{}
|
||||
A \textit{deletion} error occurs when one bit of the message is deleted. \par
|
||||
Likewise, an \textit{insertion} error consists of a random inserted bit. \par
|
||||
|
||||
\definition{}
|
||||
A \textit{message stream} is an infinite string of binary digits.
|
||||
|
||||
\problem{}
|
||||
Show that Hamming codes do not reliably detect bit deletions: \par
|
||||
\hint{
|
||||
Create a 17-bit message whose first 16 bits are a valid Hamming block, \par
|
||||
and which is still valid when a bit (chosen by you; not the $17^\text{th}$) is deleted.
|
||||
}
|
||||
|
||||
\vfill
|
||||
|
||||
\problem{}
|
||||
Convince yourself that Hamming codes cannot correct insertions. \par
|
||||
Then, create a 16-bit message that...
|
||||
\begin{itemize}
|
||||
\item is a valid Hamming block, and
|
||||
\item incorrectly "corrects" a single bit error when it encounters an insertion error.
|
||||
\end{itemize}
|
||||
|
||||
\vfill
|
||||
|
||||
|
||||
As we have seen, Hamming codes effectively handle substitutions, but cannot reliably
|
||||
detect (or correct) insertions and deletions. Correcting those errors is a bit more difficult:
|
||||
if the number of bits we receive is variable, how can we split a stream into a series of messages? \par
|
||||
\note{This is a rhetorical question, which we'll discuss another day.}
|
||||
\pagebreak
|
@ -36,7 +36,7 @@ This code defines a function `Q_sqrt`, which was used as a fast approximation of
|
||||
|
||||
#v(3mm)
|
||||
|
||||
The key word here is "fast": _Quake_ ran on very limited hardware, and traditional approximation techniques (like Taylor series)#footnote[In fact, Taylor series aren't used today, and for the same reason: there are better ways.] were too computationally expensive to be viable.
|
||||
The key word here is "fast": _Quake_ ran on very limited hardware, and traditional approximation techniques (like Taylor series)#footnote[Taylor series aren't used today, and for the same reason. There are better ways.] were too computationally expensive to be viable.
|
||||
|
||||
#v(3mm)
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
A _bit string_ is a string of binary digits. \
|
||||
In this handout, we'll denote bit strings with the prefix `0b`. \
|
||||
#note[This prefix is only notation---it is _not_ part of the string itself.] \
|
||||
For example, $1010$ is the number "one thousand and one," while $#text([`0b1001`])$ is the string of bits "1 0 0 1".
|
||||
For example, $1001$ is the number "one thousand and one," while $#text([`0b1001`])$ is the string of bits "1 0 0 1".
|
||||
|
||||
#v(2mm)
|
||||
We will separate long bit strings with underscores for readability. \
|
||||
@ -69,19 +69,19 @@ Find the value of each of the following 32-bit unsigned integers:
|
||||
|
||||
|
||||
#definition()
|
||||
In general, fast division of `uints` is difficult.#footnote([One may use repeated subtraction, but this isn't efficient.]). \
|
||||
In general, fast division of `uints` is difficult#footnote([One may use repeated subtraction, but this isn't efficient.]). \
|
||||
Division by powers of two, however, is incredibly easy: \
|
||||
To divide by two, all we need to do is shift the bits of our integer right.
|
||||
|
||||
#v(2mm)
|
||||
|
||||
For example, consider $#text[`0b0000_0110`] = 6$. \
|
||||
If we insert a zero at the left end of this bit string and delete the digit at the right \
|
||||
If we insert a zero at the left end of this string and delete the zero at the right \
|
||||
(thus "shifting" each bit right), we get `0b0000_0011`, which is 3. \
|
||||
|
||||
#v(2mm)
|
||||
|
||||
Of course, we lose the remainder when we left-shift an odd number: \
|
||||
Of course, we lose the remainder when we right-shift an odd number: \
|
||||
$9$ shifted right is $4$, since `0b0000_1001` shifted right is `0b0000_0100`.
|
||||
|
||||
#problem()
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
= Floats
|
||||
#definition()
|
||||
_Binary decimals_#footnote([Note that "binary decimal" is a misnomer---"deci" means "ten"!]) \
|
||||
_Binary decimals_#footnote([Note that "binary decimal" is a misnomer---"deci" means "ten"!]) are very similar to base-10 decimals.\
|
||||
In base 10, we interpret place value as follows:
|
||||
- $0.1 = 10^(-1)$
|
||||
- $0.03 = 3 times 10^(-2)$
|
||||
@ -113,7 +113,7 @@ Floats represent a subset of the real numbers, and are interpreted as follows: \
|
||||
They are interpreted as the fractional part of a binary decimal. \
|
||||
For example, the bits `0b10100000_00000000_00000000` represent $0.5 + 0.125 = 0.625$. \
|
||||
We'll call the value of these bits as a binary integer $F$. \
|
||||
Their value as a binary decimal is then $F div 2^23$. #note([(Convince yourself that this is true!)])
|
||||
Their value as a binary decimal is then $F div 2^23$. #note([(convince yourself of this)])
|
||||
|
||||
|
||||
#problem(label: "floata")
|
||||
@ -145,7 +145,7 @@ $
|
||||
|
||||
#note[
|
||||
We subtract 127 from $E$ so we can represent positive and negative numbers. \
|
||||
$E$ is an eight bit binary integer, so $0 <= E <= 255$ and $-127 <= (E - 127) <= 127$.
|
||||
$E$ is an eight bit binary integer, so $0 <= E <= 255$ and thus $-127 <= (E - 127) <= 127$.
|
||||
]
|
||||
|
||||
#problem()
|
||||
|
@ -64,7 +64,7 @@ This allows us to improve the average error of our linear approximation:
|
||||
Max error: 0.086 \
|
||||
Average error: 0.0573
|
||||
],
|
||||
[$log(1+x)_2$ and $x + 0.045$]
|
||||
[$log_2(1+x)$ and $x + 0.045$]
|
||||
+ cetz.canvas({
|
||||
import cetz.draw: *
|
||||
|
||||
@ -125,7 +125,7 @@ We won't bother with this---we'll simply leave the correction term as an opaque
|
||||
[
|
||||
"Average error" above is simply the area of the region between the two graphs:
|
||||
$
|
||||
integral_0^1 abs( #v(1mm) log(1+x) - (x+epsilon) #v(1mm))
|
||||
integral_0^1 abs( #v(1mm) log(1+x)_2 - (x+epsilon) #v(1mm))
|
||||
$
|
||||
Feel free to ignore this note, it isn't a critical part of this handout.
|
||||
],
|
||||
|
@ -20,9 +20,8 @@ This code defines a function `Q_rsqrt` that consumes a float `number` and approx
|
||||
If we rewrite this using notation we're familiar with, we get the following:
|
||||
$
|
||||
#text[`Q_sqrt`] (n_f) =
|
||||
#h(5mm)
|
||||
6240089 - (n_i div 2)
|
||||
#h(5mm)
|
||||
#h(10mm)
|
||||
approx 1 / sqrt(n_f)
|
||||
$
|
||||
|
||||
@ -70,7 +69,7 @@ In other words,
|
||||
$
|
||||
r_f := 1 / (sqrt(n_f))
|
||||
$
|
||||
This is the value we want to approximate.
|
||||
This is the value we want to approximate. \
|
||||
|
||||
#problem(label: "finala")
|
||||
Find an approximation for $log_2(r_f)$ in terms of $n_i$ and $epsilon$ \
|
||||
@ -92,7 +91,11 @@ Let's call the "magic number" in the code above $kappa$, so that
|
||||
$
|
||||
#text[`Q_sqrt`] (n_f) = kappa - (n_i div 2)
|
||||
$
|
||||
Use @convert and @finala to show that $#text[`Q_sqrt`] (n_f) approx r_i$
|
||||
Use @convert and @finala to show that $#text[`Q_sqrt`] (n_f) approx r_i$ \
|
||||
#note(type: "Note")[
|
||||
If we know $r_i$, we know $r_f$. \
|
||||
We don't even need to convert between the two---the underlying bits are the same!
|
||||
]
|
||||
|
||||
#solution[
|
||||
From @convert, we know that
|
||||
|
@ -1,18 +1,3 @@
|
||||
% Copyright (C) 2023 <Mark (mark@betalupi.com)>
|
||||
%
|
||||
% This program is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% You may have received a copy of the GNU General Public License
|
||||
% along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
%
|
||||
%
|
||||
%
|
||||
% If you edit this, please give credit!
|
||||
% Quality handouts take time to make.
|
||||
|
||||
% use the [nosolutions] flag to hide solutions,
|
||||
% use the [solutions] flag to show solutions.
|
||||
\documentclass[
|
||||
|
@ -1,19 +1,3 @@
|
||||
% Copyright (C) 2023 <Mark (mark@betalupi.com)>
|
||||
%
|
||||
% This program is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% You may have received a copy of the GNU General Public License
|
||||
% along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
%
|
||||
%
|
||||
%
|
||||
% If you edit this, please give credit!
|
||||
% Quality handouts take time to make.
|
||||
|
||||
|
||||
% use [nosolutions] flag to hide solutions.
|
||||
% use [solutions] flag to show solutions.
|
||||
\documentclass[
|
||||
|
@ -1,19 +1,3 @@
|
||||
% Copyright (C) 2023 <Mark (mark@betalupi.com)>
|
||||
%
|
||||
% This program is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% You may have received a copy of the GNU General Public License
|
||||
% along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
%
|
||||
%
|
||||
%
|
||||
% If you edit this, please give credit!
|
||||
% Quality handouts take time to make.
|
||||
|
||||
|
||||
\section{Dual Numbers}
|
||||
|
||||
\definition{}
|
||||
|
@ -1,18 +1,3 @@
|
||||
% Copyright (C) 2023 <Mark (mark@betalupi.com)>
|
||||
%
|
||||
% This program is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% You may have received a copy of the GNU General Public License
|
||||
% along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
%
|
||||
%
|
||||
%
|
||||
% If you edit this, please give credit!
|
||||
% Quality handouts take time to make.
|
||||
|
||||
\section{Extensions of $\mathbb{R}$}
|
||||
|
||||
\definition{}
|
||||
|
@ -1,19 +1,3 @@
|
||||
% Copyright (C) 2023 <Mark (mark@betalupi.com)>
|
||||
%
|
||||
% This program is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% You may have received a copy of the GNU General Public License
|
||||
% along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
%
|
||||
%
|
||||
%
|
||||
% If you edit this, please give credit!
|
||||
% Quality handouts take time to make.
|
||||
|
||||
|
||||
\section*{The supremum \& the infimum}
|
||||
|
||||
\definition{}
|
||||
|
Loading…
x
Reference in New Issue
Block a user