According to the principle of energy conservation, the energy is not created, nor destroyed, it is transformed.
In this problem, we are talking about Mechanical Energy (
) which is the addition of the Kinetic Energy
(energy of the body in motion) and Potential Energy
(It can be Gravitational Potential Energy or Elastic Potential Energy, in this case is the first one):
(1)
The Kinetic Energy is:

Where
is the mass of the body and
its velocity
And the Potential Energy (Gravitational) is:

Where
is the gravitational acceleration and
is the height of the body.
Knowing this, the equation for the Mechanical Energy in this case is:
(2)
Now, according to the Conservation of the Energy Principle, the initial energy
must be equal to the final energy
:
(3)
(4)
At the beginning, the ball is in
over the point where it is released and has an initial speed
, this means the initial energy
is only the Kinetic Energy:
(5)
At the maximum height of
from the point at which the ball was released, it has an speed
, because at that very moment the ball stops and then begins to fall.
This means the final energy
is only the Potential Gravitational Energy
(6)
Well, according to the explanation above, we have to substitute (5) and (6) in (3):
(7)
Now we have to find
, the velocity of the ball when it was released:
Finally: