Our beloved tanh

Just a thought.

A special perspective on our beloved tanh. It has become very common in the supercollider community to use the hyperbolic tangens as a distortion function. We seem to be sympathetic to it, somehow.

{ SinOsc.ar(20, mul: MouseX.kr(1, 100, 1)).tanh * 0.1 }.play;

But there is something else. In relativistic physics, the hyperbolic tangens transposes from the world of speed as we usually take it into “relativistic speed”, called rapidity. Because of the way the speed of light works as a limit, you cannot simply add speeds. But once converted into rapidities, they can be added.

In a similar way, when we consider the limit of our sound output volume to function like the speed of light, our signal amplitudes can be thought of as analog to rapidities – we can just add them up. Just before we send them to the sound output, we convert them into speed by calling the beloved .tanh.

Finally, a similar example with three sine tones. One can hear that + (or sum) and tanh are not commutative, that is x.tanh + y.tanh ≠ (x + y).tanh. We hear the difference between the nonrelativistic and the relativistic amplitude saturation.

{ SinOsc.ar([20, 50, 75], mul: MouseX.kr(1, 100, 1)).tanh.sum * 0.1 }.play;
{ SinOsc.ar([20, 50, 75], mul: MouseX.kr(1, 100, 1)).sum.tanh * 0.1 }.play; 

P.S.
The equivalent of the speed of light (c) in the above examples is 0.1.

We can check if the conversion is correct by comparing the addition formula for relativistic speeds with the addition of rapidities, so the following two functions should do the same:

t = { |v, u, c| (v + u) / (1 + (v * u / c.squared)) }; // relativistic addition of speeds
k = { |v, u, c| tanh(atanh(v/c) + atanh(u/c)) * c }; // addition of rapidities (atanh(v/c))

t.(0.02, 0.03, 0.1)
k.(0.02, 0.03, 0.1)

14 Likes