Find a and p in the given question 
I would be grateful if someone helps me with this question. 
I get $p$ but to get $a$, the term with $a$ vanishes.
I checked continuity at $x=1$ for finding $p$.
$p$ comes out to be $-2$.
 A: As $f(x)$ is differentiable for $x\in(0,2)$ we know that the  limit $$\lim_{n\to\infty}\dfrac{ax(x-1)\left(\cot^n\left(\dfrac{\pi x}4\right)\right)+px^2+2}{\left(\cot^n\left(\dfrac{\pi x}4\right)\right)+1}$$ is finite, and $f(x)$ is continuous for $x\in(0,2)$. 
$$$$
Let $$L=\lim_{n\to\infty}\dfrac{ax(x-1)\left(\cot^n\left(\dfrac{\pi x}4\right)\right)+px^2+2}{\left(\cot^n\left(\dfrac{\pi x}4\right)\right)+1}$$
$$\Rightarrow L=\lim_{n\to\infty}\dfrac{ax(x-1)+(px^2+2)\left(\tan^n\left(\dfrac{\pi x}4\right)\right)}{1+\left(\tan^n\left(\dfrac{\pi x}4\right)\right)}$$
$$$$
For $x\in(1,2)$, $\dfrac\pi4<\dfrac{\pi x}{4}<\dfrac{\pi}2\Rightarrow 0<\cot\left(\dfrac{\pi x}4\right)<1\Rightarrow\cot^n\left(\dfrac{\pi x}4\right)\to 0 $ as $n\to\infty$
$$$$
Hence $$L=\lim_{n\to\infty}\dfrac{ax(x-1)\left(\cot^n\left(\dfrac{\pi x}4\right)\right)+px^2+2}{\left(\cot^n\left(\dfrac{\pi x}4\right)\right)+1}=\dfrac{0(ax(x-1))+px^2+2}{0+1}=px^2+2$$
$$$$
We need that the limit is equal to $0$ as $x\to 1^+$ for the function to be continuous. Hence $\lim_{x\to1^+}px^2+2=0\Rightarrow p=-2$.
$$$$
Let $L_1$ and $L_2$ be the limits (of $f(x)$) from the left and from the right of $x=1$  respectively.
$$$$
Thus $$L_2=\lim_{n\to\infty}\dfrac{ax(x-1)\left(\cot^n\left(\dfrac{\pi x}4\right)\right)+2-2x^2}{\left(\cot^n\left(\dfrac{\pi x}4\right)\right)+1},x\to1^+$$
$$L_1=\lim_{n\to\infty}\dfrac{ax(x-1)+(2-2x^2)\left(\tan^n\left(\dfrac{\pi x}4\right)\right)}{1+\left(\tan^n\left(\dfrac{\pi x}4\right)\right)},x\to1^-$$
$$$$
Now, for $x\in(0,1)$, $\tan^n\left(\dfrac{\pi x}4\right)\to0$ as $n\to\infty$ $$$$For $x\in(1,2)$, $\cot^n\left(\dfrac{\pi x}4\right)\to 0$ as $n\to\infty$.
$$$$
Thus, $$L_2=\dfrac{2-2x^2}{2},x\to 1^+$$
$$\Rightarrow L_2=\lim_{h\to 0}\dfrac{2-2(1+h)^2}{2}=\lim_{h\to0}\dfrac{-2h^2-4h}{2}=\lim_{h\to0}\dfrac{-2h(h-2)}{2}=\lim_{h\to0}\dfrac{2h(2-h)}{2}$$
$$$$
$$L_1=\dfrac{ax(x-1)}{2},x\to1^-$$
$$\Rightarrow L_1=\lim_{h\to 0}\dfrac{a(1-h)(1-h-1)}{2}=\lim_{h\to 0}\dfrac{a(1-h)(-h)}{2}$$
$$$$
Now it is given that $f(x)$ is differentiable for $x\in(0,2)$. Thus, $f(x)$ is continuous for $x\in(0,2)$. Thus $f(x)$ must be continuous at $x=1$. Therefore, $L_2$ must be equal to $L_1$ (and both must be respectively equal to $f(1)=0$). Equating both $L_2$ and $L_1$,
$$$$
$$\lim_{h\to0}\dfrac{2h(2-h)}{2}=\lim_{h\to 0}\dfrac{a(1-h)(-h)}{2}$$
$$\Rightarrow \lim_{h\to0}\dfrac{2h(2-h)}{2}-\lim_{h\to 0}\dfrac{a(1-h)(-h)}{2}=0$$ 
$$$$We now use the property $\lim_{x\to a}f(x)\pm\lim_{x\to a}g(x)=\lim_{x\to a}(f\pm g)(x)$
$$$$
$$\Rightarrow \lim_{h\to0}\left(\dfrac{2h(2-h)}{2}-\dfrac{a(1-h)(-h)}{2}\right)=0$$
$$\Rightarrow \lim_{h\to0}\dfrac{2h(2-h)+a(1-h)(h)}{2}=0$$
$$\Rightarrow 2(2-h)+a(1-h)=0, h\to0$$
$$\Rightarrow a+4=0$$
Finally, we get $a=-4$.
