Find the minimum value of $|\sin x+\cos x+\tan x+\cot x+\sec x+\csc x|$ for real numbers $x$ I'm tutoring for a college math class and we're doing putnam problems next week and this one stumped me: 

Find the minimum value of $|\sin x+\cos x+\tan x+\cot x+\sec x+\csc x|$ for real numbers $x$.

 A: Let $x \in [0,2 \pi)$ and
$$f(x) = \sin{x} + \cos{x}+\tan{x}+\cot{x}+\sec{x}+\csc{x}$$
Then
$$\begin{align}f'(x) &= \cos{x} - \sin{x} + \sec^2{x} - \csc^2{x} + \sec{x} \tan{x} - \csc{x} \cot{x}\\ &= \frac{\cos{x}-\sin{x}}{\cos^2{x} \sin^2{x}} (\cos^2{x} \sin^2{x} - (\cos{x} + \sin{x}) - (\cos^2{x}+\cos{x} \sin{x} + \sin^2{x}))\\ &= \frac{\cos{x}-\sin{x}}{\cos^2{x} \sin^2{x}} (\cos{x} \sin{x} - \cos{x} - \sin{x})(1 + \cos{x} \sin{x} + \cos{x}+\sin{x}) \end{align}$$
Regardless of the absolute value, we have extrema where
$$\begin{array} \\ \cos{x} - \sin{x} = 0 & (1) \\ \cos{x} \sin{x} - \cos{x} - \sin{x}=0 & (2) \\ 1 + \cos{x} \sin{x} + \cos{x}+\sin{x}=0 & (3) \end{array}$$
(1) implies that $x \in \{\pi/4,5 \pi/4\}$, while (3) implies that $x \in \{\pi,3 \pi/2\}$.  (2) on the other hand implies that
$$\frac{1}{4} \sin^2{2 x} = 1 + \sin{2 x} $$
or that $2 x = 2 \pi-\arcsin{[2 (\sqrt{2}-1)]}$ so that the solution is $\in [0,2\pi)$.  (The other solution to the quadratic is $> 1$.)
Plugging in these values into $g(x)$, we find that
$$\begin{align}\left |g \left ( \frac{\pi}{4} \right ) \right | &= 3 \sqrt{2} + 2\\ \left |g \left ( \frac{5\pi}{4} \right ) \right | &= 3 \sqrt{2} - 2\\ |g(\pi)| &= 2\\ \left |g \left ( \frac{3\pi}{2} \right ) \right | &=2\\\end{align}$$
Finally, for the last solution, I will spare you the simplifications involved; we get
$$\left|g \left ( \pi - \frac{1}{2} \arcsin{[2 (\sqrt{2}-1)]} \right ) \right | = 2 \sqrt{2}-1 $$
The minimum value is thus $2 \sqrt{2}-1 $.
EDIT
Per the point raised by @Ivan below, I show that $f(x) \ne 0 \: \forall x \in [0,2 \pi)$.  $f(x)$ may be rewritten as 
$$f(x) = \frac{\csc \left(\frac{\pi }{4}-\frac{x}{2}\right) \csc \left(\frac{x}{2}\right)
   (-\sin (x)-\cos (x)+2 \sin (x) \cos (x)+3)}{2 \sqrt{2}}$$
The solution to $f(x)=0$ means that
$$\sin^2{2 x} + 5 \sin{2 x} + 8 = 0$$
which has no real solutions.  Thus, $f(x) \ne 0 \: \forall x \in [0,2 \pi)$ and the result holds.
A: Let $\sin{x}+\cos{x}=\sqrt{2}\sin{(x+\frac{\pi}{4})}=a$, then $a$ can take any value between $-\sqrt{2}$ and $\sqrt{2}$. We have $\sin{x}\cos{x}=\frac{a^2-1}{2}$. Thus
\begin{align}
\left||\sin{x}+\cos{x}+\tan{x}+\cot{x}+\sec{x}+\csc{x} \right|& =\left|\sin{x}+\cos{x}+\frac{1}{\sin{x}\cos{x}}+\frac{\sin{x}+\cos{x}}{\sin{x}\cos{x}} \right| \\
& =\left|a+\frac{2+2a}{a^2-1} \right| \\
& =\left|a+\frac{2}{a-1} \right|
\end{align}
If $a<1$, let $b=1-a>0$, then $a+\frac{2}{a-1}=1-(b+\frac{2}{b}) \leq 1-2\sqrt{2}<0$, so $\left|a+\frac{2}{a-1} \right| \geq 2\sqrt{2}-1$. 
($b+\frac{2}{b} \geq 2\sqrt{2}$ by AM-GM inequality or square $\geq 0$)
Equality holds when $b=\sqrt{2}, a=1-\sqrt{2}, x=\sin^{-1}{(\frac{1-\sqrt{2}}{\sqrt{2}})}-\frac{\pi}{4}$.
If $1 \leq a \leq \sqrt{2}$, then $a+\frac{2}{a-1}>\frac{2}{a-1}>2$, so $\left|a+\frac{2}{a-1} \right|>2>2\sqrt{2}-1$.
Thus the minimum value is $2\sqrt{2}-1$, achieved when $x=\sin^{-1}{(\frac{1-\sqrt{2}}{\sqrt{2}})}-\frac{\pi}{4}$.
A: I've found one solution here. Have a look.
