Posts

Externalities

I got The Age of Turbulence for Christmas. Very interesting so far, especially to read with hindsight given recent history. This passage is fascinating: “…According to objectivist precepts, taxation was immoral because it allowed for government appropriation of private property by force. Yet if taxation was wrong, how could you reliably finance the essential functions of government, including the protection of individuals’ rights through police power? The Randian answer, that those who rationally saw the need for government would contribute voluntarily, was inadequate.

Sieving Primes 2

Success! I found a reference to Mertens’ theorem in a paper by Adam Kalai, which is exactly what I needed to analyze the complexity of the prime sieve from the previous post. Alas, my previous complexity guess was wrong. The actual complexity is $O(n^{3/2} / \log^3 n)$. Apparently my numerical estimates didn’t go out far enough (also I was biased towards finding $O(n \log^m n)$). From before, the cost of the algorithm is $O(C(n))$ where $$C(n) = \sum_{c \lt n} \pi(lpf(c ))$$ where $c \lt n$ means all composite numbers up to $n$.

Rmvng ll vwls

whl g w wr dscssng th vrs trnsfrmtns y cn pply t txt wtht mkng t nrdbl. Fr xmpl, sm t rcll xmpls shwng tht txt wth ll bt th frst nd lst lttr f ch wrd rrrngd s stll rdbl. Smn ls rclld sng rdbl xmpl wth ll vwls rmvd, bt thght t mght hv bn spclly cnstrctd fr tht prps. Thrfr, md nt t try strppng th vwls t f lrg blck f txt.

Sieving Primes

Here’s an interesting lazy variant of the sieve of Eratosthenes by Nick Chapman, from a discussion on LTU: primes = 2 : diff [3..] (composites primes) composites (p:ps) = cs where cs = (pp) : merge (map (p) (merge ps cs)) (composites ps) merge (x:xs) (y:ys) | xy = diff (x:xs) ys In words, the algorithm computes the list of primes as all numbers which are not composites, and the computes the list of composites by extremely constructing and merging all prime factorizations.

Public domain

I found a rather spectacular article on copyright while reading about the [Copyright Term Extension Act] 1: Scott M. Martin, “The Mythology of the Public Domain: Exploring the Myths Behind Attacks on the Duration of Copyright Protection”, Sep 24, 2002. There’s no shortage of absurdity, but here’s one of the highlights: Copyright Encourages, While the Public Domain Discourages, Progress in the Arts At the risk of speaking words of heresy, it is copyright protection that encourages innovation and creativity, while the public domain discourages both innovation and creativity.

Christmas Tree

This is pretty sweet. It took me a bit to register that this was a real picture and not a photoshop trick. Nicely done, Mom. In the past we’ve always picked a tree the correct way, by searching through the woods and cutting one down (one year the tree was the top of a large tree removed from the edge of the yard). Mom claims we’ll fix it, but if we have to resort to buying one to do that the virtual tree might be a cooler alternative.

Visualizing collisions

We added visualization of collisions to physbam’s opengl viewer for the high resolution cloth paper. These turn out to be one of the prettiest things it generates. Here are screenshots of edge-edge collision pairs (two edges colliding) and point-face collision pairs (a point colliding with a face) for a scene with a bunch of soft deformable objects:

Never do this

Here’s a snippet of code to sneak into someone’s .pythonrc if you want them to hate you:

    import sys
    from numpy import *

    class Evil:
        size = array(1).itemsize
        __array_interface__ = {
            'shape' : (1,),
            'typestr' : '<i%d'%size,
            'data' : (id(1)+2*size, 0) }

    asarray(Evil())[0] = 2
    assert 1 == 2

It’s even platform independent! (Note: it will be less innocuous if the class isn’t named Evil.)

Balancing circles

After extensive testing with glasses of water, I’ve determined that it’s impossible to stably balance one infinitely thin circle on top of another. This is true whether the circles are the same size or different, and does not depend on the mass distribution of the circles. This is because two circles intersect at either zero or two points (unless they are the same, and that still isn’t a stable configuration).

Hydrogen to electricity?

Here’s a good candidate for the silliest energy idea I’ve heard in a while: http://www.ted.com/index.php/talks/reinventing_the_car.html Larry Burns, the vice president for R&D; at GM, notes that 4% of cars equal the power generation ability of the entire current electric grid, and dreams of a future where fuel cell vehicles are used to generate electricity while parked. This is great because hydrogen can come from a wide variety of sources, so as long as each community has their own tailor-made method for generating it, we can use the cars to cheaply generate electricity.