The smallest positive, and largest negative, values attained by $\sin x+\cos x+\tan x+\cot x+\sec x+\csc x$ Question:-

Consider the function
$$f(x)=\sin x+\cos x+\tan x+\cot x+\sec x+\csc x$$
Let $P$  be the smallest possible positive real number such that the equation $f(x)=P$ has real solutions, and let $N$ be the largest possible negative real number such that the equation $f(x)=N$  has real solutions.
Find the value of $[1000(P+N)]$.

MyApproach:
I am not getting idea how to proceed, since I can't understand how to find the real solutions. If I somehow find the smallest positive and largest negative from the real solutions, then it would be possible for me to solve this question.

Any idea how to get the real solutions from f(x)?

 A: Hint:
Let $\sin x+\cos x=y\implies2\sin x\cos x=y^2-1$
$$a=\sin x+\cos x+\tan +\cot x+\sec x+\csc x=y+\dfrac2{y^2-1}+\dfrac{2y}{y^2-1}$$
$$\iff y^3-ay^2+y+a+2=0$$
Now $$-\sqrt2\le y\le\sqrt2\implies-2\le-y^2\le0$$
Case $\#1:$ 
If $a\le0,$
$$0=y^3-ay^2+y+a+2\le2\sqrt2-2a+\sqrt2+a+2$$
$$\iff a\le3\sqrt2+2,\text{ but }a\le0$$
and $$0=y^3-ay^2+y+a+2\ge-2\sqrt2-2a-\sqrt2+a+2$$
$$\iff a\ge2-3\sqrt2\implies 0\le a\le2-3\sqrt2$$
Case $\#2:$ 
If $a>0$
Please try yourself , I'm yet to complete it.
A: Period of $f$ is $2\pi$ so lets analyse it in the length $[0,2\pi]$ with the help of $f'$.
$$f'(x) = \cos x - \sin x+\sec^2x-\csc x \cot x+\sec x\tan x-\csc^2 x = 0\\
 $$
Now you have to factorise this to get the roots.
$$\frac{ (\cos(x) - \sin(x)) (  \sin(x) \cos(x) - \sin(x)- \cos(x))}{2 (\cos(\tfrac{x}{2}) - \sin(\tfrac{x}{2}))^2\sin^2(\tfrac{x}{2}) }=0$$
Now after finding the roots of $f'$, which should not be many in number, its easier to manually check for value of $f$ at these points.
I get two trivial roots as $\frac{\pi}{4}, \frac{5\pi}{4}$. There are more roots from the factor $(\sin(x) \cos(x) - \sin(x)- \cos(x))$ which I havent evaluated.
