### Finding a monotonic subsequence

This interactive page is intended to demonstrate the proof using 'peaks' of the Bolzano-Weierstrass Theorem, namely that every sequence has a monotonic subsequence.

The term 'peak' is used for a term in the sequence that is greater than or equal to all subsequent terms.

There are four sequences to choose from. In each case the sequence is plotted in the upper diagram, with a monotonic subsequence highlighted in red, and the subsequence shown in the diagram below. In the case where there are no peaks and the sequence is bounded the terms of the subsequence get very infrequent as $n$ increases. For this reason, each time the 'Next terms' button is pressed either the next terms up to the next term in the chosen subsequence are plotted or the next 500 terms whichever is the fewer.

The sequences used are as follows.

• No peaks - bounded: $\{\cos(n)\}$
• Convergent - infinite peaks: $\displaystyle\left\{\frac{5\cos(n)}{n}\right\}$
• Not convergent - infinite peaks: $\displaystyle\left\{\cos\left(\frac{n\pi}{10}\right)\right\}$
• No peaks - unbounded: $\{\sqrt{n+2}\cos(n)\}$
• Infinite number of peaks - bounded: $\{(-1)^n+\frac{1}{n}\}$