We have an optimization problem $\max_x f(x)$.
We have a procedure that computes an approximate solution $x$.
The procedure assumes that $x$ is not constrained. In this case, $x \in [-1,1]$.
Therefore, we can run the procedure on the function $f(g(x))$, where $g$ is a transformation that takes any $x \in \mathbb{R}$ and maps it to $[-1,1]$.
Question: Which transformation is typically used? Are some better than others? I used a few transformations like $\sin$ and $\cos$, and they produced different outputs.
I'd suggest using a logistic function modified to output between $(-1, 1)$:
$$g(x) = \frac{2}{1 + e^{-x}} - 1$$
If you use a periodic mapping like sine or cosine, your optimizer might run into identifiability issues, because there are an infinite set of $x$ that all maximize $f(g(x))$. A logistic function is one-to-one, so you won't have identifiability issues.
One caveat of this approach is that $-1$ and $1$ cannot be produced by this $g(x)$, but you can check $-1$ or $1$ quickly to see if the optimum lies there.