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
    [Here's the plot by WolframAlpha for everyone's convenience.](http://www.wolframalpha.com/input/?i=2*%28%5Cfrac%7B1%7D%7B%281%2be%5E%7B-6%28arcsin%28cos%28x%29%29/%28pi/2%29%29%29%7D%7D-1/2%29)2012-01-20
  • 0
    When you say large peaks and valleys, do you mean flat peaks and valleys, or something else?2012-01-20
  • 0
    Flat, yes. That's a better way of putting it. I'll edit my question to say this and to include the wolfram link.2012-01-20
  • 0
    The elegant way would be to use $f(\cos x)$ for any roughly S-shaped $f\colon [0,1] \to [0,1]$, like $(3t - t^3)/2$ or $\sin(\pi t/2)$.2012-01-20
  • 0
    Thanks, you can submit this as an answer Rahul.2012-01-20
  • 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} $$