MattConn.io

Matthew Connelly's Developer Page

A Pattern in Quotients of Seven and Rational Pi

A quotient of seven will always have this repeating pattern in the mantissa (the fractional portion beyond the decimal point). This pattern also “shifts” a certain predictable amount of digits every division. We could also think of a quotient of seven as a circular queue, with its mantissa “wrapping around”, like a speedometer or certain type of combination lock.

For every seven quotients, we can see the number of digit shifts (or rotations, in terms of the queue/lock comparison) repeats, marked in the table below of 14 quotients of 7, in the column labeled “offset from 1/7” and underlined in the “decimal” column:

Concatenating these offsets, you get the number:

As an integer, this number is evenly divisible by 7, which is interesting.

Here is the Julia script I wrote to find these offsets:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# division by 7
# =============
#=
Division by 7 always produces this pattern in the mantissa:
1/7 = 0.142857... 
This script checks the offset (or position shift) of this pattern
for each quotient by checking the current pattern against the pattern in 1/7

example:
1/7 = 0.14285714285714285
2/7 = 0.2857142857142857
            ^ 
The offset here is 4 (original pattern has been shifted over 4 places).
=#

master = string(1/7)

println("quotient, decimal, and offset from 1/7:")

last = '\0'
for i in 1:100
	current = string(i/7)
	last = current

	point = false # decimal point detection
	cindex = 1 # character index of quotient string current (1-indexed)
	
	# find decimal point to ignore
	while !point
		if current[cindex] == '.'
			point = true
		end

		cindex += 1
	end


	# count offset from master quotient
	masterOffset = 0
	while current[cindex] != master[3] && cindex < length(current)
		masterOffset += 1
		cindex +=1
	end


	println(i,"/7 : ",current, " : ", masterOffset)

end

A Quotient of Seven as a Bad Rational Approximation of Pi

This is one of the smaller rational approximations of pi, and it is a bad one; not because it only gets you two digits of pi (or pi rounded to one thousandth), but because it relates more to the nature of division by seven than to the nature of pi.

Looking at the table shown earlier, quotients 1/7, then 8/7, both have the same mantissa as 22/7. We can then see that we can pick the offset from 1/7 that we want (from the available offsets 0, 4, 5, 2, 1 and 3), knowing the nature of division by 7, which can be modeled by an expression like the one below, the braces denoting the fractional part.

Here, n denotes some integral value that will give us a multiple of seven, with k denoting an increase in this multiple necessary to give us a mantissa after division by seven.
Then if we wanted to design a rational number that looked something like pi, we could consider that 1/7 has the digits 1 and 4 at the beginning of its mantissa. All that’s left would be the integer 3 in front. Using the expression above, we would wind up with:

This gets us our integer 3 and the mantissa we want through an addition of 1. As seen in the table, the first division by 7 out of any 7 divisions will have a mantissa starting with 1 and 4.

If we wanted the next offset available (mantissa of 1/7 shifted 4 digits right) but the same integer part (3.0), we would use the same expression above, but add 2 instead of 1, to get the second offset, and so on.

Comments