## Wednesday, June 15, 2016

Continuing on from this post, I am playing around with some unusual R language programming activities by creating some simplified Chladni figures.

Named for Ernst Chladni, these figures represent nodal patterns formed by vibrating surfaces. Traditionally, these are formed placing fine particles on a surface, like a sheet of metal that is set vibrating (a violin bow against an edge of the metal plate is one popular method). The particles settle in the areas of the surface that have the least motion - the nodes. When you achieve a resonant frequency, a characteristic pattern emerges.

Chladni was not the first to study these, but his text is an early systematic treatment (several French and German versions are on Google Books, the German text has the best figures, in an appendix). A more recent contributor, Mary Desiree Waller, published a book Chladni Figures, a Study in Symmetry in 1961, which I would love to get a look at someday. In the 1970s, Chilandi figures were sucked down the rabbithole of Cymatics, and seem now seem to appeal equally to students of actual physics and metaphysics. It is probably fitting that these figures are embraced by romantics as much (or more) as they are by scientists. Chladni's study appeared at the end of the Enlightenment, almost at the beginning of the 19th century, and I imagine his demonstrations occurring in parlors similar to those where seances were held. The mysterious formation of these figures must have seemed to some as the manifestation of a hidden world. Chladni's sketches of some nodal patterns on a vibrating surface
Why use R for this? My motivation was not to select the best tool for exploring this topic, but to learn a bit more about programming in R. It was also not to try and produce exact Chladni figures, but something that reasonably resembled them. It turns out that R isn't such an unreasonable choice for this particular programming exercise, if you consider how easy it turns out to be to generate the figures using R. As an educational exercise, it makes some instructive use of R's vectorized methods, for loops, and the image function.On the other hand, we are not going to use any of R's statistical functions, so in some respects R remains an unusual (or maybe even bizarre) choice for this.

In any case, we can create simple Chladni-esque figures by thinking of a rectangular metal plate as a matrix in R (each cell being a point on the metal plate).Each entry in the matrix will receive values that represent the displacement of the plate at those coordinates at some snapshot in time.The matrix is plotted using R's image function, using a grey color range (try experimenting with other color ranges, or with the contour function).

The source code is here.

The idea is that a vibrating square surface whose edges are fixed (not moving) can be modeled as a product sine waves - one going in the horizontal direction, the other going in the vertical direction. Essentially, the displacement caused by a standing wave at a point x,y on the square is modeled as sin(kfx)*sin(kfy), where f is pi/2L, L being the length of the side of the square. and k is an integer. If k = 1, we get the 'fundamental' wave (first harmonic) for the square surface, and if k = 2 we get the first overtone (second harmonic). If we plot each wave separately we end up with a grid that gets finer and finer as we increase k values. However, things get more interesting if we form the sum of different harmonics. The images below show what we get forming the image for waves with = 1 and k = 2 separately, and then what we get when we sum them together. fundamental, first overtone, and both together
Including or excluding overtones gives a wide variety of images, and if you increase the amplitude of particular overtones (by multiplying the corresponding term by some integer greater than 1), you can get even more patterns, some of which bear a striking resemblance to Chladni's original hand-drawn figures.