# Finding the global maxima and minima on closed interval

Given a function $f(\theta) = (4\theta-\pi)\sin(\theta)+4\cos(\theta)-2.$ I want to find a value for $\theta$ in interval $\theta \in [0,\frac{\pi}{2}]$ such that for that value of $\theta$ my function has global maximum and minimum.

I took the derivative of the function which is equal $f'(\theta) = \cos(\theta)(4\theta-\pi)$.

Here i got two critical points which are $\frac{\pi}{4},\frac{\pi}{2}$.

I picked $\frac{\pi}{6}$ at the left of the crictical point $\frac{\pi}{4}$ and $\frac{\pi}{3}$ at the right of the critical point $\frac{\pi}{4}$ to see the behaviour of the function.

It seems that the function is decreasing on the interval $(0,\frac{\pi}{4})$ and increasing on the interval $(\frac{\pi}{4},\frac{\pi}{2})$ but $\frac{\pi}{2}$ is not included because it is also a critical point. I don't know how to deal with this kind of situation?

I tried to find the co-ordinates also and they are

$f(0) = 2$

$f(\frac{\pi}{2}) = 1.141$

$f(\frac{\pi}{4}) = 0.82$

Is my global max at $(\theta = 0)$ and global min at $(\theta = \frac{\pi}{4})$?

I think you got both answers right. $\theta = \frac{\pi}{2}$ is a critical point and yields a "local maximum" value, indeed. I plotted the graph of the function on given interval so you can check it: https://www.wolframalpha.com/input/?i=f(%CE%B8)%3D(4%CE%B8%E2%88%92%CF%80)sin(%CE%B8)%2B4cos(%CE%B8)%E2%88%922;+0+%3C%3D+%CE%B8+%3C%3D+pi%2F2
Also, I plotted the graph of the same function on the interval $0 \le \theta \le \frac{11 \pi}{20}$ in here and as you can see, function starts to decrease after $\theta = \frac{\pi}{2}$: https://www.wolframalpha.com/input/?i=f(%CE%B8)%3D(4%CE%B8%E2%88%92%CF%80)sin(%CE%B8)%2B4cos(%CE%B8)%E2%88%922;+0+%3C%3D+%CE%B8+%3C%3D+11pi%2F20&rawformassumption=%7B%22C%22,+%220%22%7D+-%3E+%7B%22NumberMath%22%7D
Since you already found the critical points, why not apply the second derivative test ? $$f'(\theta) = \cos(\theta)(4\theta-\pi)\implies f''(\theta) =4 \cos (\theta)-(4 \theta-\pi ) \sin (\theta)$$ from which $$f''\left(\frac{\pi }{4}\right)=2 \sqrt{2}\color{red} {>0} \qquad \text{and} \qquad f''\left(\frac{\pi }{2}\right)=- \pi \color{red} {<0}$$ revealing that $\theta=\frac{\pi }{4}$ corresponds to a minimum and $\theta=\frac{\pi }{2}$ corresponds to a maximum.
This is right. Just to add something: if you were only asked to look for global extrema, you can relay on Weierstrass theorem, which guarantees that a continuous function on a compact set (in $\mathbb{R}$ this is just the same as bounded and closed) has a global maximum and a global minimum. So once you've checked that they could only be achieved on $\theta=0$, $\theta=\frac\pi 4$ or $\theta=\frac \pi 2$, checking which of $f(0)$, $f(\frac \pi 4)$ and $f(\frac \pi 2)$ is greater and which is lower, you can conclude where are those global extrema.