next up previous contents
Next: Multiplication Up: Dyadic Digit Operations Previous: Lowest Terms

Average

  In order to compute the average of two dyadic digits

\begin{displaymath}
(a,b) \oplus (c,d) = \frac{a}{2^b} \oplus \frac{c}{2^d}\end{displaymath}

it is necessary to compute the value

\begin{displaymath}
\frac{x}{2^y} = \frac{a\cdot 2^d + c\cdot 2^b}{2^{b+c+1}}\end{displaymath}

with the property that (x,y) is a dyadic digit (ie. x is odd or (x,y) = (0,0)).

We examine the powers of the denominators b and d and come up with three different cases.

Case 1: (b>d)

\begin{displaymath}
\frac{x}{2^y} = \frac{a\cdot 2^d + c\cdot 2^b}{2^{b+c+1}} = \frac{a + c\cdot 2^{b-d}}{2^{b+1}}\end{displaymath}

As (b > d), we know $(a,b) \neq (0,0)$, so a is odd, $(c\!\cdot\!2^{b-d})$is even, and hence $(a + c\!\cdot\!2^{b-d})$ is odd. Hence:

\begin{displaymath}
b \gt d \Rightarrow (a,b) \oplus (c,d) = (a + c\!\cdot\!2^{b-d},b+1)\end{displaymath}

Case 2: (d>b)
As average is commutative, we can treat this in exactly the same way as the previous case, but with the arguments reversed. Hence:

\begin{displaymath}
d \gt b \Rightarrow (a,b) \oplus (c,d) = (a\!\cdot\!2^{d-b} + c,d+1)\end{displaymath}

Case 3: (b=d)
:

\begin{displaymath}
\frac{x}{2^y} = \frac{a\!\cdot\!2^d + c\!\cdot\!2^b}{2^{b+c+1}} = \frac{a + c}{2^{b+1}}\end{displaymath}

However as a and c are odd or zero, (a + c) may be even, or (a+c,b+1) may have a zero first element and non-zero second element. Therefore it is necessary to apply the function described in section A.1 to the pair (a+c,b+1).

Using an almost identical approach, it is possible to define similar functions for finding the average of one digit with the negation of another, addition or subtraction of two digits (with the caveat that if the result of the addition or subtraction is not in the range [-1,1], the pair returned will not be a valid dyadic digit), and other combinations such as addition or subtraction of two dyadic digits (a,b) where a pair of digits (x,y) is returned with the property that:

\begin{displaymath}
(x,y) = \left\{
\begin{array}
{lllcr}\big(-1, \llbracket a \...
 ... \rrbracket+\llbracket b \rrbracket & \gt & 1\end{array}\right.\end{displaymath}


next up previous contents
Next: Multiplication Up: Dyadic Digit Operations Previous: Lowest Terms
Martin Escardo
5/11/2000