Show that $x \mapsto \frac{\|x\|^2}{2}+\cos\|x\|$ is strictly convex. I'm trying to solve a past year exam question. I'm having trouble with this question.
I have to show that the following function is strictly convex.
$$f: \mathbb{R}^n \rightarrow \mathbb{R}, \\  x \mapsto \frac{\|x\|^2}{2}+\cos\|x\|,$$
where $\|\cdot \|$ is the Euclidean norm on $\mathbb{R}^n$. Any help would be greatly appreciated.
I wanted to compute the Hessian. To do so, I wanted to use the fact that this function is constant on any sphere. Since $f$ is constant on any sphere, the gradient is perpendicular to the sphere at any point on the sphere. But I'm not sure how to proceed. I've showed that this function is convex by decomposing it as $u \circ v$ with  $v$ the norm and $u$ as $x^2/2 + \cos(x)$. I showed that $v$ is convex and that $u$ is convex and increasing.
 A: First answer
You were almost there!
$f=u\circ v$ with $v(x)=\|x\|$ and $u(t)=\frac{t^2}2+\cos t.$
Since $v$ is strictly convex and $u$ is strictly convex and increasing, $f$ is strictly convex.
Second answer
For $x\ne0,$ let $t:=\|x\|>0.$
The first and second differentials of $f$ at $x$ are given by:
$$df_x(h)=\langle x,h\rangle\left(1-\frac{\sin t}t\right),
$$
$$d^2f_x(h,k)=\langle h,k\rangle\left(1-\frac{\sin t}t\right)-\langle x,h\rangle\langle x,k\rangle\frac{t\cos t-\sin t}{t^3}
$$
hence if $t\notin2\pi\Bbb Z$:

*

*for all $h$ linearily independent from $x,$
$$\begin{align}t^3d^2f_x(h,h)&=\|h\|^2\|x\|^2\left(t-\sin t\right)-\langle x,h\rangle^2\left(t\cos t-\sin t\right)\\
&>\langle x,h\rangle^2t\left(1-\cos t\right)\ge0,\end{align}$$

*for $h=\lambda x$ with $\lambda\ne0,$
$$d^2f_x(h,h)=\|h\|^2\left(1-\cos t\right)>0.$$
This proves that $d^2f_x$ is positive definite for all $x$ such that $\|x\|\notin2\pi\Bbb Z.$ So,  the set of "bad" $x$'s contains no non-trivial segment,  hence $f$ is strictly convex.
A: Consider the function $g:\mathbb R^+\rightarrow \mathbb R$ given by $g\left(t\right) =\frac{t^2}2 + \cos t$.
We have $g’\left(t\right)=t-\sin t > 0$ so that $g$ is strictly increasing.
Suppose $r<s$. Then
$$\begin{align}
\sin s -\sin r&=2\sin\left(\frac{s-r}2\right)\cos\left(\frac{s+r}2\right) \\
&\leq 2\sin\left(\frac{s-r}2\right) \\
&<2\frac{s-r}2 \\
&=s-r
\end{align}$$ so that $g’$ is strictly increasing.
This implies that $g$ is strictly convex.
Suppose $x\neq y$ and $0<\lambda<1$.
If $\left\Vert x\right\Vert \neq\left\Vert y\right\Vert$ then
$$ \begin{align}
f\left(\lambda x + \left(1-\lambda\right)y\right) &= g\left(\left\Vert \lambda x + \left(1-\lambda\right)y\right\Vert\right) \\
&\leq g\left(\lambda\left\Vert x \right\Vert + \left(1-\lambda\right)\left\Vert y\right\Vert\right) \\
&< \lambda g\left(\left\Vert x\right\Vert\right)+\left(1-\lambda\right)g\left(\left\Vert y \right\Vert\right) \\
&=\lambda f\left(x\right)+\left(1-\lambda\right)f\left(y\right)
\end{align}$$
where the first inequality holds because $g$ is strictly increasing and the second because it is strictly convex.
If $\left\Vert x\right\Vert = \left\Vert y\right\Vert$ then $\lambda x+\left(1-\lambda\right)y$ is an interior point of the ball of radius $\left\Vert x\right\Vert $ ($=\left\Vert y\right\Vert$). Then $\left\Vert \lambda x+\left(1-\lambda\right)y\right\Vert <\left\Vert x\right\Vert $ so that
$$ \begin{align}
f\left(\lambda x + \left(1-\lambda\right)y\right) &= g\left(\left\Vert \lambda x + \left(1-\lambda\right)y\right\Vert\right) \\
&< g\left(\left\Vert x \right\Vert\right) \\
&= \lambda g\left(\left\Vert x\right\Vert\right)+\left(1-\lambda\right)g\left(\left\Vert x \right\Vert\right) \\
&= \lambda g\left(\left\Vert x\right\Vert\right)+\left(1-\lambda\right)g\left(\left\Vert y \right\Vert\right) \\
&=\lambda f\left(x\right)+\left(1-\lambda\right)f\left(y\right)
\end{align}$$
where the inequality holds since $g$ is strictly increasing.
This proves that $f$ is strictly convex.
