What is the maximum value of the function sin x + cos x?
Let f(x) = sin x + cos x.
$\therefore f^{\prime}(x)=\cos x-\sin x$
$f^{\prime}(x)=0 \Rightarrow \sin x=\cos x \Rightarrow \tan x=1 \Rightarrow x=\frac{\pi}{4}, \frac{5 \pi}{4} \ldots$,
$f^{\prime \prime}(x)=-\sin x-\cos x=-(\sin x+\cos x)$
Now, $f^{\prime \prime}(x)$ will be negative when $(\sin x+\cos x)$ is positive i.e., when $\sin x$ and $\cos x$ are both positive.
Also, we know that $\sin x$ and $\cos x$ both are positive in the first quadrant. Then, $f^{\prime \prime}(x)$ will be negative when $x \in\left(0, \frac{\pi}{2}\right)$.
Thus, we consider $x=\frac{\pi}{4}$.
$f^{\prime \prime}\left(\frac{\pi}{4}\right)=-\left(\sin \frac{\pi}{4}+\cos \frac{\pi}{4}\right)=-\left(\frac{2}{\sqrt{2}}\right)=-\sqrt{2}<0$
$\therefore$ By second derivative test, $f$ will be the maximum at $x=\frac{\pi}{4}$ and the maximum value of $f$ is $f\left(\frac{\pi}{4}\right)=\sin \frac{\pi}{4}+\cos \frac{\pi}{4}=\frac{1}{\sqrt{2}} \times \frac{1}{\sqrt{2}}=\frac{2}{\sqrt{2}}=\sqrt{2}$.