Evaluation of limits and finding the value of $\lambda$ 
If $f(x)= \lim_{n\to \infty}\dfrac{\left(1- \cos \left(1- \tan \left(\dfrac {\pi}{4}-x\right)\right)\right)(x+1)^n+ \lambda\sin((n - \sqrt{n^2 -8n})x)}{x^2(x+1)^n+x}$ ,$x\ne 0$  is continuous at $x=0$, then find the value of $(f(0)+ 2\lambda)$

Attempt: 
I know that we are supposed to evaluate limit as $n \to \infty$ and $x \to 0$ but I am facing real trouble while doing that. It's $0/0$ form LHopital doesn't help here because differentiation of that function would be really long. 
The term inside cos simplifies to $\dfrac{2\tan x}{1+\tan x}$
For $\dfrac {P(x)}{Q(x)}$'s limit when $x\to 0$ we see the ratio of the lowest powers of $x$ so according to that the ratio of lowest powers of $x$ is $\lambda(n- \sqrt{n^2-8n}) $ whose limit is $4\lambda$ but I am not sure we can use this method when we have double limits (limit on both $x$ and $n$). 
Tl;dr: 
Is the method of the last paragraph above allowed here? Why or why not? 
What is the apt way to solve this problem? 

Rewrite the given function as:
$$f(x) = \lim_{n\to\infty}\frac{2\sin^2\left(\frac{\tan(x)}{1+\tan(x)}\right)(x+1)^n + \lambda \sin\left(\frac{8nx}{n+\sqrt{n^2-8n}}\right)}{x^2(x+1)^n+x}$$
We need left and right limits at $x=0$ to be equal as $n\to \infty$. First let us consider individual limits:


*

*For right hand limit, as $n\to \infty,$ and $x\to 0^+$, note that $\sin \left(\frac{8nx}{n+\sqrt{n^2-8n}}\right) \to 4x \to 0$. But $(x+1)^n \to \infty$. So the limit is of form $\infty / \infty$. Divide by $x^2(x+1)^n$ on numerator and denominator and the limit is
$$\lim_{x\to 0^+, n\to \infty} \frac{\frac{2\sin^2\left(\frac{\tan(x)}{1+\tan(x)}\right)(x+1)^n}{x^2 (x+1)^n}+\frac{\sin \left(\frac{8nx}{n+\sqrt{n^2-8n}}\right)}{x^2(1+x)^n}}{1+\frac{x}{x^2(1+x)^n }} \\
=  \frac{\lim_{x\to 0^+, n\to \infty}\frac{2\sin^2\left(\frac{\tan(x)}{1+\tan(x)}\right)(x+1)^n}{x^2 (x+1)^n}+0}{1+0} 
\\=\lim_{x\to 0^+} \frac{2\sin^2\left(\frac{\tan(x)}{1+\tan(x)}\right)}{x^2 } = 2$$

*For left limit, as $n\to \infty$ and $x\to 0^-$, $(x+1)^n \to 0$ , so limit is of form $0/0$:
$$\lim_{x\to 0^-,n\to \infty} \frac{2\sin^2\left(\frac{\tan(x)}{1+\tan(x)}\right)(x+1)^n + \lambda \sin\left(\frac{8nx}{n+\sqrt{n^2-8n}}\right)}{x^2(x+1)^n+x} \\ 
=\lim_{x\to 0^-, n\to \infty} \frac{2\sin^2\left(\frac{\tan(x)}{1+\tan(x)}\right)\frac{(x+1)^n}{x} + \frac{\lambda}{x} \sin\left(\frac{8nx}{n+\sqrt{n^2-8n}}\right)}{x(x+1)^n+1}  \\
= \frac{0+4\lambda}{0+1}$$
For continuity we need $4\lambda = 2 = f(0)$ or $\lambda = 1/2$. So $f(0)+2\lambda = 2+1 = 3$.
