Potential Energy for Sum of two opposite forces Suppose I have the superpostion of a repulsive force pointing in the positive x-direction
$$ \frac{B}{x^2}\hat i  $$ And the constant force along x-axis pointing towards the origin
$$ -A \hat i$$
The superposition of both is
$$ F_x = \frac{B}{x^2}-A $$
I want to find the potential energy $U(x)$ of this force. But to find $U(x)$ I need a reference point where the potential energy is 0. For the gravitational and electric potentials we take this to be infinity and this allows us to find $U(x) = KqQ/x$ and $-GMm/x$. However the potential of our new force is given by
$$ \int dU = \int \left(\frac{B}{x'^2}-A\right) dx' $$
If I integrate from $a$ to $x$ to get  $$ U(x)-U(a) $$
then if I can find a position $a$ along the $x$-axis such that $U(a) = 0$ then I can get $U(x)$ relative to that point. For the gravitational and electric energies this corresponds to $x =\infty$, and for the spring force this corresponds to $x=0$. However solving the equation above we get
$$ U(x)-U(a) = \frac{Ax^2+B}x - \frac{Aa^2+B}a  $$
$$ U(x) = \frac{Ax^2+B}x +\left(U(a) - \frac{Aa^2+B}a\right)  $$
This function never has a 0 but the questions says to find $U(x)$. There is no $a$ such that $U(a) = 0$. Where did I go wrong?
 A: The zero of potential energy is always arbitrary.  Because the force is the (negative) derivative of the potential, you can add a constant to the potential without changing the dynamics predicted by the forces.
When we are dealing with a $1/r^2$ force like gravity or electrostatic attraction, we usually choose the potential energy zero to be at infinity, because then we can use the potential energy form $U \sim 1/r$ without any extra terms. But when we are dealing with a constant force, like the “mg” approximation to gravity near Earth’s surface, we usually choose the zero to be a convenient height in our problem, such as the starting altitude, or the height of the floor, or sea level, or the origin of our coordinate system.
If you choose the “default” potential energy
$$
U(x) = +Ax +B/x
$$
for your constant attraction and inverse-square repulsion, you’ll have no $U(x)=0$  for positive $x$ because both terms are everywhere positive. If you want a zero at $a$, just use
$$
U’(x) = U(x) - U(a)
$$
as your shifted potential energy. Since
$
\frac{\mathrm d}{\mathrm dx}U(a) =0
$,
this doesn’t change any of your forces.
Beware that somewhere in your question you mention a “spring force.” But the Hooke’s Law force is linear in position, not constant, and has a quadratic potential.
A: lets put it this way
the force is
$$F=-\frac{dU(x)}{dx}\tag 1$$
this means that if the  potential U is constant the force is zero $~(\frac{dC}{dx}=0)~$ and zero force   doesn't change the dynamic of your system.
thus  equation (1):
$$U(x)\pm C=-\int F(x)\,dx$$
your case
$$U(x)\pm C=-\int\left(\frac {B}{x^2}-A\right)=\frac{B}{x}+A\,x\\
U(a)\pm C\,\overset{!}{=}0\quad\Rightarrow C=\pm \left(\frac Ba+\frac Aa\right)$$
A: Potential energy can be defined as work done bringing object from infinity to the point $x$. Definite integral of the form :
$$ \int_\infty^x \frac {1 - x^2}{x^2} dx ~~~~(1)$$ diverges, so this type of potential doesn't make much sense if defined as in gravitational potential.
However, if you choose potential to be work done bringing object from $a$ to $b$ point,  then potential energy:
$$ U_{a_ \to b} = \int_a^b \frac {1 - x^2}{x^2} dx = (a-b) + \left(\frac 1a - \frac 1b\right) ~~~~(2)$$
Then you can find some $a,b$ values, with which such potential energy converges. It's interesting to note, that if in eq.(2) we assume $a=nb$, then (2) equation limit becomes :
$$ \lim_{n\to ∞} (n b - b) + \left(\frac {1}{n b} - \frac 1b\right) = b~ \infty ~~~~(3)$$
then for :
$$ b \in [-∞, 0) \cup (0, ∞]  ~:~ b~\infty = \pm \infty ~~~~(4)$$
So it seems that if your potential is defined as in gravitational potential analogy, then it is infinite.
