Suppose I have a minimization problem
\begin{equation} \begin{aligned} & \min\limits_{x} & & g(x)+f(x) \end{aligned} \end{equation}
\begin{equation} f(x)= \begin{cases} 1, & \text{if}\ -1\leq x \leq 1 \\ x^2, & \text{otherwise} \end{cases} \end{equation}
$g(x)$ is some convex function, $f(x)$ is loosely convex, and $g(x) + f(x) $ will still be strictly convex.
How to use some math magic to replace the if-else into something regular that an off-the-shelf convex solver can recognize?
Edit: To make sure $f(x)$ is convex
The function $f$ can be written as $\max\{1, x^2\}$. Minimising a maximum of two functions is equivalent to minimising an upper bound $z$ to both functions. The modified problem reads: Minimise $g(x)+z$ subject to the additional constraints $$z\ge 1,\quad z\ge x^2.$$