# Hessian at a maximum point lying on the boundary

Let $$\Omega$$ be a bounded domain of class $$C^2$$ in $$\mathbb{R}^n$$ and let $$f: \overline{\Omega} \to \mathbb{R}$$ be a smooth function. Assume $$f$$ attains its maximum at $$x_0 \in \partial \Omega$$. Can we say that the Hessian of $$f$$ at $$x_0$$ is negative semidefinite? I know this is true if $$x_0$$ lies in the interior of $$\Omega$$.

No. Take $$\ \Omega\$$ to be the open unit ball in $$\ \mathbb{R}^n\$$ and $$\ f\left(x_1,x_2,\dots, x_n\right)=\sum_{i=1}^na_ix_i^2\$$ with $$\ a_i>a_{i+1}>0\$$ for all $$\ i=1,2,\dots, n-1\$$. Then the Hessian of $$\ f\$$, $$H=\pmatrix{2a_1&0&\dots&0\\ 0&2a_2&\dots&0\\ \vdots&\vdots&\ddots&\vdots\\ 0&0&\dots&2a_n}\ ,$$ is everywhere strictly positive definite, but $$\ f\$$ attains a maximum of $$\ a_1\$$ on $$\ \overline\Omega\$$ at $$\ x_0=\pmatrix{1,&0,&0,&\dots,&0}\$$.