Why does $\lim_{x\rightarrow\infty} x-x^{\frac{1}{x}^{\frac{1}{x}}}-\log^2x=0?$ Why does $$\lim_{x\rightarrow\infty} x-x^{\frac{1}{x}^{\frac{1}{x}}}-\log^2x=0?$$
Moreover, why is $$x-x^{\frac{1}{x}^{\frac{1}{x}}}\approx\log^2 x?$$

By a Taylor expansion,
$$
\left( \frac{1}{x} \right)^{1/x} = \exp\left( -\frac{1}{x}\ln x \right) = 1-\frac{\ln x}{x} + O\left(\frac{\ln^2 x}{x^2}\right) .
$$
Thus the second term equals
$$
(1+\delta)\exp\left( \ln x \left( 1 - \frac{\ln x}{x} \right) \right)  = x \left( 1-\frac{\ln^2 x}{x} + O\left(\frac{\ln^4 x}{x^2}\right) \right)(1+\delta)
$$
with $\delta = O(\ln^3 x/x^2)$, so this gives the claim.
