I was just messing around in desmos when I came across an interesting function, $f(x)=x^{\cos(x)}$. I noticed that the peaks were getting closer and closer to the inputted $x$ values, while the troughs approached $0$. So I went and found the derivative, solved for $f'(x)=0$, and this is true when $x=\frac{\cot(x)}{\ln(x)}$. I don't exactly know how I would analyse the function to show that the peaks do in fact converge to $g(x)=x$, I found it quite interesting though, and would like to know how people would approach this!
4 Answers
The points where $\cos(x)=1$ are tangency points to the line $y=x$. As the peaks get more and more pointed, these points are very close to the maxima.
Analysis of the maxima is uneasy, as the equation to locate them is transcendental. Anyway, $x\log(x)=\cot(x)$ has a LHS that is a growing, smooth function, while the cotangent in the RHS has vertical asymptotes at odd multiples of $\frac\pi2$. These are good approximations for the locations of the maxima, with ordinate $x^1$.
For a more accurate approximation of the roots, one can try one Newton's iteration.
Note that if we instead look at $f_2(x)=a^{\cos x}$ then the maxima of $f_2$ occur when $\cos x = 1$, achieving value $a$. So intuitively, when $x$ gets large enough that it is "effectively constant" on the scales of a single period of $\cos x$ then we'd expect the maxima to have value $x$.
TLDR: It turns out that some careful analysis can prove that the difference $x_n-f(x_n)$ for the maximum $x_n \approx 2\pi n$ approaches $0$ rather rapidly.
Longer analysis:
As you calculated, if $f(x)=x^{\cos x} = e^{\cos(x)\ln(x)}$ then $$f'(x) = \left(-\sin(x)\ln(x)+\cos(x)\frac{1}{x}\right)e^{\cos(x)\ln(x)} = 0$$ or $x = \frac{\cot x}{\ln x}$. Note that when $x$ is a multiple of $\pi$ then $\cot x$ is not defined!
So let's look at the maximum at $x_n = 2\pi n + \varepsilon$, where we know that $\epsilon > 0$. Then we have $$2\pi n + \varepsilon = x_n = \frac{\cot(x_n)}{\ln x_n} = \frac{1}{\tan(x_n)\ln(x_n)} \approx \frac{1}{\varepsilon \ln(2\pi n + \varepsilon)} \approx \frac{1}{\varepsilon \ln(2\pi n)}$$ where I use the approximations $\tan(2\pi n + \varepsilon) = \tan(\varepsilon) \approx \varepsilon$ for small $\varepsilon$, and $2\pi n + \varepsilon \approx 2\pi n$ for small $\varepsilon$ and large $n$.
or $\varepsilon \approx \frac{1}{2\pi n\ln(2\pi n)}$.
So the maximum value is $$f(x_n) = (2\pi n + \varepsilon)^{\cos(2\pi n + \varepsilon)} \approx (2\pi n + \varepsilon)^{1 - \frac{1}{2}\varepsilon^2}$$
Taking the natural logarithm $$\ln (f(x_n)) \approx \ln(2\pi n + \varepsilon)\left(1 - \frac{1}{2}\varepsilon^2\right) \approx \ln(2\pi n)\left(1 + \frac{\varepsilon}{2\pi n}\right)\left(1 - \frac{1}{2}\varepsilon^2\right) \approx \ln(2\pi n)\left(1 + \frac{\varepsilon}{2\pi n}\right) \approx \ln(2\pi n + \varepsilon) = \ln(x_n)$$ to the first order in $\varepsilon$, and note that as $n \to \infty$, $\varepsilon \to 0$.
All of this can be formalized using Taylor approximations (Taylor's theorem).
- 232
- 5,900
-
Interesting, I'm quite interested in why $\epsilon \to 0$ as $n \to \infty$, I'm not entirely sure how that link works. – R. Reed Oct 29 '24 at 14:28
-
@ThatOneCoder $\varepsilon \to 0$ as $n \to \infty$ was argued in the first part of my "longer analysis" -- specifically, it behaves like $1/2\pi n \ln(2\pi n)$. The Taylor approximations just make the $approx$ analysis more exact. – mathperson314 Oct 29 '24 at 14:31
-
Ah okay, thank you, I didn't properly read the last line defining an approximation of epsilon in terms of n. Why must we require large n for $2\pi n + \epsilon \approx 2\pi n$ along with small epsilon? – R. Reed Oct 29 '24 at 14:37
-
@ThatOneCoder We're assuming $n$ is large, and qualitative observations show that there is one maximum near every $2\pi n$. So even if $\epsilon = 1$, compared to $n = 1000$, that's rather small. – mathperson314 Oct 29 '24 at 14:39
-
$h=\log f$ has the same local maxima and minima as $f$, and has derivative $$h'(x)=\frac{\cos x}{x}-\sin(x)\log x$$ This means the peaks and troughs are when $\sin(x)=\frac{\cos x}{x\log x}$. For $x$ larger and larger, this means $\sin x$ must be closer and closer to $0$.
- 188,543
$f(x)=x$ when $\cos x = 1,$ which is precisely when $x$ is an integer multiple of $2\pi\approx 6,$ which you can see from Yves Daoust's graph. For other values of $x,\ \cos x<1,$ and so $x^{\cos x}< x.$
The troughs will be when $x$ is close to $(2n+1)\pi$ for integer $n.$ To see why, compute $f((2n+1)\pi)$ for integer $n.$ Note that the troughs will not be $0,$ but will approach $0$ as $n\to\infty.$
- 25,208
cos x→ $cos x$ vs.\cos x→ $\cos x$. – CiaPan Oct 29 '24 at 13:47