How to calculate the absolute extrema for this equation Basically, I am trying to find the absolute extrema for this problem, but I am stuck after a few steps.
$$y=\frac{4}{x}+\tan\left(\frac{\pi x}{8}\right),\quad x\in[1,2].$$
I have figured out the derivative, which is
$$y'=-\frac{4}{x^2}+\sec^2\left(\frac{\pi x}{8}\right)\cdot\frac{\pi}{8}.$$
However, after reaching this step, I am stuck. I have tried setting the derivative equal to zero, but I do not get anywhere as I don't know what to do next. How can I solve this problem? Any help is appreciated. Thanks.

Hint: You can use a difference of squares with the derivative:
$$ \frac{\pi}{8} \sec^2 \left( \frac{\pi x}{8} \right) - \frac{4}{x^2} = 0 $$
$$ \Rightarrow \left(\sqrt{\frac{\pi}{8}} \sec \left( \frac{\pi x}{8} \right) + \frac{2}{x}\right) \left(\sqrt{\frac{\pi}{8}} \sec \left( \frac{\pi x}{8} \right) - \frac{2}{x}\right) = 0 $$
Update:
$$ \Rightarrow \pm \frac{2}{x} = \sqrt{\frac{\pi}{8}} \sec \left( \frac{\pi x}{8} \right)$$
$$ \Rightarrow \pm \frac{x}{4}\sqrt{\frac{\pi}{2}} = \cos \left( \frac{\pi x}{8} \right) $$
Let $f_1(x) = \frac{x}{4}\sqrt{\frac{\pi}{2}}$, $f_2(x) = -\frac{x}{4}\sqrt{\frac{\pi}{2}}$, and $g(x) = \cos \left( \frac{\pi x}{8} \right) $.
We'll start with $f_1(x) = g(x)$. First, note $f_1(0) = 0$, and $g(0) = 1$. The period of $g(x)$ is $16$, so the next time it reaches its maximum value of $1$ is at $x = 16$. At the same time, $f_1(x) = 1$ at $x = \frac{4\sqrt{2}}{\pi} < 16 $. Since $f_1$ strictly increasing, $f_1$ and $g$ intersect exactly once on $x\ge 0$, somewhere on $x \in \left[0,\frac{4\sqrt{2}}{\pi}\right] $.
For $x \le 0$, $f_1(x) = -1$ at $x = -\frac{4\sqrt{2}}{\pi} > -4 $. Again, since $f_1$ is strictly increasing, $f_1$ is below the minimum value of $g$ for all $x < -\frac{4\sqrt{2}}{\pi} $ . Since $g(x) > 0$ for $x \in (-4,0] $, we have $f_1(x) < g(x) $ for all $x \le 0$.
Combining these, we have $f_1$ and $g$ intersect exactly once, let's say at $x = r_1$, where $r_1 \in \left[0,\frac{4\sqrt{2}}{\pi}\right] $.
Then, since $f_2(x) = f_1(-x)$ and $g(x) = g(-x)$, $f_2$ and $g$ intersect exactly once at $x = r_2 = -r_1$.
Further, note that there must be a sign change in $y'$ at $r_1$ because $f_1$ is strictly increasing for all $x$, and $g$ is decreasing on $[0,8]$, implying that $g$ is decreasing at $r_1$. The same logic implies a sign change at $r_2$ as well.
These two solutions are the unique roots of the factored form of the derivative we had above.
Then, we have
$$ y'|_{x=1} = -4 + \frac{\pi}{8}\sec^2 \left( \frac{\pi}{8} \right) $$
$$ = -4 + \frac{\pi}{8}\frac{4}{2+\sqrt{2}} $$
$$ = -4 + \frac{\pi}{4+2\sqrt{2}} $$
$$ < 0 . $$
Similarly,
$$ y'|_{x=2} = -1 + \frac{\pi}{8}\sec^2 \left( \frac{\pi}{4} \right) $$
$$ = -4 + \frac{\pi}{8}*2 $$
$$ = -4 + \frac{\pi}{4} $$
$$ < 0 . $$
Since $y' < 0$ at both $x = 1$ and $x = 2$, we know that $r_1 \notin [1,2]$, since there is no sign change in $y'$ and there is exactly one root (which has a corresponding sign change) for $x \ge 0$.
Then, the extreme values of $y$ must be at $x = 1$ and $x = 2$.
