Gluten Freendly

December 10th, 2008

I’ve been living gluten free since I tested positive for Celiac Disease about 8 months ago. That means no wheat, rye, or barley. Except the convenience of foods like pizza, sandwiches and crackers, I don’t feel like I’m missing too much thanks to Bonnie and local grocery markets that have lots of gluten-free alternatives. Gluten-free bread and pizza are just passable, but Pamela’s gluten-free pancake mix is as good as any.

Eating at restaurants is tough, but some are accommodating. As I learn which places or menus are friendly to gluten-free diets, I identify them as “gluten-freendly”. Amazingly, Google currently reports no hits for the two word term, so I’ll have to start promoting it. Maybe I should add a Wikipedia article on the topic …

Most high end local restaurants are gluten-freendly in that the staff is aware of gluten and can both point out gluten-free dishes and get the kitchen to make substitutions on other dishes. The Lantern in Chapel Hill and Acme in Carrboro both fall into that category. A couple of chain restaurants that are gluten-freendly are Bonefish Grill and PF Chang’s. Both have separate gluten-free menus. Most soy sauce contains wheat, but PF Chang’s will substitute a gluten-free soy sauce; I just wish they would put a little flag or something on the gluten-free plate so I could be more confident that it’s not getting mixed up with others.

Italian is out, but Indian restaurants are fairly safe, and Mexican places usually have a couple corn tortilla dishes. They will also substitute corn tortillas in other dishes, but the ones I’ve had were smaller and too weak to hold a burrito together well.

Citysearch Math

November 24th, 2008

Ever notice that everything on Citysearch has a good rating? In scanning a few dozen ratings I have yet to find anything lower than 3.5 stars or a correlation with the rating and the review ratings. This Glass Doctor summary is typical. The average of the reviews is 2.17, but it gets 3.5 stars. Maybe there’s some hidden internal review with a heavier weight, but I haven’t been able to find any explanation at the site. All I can find is another confused user.

I thought maybe the low participation in this area was revealing some seed ratings from Citysearch, but even places with many ratings exhibit the strange math. Here’s a restaurant in Atlanta with 70 reviews averaging 3.86 but getting a full 5 stars.

The ratings don’t always go up — I found a couple of places with a one or two 5-star reviews but with 4 star ratings.

Willow 1996 - 2008

November 19th, 2008

Last week, Willow ended a brave struggle with bone cancer. She stayed active until the end, never failing to remind me when it was time to hit the trails for a walk or a swim any day I was home past 10 a.m. She is missed.

Fast Factoring for 64-bit Integers

October 19th, 2008

Some of the Project Euler problems involve factoring numbers which are either large or small depending on your perspective. Problems are generally limited to 64-bit integers (about 18 digits) which are big numbers for most of us, but in the field of factorization those numbers are terribly small compared to the 100+ digit numbers security protocols deal with. Most advanced methods deal with optimizing the factoring of those huge numbers and don’t mind significant amount of overhead, but I want to know what’s fastest for 64-bit integers.

To find out, I ran some tests on some variations on three basic, low-overhead methods: Trial Division, Fermat’s method, and Pollard’s Rho method. All of these take a long time if the number being factored is actually prime, so it’s worthwhile to add in a fourth component which is a Miller-Rabin primality check. Here are my timing results for 400,000 random 64-bit integers. Actually, only the first test uses 400,000 numbers since I limited each test to 1 hour and extrapolated beyond that.

Seconds Method
811 Rho + Trial Division + MR
6359 Fermat + Trial Division + MR
6393 Trial Division + MR after each factor found
29397 Trial Division +MR at start
71195 Trial Division without MR

I was really surprised at how well the Rho method worked in practice. It’s a probabilistic method that’s basically like trial division except it chooses numbers at random instead of sequentially. However, the “random” generator uses a polynomial such that lots of the values can be tested at once using some fancy number theory.

Fermat’s Method works best when there are two divisors near √n, which apparently doesn’t happen very often. Here is my Rho code, which is adapted from some pseudocode in a gamedev forum thread.

   long rhoFactor(long n, int c, int max) {
        int check = 10;
        long x1 = 2;
        long x2 = 4 + c;
        long range = 1;
        long product = 1;
        int terms = 0;

        for (int i = 0; i < max; i++) {
            for (int j = 0; j < range; j++) {
                x2 = (squareMod(x2, n) + c) % n;
                long next = multiplyMod(product, Math.abs(x1 - x2), n);
                if (next == 0) {
                    return Math.max(gcd(product, n), gcd(Math.abs(x1 - x2), n));
                }
                else if (++terms == check || j == range - 1) {
                    long g = gcd(next, n);
                    if (g > 1)
                        return g;
                    product = 1;
                    terms = 0;
                }
                else
                    product = next;
            }

            x1 = x2;
            range *= 2;
            for (int j = 0; j < range; j++) {
                x2 = (squareMod(x2, n) + c) % n;
            }
        }
        return 1;
    }

For the parameters, I used small odd numbers for c, the polynomial constant term, and 16 - 20 for max which limits the generated values at around 2^max. If the factorization fails, I increase c by 2 and try again. For max = 16, it failed to find a factor about once for every 10,000 numbers and never failed twice in my tests. And those numbers had already had any small factors (less than about 50,000) removed with trial division.

Obama Tie-dye

October 14th, 2008

I figured out a folding pattern to make the Obama logo in one pass. After I made the first one for Beth, I made a second batch for other friends, though I think the first one came out better. I keep thinking I know what I’m doing, but it’s hard to reproduce a tie-dye pattern. Here’s the first one on the left and one from the second batch on the right.

Now, if only I had thought of this a year ago, they’d be all over the country…

Summer of Tie-Dye

September 21st, 2008

After making a dozen or tie-dye shirts in January, I said I would have to be wearing a lot of tie-dye this summer. I can now report that that goal was accomplished. I knew I had achieved success when I had eight shirts in a load a laundry, and they were all tie-dye. Twice, I think, I managed nine days in a row of the custom shirts. Next summer’s goal will be ten days in a row.

I also made more shirts over the summer, including some superhero shirts, which I’ve sold a few of. I still haven’t got the Superman S quite right, but the Batman shirts have come out well.

Unsophisticated Art Review: 10 by 10

July 22nd, 2008

I imagine a lot of art pieces start with a single good idea and get expanded with supporting content that isn’t as good as the original idea. In the “10 by 10″ format, each of the ten plays is only ten minutes long, so there’s no time for supporting content — you just get the good idea. It seemed like that way at the Ten by Ten in the Triangle show we saw at the Carrboro Arts Center last week.

Technically, most of the plays ran a few minutes more than ten minutes, but no one was complaining as the quality was good throughout. The entire show of ten plays and intermission took 150 minutes. The set changes between plays was very fast, often less than a minute when they just had to move a couple of chairs. The minimal sets did forgo the extra dimension of set design in the presentation.

Speed Mating was probably my favorite. Written by a mathematician, it featured four cicadas in their brief emergence to mate after 17 years underground. The actors made the most of their wings and bug eyes to capture the stages of cicada activity.

Dead Cat was also notable just because it seemed like an exercise in how much can we put into a ten minute play. Narration was mixed with “live” scenes and flashbacks. It all went together seamlessly, but I don’t remember the message.