Using calculus to prove cosine inequality

I’m not very good with the calculus of functions of two variables so I need someone to check my working below.

Prove that if *x*, *y*, *z* are the interior angles of a triangle, then $\displaystyle \cos{x}+\cos{y}+\cos{z}\leq\frac{3}{2}$.

I decided to use calculus to prove the result, so I defined a function of two variables

$\displaystyle \mathrm{f}(x,y)\ =\ \cos{x}+\cos{y}+\cos{(\pi-x-y)}\ =\ \cos{x}+\cos{y}-\cos{(x+y)}$

So

$\displaystyle \frac{\partial f}{\partial x}\ =\ -\sin{x}+\sin{(x+y)}$

$\displaystyle \frac{\partial f}{\partial y}\ =\ -\sin{y}+\sin{(x+y)}$

$\displaystyle \frac{\partial f}{\partial x}\ =\ \frac{\partial f}{\partial y}\ =\ 0\ \Rightarrow\ \sin{(x+y)}\ =\ \sin{x}\ =\ \sin{y}$

Since $\displaystyle 0\lneqq x,y\lneqq\pi$, we must have $\displaystyle x+y\ =\ \pi-x\ =\ \pi-y\ \Rightarrow\ x\ =\ y\ =\ \frac{\pi}{3}$.

Now

$\displaystyle \frac{\partial^2f}{\partial x^2}\ =\ -\cos{x}+\cos{(x+y)}$

$\displaystyle \frac{\partial^2f}{\partial y^2}\ =\ -\cos{y}+\cos{(x+y)}$

$\displaystyle \frac{\partial^2f}{\partial x\partial y}\ =\ \cos{(x+y)}$

$\displaystyle \therefore\ \left(\frac{\partial^2f}{\partial x^2}\right)\left(\frac{\partial^2f}{\partial y^2}\right)-\left(\frac{\partial^2f}{\partial x\partial y}\right)^2\ =\ \cos{x}\cos{y}-\cos{(x+y)}(\cos{x}+\cos{y})$

When $\displaystyle x=y=\frac{\pi}{3}$,

$\displaystyle \frac{\partial^2f}{\partial x^2}\ =\ -\frac{1}{4}\ <\ 0$ and

$\displaystyle \frac{\partial^2f}{\partial x^2}\frac{\partial^2f}{\partial y^2}-\left(\frac{\partial^2f}{\partial x\partial y}\right)^2\ =\ \frac{3}{8}\ >\ 0$

Hence f(*x*,*y*) has a maximum at $\displaystyle x=y=\frac{\pi}{3}\ (=z)$, which is $\displaystyle \frac{3}{2}$.

$\displaystyle \therefore\ \cos{x}+\cos{y}+\cos{z}\leq\frac{3}{2}$ for all the angles *x*, *y*, *z* of a triangle. Is my working all okay? ;)