There is a close connection between force and potential energy. One can be obtained from the other, in fact.
Force is the negative of the gradient of the potential.
The gradient operator looks like ∇
Mathematically, it involves partial derivatives:
∇ = ∂/∂x i + ∂/∂y j + ∂/∂z k
F = -∇U
Note that potential energy is a scalar, but taking the gradient of the potential energy results in a vector.
Ug = mgy
Because there is only a y-dependence, the force will only have a y-component.
F = -∇Ug = -mg j
The minus sign indicates that the force is directed down.
How about a horizontal spring:
Us = ½ kx2
Again, because there is only an x-dependence, the force will only have an x-component.
F = -∇Us = -kx i
How about a potential energy that's somewhat complicated?
U = 3xy + 5xz2
The force has three components:
F = -(3y + 5z2) i - 3x j - 10xz k