query
a pythonic query language
Sign in or create a new account.


matplotlib powered data graphics.

Parameters:
b, n, r

The PyQL query format is: fields @ conditions.
  fields is a field or a comma delimited list of fields.
 conditions is a condition or an and delimited list of conditions.

Both fields and conditions are made up of terms.
A term is a valid Python expression in a name space made up of: database parameters; any imported python modules; PyQL Aggregators such as Average (A), Sum (S), and Replace (R); and other domain specific terms.

About the Barely Rational DatabaseSample Queries
n are integers from 2 to 1001.

r is the number of 'digits' required to represent 1/n (+1 for the bar).

b is the base.

Primes is a list of prime numbers.

To see n vs r in base 10, use the PyQL:
n,r@b=10

To see n vs r for bases 2 - 10, use the PyQL:
n,r@b and b<=10

To see n vs r for bases 2 - 10 for prime n, use the PyQL:
n,r@b and b<=10 and n in Primes

To see n vs r for bases 2 - 10 with icons colored by primeness, use the PyQL:
n,r@b and b<=10 and (n in Primes),(n not in Primes)

To see n v r/n for bases 2 - 10 with icons colored by primeness, use the PyQL:
n,r/n@b and b<=10 and (n in Primes),(n not in Primes)

To see n v r/n with icons colored by primeness for bases that are perfect squares, use the PyQL:
n,r/n@b and math.pow(b,0.5)=int(math.pow(b,0.5)) and (n in Primes),(n not in Primes)

n v math.log(r/n) seems to have something to tell us:
n,math.log(r/n)@b and b<=10 and (n in Primes),(n not in Primes)

What about those dots between the main lines in these graphics? Are there patterns to those barely rational numbers? Let's have a peek with a histogram:
n@0.55<r/n<1 and n<100
Hmmm, 81, 49, 27 and 25 are well represented.

We can have a closer look with that most excellent data visualization tool called a table of numbers:
S(1),R(n)@0.55<r/n<1 and n
And we see that those middling dots come from powers of primes the 4 most common values of n being squares of 17,29,23 and 11. Cubes of primes are also well represented at 125, 343, 27 and 729.

Another nice query is:
R(n),R(r),R(b)@0.55<r/n<1 and r and n and b and b<10
1/9 repeats after 6 digits in bases 2 and 5. Likewise for bases 2, 3 and 8 where 1/841 repeats after 812 digits. How interesting!

Let's continue to graphically explore the cases of non-integer n/r. To start, let's look at n/r between 1 and 2 with the PyQL:
n,n/r,(n,r)@1<n/r<2

There is a lot going on there and and coloring by oddness reveals a pattern:
n,n/r,(n,r)@b<=200 and 1<n/r<2 and (n/2.=int(n/2.)),(n/2.!=int(n/2.))

Grouping by n being a perfect square shows in interesting set of numbers.
n,n/r,(n,r)@1<n/r<2 and (int(math.pow(n,0.5))=math.pow(n,0.5)) as 'perfect square',(int(math.pow(n,0.5))!=math.pow(n,0.5)) as 'not perfect square'