Each one had six wings; with twain he covered his face, and with twain he covered his feet, and with twain he did fly.

Posted in Uncategorized by Mike Stay on 2019 April 28

All insects have two pairs of wings, sprouting from the second and third segment of the thorax.  Even insects that appear to have only one pair, like flies and beetles, really have two: in flies, the second pair of wings diminished to new structures called halteres, while in beetles, the first pair became the elytra. In cockroaches and bugs, the first pair only got halfway to elytra and are called hemelytra.

But!  A 2011 paper in Nature gives morphological and genetic evidence that the helmet of treehoppers is derived from third pair of wing buds on the first segment.  Hox genes have suppressed wing expression on every segment but 2 and 3 for 300 million years. Hox genes control repetition of certain body parts.  They are very strongly preserved, since they govern the gross body plan of a creature—in humans, for instance, they control how many vertebrae we have.  The authors suspected that the treehopper hox gene no longer suppressed production on the first gene and inserted it into drosophila flies to see if wing primordia formed, but they didn’t.  So somehow, despite the hox genes being preserved, treehoppers found a way around the inhibition of wing production and were able to evolve their fantastic helmets.


More coverage here.


TIL: Till is not a shortening of until

Posted in Uncategorized by Mike Stay on 2019 April 26

‘Til is a corruption of till under the assumption that it is a shortening of until, but till is, in fact, an older word than until.  Both till and until mean the same thing.

Journey to the black hole at the center of the galaxy

Posted in Uncategorized by Mike Stay on 2019 April 24

Here’s some context for the recent black hole image.

Shock diamonds and aerospikes

Posted in Uncategorized by Mike Stay on 2019 April 23

I was curious what caused the oscillations in rocket exhaust.  I learned they’re called “shock diamonds”, among other names, and are due to the lateral pressure of the exhaust being mismatched with the atmospheric pressure.  At low altitudes / high pressure, the exhaust is immediately pinched and then bounces off itself as the pressure increases, then becomes repinched as it expands again.  At high altitudes / low pressure, the exhaust expands first, then gets pinched at the lower pressure.  The bell-style rocket only has its maximum efficiency at one specific altitude; this is one reason for multistage rockets.


There’s a rocket design called an aerospike that effectively uses air for half the bell and then controls the flow to match the air pressure.  It’s more efficient, but has had bad luck as far as deployment goes.  Since fuel is about the cheapest part of a rocket, new space companies have opted for using known, proven designs instead.  This is a good video about the history and development of the aerospike.

While looking for the explanation, I came across this wonderful paper that examines what happens when two laminar flows collide.  Depending on the viscosity, surface tension, and velocity of the streams, you get several different “phases” of interaction.

Screen Shot 2019-04-23 at 1.46.24 PM.png

A modest proposal for overloading arithmetic operators in JavaScript

Posted in Uncategorized by Mike Stay on 2019 April 19

Bignum usage:

var x, y;
with(BN) {
  y = L5;
  x = BN()(L282376418273964982736149872 * L29618763948127639 - y);
console.log('' + x);
// 8.363640477374324661331988841549874089512203e42

Complex usage:

console.log(Complex()({r:2, i:0} / {r:1, i:1} + {r:-3, i:2}))
// {r:-2, i:1}


Note that JavaScript does not support overloading operators in the same way as C++, but here they work fine.  Note also that it would be easy to write something like eval(translateToJS(myDSLstring)), but here I’m using raw JavaScript arithmetic operators on objects, something that usually just gets you concatenations of “NaN” and “[object Object]”.

The setup for operator overloading enumerates all expressions involving the binary operations +, -, *, / with up to five variables indexed from left to right.  It calls Math.random() five times and stores the results in a list R.  It substitutes the nth random number for the nth variable in the expressions, then stores the expression under the result in a table.  Real numbers chosen uniformly at random in [0,1) are transcendental with probability 1 and therefore satisfy no algebraic equation; while we don’t have transcendentals, the number of bits in an IEEE 754 double easily suffices to distinguish the set of expressions we want to handle.

BN is a Proxy object with a get handler that returns, for any property beginning with ‘L’, a Bignum object from your favorite bignum library encoding the rest of the property name as its value.  BN temporarily replaces Bignum.prototype.valueOf so that it pushes “this” onto a list V and returns the corresponding random number at the same index from the list R.  The function BN() looks up the appropriate expression in the table, gets the actual values from V and returns the evaluation of the expression with the variables bound to the values, emptying the list V and replacing the original valueOf before returning.

Complex() replaces the Object.prototype.valueOf with one that does the right thing with an object like {r:-5, i:-3}.  It’s also straightforward to implement automatic differentiation in a similar way.

We don’t necessarily need to stick to mere objects; we can even do things like monadic bind by replacing Function.prototype.valueOf.

Current developers are sadly undereducated in the fantastic tools that JavaScript provides for enriching the lives of future developers tasked with maintaining their code.  I encourage everyone to make broader use of them.

The interesting code starts at line 956.
Start at line 1044 to see how to define your own overloadings.

The “valueOf pushes objects into a list” trick for operator overloading came from Brian McKenna’s Bilby functional library, but it only allowed a single kind of operator in an expression: when applied to two functions, >= returns true, > returns 0, * returns NaN, and + returns a string (the concatenation of their sourcecode). I came up with the “enumerate expressions and store them under the result of evaluating them on transcendental numbers” trick to allow multiple operators and the “proxy handler to parse the identifier and construct an object” trick.

The modern Sisyphus

Posted in Uncategorized by Mike Stay on 2019 April 3

Lightfield 3d photos from an inkjet!

Posted in Uncategorized by Mike Stay on 2019 April 3

Lumii uses multilayer Moire patterns to simulate lightfields.  You print out the layers on a regular transparency from an inkjet printer!

Amazing water spout photo

Posted in Uncategorized by Mike Stay on 2019 April 3

(Found on Reddit)

Fantastic fossil find from dinosaur killer asteroid

Posted in Uncategorized by Mike Stay on 2019 April 3

Seismic waves from the Chicxulub impact set up enormous standing waves in a large inland sea in North Dakota.  The waves hit the mouth of an incoming river, which focused the waves into a 30 foot wall of water that knocked down trees and put fish next to triceratops and hadrosaurs in the fossil bed.  The fish’s gills were also clogged with tektites, ejecta from the impact made of hot glass spherules that set the world’s forests on fire.

Seismic metamaterials can “cloak” buildings

Posted in Uncategorized by Mike Stay on 2019 April 2