6
$\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).

$\endgroup$
6
  • $\begingroup$ Here's the plot by WolframAlpha for everyone's convenience. $\endgroup$
    – user856
    Jan 20, 2012 at 3:45
  • $\begingroup$ When you say large peaks and valleys, do you mean flat peaks and valleys, or something else? $\endgroup$
    – soandos
    Jan 20, 2012 at 3:47
  • $\begingroup$ Flat, yes. That's a better way of putting it. I'll edit my question to say this and to include the wolfram link. $\endgroup$
    – ro44
    Jan 20, 2012 at 3:48
  • $\begingroup$ 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)$. $\endgroup$
    – user856
    Jan 20, 2012 at 3:50
  • $\begingroup$ Thanks, you can submit this as an answer Rahul. $\endgroup$
    – ro44
    Jan 20, 2012 at 3:53

3 Answers 3

13
$\begingroup$

How about

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

where $b$ is an adjustable parameter?

fake square waves

$\endgroup$
0
7
$\begingroup$

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} $$

$\endgroup$
1
$\begingroup$

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

enter image description here

$\endgroup$
1
  • $\begingroup$ Oh, sorry, I've just seen that this was in Rahul Narain's comment... $\endgroup$
    – Dirk
    Jan 20, 2012 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.