Pseudo sinusoidal waveform II

Mr Stenzel, CEO of Waldorf Music GmbH, decided to disclose his excellent pseudo sinusoidal formula: 4x \cdot (1-|x|) .

Here is a plot of the function:


As you can see, this really looks like a sine wave! The following error plot reveals a maximum error of 0.056:


In terms of distortion, Mr. Stenzel is right. This function is 2.85 times better than the previous pseudo sine.


Pseudo sinusoidal waveform

I needed a small routine to generate a cyclic waveform resembling sin(x) to test a CODEC board. This is what I came up with:

float pseudoSin(float x)
  return (1.0f-x*x)*x

This produces the following waveform over the domain [-1,1]:


The derivative of the function is 1-3x^2 . The maximum and minimum occur at x = \sqrt{ \frac{1}{3} } and x = -\sqrt{ \frac{1}{3} }, respectively. The function has maximum and minimum values of \frac{2}{3} \sqrt{ \frac{1}{3} } \approx 0.38490 and -\frac{2}{3} \sqrt{ \frac{1}{3} } \approx -0.38490 .

The amplitude normalisation factor is approximately 2.5981. For completeness, here is the error of the function with respect to a real sin(x):


The error maximum is about 16.3%.