Find the general solution of $\theta$ for which the quadratic equation
$$\left(\sin\theta\right)x^2+(2\cos\theta)x+\dfrac{\cos\theta+\sin\theta}{2}$$ is the square of a linear function.
$$D=0$$ $$4\cos^2\theta-2\sin\theta\left(\sin\theta+\cos\theta\right)=0$$ $$2\cos^2\theta-\sin^2\theta-\sin\theta\cos\theta=0$$ $$2\cos^2\theta-2\sin\theta\cos\theta+\sin\theta\cos\theta-\sin^2\theta=0$$ $$2\cos\theta(\cos\theta-\sin\theta)+\sin\theta(\cos\theta-\sin\theta)=0$$ $$(\cos\theta-\sin\theta)(2\cos\theta+\sin\theta)=0$$ $$\tan\theta=1 \text { or } \tan\theta=-2$$
$$\theta=n\pi+\dfrac{\pi}{4} \text { or } \theta=\tan(2\pi-\tan^{-1}(2))$$ $$\theta=n\pi+\dfrac{\pi}{4} \text { or } \theta=n\pi+2\pi-\tan^{-1}(2)$$ $$\theta=n\pi+\dfrac{\pi}{4} \text { or } \theta=\pi(n+2)-\tan^{-1}(2)$$ $$\sin\theta\ne 0$$ $$\theta\ne m\pi \text { where $m \in$ I }$$
$$\theta=n\pi+\dfrac{\pi}{4} \text { can't be integral multiple of $\pi$ as } \theta=\dfrac{\pi(4n+1)}{4}$$
$$\theta=n\pi+\dfrac{\pi}{4} \text { is the valid solution }$$ $$\theta=\pi(n+2)-\tan^{-1}(2) \text { cannot be the integral multiple of $\pi$ as $\tan^{-1}(2)$ is not the integral multiple of $\pi$ } $$ $$\theta=\pi(n+2)-\tan^{-1}(2) \text { is the valid solution }$$
Hence $\theta=\pi(n+2)-\tan^{-1}(2) \text { or } \theta=n\pi+\dfrac{\pi}{4}$
But actual answer is $\theta= 2n \pi+\dfrac{\pi}{4} \text{or } \theta =(2n+1)\pi - \tan^{-1}(2) \text { where $n \in$ I}$
I tried to find out the mistake but didn't get any breakthrough. What am I missing.