Answer: escape velocity v = sqrt[(2GM)/r], where G is the gravitational constant.
Reasoning:
Conservation of energy means that the total initial energy must be equal to the total final energy, in other words, E_total = E_kinetic, initial + E_potential, initial = E_kinetic, final + E_potential, final.
E_kinetic = (1/2)mv^2, as always. And in this case, E_potential is gravitational potential energy, so it is equal to -[(GMm)/r].
We want to find the speed required for m to reach r = infinity, so the final energy values should be calculated at r = infinity. Let's find those final values.
E_kinetic, final = 0, since we are trying to find the minimum velocity required to get m to r = infinity, but no further, so that at r = infinity, m should come to a complete stop. It should have zero velocity there, and therefore its final kinetic energy should be zero.
E_potential, final = 0 as well, since as r approaches infinity, -[(GMm)/r] approaches zero.
This means that E_total = 0, so that by conservation of energy, E_kinetic, initial + E_potential, initial = 0.
Now we just need to solve this equation for v.
E_kinetic, initial + E_potential, initial = 0 is equivalent to (1/2)mv^2 - [(GMm)/r] = 0
Solving this for v gives us the answer: v = sqrt[(2GM)/r].