If $f(x)$ is continuous at $x=0$, find $f(0)+2\lambda$. If the function
$$ 
f(x)=\lim_{n\to\infty} \frac{(1-\cos(1-\tan(\frac{\pi}{4}-x)))(1+x)^n+\lambda\sin((n-\sqrt{n^2-8n})x)}{x^2(1+x)^n+x} ; x\ne0
$$
(the value of $f(0)$ is unknown) is continuous at $x=0$, find $f(0)+2\lambda$.
My reasoning is as follows... If $f(x)$ is continuous at $x=0$, then
$$
\lim_{x \to 0^+}f(x)=\lim_{x \to 0^-}f(x)=f(0)
$$
So, the problem is solved if we know how to find :
$$
\lim_{x \to0} \lim_{n\to\infty} \frac{(1-\cos(1-\tan(\frac{\pi}{4}-x)))(1+x)^n+\lambda\sin((n-\sqrt{n^2-8n})x)}{x^2(1+x)^n+x}
$$
So, I thought of substituting $x=\frac{1}{n}$ and tried to solve the resulting limit. I'm not confident that this substitution is a valid step and was not able to solve the limit.
Any thoughts ?
 A: Note that $$\tan(\tfrac\pi4-x)=\tan\tfrac\pi 4-\frac1{\cos^2\frac\pi4}\cdot x+O(x^2)=1-2x+O(x^2),$$
$$1- \cos(1-\tan(\tfrac \pi4-x))=1-\cos(2x+O(x^2)) =2x^2+O(x^3).$$
At least this is $\ne0$ for $x$ sufficiently close to $0$, i.e., there exists $r>0$ such that $1- \cos(1-\tan(\tfrac \pi4-x))\ne 0$ for $0<|x|<r$. Hence for fixed $x$ with $0<|x|<r$, 
the first summand in the numerator in the definition of $f(x)$ goes $\to\infty$ as $n\to \infty$, whereas the other summand is bounded by $\lambda$. Similarly, the first summand in the denominator dominates the other summand as $n\to\infty$. We conclude that for $x$ with $0<|x|<r$  we have
$$\begin{align} f(x)&=\lim_{n\to\infty}\frac{(1- \cos(1-\tan(\tfrac \pi4-x)))(1+x)^n+\lambda\sin((n-\sqrt{n^2-8n})x)}{x^2(1+x)^n+x}\\&=\lim_{n\to\infty}\frac{(1- \cos(1-\tan(\tfrac \pi4-x)))(1+x)^n}{x^2(1+x)^n}\\&=\frac{1- \cos(1-\tan(\tfrac \pi4-x))}{x^2}\\
&=2+O(x).\end{align}$$
Note that $f$ does not depend on $\lambda$ (at least for such $x$)
We conclude that
$$ f(0)=\lim_{x\to 0}f(x)=2.$$
