We want to maximize the convex function: $$\vec{q} \cdot \vec{x} - \lambda||\vec{x} - \vec{1}||_2^2$$ where $\lambda$ is some parameter.
I'm looking at a solution that states that the maximum is a piecewise function depending on whether $||q|| \leq 2 \cdot \lambda$ or otherwise.
The value of $x$ that maximizes the function above is claimed to be: $$\begin{cases} (1/2)\vec{q}/\lambda + \vec{1} & ||\vec{q}|| \leq 2\lambda \\ \vec{q}/||\vec{q}|| + \vec{1} & ||\vec{q}||> 2\lambda\\ \end{cases}$$
I didn't even consider how the norm of $\vec{q}$ might relate to $\lambda$ when trying to compute this myself. In fact, I arrived at only the solution for when $||\vec{q}|| \leq 2\lambda$ by taking the derivative of $\vec{q} \cdot \vec{x} - \lambda||\vec{x} - \vec{1}||_2^2$ with respect to $\vec{x}$ coordinate-wise, setting it equal to $0$, and then solving for $\vec{x}$ again coordinate-wise.
Can someone please explain why we should care whether or not $||\vec{q}|| > 2\lambda$, and how to compute the $x$ that maximizes the above function when $||\vec{q}|| > 2\lambda$?
Edit: there is a constraint on $\vec{x}$ that was mentioned elsewhere in the solution: $\vec{x}$ is in the $2-$norm unit ball centered at $1$.
The function (which is concave, not convex) is always maximized at $x= 1 + \frac{q}{2 \lambda}$ for $\lambda > 0$. Perhaps there is some constraint on $x$. Also, the solution you suggest for the second case is a number, not a vector.