# Help Evaluating $\lim_{x\to\frac{\pi}{2}}\left(\frac{1}{\frac{\pi}{2}-x}-\tan {x}\right)$

Does anyone know how to evaluate the following limit?

$$\lim_{x\to\frac{\pi}{2}}\left(\frac{1}{\frac{\pi}{2}-x}-\tan {x}\right)$$

The answer is 0 , but I want to see a step by step solution if possible.

Here are the steps $$\lim_{x\to \frac{\pi}{2}} \left[\frac{1}{\frac{\pi}{2}-x}-\tan x\right]= \lim_{x\to \frac{\pi}{2}} \left[\frac{2}{\pi-2x}-\frac{\sin x}{\cos x}\right]$$ $$= \lim_{x\to \frac{\pi}{2}} \left[\frac{2\cos x-(\pi-2x)\sin x}{(\pi-2x)\cos x}\right]= \lim_{x\to \frac{\pi}{2}} \left[\frac{\frac{d}{dx}[2\cos x-(\pi-2x)\sin x]}{\frac{d}{dx}[(\pi-2x)\cos x]}\right]$$ $$= \lim_{x\to \frac{\pi}{2}} \left[\frac{-2\sin x-(\pi-2x)\cos x+2\sin x}{-(\pi-2x)\sin x-2\cos x}\right] = \lim_{x\to \frac{\pi}{2}} \left[\frac{\frac{d}{dx}[(\pi-2x)\cos x]}{\frac{d}{dx}[(\pi-2x)\sin x+2\cos x]}\right]$$ $$= \lim_{x\to \frac{\pi}{2}} \left[\frac{-(\pi-2x)\sin x-2\cos x}{(\pi-2x)\cos x-2\sin x-2\sin x}\right] = \lim_{x\to \frac{\pi}{2}} \left[\frac{(\pi-2x)\sin x+2\cos x}{4\sin x -(\pi-2x)\cos x}\right]$$ $$= \frac{0\cdot 1+2\cdot 0}{4\cdot 1 -0\cdot 0}= \frac{0}{4}=0$$
2) Since $f(\pi/2)$ is undefined (and hence your function $f$ is not continuous at $\pi/2$), you can't just plug in $\pi/2,$ so use L'Hospital's rule (i.e. differentiate the numerator and the denominator with respect to $x$ until you no longer obtain a result in the form $\frac{0}{0}$).
Take $y=\pi/2-x$ and write the limit as $$\lim_{y\rightarrow0}\,\left(\frac{1}{y}-\frac{\cos\,y}{\sin \,y}\right),$$ then use Maclaurin series expansion