3
$\begingroup$

I came up with this function: $2\left(\frac{1}{1+e^{\textstyle\frac{-6\sin^{-1}(\cos(x))}{\pi/2}}}-\frac12\right)$ to mimic a 'cosine'-esque function with flat peaks and valleys. Here it is as plotted by Wolfram Alpha:

Wolfram Alpha plot of above function

What I was wondering is, is there a more elegant way to achieve this effect? (The values the function outputs need not be the same as those of this function - it only needs to look cosine-esque and have flat peaks and valleys).

  • 0
    I think your function looks better as $\tanh \left(\frac{6 \sin ^{-1}(\cos (x))}{\pi }\right)$. Makes it easier to see what is going on.2012-01-20

3 Answers 3

1

How about $f(x) = \sin(\tfrac{\pi}{2}\cos(x))$?

enter image description here

  • 0
    Oh, sorry, I've just seen that this was in Rahul Narain's comment...2012-01-20
10

How about

$\sqrt{\frac{1+b^2}{1+b^2 \cos^2 v}}\cos\,v$

where $b$ is an adjustable parameter?

fake square waves

7

Well, if you accept $x^{1/25}$ as being defined for all real $x$ and giving a negative value when $x$ is negative, just take $ f(x) = \left( \cos x \right)^{1/25} $