Why do I get a square wave when iterating $\cos\left(\tan\left(\cos\left(\tan\left(\cos(x)\right)\right)\right)\right)$?

89 Views Asked by At

Why do I get a square wave when iterating $$\cos\left(\tan\left(\cos\left(\tan\left(\cos(x)\right)\right)\right)\right)?$$ And why does the square wave happen where it does? It is clearly an even function, and it seems to have period $1.634$

enter image description here

1

There are 1 best solutions below

0
On BEST ANSWER

First of all, notice that it depends on how you "iterate". If you repeatedly apply $x \mapsto \cos(\tan(x))$ to $\cos(x)$, you will eventually get graphs that look like square waves, but the wave will "flip" every time you iterate: the peaks will become troughs and the troughs will become peaks. This is not a convergent sequence of functions.

If you repeatedly apply $x \mapsto \cos(\tan(\cos(\tan(x))))$ to $\cos(x),$ however, you do get a converging sequence of functions.

I think this is a little easier to make sense of by considering the function $f(x) = \tan(\cos(\tan(\cos(x)))).$ The figure below is a graph of $y=f(x)$ with the graph of $y=x$ for comparison.

enter image description here

There are exactly three values of $x$ for which $f(x) = x.$ Let's call them $x_1,$ $x_2,$ and $x_3.$ These numbers are approximately \begin{align} x_1 &\approx 0.0137109619668026, \\ x_2 &\approx 0.816541226172734, \\ x_3 &\approx 1.55708579436399. \end{align}

Because $f(x) < x$ when $x_1 < x < x_2,$ if we apply $f$ repeatedly to a value of $x$ in that range, the outcomes of $f(x),$ $f(f(x)),$ $f(f(f(x))),$ $f(f(f(f(x)))),$ and so forth will be progressively smaller, eventually approaching $x_1.$

Because $f(x) > x$ when $x_2 < x < x_3,$ if we apply $f$ repeatedly to a value of $x$ in that range, the outcomes of $f(x),$ $f(f(x)),$ $f(f(f(x))),$ $f(f(f(f(x)))),$ and so forth will be progressively larger, eventually approaching $x_3.$

For similar reasons, if $0 \leq x < x_1$ then the successive applications of $f$ produce larger and larger values approaching $x_1,$ whereas if $x_3 < x \leq \frac\pi2$ then the successive applications of $f$ produce smaller and smaller values approaching $x_3.$

On the other hand, $f(x_1) = x_1$ exactly, and therefore $f(x_1) = f(f(x_1)) = f(f(f(x_1))) = f(f(f(f(x_1))))$ and so forth. Likewise $x_2 = f(x_2) = f(f(x_2)) = f(f(f(x_2))) = f(f(f(f(x_2))))$ and $x_3 = f(x_3) = f(f(x_3)) = f(f(f(x_3))) = f(f(f(f(x_3)))).$

So for every possible value of $x$ in the range from $0$ to $\frac\pi2$ inclusive, whenever $x < x_2$ the repeated application of $f$ produces a sequence of outputs converting to $x_1,$ and whenever $x > x_2$ the repeated application of $f$ produces a sequence of outputs converting to $x_3.$ The result is a sequence of functions, which if restricted to the domain $\left[0,\frac\pi2\right]$ converge on the step function $$ f^*(x) = \begin{cases} x_1 & 0 \leq x < x_2, \\ x_2 & x = x_2, \\ x_3 & x_2 < x \leq \frac\pi2.\end{cases} $$

Outside of the interval $\left[0,\frac\pi2\right],$ we can use the fact that $\cos(-x) = \cos(x)$, the fact that $\cos(\pi - x) = -\cos(x)$, and the fact that $\tan(-x) = -\tan(x)$ to conclude that $$ \cos(\tan(\cos(\pi - x))) = \cos(\tan(-\cos(x))) = \cos(-\tan(\cos(x))) = \cos(\tan(\cos(x))) $$ and therefore $f(\pi - x) = f(x)$ and $f(f(\cdots f(\pi - x))) = f(f(\cdots f(x)))$ for any number of iterations of the application of $f$; that is, each of these functions is symmetric around the line $y = \frac\pi2,$ and each function on the interval $\left[\frac\pi2,\pi\right],$ is just a mirror image of the same function over $\left[0,\frac\pi2\right].$ This gives us $$ f^*(x) = \begin{cases} x_1 & 0 \leq x < x_2, \\ x_2 & x = x_2, \\ x_3 & x_2 < x < \pi - x_2,\\ x_2 & x = \pi - x_2, \\ x_1 & \pi - x_2 < x \leq \pi.\end{cases} $$ This is already starting to look like a square wave.

The fact that $\cos(-x) = \cos(x)$ also tells us that any of these functions on the interval $[-\pi,0]$ is a mirror image of the function on the interval $[0,\pi].$ This gives us something that looks like two cycles of a square wave.

Then the fact that $\cos(x+2\pi) = \cos(x-2\pi) = \cos(x)$ means the function over $[-\pi,\pi]$ repeats forever to the left and right, so $f^*$ actually is a square wave with period $\pi$ (not $1.634$).

You are interested in functions of the form $\cos(f(\cdots f(x)))$, which converge on the limit function $\cos(f^*(x)).$ This again is a square wave, except that all the $x_1$ values are replaced by $\cos(x_1)$ (which is close to $1$), all the $x_3$ values are replaced by $\cos(x_3)$ (which is close to $0$), and all the $x_2$ values are replaced by $\cos(x_2)$. That is, the wave has a smaller amplitude, it has peaks where $f^*(x)$ has troughs, and it has troughs where $f^*(x)$ has peaks.

Unlike what you might have expected, the peaks and troughs are not of equal width. One peak of $\cos(f^*(x))$ runs from $-x_2$ to $x_2,$ so its width is $2x_2 \approx 1.63308.$ That is greater than $\frac\pi2,$ so the trough has a width less than $\frac\pi2$ in order to make the length of one complete cycle be $\pi.$