2 added 401 characters in body
source | link

Taking the zero of elastic potential energy to be when the spring is unextended, $x=0$, the elastic potential energy is $\frac 12 k\, x^2$$U_{\rm spring}=\frac 12 k\, x^2$ where $k$ is the spring constant and $x$ is the extension or compression of the spring.
You will note that both $k$ and $x^2$ are positive quantities which means that the elastic potential energy is always positive whether the spring is extended ($x$ positive) or compressed ($x$ negative).

However the change in elastic potential energy of a spring can be either positive when $x^2_{\rm final} > x^2_{\rm initial}$ or negative when $x^2_{\rm final} < x^2_{\rm initial}$.

Gravitational potential energy $U_{\rm gravitational}$ does not have a distance squared term so it all depends where the zero of gravitational potential is.
If it is at the position when the spring is unextended then the gravitational potential energy of the mass at the end of the spring is positive if the mass is above the unextended position and negative if the mass is below.

Taking the zero of elastic potential energy to be when the spring is unextended, $x=0$, the elastic potential energy is $\frac 12 k\, x^2$ where $k$ is the spring constant and $x$ is the extension or compression of the spring.
You will note that both $k$ and $x^2$ are positive quantities which means that the elastic potential energy is always positive whether the spring is extended ($x$ positive) or compressed ($x$ negative).

However the change in elastic potential energy of a spring can be either positive when $x^2_{\rm final} > x^2_{\rm initial}$ or negative when $x^2_{\rm final} < x^2_{\rm initial}$.

Taking the zero of elastic potential energy to be when the spring is unextended, $x=0$, the elastic potential energy is $U_{\rm spring}=\frac 12 k\, x^2$ where $k$ is the spring constant and $x$ is the extension or compression of the spring.
You will note that both $k$ and $x^2$ are positive quantities which means that the elastic potential energy is always positive whether the spring is extended ($x$ positive) or compressed ($x$ negative).

However the change in elastic potential energy of a spring can be either positive when $x^2_{\rm final} > x^2_{\rm initial}$ or negative when $x^2_{\rm final} < x^2_{\rm initial}$.

Gravitational potential energy $U_{\rm gravitational}$ does not have a distance squared term so it all depends where the zero of gravitational potential is.
If it is at the position when the spring is unextended then the gravitational potential energy of the mass at the end of the spring is positive if the mass is above the unextended position and negative if the mass is below.

1
source | link

Taking the zero of elastic potential energy to be when the spring is unextended, $x=0$, the elastic potential energy is $\frac 12 k\, x^2$ where $k$ is the spring constant and $x$ is the extension or compression of the spring.
You will note that both $k$ and $x^2$ are positive quantities which means that the elastic potential energy is always positive whether the spring is extended ($x$ positive) or compressed ($x$ negative).

However the change in elastic potential energy of a spring can be either positive when $x^2_{\rm final} > x^2_{\rm initial}$ or negative when $x^2_{\rm final} < x^2_{\rm initial}$.