# Finding extrema of general function of n variables without constrained optimization

In our calculus textbook we are given the following exercise:

Given function $f(x_1, x_2, \dots, x_n) = \sum_{i = 1}^{n}\sin(x_i) + \sin\left(\sum_{i=1}^{n}x_i\right)$ with $x_i \in (0, \pi)$ and $\sum_{i = 1}^{n}x_i \in (0, \pi)$ find it's extrema points and determine their type using only gradient and Hessian matrix.

Taking partial derivatives for two arbitrary variables $x_i$ and $x_j$ we get $$\partial_{i}f = \cos(x_i) + \cos\left(\sum_{i = 1}^{n} x_i\right) = 0,$$ $$\partial_{j}f = \cos(x_j) + \cos\left(\sum_{i = 1}^{n} x_i\right) = 0.$$ Subtracting them we get that $$\cos(x_i) = \cos(x_j),$$ and so all minima lie at point where all values will be the same. Now trying to find points of interest gives me the condition $$\cos(x_i) = \cos(nx_i).$$

From that point and on, I'm stuck. How can I proceed there?

## 2 Answers

You have all $x_i=x$ with $$\cos x=-\cos nx$$ (note the minus sign that you have missed above) where $x,nx\in(0,\pi)$. The only solution to this equations is easy to see on the unit circle from symmetry (note $nx>x$) $$nx=\pi-x.$$ Thus $x_i=x=\frac{\pi}{n+1}$.

Calculate the Hessian and verify that it is negative definite, hence the critical point is a local maximum.

Hint: According to your conclusion "all minima lie at point where all values will be the same", at mimimum point we have $(x_1, x_2, \dots, x_n) = (t, t, \dots, t)$ so to find $t \in (0 , \pi)$ you need to minimize the function

$$g(t) = n \sin(t) + \sin(nt)$$

Now go ahead and set derivative equal to zero...

By the way I assumed minimum exists !