[math-fun] Reciprocals of integers in binary
Dan Asimov <asimov@msri.org> wrote:
Very interesting.
Thank you.
Which leads me to wonder what reciprocal integers look like in factorial base, where x ? (0, 1) is represented as
x = ? a_n / n!
where the sum is over n ? 2 with a_n ? Z+, 0 ? a_n < n, using the greedy algorithm.
I didn't understand most of that, due to -- as I've mentioned several times before -- non-ASCII characters being converted by this list's digest option into question marks, which makes lots of posts almost entirely incomprehensible. Here's my best guess as to what you were asking for. The first place after the point is 1/2!, the next place is 1/3!, the next place is 1/4!, etc. I only go to 20! since that's as far as 64-bit integers go. Also, my digits would soon run off the end of the alphabet. Note that in this base all rationals terminate. 1/2: 0.1 1/3: 0.02 1/4: 0.012 1/5: 0.0104 1/6: 0.01 1/7: 0.003206 1/8: 0.003 1/9: 0.00232 1/10: 0.0022 1/11: 0.002053140A 1/12: 0.002 1/13: 0.00141254850C 1/14: 0.001333 1/15: 0.0013 1/16: 0.00123 1/17: 0.001202368909270G 1/18: 0.00114 1/19: 0.001116209526BBD80I 1/20: 0.0011 Here's my code. It works right to left, placing all of 1/N in the 1/N! bin, then distributing as much of it as possible as far left as possible. #include <stdio.h> int main() { long long i,j,k,a[21],f[21]; char c; f[0] = 1; for (i=1;i<21;i++) f[i] = f[i-1]*i; for (i=2;i<21;i++) { for (j=0;j<21;j++) a[j] = 0; a[i] = f[i-1]; for (j=i-1;j;j--) { a[j] = a[j+1]/(j+1); a[j+1] %= (j+1); } for (j=0;j<21;j++) if (a[j]) k=j; printf("1/%lld: 0.",i); for (j=2;j<k+1;j++) { c = a[j]+48; if (c>57) c=a[j]+55; printf("%c",c); } printf("\n"); } return(0); } For my next trick I will calculate reciprocals of integers in negabinary (base -2). Remember, there are 110 kinds of people: Those who understand negabinary, and those who don't.
Yes, you managed to understand what I meant despite the problem with non-ASCII characters. I apologize for the problem. I will try to avoid these in the future. (Having recently discovered that I can use all these handy math characters on my Mac when e-mailing *some* of my math friends, I was unduly tempted to use them with no matter whom. Thanks for calculating those reciprocals. I guess factorial base can become quite problematic when trying to use more than 36 characters since in general it requires an infinite character set. When in high school I calculated expressions for periodic factorial base series, that is, Sum_{n >= 2} a_n / n! where 0 <= a_n < n and for some p we have a_(n+p) = a_n for all n. It's a fun exercise, which boils down to just evaluating the series whose coefficients satisfy a_n = 1 for all n belonging to any fixed arithmetic sequence, and the rest equal to 0. —Dan
On Sunday/31January/2021, at 10:09 AM, Keith F. Lynch <kfl@KeithLynch.net> wrote:
Dan Asimov <asimov@msri.org> wrote:
Very interesting.
Thank you.
Which leads me to wonder what reciprocal integers look like in factorial base, where x ? (0, 1) is represented as
x = ? a_n / n!
where the sum is over n ? 2 with a_n ? Z+, 0 ? a_n < n, using the greedy algorithm.
I didn't understand most of that, due to -- as I've mentioned several times before -- non-ASCII characters being converted by this list's digest option into question marks, which makes lots of posts almost entirely incomprehensible.
Here's my best guess as to what you were asking for. The first place after the point is 1/2!, the next place is 1/3!, the next place is 1/4!, etc. I only go to 20! since that's as far as 64-bit integers go. Also, my digits would soon run off the end of the alphabet.
Note that in this base all rationals terminate.
1/2: 0.1 1/3: 0.02 1/4: 0.012 1/5: 0.0104 1/6: 0.01 1/7: 0.003206 1/8: 0.003 1/9: 0.00232 1/10: 0.0022 1/11: 0.002053140A 1/12: 0.002 1/13: 0.00141254850C 1/14: 0.001333 1/15: 0.0013 1/16: 0.00123 1/17: 0.001202368909270G 1/18: 0.00114 1/19: 0.001116209526BBD80I 1/20: 0.0011
Here's my code. It works right to left, placing all of 1/N in the 1/N! bin, then distributing as much of it as possible as far left as possible.
#include <stdio.h> int main() { long long i,j,k,a[21],f[21]; char c; f[0] = 1; for (i=1;i<21;i++) f[i] = f[i-1]*i; for (i=2;i<21;i++) { for (j=0;j<21;j++) a[j] = 0; a[i] = f[i-1]; for (j=i-1;j;j--) { a[j] = a[j+1]/(j+1); a[j+1] %= (j+1); } for (j=0;j<21;j++) if (a[j]) k=j; printf("1/%lld: 0.",i); for (j=2;j<k+1;j++) { c = a[j]+48; if (c>57) c=a[j]+55; printf("%c",c); } printf("\n"); } return(0); }
For my next trick I will calculate reciprocals of integers in negabinary (base -2). Remember, there are 110 kinds of people: Those who understand negabinary, and those who don't.
On Sun, Jan 31, 2021 at 11:10 AM Keith F. Lynch <kfl@keithlynch.net> wrote:
I didn't understand most of that, due to -- as I've mentioned several times before -- non-ASCII characters being converted by this list's digest option into question marks, which makes lots of posts almost entirely incomprehensible.
For what it's worth, this is only an issue with the digest. UTF-8 in individual emails gets through just fine. -- Mike Stay - metaweta@gmail.com http://math.ucr.edu/~mike https://reperiendi.wordpress.com
participants (3)
-
Dan Asimov -
Keith F. Lynch -
Mike Stay