solve trigonometric lim with tan Hi guys I tried to solve the following problem lately and got stucked.
I'd love to get some help and guidance. 
consider this:
$$\lim_{x \rightarrow\infty}\tan\left(\frac{\pi x}{2x+1}\right)^{\frac{1}{x}}
$$
I did the following:
1. break to sin and cos :
$$
\lim_{x \rightarrow\infty}\tan\left(\frac{\pi x}{2x+1}\right)^{\frac{1}{x}} = \lim_{x\rightarrow\infty}\frac{\left(\sin\left(\frac{\pi x}{2x+1}\right)\right)^\frac{1}{x}}{\left(\cos\left(\frac{\pi x}{2x+1}\right)\right)^\frac{1}{x}}$$


*use log rules:


$$\lim_{x\rightarrow\infty}\frac{\left(\sin\left(\frac{\pi x}{2x+1}\right)\right)^\frac{1}{x}}{\left(\cos\left(\frac{\pi x}{2x+1}\right)\right)^\frac{1}{x}} =  \lim_{x\rightarrow\infty}\frac{e^{\frac{1}{x}\ln\left(\sin\left(\frac{\pi x}{2x+1}\right)\right)}}{e^{\frac{1}{x}\ln\left(\cos\left(\frac{\pi x}{2x+1}\right)\right)}}$$


*Numerator converges to one so I am going to work with the denominator:
$$
 \lim_{x \rightarrow \infty}e^{\frac{1}{x}\ln\left(\cos\left(\frac{\pi x}{2x+1}\right)\right)} = e^\left(\lim_{x \rightarrow \infty}{\frac{1}{x}\ln\left(\cos\left(\frac{\pi x}{2x+1}\right)\right)}\right) 
$$


$$
\lim_{x \rightarrow \infty}{\frac{1}{x}\ln\left(\cos\left(\frac{\pi x}{2x+1}\right)\right)} = \frac{-\infty}{\infty}$$


*at this point I tried to apply l'hopital but encountered a huge mess, and now I feel that maybe I chose the wrong way. Please help me guys.

 A: Set $1/x=h$  to find $$A=\lim_{h\to0^+}\left(\tan\dfrac{\pi}{2+h}\right)^h$$
$$\ln A=\lim_{h\to0^+}\dfrac{\ln\tan\dfrac{\pi}{2+h}}{1/h}=\lim_{h\to0^+}\dfrac{h^2\pi\cdot\sec^2\dfrac{\pi}{2+h}}{(2+h)^2\tan\dfrac{\pi}{2+h}}$$
$$=\pi\lim_{h\to0^+}\dfrac1{(2+h)^2\sin\dfrac\pi{2+h}}\lim_{h\to0^+}\dfrac{h^2}{\cos\dfrac\pi{2+h}}$$
As $\cos\dfrac\pi{2+h}=\sin\left(\dfrac\pi2-\dfrac\pi{2+h}\right)=\sin\dfrac{\pi h}{2(2+h)}$
$$\ln A=\dfrac\pi{2^2}\cdot\lim_{h\to0^+}\dfrac{h^2}{\sin\dfrac{\pi h}{2(2+h)}}$$
Apply L'Hospital on $\lim_{h\to0^+}\dfrac{h^2}{\sin\dfrac{\pi h}{2(2+h)}}$
A: Let $y=\dfrac\pi2-\dfrac{\pi x}{2x+1}=\dfrac\pi{2(2x+1)}$
$\implies x=\dfrac{\pi-2y}{4y}$
$$\lim_{x \rightarrow\infty}\tan\left(\frac{\pi x}{2x+1}\right)^{\frac{1}{x}}=\left(\lim_{y\to0}(\cot y)^y\right)^{\lim_{y\to0}4/(\pi-2y)}$$
Let $A=\lim_{y\to0}(\cot y)^y$
$\implies\ln A=\lim_{y\to0}\dfrac{\ln\cot y}{\dfrac1y}$ which is of the form $\dfrac\infty\infty$
Applying L'hosiptal's rule $$\ln A=\lim_{y\to0}\dfrac{y^2\csc^2y}{\cot y}=\lim_{y\to0}\dfrac y{\sin y}\cdot\dfrac1{\lim_{y\to0}\cos y}\cdot\lim_{y\to0} y=0$$
Can you take it from here?
A: Considering $$A=\tan\left(\frac{\pi x}{2x+1}\right)^{\frac{1}{x}}$$ first $$\tan\left(\frac{\pi x}{2x+1}\right)=\tan\left(\frac{\pi} 2-\frac{\pi }{2(2 x+1)}\right)=\cot \left(\frac{\pi }{2(2 x+1)}\right)$$ So $$\log(A)=\frac 1 x \log\left(\cot \left(\frac{\pi }{2(2 x+1)}\right)\right)$$ Now, using Taylor series starting with $$\cot(\epsilon)=\frac{1}{\epsilon }-\frac{\epsilon }{3}-\frac{\epsilon ^3}{45}+O\left(\epsilon
   ^4\right)$$ and replacing $\epsilon=\frac{\pi }{2(2 x+1)}$ and continuing the expansion $$\cot \left(\frac{\pi }{2(2 x+1)}\right)=\frac{4 x}{\pi }+\frac{2}{\pi }-\frac{\pi }{12
   x}+O\left(\frac{1}{x^2}\right)$$ $$\log\left(\cot \left(\frac{\pi }{2(2 x+1)}\right)\right)=\log \left(\frac{4}{\pi }\right)+\log
   \left({x}\right)+\frac{1}{2 x}+O\left(\frac{1}{x^2}\right)$$ $$\log(A)=\frac 1x\log \left(\frac{4}{\pi }\right)+\frac{\log
   \left({x}\right)}x+O\left(\frac{1}{x^2}\right)$$ $$A=e^{\log(A)}=1+\frac{\log \left(\frac{4 x}{\pi }\right)}{x}+O\left(\frac{1}{x^2}\right)$$ which shows the limpit and how it is approached.
To check how good (or bad) is the approximation, let us set $x=10^k$ and compute the exact and approximate values 
$$\left(
\begin{array}{ccc}
 k & \text{approximation} & \text{exact} \\
 1 & 1.295772742 & 1.254414957 \\
 2 & 1.049713236 & 1.048467347 \\
 3 & 1.007175440 & 1.007149320 \\
 4 & 1.000945642 & 1.000945190 \\
 5 & 1.000117552 & 1.000117545 \\
 6 & 1.000014057 & 1.000014057
\end{array}
\right)$$
