User:Beneficii/frac

To convert the fractional part of a number into a fraction, you do this:

Terminating representations only (fractional part of number only):

Where integer r > 1 is the number base of the representation, integer m ≥ 0 is the length of terminating representation, integer sequence 0 ≤ ax < r is the sequence from first to last of the integers of the terminating representation.

$$N = \frac{\displaystyle \sum_{i=0}^{m-1} a_i r^{m-i-1}}{\displaystyle r^m}$$

Repeating representations only (fractional part of number only):

Where integer r > 1 is the number base of the representation, integer m ≥ 0 is the length of the initial non-repeating portion of the repeating representation, where integer n > 0 is the length of one sequence of the endlessly repeating portion of the repeating representation, integer sequence 0 ≤ ax < r is the sequence from the highest to the lowest of the integers of the initial non-repeating portion of the repeating representation, integer sequence 0 ≤ bx < r is the sequence from first to last of the integers of one sequence of the endlessly repeating portion of the repeating representation.

$$N = \frac{\displaystyle (r^n - 1) \sum_{i=0}^{m-1} a_i r^{m-i-1} + \sum_{j=0}^{n-1} b_j r^{n-j-1}}{\displaystyle r^{m+n} - r^m}$$

As an example, let us do the decimal 0.34$\overline{894}$ where the 894 repeats endlessly:

$$\begin{align} r & = 10 \\ a & = (3, 4) \\ m & = 2 \\ b & = (8, 9, 4) \\ n & = 3 \end{align} $$

$$ \begin{align} N & = \frac{\displaystyle ((10)^{(3)} - 1) \sum_{i=0}^{(2)-1} a_i (10)^{(2)-i-1} + \sum_{j=0}^{(3)-1} b_j ((10)^{(3)-j-1})}{\displaystyle (10)^{(2)+(3)} - (10)^{(2)}} \\ & = \frac{(1000 - 1) (3 \times 10 + 4 \times 1) + (8 \times 100 + 9 \times 10 + 4 \times 1)}{100000 - 100} \\ & = \frac{999 \times 34 + 894}{99900} = \frac{34860}{99900} = (0.34 \overline{894}) \end{align} $$

We can try simplifying our fraction: $$\begin{align} N & = \frac{34860}{99900} & = \frac{3486}{9990} & = \frac{581}{1665} \end{align} $$

As another one, let us do the example (0.2B$\overline{D83}$)hex

$$\begin{align} r & = 16 \\ a & = (2, 11) \\ m & = 2 \\ b & = (13, 8, 3) \\ n & = 3 \end{align} $$

$$ \begin{align} N & = \frac{\displaystyle ((16)^{(3)} - 1) \sum_{i=0}^{(2)-1} a_i (16)^{(2)-i-1} + \sum_{j=0}^{(3)-1} b_j ((16)^{(3)-j-1})}{\displaystyle (16)^{(2)+(3)} - (16)^{(2)}} \\ & = \frac{(4096 - 1) (2 \times 16 + 11 \times 1) + (13 \times 256 + 8 \times 16 + 3 \times 3)}{1048576 - 256} \\ & = \frac{(4095 \times 43) + 3459}{1048320} = \frac{179544}{1048320} = \frac{(2BD58)_{hex}}{(FFF00)_{hex}} = \frac{(57AB)_{hex}}{(1FFE0)_{hex}} = \frac{(1D39)_{hex}}{(AAA0)_{hex}} \end{align} $$

(1D39)hex is a prime number, so the fraction is simplified!

Simplified way:

Let A be the initial non-repeating part as an integer (if it exists). Let B be the fractional portion of digits with just one instance of the repeating sequence as an integer.

$$ \begin{align} A & = \sum_{i=0}^{m-1} a_i r^{m-i-1} \\ B & = \sum_{i=0}^{m-1} a_i r^{n+m-i-1} + \sum_{j=0}^{n-1} b_j r^{n-j-1} \\ & = r^n A + \sum_{j=0}^{n-1} b_j r^{n-j-1} \\ N & = \frac{\displaystyle (r^n - 1) \sum_{i=0}^{m-1} a_i r^{m-i-1} + \sum_{j=0}^{n-1} b_j r^{n-j-1}}{\displaystyle r^{m+n} - r^m} \\ & = \frac{\displaystyle (r^n - 1) A + \sum_{j=0}^{n-1} b_j r^{n-j-1}}{\displaystyle r^{m+n} - r^m} \\ & = \frac{\displaystyle r^n A - A + \sum_{j=0}^{n-1} b_j r^{n-j-1}}{\displaystyle r^{m+n} - r^m} \\ & = \frac{\displaystyle r^n A + \sum_{j=0}^{n-1} b_j r^{n-j-1} - A}{\displaystyle r^{m+n} - r^m} \\ & = \frac{B - A}{\displaystyle r^{m+n} - r^m} \\ \end{align} $$

That should simplify it somewhat.

Example:

$$ \begin{align} & 0.355\overline{8329}, decimal. \\ A & = 355 \\ B & = 3558329 \\ r & = 10 \\ m & = 3 \\ n & = 4 \\ N & = \frac{(3558329) - (355)}{\displaystyle (10)^{(3)+(4)} - (10)^{(3)}} = \frac{3557974}{9999000} \end{align} $$

Notice how in the denominator the number of 9's is equal to n and the number of 0's is equal to m. There is a connection there to keep in mind. Also the fact that it is 9, 10 - 1, that appears. If you look above you can see(F)hex in the denominator, which is (10)hex - (1)hex.

For this example, all numbers are in octal (base 8) unless otherwise specified with (number)base notation:

$$ \begin{align} & 0.157\overline{3365}, octal \\ A & = 157 \\ B & = 1573365 \\ r & = 10, (r=(8)_{dec}) \\ m & = 3 \\ n & = 4 \\ N & = \frac{(1573365) - (157)}{\displaystyle (10)^{(3)+(4)} - (10)^{(3)}} = \frac{1573206}{7777000} \end{align} $$

What about repeating binaries?

For this example, all numbers are in binary (base 2) unless otherwise specified with (number)base notation:

$$ \begin{align} & 0.101110\overline{1101001111}, octal \\ A & = 101110 \\ B & = 1011101101001111 \\ r & = 10, (r=(2)_{dec}) \\ m & = 110 \\ n & = 1010 \\ N& = \frac{(1011101101001111) - (101110)}{\displaystyle (10)^{(110)+(1010)} - (10)^{(110)}} = \frac{1011101100100001}{1111111111000000} = \frac{(47905)_{dec}}{(65472)_{dec}} \end{align} $$