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%.


One thought on “Pseudo sinusoidal waveform

  1. Pseudo sinusoidal waveform II | Niels Moseley's bloggy bits

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s