How to make a cos function where each crest and trough is not exactly the same distance apart? In a typical $\cos(x)$ or $\sin(x)$ function, each successive crest or trough is equidistant from the next.
How can I represent a function where as $x$ increases, the next crest or trough may not be equidistant (slightly more or less than what it should)?
I want to plot this on a graph, so I would prefer it if it is the form $y=\cos(x)$ or something else easy to calculate when I feed it into the computer.
EDIT: Is it possible for this the crests to neither get closer or further as $x$ tends to infinity? (the distance between crests and trough should keep varying, but neither get successively closer or further).
 A: In this example, every two maxima have a unique distance, but the average distance stays constant: 
$$f(x)=\cos(g_\epsilon (x)), \qquad g_\epsilon (x)=x+\epsilon \sin(\sqrt{2}\cdot x), \qquad \epsilon=0.4$$
Edit: To understand the idea, first draw the unperturbed inner function $g_0(x)=x$ on a sheet of paper. Whenever this diagonal line crosses the equidistant lines $y=n\pi$, the $\cos(\cdot)$ has a maximum. If we perturb $g_0$ by the small $\sin(\cdot)$-term, it will never be in sync with the lines $y=n\pi$, due to the irrational frequency $\sqrt{2}$. So that should be exactly what you want.

A: For the function $f:(0,\infty) \rightarrow \Bbb R$ ,$f(x)=sin(1/x)$ the successive minimas and maximas keep on going far apart.
A: The instantaneous period (what you call the "trough spacing") at $x$ is the reciprocal of the cyclic frequency at $x$. The frequency of $y = \cos( f(x) )$ is defined to be $f'(x)/(2\pi)$, so all you need to do is choose $f(x)$ such that $f'(x)$ is not a constant. A common example would be
$$
y = \cos( \pi \gamma x^2),
$$
such that $f'(x) = 2\pi \gamma x$. The instantaneous period at any point $x$ is then give by $1/(\gamma x)$, which will be closer and closer as $x$ becomes larger.
