X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fsam.git;a=blobdiff_plain;f=chapters%2FBackground%2FRationals.tex;h=5a551985a578f552b33de7740dddd10ea3f9c97e;hp=da4f77a68ab8b38a8466236dbbe85a16dbdbc0bb;hb=a1ede3cfc3ef650aa0f7d3d06e78c6c6ef4cb0cc;hpb=7fe12ce195f039925222ad98b38018ad31d1b1f2 diff --git a/chapters/Background/Rationals.tex b/chapters/Background/Rationals.tex index da4f77a..5a55198 100644 --- a/chapters/Background/Rationals.tex +++ b/chapters/Background/Rationals.tex @@ -1,15 +1,13 @@ +A rational number $Q$ may be represented by two integers $N$ the numerator and $D$ the denominator. + +\begin{align} + Q &= \frac{N}{D} +\end{align} + +Compared to floating point arithmetic which is generally inexact, rational arithmetic including the division operation is always exactly representable as another rational number. However, a \emph{fixed size} rational representation is of rather limited use as $D$ will always grow after repeated operations and overflow. Use of arbitrary sized integers as described in section \ref{Big Integers} and implemented by GMP\cite{granlund2004GMP} overcomes this issue; however as we will see in Chapter \ref{Results and Discussion} there can be a significant performance cost associated with Rationals. + \begin{align} - Q &= \frac{N}{D} - \end{align} - \begin{itemize} - \item $N$ and $D$ are arbitrary precision integers - \end{itemize} - \begin{align} - N &= \sum_{i=0}^{S} d_i \beta^{i} + N = \sum_{i=0}^{S} n_i \beta^{i} & \text{ and } + D = \sum_{i=0}^{S} d_i \beta^{i} \text{ where $S$ grows as needed} \end{align} - \begin{itemize} - \item $d_i$ are fixed size integers, $\beta = 2^{64}$ - \item Size $S$ grows as needed - \item Operations are always exact - \item Implemented by GNU Multiple Precision Library - \end{itemize} +