Wednesday, March 13, 2024

Finding the Phase Transition

I've been using an algorithmic approach to music composition, based on thermodynamic simulation. One advantage of an algorithmic approach is its generality. One can use the same software to generate music in a wide variety of tuning systems. Other parameters can be adjusted easily, too. Of course, no algorithm is likely to generate music of the quality that a skilled human composer could produce. On the other hand, there can be some value to music that is outside the usual patterns.

These days a different algorithmic approach to composition has gained some traction, an approach that works with a large number of existing compositions, extracts some patterns, and then follows these patterns to generate a new composition that sounds much like the existing compositions. Just to be clear, the approach I am using does not use existing compositions in the execution of the software. I listen to a lot of music, and I listen to the output of my software; I tweak my software in an effort to coax it into producing something as music-like as I can. But this is a long way from the Deep Learning methods of the predominant Artificial Intelligence software.

Thermodynamic simulation is a randomized process that repeatedly adjusts the values of a large number of inter-related variables. The variables are connected in some kind of network, that defines the interactions between the variables. In my music composition software, the variables are the pitches of what is to be played at each particular time by each particular voice. When a voice is to sound a pitch at one time and then a second pitch at a succeeding time, these pitches should be nicely related if the music is to sound good. The pitches should not be too far apart, and should be reasonably consonant. Similarly, if one voice is sounding one pitch, and another voice is sounding another pitch at the same time, these two pitches need to be consonant if the music is to sound good.

If a piece is ten minutes long, each voice might involve a thousand pitch choices. During the simulation, all of these choices have provisional pitch values. Again and again, one or another of these choices is selected at random, and then the pitch selection for that specific time is reevaluated, in the context of the provisional choices in place for what that voice is to sound before and after, etc. The software will choose a new pitch for that voice at that time, preferring pitches that are consonant with the other pitch choices nearby in space and time. Then some other voice and time will have its pitch reevaluated. Over the course of the composition process, each pitch will change hundreds of times. Other related pitches will have changed between one evaluation and the next, so which pitch is most consonant may well change over the course of the simulation.

Thermodynamic simulation is driven by a key parameter, the temperature. At high temperature, the preference for consonant pitches is not very strong. At low temperature, only the most consonant pitches will be assigned. At very high temperature, the simulation will assign pitches essentially at random, so the music will be pure noise. At very low temperature the simulation will strive to maximize consonance. But if the pitches are initially very random and then the simulation is run at very low temperature, very often it will happen that in evaluating the best pitch for a particular voice at a particular time, the related pitches don't pull in a consistent direction. One pitch choice will be consonant with some neighbors but dissonant with others. There will often be no choice that is consonant with all the nearby pitches.

The way to generate pitch assignments that are mutually consonant throughout the network is to start the simulation at a high temperature and then to slowly lower the temperature. Each pitch selection provides some communication between more remote regions of the composition. The entire system can eventually negotiate mutually agreeable pitch choices in this way.

Thermodynamic simulation thus has the capability of generating pure noise at high temperature and pure order at low temperature. Neither of these makes interesting music: either extreme is quite dull! Interesting music happens in the region between total noise and total order.

The fascinating thing about this kind of thermodynamic system, whether simulated or in real physical systems, is that the transition between order and disorder is often not smooth and gradual, but can be quite abrupt. Right at the boundary between the ordered phase and the disordered phase, the system can exhibit fractal fluctuations as it wavers between the behaviors of the different phases. Fractal fluctuations are a characteristic of interesting music. So the approach I generally use for generating interesting music with thermodynamic simulation is to set the temperature to where the phase transition happens and make the pitch choices at that temperature, where consonant choices are preferred but not too strongly.

One challenge with this approach is that the temperature at which the phase transition happens is not something one can calculate in any simple way. One is basically stuck with simulating the system at different temperatures, observing its behaviors, and identifying an abupt shift. That's what the graph at the top of this post illustrates. At each temperature, the system will settle into an overall level of consonance, which corresponds to energy in thermodynamics. A highly consonant system has very low energy; a highly dissonant system has very high energy.

The graph above has a clear enough abrupt shift at a temperature of around 380. There is a sudden drop in the energy with a small change in the temperature. Locating this sudden drop is a bit tricky though, because of the random nature of the simulation. The energy is always bouncing around even at a fixed temperature. What I do to filter out this randomness is to fit a smooth curve through each small family of temperature and energy measurements. Then I look for which such small curve shows the most abrupt change in energy over a small change in temperature. That tells me the temperature of the phase transition.

Once the temperature of the phase transition has been determined, I can set the simulation temperature to that value and let the simulation run so all the pitch choices come to reflect that boundary behavior, to exhibit fractal fluctuations.

Here are two pieces generated using this approach:

Thursday, February 29, 2024

A Tale of Two Unconventional Tunings

Nowadays the notes available on a conventional piano, seven white keys and five black keys per octave, form the building blocks for almost all the music in circulation. And of course these building blocks have been very effective at enabling the crafting of a vast treasure chest of music, diverse, profound, and beautiful. And yet, there is value in exploring other tuning systems.
  • Around the world, there are still many different traditional tuning systems in use.
  • Tuning systems evolved over the centuries in Europe, only settling on the present convention some two centuries ago.
  • Different tuning systems enable different musical structures; they are a rich compositional resource.
  • Conventional tuning can be better understood in perspective, as being one alternative among many.

One could spend a lifetime learning about different tuning systems, their histories and features etc. But sometimes when encountering a large building it can be difficult to find an entrance! Recently I have been exploring the tuning system that divides octaves into fifty equal intervals, rather than the conventional twelve. Dividing octaves into fifty three equal intervals is another useful tuning. The sizes of the intervals in these two tunings is not very different, yet the tunings have quite different strengths. Comparing these two systems could work as a doorway into the world of alternate tunings.

A general foundation for tuning theory is the observation that two pitches sound consonant when the ratio between their frequencies is a simple rational fraction. For example, the A above middle C is conventionally tuned to 440 Hertz. The next higher A, an octave higher, is at 880 Hz, a ratio of 2:1. If one tunes the E in between to 660 Hz, it will sound very nicely consonant with either of the As, with ratios of a perfect fifth, 3:2, or a perfect fourth, 4:3. Tuning the C# to 550 Hz will complete a consonant major triad. The interval from the A of 440 Hz and the C# of 550 Hz is a major third, with a frequency ratio of 5:4. The interval from the C# of 550 Hz to the E of 660 Hz is a minor third, with frequency ratio 6:5.

The pitches involved in a piece of music form a network. Each pitch is related to several other pitches, and these related pitchs then relate to yet other pitches. Pitches are thus related by chains of simple intervals. The whole pitch space forms a kind of network. If the simple relationships are built from the consonant relationships of fifths and thirds described above, the network of pitches will look something like this:

These pitches are all inside a single octave range - the network could be replicated in as many octaves as needed. The network can also be extended arbitrarily in any and all directions.

While one can make perfectly good music with a tuning system like this, with very precisely consonant frequency ratios, it does run into difficulties. As the network is extended, each octave gets broken up more and more finely, without limit. It's hard to build instruments that can play so many notes, hard for players to hit the right notes, and hard for listeners to distinguish among so many notes. Over the centuries, musicians, composers, and instrument builders have developed simpler tuning systems that approximate these ideal intervals while avoiding the infinite division problem. And then music has evolved to take advantage of opportunities these simpler tuning systems provide for harmonic movement. A tuning system is a network of pitches with a particular shape. Music is then a kind of dance that moves around through that shape.

The fine divisions brought about by precise consonance first arise with the 81:80 pitch on the right column of the tuning network above. It is very difficult to distinguish that from the 1:1 in the center. So the first tuning simplification is to adjust the pitches in the network somehow so that 81:80 is changed back to 1:1. This changes the shape of the tuning network from a flat plane to a cylinder. If one travels in a suitable constant direction on the surface of a cylinder, one can end up back where one started.

There are many ways to adjust the pitches in the network so the 81:80 is flattened slightly to become 1:1, but in general this tuning system is known as meantone. The way pitches are named in European music is a reflection of the meantone system:

While this system does allow unbounded movement, that movement needs to flow around the cylinder, along the diagonal strip where the sharps and flats don't get too wild. Old keyboard instruments sometimes have extra black keys to accommodate a wider range of movement, but still, it can be challenging to dance freely when there is an abrupt edge that one must steer away from. So the next step of evolution is to wrap the cylinder into a torus:

If one moves a perfect fifth from G#, one arrives at Eb. The network of pitches has been tweaked somehow so that D# and Eb are the same pitch. There are various ways to do this, but the simplest way is to adjust all the fiths and thirds in the same way, so the system is totally uniform. This is our conventional tuning of today.

To review the development so far: A network of precise consonances splinters the pitch space to an impractical unbounded extent. Adjusting, or tempering, the intervals allow the network to wrap back on itself, so the number of pitches required can be limited.

Fundamentally, a tuning system is a compromise between simplicity and precision. But tuning must serve music. The shape of the tuning network enables some kinds of harmonic movement but prevents other sorts. Music and tuning evolve in response to each other, meeting each other's demands and taking advantage of each other's opportunities.

One can build a tuning system by dividing octaves into equal intervals of any number. A good tuning system will provide intervals that are close approximations of the precise consonances of 3:2 and 5:4. Dividing octaves into 50 or 53 equal parts will provide reasonable approximations:

This table gives the error, in cents, for each tuning system for each consonant interval. One can see that the conventional tuning system has somewhat large errors for several intervals, though it comes quite close for 3:2. The 53 steps per octave system is quite accurate for all the intervals. The 50 step system is not so good for 3:2, but it is at least better than conventional tuning for the thirds 5:4 and 6:5.

It might seem that, since 53 steps per octave is only slightly more than 50 steps per octave, and provides a significant improvement in precision, that the 50 step per octave system is not very useful. But beyond simplicity and precision, one must look at the shape of the tuning network:

The bright blue highlighted cells marked "0" show the way the torus is wrapped back on itself. Those closely spaced "0" cells along a line sloping slightly down to the right, those cells are wrapped in exactly the way that the meantone tuning system is wrapped. What this means is that most any music written for the meantone system will be playable in the 50 step per octave system. The 50 step system will support even triple sharps and triple flats. It would be a rare piece of music that requires more sharps and flats than that!

The 53 step per octave system has a very different shape:

The pattern of repeated cells, the way the tuning torus is wrapped, does not match the meantone system at all. Music written in the meantone system will fail to return or connect back properly if one tries to play it in the 53 step system.

I have been exploring some of the unconventional musical possibilities of these two tuning systems. For each, I picked a subset of the available pitches to work as a scale. In both systems I built the scale to form a path from lower left to upper right, which is, roughly speaking, a chromatic scale. I then used my algorithmic composition software to generate some music that would flow with the shapes of the scales:

Sunday, April 23, 2023

The Disintegration of Science

In the 1990s, the science wars were fought between advocates of science and folks who saw flaws in science. Nowadays, the science wars underway are between folks claiming scientific support for wildly differing claims. Does our global use of fossil fuels for energy have significant impact on the climate? Are covid vaccines safe and effective? Of course scientific progress is driven by debate, so perhaps these disagreements are healthy.

A healthy organism is constantly fighting off infections and other disturbances. The integrity of an organism is constantly under threat. For a while, various homeostatic processes manage to preserve that integrity, but eventually those processes are overwhelmed, and the organism loses its integrity. Sometimes this lack of integrity means the death of the organism, but it can also mean division into multiple separate organisms. Presevation of integrity and subsequent loss of integrity can happen at many scales, from single cells to cell colonies to insect colonies to human societies.

Science nowadays, for the most part, maintains a very healthy level of integrity. A key component of this integrity is the vision of scientific knowledge as a coherent whole. All the bits and pieces of our scientific knowledge fit together somehow, or eventually will. We're always discovering inconsistencies, but our processes of research and mutual critique keep these inconsistencies under sufficient control that the overall integrity of the system is not under threat. The loud arguments over e.g. climate change are a sore point, but they are certainly at a small enough scale not to threaten the entire system.

And yet... these superficial rashes could be symptoms of a larger systemic problem. Is the rough coherence of scientific knowledge something inevitable? What processes maintain this coherence? What could threaten this coherence?

The coherence of science is maintained by a kind of circulatory system. Information circulates: researchers publish papers but also exchange preliminary results, critiques of draft versions of papers, and also text books and other coordinated summaries of scientific knowledge. People circulate: researchers meet to discuss their work, but also visit each other's laboratories to collaborate on research. Students are trained in one research organization and then get hired to work in other research organizations. Equipment and materials circulate: measuring devices can be calibrated to common standards. Experimental samples are exchanged between laboratories.

What would precipitate the disintegration of science would be the breakdown of this circulatory system. Circulation is supported by the larger social context. Freedom of the press allows research results to be published. Freedom of travel allows people to collaborate. Free trade enables the exchange of equipment and materials.

These freedoms are the hallmarks of liberal society. Science and liberal society have emerged together since early modern times. A free market of ideas allows the best ideas to emerge. Basing policy on effective ideas leads to success and growth, to progress. This progress provides a platform for further exploration, leading to better ideas, more effective policies, and further growth. We have been riding this feedback loop for four hundred years. It's not just science that is coherent, but our global society.

The general pattern in biological systems is that growth is followed by decline. Perhaps this time it will be different, but that is a position that requires a lot of faith! Just as science, liberalism, and progress supported each other in a feedback loop of expansion, there are signs that the same feedback loop may be picking up momentum in the direction of decline.

Of course one can pick a measure of prosperity to support whatever argument one wishes to advance. But it really seems like the financial crash of 2008 is one we have not really recovered from. The rise of vehement anti-liberalism is largely driven by the failure of liberalism. We were promised progress but that is not what we are experiencing. The underlying cause for the lack of progress is probably our reaching various ecological limits, but that's not a message that sells. Science and liberalism have built their castles on progress. As progress falters, so will liberalism, and so will science. Liberalism maintained the circulatory system on which scientific coherence depended.

Of course change is the nature of things. How science might best maintain itself in a new dark age, that is one worthy puzzle. It is valuable to step back a bit, to try to think strategically. How things will unfold in the coming decades and centuries, it is impossible to foresee with any accuracy. What is more feasible is to consider a range of possible trajectories, and to prepare responses across some plausible range. Insurance policies, diversified portfolios, hedged bets: these are effective approaches to dealing with uncertainty. We need to bring these approaches into our investments in scientific research programs.

Thursday, March 30, 2023

Heat Pump Efficiency

Thermodynamics is a fundamental branch of physics. It gets a bit subtle: I find myself getting tripped up often enough!

The cornerstone of thermodynamics is the Carnot cycle, an ideal process for converting heat to work. It's a model for what steam engines do, for example. The Carnot cycle sets a limit on how efficient an engine can be: it is not possible to convert all the energy from heat to mechanical work.

A heat pump is simply an engine running backwards. An engine has heat flowing from a hot reservoir to a cold reservoir, converting some of that heat to mechanical work. A heat pump uses mechanical work to push heat from a cold reservoir to a hot reservoir. The amount of heat added to the hot reservoir will be the sum of the energy from the work and the heat energy removed from the cold reservoir.

To heat a home, one can use a natural gas furnace, or one can use a heat pump. The heat pump runs off electricity, much of which is generated from an engine running off natural gas. Energy is lost when the natural gas heat energy is converted to electricity, but then energy is gained when the electricity is used to heat the home. Since the heat pump is just an engine running backwards, these losses and gains are in some sense reflections of each other, and might seem to cancel out. But they don't!

The missing detail is that there are three heat reservoirs involved. The engine at the utility power generation plant has energy flowing from a furnace to the environment, converting some of that to electrical energy. The heat pump has energy flowing from the environment to the interior living space, driving that with electrical energy:

The two efficiency factors have inverse forms, but the numbers involved are different, so they don't cancel each other.

Plugging in some roughly plausible numbers, a graph can be generated for maximum effiency of the overall system as a function of the outside temperature. As the outside temperature warms to near the interior living space temperature, the round trip efficiency increases without bound. At cold temperatures, the utility's power generation engine can run more efficiently, but the reduction in effectiveness of the heat pump is more dramatic, so the overall effiency is reduced.

Friday, March 24, 2023

Aperiodic Tiling

I've been seeing reports of an aperiodic tiling. At first, I couldn't imagine how a tiling could be aperiodic. Now the pendulum has swung to the other extreme, where it seems trivial:

The tile is just a 1x2 rectangle. Mostly they are all placed vertically, but there is a line along which horizontal tiles are placed. One could interpret the pattern of absence or presence of a horizontal tile in the sequence of columns as expressing a fraction in base 2. If the fraction is irrational, the pattern will be aperiodic. Hmmm, even if there was just one horizontal tile in the middle, the pattern would be aperiodic!

There must be some trickier definition in play, of what aperiodic means. But anyway, now it doesn't seem so impossible!

Friday, March 17, 2023

Scientific Equipment

Galileo did not invent the telescope. Galileo looked at the night sky with a telescope that someone else built. Scientists do sometimes invent and build the equipment they need, but in general scientists take advantage of existing equipment to enable them to do science. Science is not a free-standing activity; it is an integral part of a much larger world. Science uses its connections with the world, just as the world uses science.

This relationship of mutual use creates a self-reinforcing feedback loop. Scientific discoveries enable new equipment to be constructed, and new equipment enables yet further scientific discoveries. The astounding technological capabilities of our time are the fruit of this system. However, the system is more complex. Our global-scale industry has global-scale impact on the environment. Climate change may be the most immediate concern, but we are seeing many other effects too. It is of course difficult to predict exactly how environmental limits will impace the availability of scientific equipment. But a starting point would be a reflection on the variety of ways that science uses what the world makes available.

Instruments with which to observe and measure natural phenomena are surely at the head of the list. Nowadays we have telescopes in orbit, detecting a wide range of electromagnetic frequencies: not just in orbit around earth, but around other planets too. And we have robots on the surface of Mars, observing at close range. At the tiniest scale we have particle accelerators and electron microscopes. Chromotography, spectroscopy, magnetic resonance imagery... a catalog of today's observation and measurement equipment would fill an encyclopedia.

Another way that science uses what industry provides is the acquisition of raw materials. All kinds of very pure simple and complex substances are available. There is also a rich variety of materials processing equipment by which raw materials can be processed to form both experimental samples and also custom observational devices. Vacuum pumps are a curious sort of equipment, since their function is to remove material rather than to supply it. But vacuum pumps are fundamental to preparing a suitable environment for observations, back to the time of Boyle at the birth of modern science.

Recording experimental observations can rely on little more than paper and pencil, though nowadays all sorts of automated recording devices make continuous accurate measurement and recording possible. A variety of automated analysis can be performed by computers, so the scientist need only attend to a summary report.

Science is a communal enterprise. Scientists compare results, critique each other's methods, exchange tools and materials, hire each other's students, etc. The worldwide transportation and communication networks make these exchanges possible. Scientists travel, too, to observe phenomena that occur at special locations, such as biological species in their native habitat, or geological phenomena in place.

Another sort of equipment that science needs is social. At the most basic level, there need to be scientists, people with the capability and freedom to pursue scientific research. The various physical equipment necessary must not only exist but be made available for use by scientists. For the self-amplifying feedback loop of scientific advancement to work, industry must be confident in the validity of scientific results so that the know-how produced by science will be applied to produce the next generation of more capable scientific equipment.

The reader is invited to augment this list. But a further exercise is to consider what impact environmental limits might have on any of these sorts of equipment. There could be other potential feedback loops that get excited as we enter some new regime of system behavior. It is not impossible that environmental limits push industry into less efficient processes, which accelerate the impact of those limits.

It seems clear enough that science has a large share of responsibility for creating our modern world, with all its miraculous technological capabilities. That is another facet of the self-amplifying feedback loop: powerful people understand how science has enhanced their power, and so they promote scientific research. We certainly seems to be at very real risk of entering a new regime, where our miraculous technological capabilities are seen instead as driving us ever more violently against environmental limits. Just has science earned support by taking credit, science may well lose support by taking blame.

Science is not a free-standing activity, but is embedded in a multi-faceted world. This relationship has been at the heart of modern industrial civilization, which is about 200 years old. We seem to be headed for a major shift. If science is to survive the shift in good health, the scientific community will need to find ways to adapt to the new patterns.

Friday, March 10, 2023

Consequences

Our actions have consequences. When we're being careful, we choose our actions so they'll have the best possible consquences. Most commonly what this means is that we try to change the world so it satisfies our desires more. But our actions don't just change the world, they change our selves. We often divide our activities into two phases, e.g. rehearsal and performance. The purpose of rehearsal is to refine our capabilities. Performance is when apply those capabilities to create an aesthetic experience for an audience, for example. But this division is just a rough cut. All of our actions change who we are at the same time that they change the world.

This division of experience into self and world is problematic. An athlete might consider their own body to be a component of the world. One's actual self might be perhaps the rational component of mind, something constant underlying even one's shifting mental capabilities. One of the essential insights of the Buddhist tradition is that the search for this constant underlying component of the self is futile. And yet this framework of thinking, e.g. "I will do this," seems practically unavoidable. If we want to use a conceptual framework of self and world, how can we think about this without getting distracted by illusions?

Organizational behavior is a doorway to a different perspective. It is not just individual human beings who act. All kinds of organizations act: political, military, industrial, academic, religious, etc. At a planetary scale, all of humanity acts. A basic principle of systems theory is that analysis starts with a clear definition of the system to be analyzed: what is part of the system, and what is not. A complementary axiom is in easy reach: the self is what is not in the system. The key point here is that the division of experience into self and world is like establishing a coordinate system or a frame of reference. It has no ontological foundation but is a practical step to allow conceptual elaboration for solving specific problems.

In organizational situations, it is commonly understood that actions both change the world and also change the self, i.e. change the organization engaged in the action. Teams develop cohesion by working together.

That what we are is a dynamic pattern that is constantly being shaped by our actions and experiences, that an important factor in choosing our actions is how those choices will reshape who we are... this perspective seems easier to achieve when we feel safe and secure. When things are good, we are happy to train ourselves to make them even better. When things are difficult, our entire focuse is on fixing problems with the world so we have no desire or opportunity to train ourselves. People do train themselves to be able to respond to difficult situations, though mostly that is to make themselves more capable of making whatever necessary changes to the world. But sometimes people do understand that shaping the world to meet their desires is not going to go very far, and they need to shape their own expectations. Aging gracefully can include such adjustments. What an older person can do is not the same as what a younger person can do. There is a lot less frustration in playing the hand you've been dealt.

At the planetary scale, the growing human population and the growing levels of consumption are driving us up against ecological limits, mostly prominently due to climate change but many other problems are accelerating too, such as aquifer depletion and ocean desertification. The reflex response is to demand that the world change in order to let us preserve our way of life. But of course our way of life is always changing and will continue to change as a consequence of our actions. However one chooses to partition the situation, it is always a dance between self and world. Our habits change, our understandings change, our values change. This dynamism is both a challenge and an opportunity. If our response to our discomfort is to become ever more stubborn and insensitive, we can certainly ramp up the level of mutual frustration to a catastrophic breaking point. But if we can respond to discomfort with care and flexibility, then we can discover tender joys in the most suprising places.