• Mood:
• Music:

# FDA Warning: Doing math may cause insomnia

I couldn't sleep much last night. It's all 's fault. In his journal, he explained a trick he developed in middle school(!) to do the decimal expansion of x/97. I won't get into the derivation here, but the algorithm involves taking the terms two-at-a-time and doing repeated multiplications by three plus an adjustment. If you're curious:

x/97 = .aabbccdd...

aa = x + trunc( x / (97/3)) )
bb' = (aa * 3) mod 100
bb = bb' + trunc( bb' / (97/3) )
cc' = (bb * 3) mod 100
cc = cc' + trunc( cc' / (97/3) )

That looks a little complicated. But, basically you take the previous two numbers, multiply by 3, and ignore the hundreds place (that's the bb' and cc' part). Then take that result and adjust by zero if it's 0-32, one if it's 33-64, two if it's 65-99. For example, 3/97 =

0.03    : First term is simply x + adjustment
09    : 03*3 + 0
27    : 09*3 = 27 + 0
83    : 27*3 = 81 + 2
50    : 83*3 = 249 -> 49 + 1
51    : 50*3 = 150 -> 50 + 1
54    : 51*3 = 153 -> 53 + 1
63...

.0309278350515463...

----

About ninety minutes before my bedtime last night, i started playing with why his method works (including figuring out the precise addition adjustment of trunc( ((x * 3) mod 100) / (97/3)) ) instead of the more vague "adding 1 for each 1/3 of 100 the result surpasses."

I then went off and extrapolated it to some other fractions in the 91sts thru 98ths range:

x/(100-m) = .aabbccdd...              : ex.  1/95  (x = 1, m = 5)

aa = x + trunc( x / ((100-m)/m)) )    : aa  = 1 + trunc( 1 / ((100-5)/5)) = 1 + trunc(1/19) = 01
bb' = (aa * m) mod 100                : bb' = (01 * 5) mod 100 = 05
bb = bb' + trunc( bb' / ((100-m)/m) ) : bb = 05 + trunc( 05 / 19) = 05
cc' = (bb * m) mod 100                : cc' = (05 * 5) mod 100 = 25
cc = cc' + trunc( cc' / ((100-m)/m) ) : cc = 25 + trunc( 25 / 19) = 26
dd' = (cc * m) mod 100                : dd' = (26 * 5) mod 100 = 30
dd = dd' + trunc( dd' / ((100-m)/m) ) : dd = 30 + trunc( 30 / 19) = 31

-> 1/95 = .01 05 26 31 57 89...
-> 9/98 = .09 18 36 73 46 93...

95ths are easy because multiplying by 5 is quick and the adjustment divisor 95/5 is an integer. 93rds are more difficult because I don't intuitively divide by 93/7. However, most of the others in the 90s work out reasonably well.

After this and watching some Tivoed Daily Show, it was time for bed. As i believe i've mentioned before, i shouldn't do mildly “interesting” math in the two hours before bedtime. I paid the price for my folly as i spent my time lying in bed pondering other decimal expansions. For example, i realized meant i could finally do 13ths (which i knew had two separate repeating decimal patterns...but nothing i wanted to memorize) and 19ths, by converting to 91sts and 95ths. I went on to calculate 49ths, 190ths, 995ths, et cetera.

Initially, while calculating 3/190 i recognized that i could add 19/190 to make it 22/190 - .1 = 11/95 - .1. After doing this, i felt like a complete dumbass because it should have been obvious that it's easier to calculate 3/19 and divide by 10. Of course, i also felt like a dumbass for mathing instead of sleeping.

However, that addition of 19/190s inspired me to realize that an easier way to calculate 14ths and 28ths is to convert to 7ths by doing ± .5 for 14th, ± .25 or .75 for 28ths. In the past, i'd just take divide by 2 or 4 and then divide by 7, realizing that the decimal would quickly adhere to the 7ths repeating decimal.

Anyway, i apologize that this isn't of interest to most (any?) of you aside from the humor stemming from immense nerdiness causing me pain, once again. However, posting this will help me retain this for later use.

Where? I have no idea...
Tags:
• #### legitimate poker update

Heading into Day 2, i'm currently in 28th place of 157 remaining in the \$1500 Pot Limit Omaha Hi/Lo World Series of Poker Event:…

• #### Sellout III & IV: Citizens on Patrol

Now, in order to earn my \$22 tourney entry, i'm supposed to link to teach you "How to Play 8 Game Mix" and "How to Play Badugi". Badugi's a…

• #### Sellout II: The Secret of the Ooze

In continuation of me using my Livejournal as a means to get free stuff from PokerStars, i must say that "High Stakes Poker Tournament" is a phrase…

• Post a new comment

#### Error

Anonymous comments are disabled in this journal

default userpic