Thursday, November 29, 2018


Canvas not supported; please update your browser.

log(Temperature) =

Energy =

This little project is based on Dan Schroeder's Ising Model animation.

The way this kind of simulation works is that cells in the array are considered one by one. At a particular cell, alternative configurations are examined and one configuration is selected to be newly assigned to the cell. Each possible configuration, or value of the order parameter, will have an energy which is determined by the configurations of the neighboring cells. The new configuration is picked at random, with a bias toward lower energy configurations. The lower the temperature, the stronger the bias.

One of the tricky parts about this kind of simulation: when the order parameter is continuous, it's hard to come up with a good set of alternative values. The full set of alternatives is huge, practically infinite. Some small sample needs to be used. The small sample needs to include some configurations whose energy is at least not too much worse than the existing configuration, or the simulation won't have a good alternative to assign to the cell. At high temperatures, suitable alternatives can be substantially worse. At low temperatures, the alternatives can only be slightly worse. Thus, the temperature determines what makes a good set of alternatives. Trying to figure out that relationship ahead of time is too complicated, so an adaptive approach is suitable.

What I do in this simulation is to consider alternatives one by one. The first alternative is chosen at random at random from the full set. Each next alternative is chosen from those that are within some range of the currently assigned configuration. As each configuration is chosen, a decision is made whether to assign that to the cell in place of the current configuration. As soon as a new configuration is assigned, the simulation moves on to look at other cells. When an alternative is not assigned, another alternative is chosen from a narrower range. The range from which alternatives are picked gets narrower and narrower with each iteration. Eventually the alternatives are so close to the current assignment that the odds of being assigned become 50/50. This narrowing range iteration provides an adaptive approach to picking a set of alternative configurations.

Wednesday, November 28, 2018


Left Side Offset:

Left Side Direction:

Right Side Offset:

Right Side Direction:

Canvas not supported; please update your browser.

Interaction Energy =

The foundation for the dynamics of a system is the way the components interact. The "wrinkles" system that I am exploring is a two dimensional array of cells. Each cell interacts with its four neighbors. The state of each cell is given by a direction and an offset. These change over time. In the thermodynamic simulation that I am building, a cell will tend to change so its direction and offset are similar to those of its neighbors.

Handling the offset gets tricky. The idea is that the dark and light strips should line up on the boundary between neighboring cells. If the cells have the same direction, the offsets should simply match. But when the cells have different directions, it gets messy!

What I'm doing to manage this is to look solely at the midpoint of the edge that forms the boundary between two neighboring cells. The offsets are close if the stripes fit together at that midpoint.

There is some topological strangeness here. The light and dark stripes have a symmetry: if you turn them upside-down, the result is the same pattern as where you started. But at the two extremes of cell direction, increasing offset will move the stripes in the opposite direction. Changing the direction rotates the stripes: every 180 degree brings the stripes back to where they were. Similarly, changing the offset enough will move the stripes back to where they started. So the topology of these two parameters together forms a kind of torus. But because the direction of offset is reversed after a 180 degree change of direction, the topology is actually that of a Klein bottle. This topology is what allows an array such as:

Monday, November 26, 2018

Order Parameter

My plan is currently to develop an animation for the "wrinkles" simulation I built a while back. Mostly it's a matter of translating C# into javascript. But I'll develop it in stages, from the ground up. That'll give me an opportunity to explain the bits and pieces which will also work as a kind of unit test.

Canvas not supported; please update your browser.



Quite a blast, huh?! I am using Dan Schroeder's tutorial to figure this stuff out!

In case anybody else wants to play like this in blogger... I am not entirely sure, but it seems like variables are shared across scripts, across posts. The code I put in one post interacts with the code I put in other posts. So far I am managing this by making lots of new variable names. Maybe there is a better way, but I don't really plan to take this little project very far anyway!

Sunday, November 25, 2018


Maybe the time has finally come to learn javascript! Take a look at Dan Schroeder's Ising Model!

Just too much fun! Step 1: just get javascript to work here!

Canvas not supported; please update your browser.

That little red dot doesn't look like much, but.... if you search on how to put javascript into a blogger post, you can find quite a bit of complicated advice. After trying a lot of it, I just did the simplest thing that I was repeatedly warned wouldn't work - I just put the javascript in my post! Look! A red dot!

Sunday, September 2, 2018

Capital Gains Indexing

I have seen reports that the President is considering changing the accounting of capital gains for tax purposes, adjusting the cost basis to reflect inflation. This would of course reduce the gain, and thus reduce the tax. Since almost all capital gains are earned by the very wealthy, and those taxes therefore paid by the very wealthy, this would be be a dramatic tax cut for the wealthy. These days the old maxim, the rich get richer, is as true as ever, so it would seem that such a tax cut is not at all appropriate.

However, it would be very simple, from an accounting perspective, to adjust for inflation in capital gains taxation in a revenue-neutral way. Of course, a change in tax accounting will change behavior, so precise revenue neutrality is too much to expect. But the resulting change in behavior should have great benefit to the economy and society. Short term capital gains are earned largely through speculation, taking advantage of price fluctuations. Long term capital gains are earned through investment, where the growth in underlying value is the primary determinant. This growth in underlying value is what benefits society. The tax code should encourage long term investment. Long term capital gains should be taxed at a lower rate than short term capital gains. This would be the effect of adjusting the basis to reflect inflation. Simply increasing the tax rate on capital gains could easily make the new accounting revenue neutral.

A parallel accounting adjustment would help the middle class. Interest earned should be corrected for inflation. When inflation is running at say 2% while bank savings accounts are paying 0.1%, perhaps the smart move would be to make the 1.9% loss a tax deduction. This would encourage savings and help middle class families build nest eggs.

Thursday, June 7, 2018

Seventh Chords

What are seventh chords? Chords that contain the seventh note in a scale starting from the root of the chord! That's not a very practical answer, though, when experimenting with microtonality, where scales are not clearly defined. Here is an alternate definition: a seventh chord is a four note chord constructed by stacking thirds. The root note is the foundation. The next note is a third above the root. Another third above that is some sort of fifth note. Another third above that is some sort of seventh note. Typically the interval of a third is composed of two steps of a scale. So a seventh chord looks like 1-3-5-7 in terms of steps of a scale. But intervals are more fundamental than scales. The notion of a sequence of three intervals, each a third, makes sense even without any scale.

There are two different intervals of a third: a major third and a minor third. This gives eight different types of seventh chords, built from sequences of these different thirds, e.g. major-major-major, major-major-minor, major-minor-major, etc.

To find out how these seventh chords sound in the microtonal system where an octave is divided into 53 equal steps (rather than the conventional 12 steps), I wrote a little program that uses simulated annealing to construct a fractal pattern near a phase transition. The program builds a 12x12x12 toroidal mesh and places a seventh chord at each vertex. The total number of possible chords is 8x53=424. Each vertex can have any one of these 424 chords. Chords at neighboring vertices are probabilistically selected to be similar to each other. Chords are more similar the more notes they have in common.

The result, so far at least, is not very musical! But it's a lot of seventh chords! 1728 sevenths

Wednesday, February 21, 2018

Good and Evil

Some years ago I was on an airplane and sat next to a person who was a life coach of some kind. I think we could all use a bit of help in leading better lives, so I was keen to find out what kind of approaches she used. I don’t remember exactly what I was struggling with myself at that time, but I asked this life coach how she helped people think through ethical dilemmas, situations where it was difficult to see which action was best.

This life coach said that she really didn’t think there was any such thing as an ethical dilemma. A good person would just know in their heart what the right thing to do would be. If a person doesn’t know right from wrong, then coaching isn’t going to help them anyway.

I was completely shocked by this answer. The idea that some people just inherently know the right thing to do where other people don’t… the idea that in the real world there is generally a choice between a right thing versus a wrong thing, rather than a choice where every option available has negative aspects… these ideas strike me as so utterly simplistic! And this woman was a life coach! These were the ideas she was encouraging in her clients. I have to admit, I let her know that I thought her approach to ethics was na├»ve to the point of being delusory and destructive. We did not disembark that flight with warm friendly feelings!

This idea, that people can be divided neatly into good people and not-good people, clearly has well established roots in American culture. It has roots in Calvin’s theology and the Puritans, the folks who came over on the Mayflower. This idea seems to be alive and well today. I hear strong echoes of it when I hear gun advocates contrasting law-abiding citizens versus criminals.

Recognizing the Puritan roots of today’s political conflicts certainly doesn’t solve any problems. John Calvin was no fool. I suspect one difficulty is that his theology was too subtle for most of his followers, so what we’re stuck with is a crude distortion. Perhaps some kind of return to Calvin, learning to dig deeper into his ideas, could be a way to help folks out of their simplistic Manichean trap. Anyway, I hope that a more accurate diagnosis of the problem can help lead us into a healthier way of living.