Differential equation involving Newton's law of gravitation 
Newton's law of gravitation states that the acceleration of an object at a distance $r$ from the centre of an object of mass $M$ is given by
$$\frac{d^2r}{dt^2}=-\frac{GM}{r^2},$$
where $G$ is the universal gravitational constant.
(a) Use the identity
$$\frac{d^2r}{dt^2}=\frac{d}{dr}\left(\frac12v^2\right),$$
combined with integration with respect to $r$. Determine the resulting constant of integration using the condition $u=v(R)$ and show that
$$v^2-u^2=\frac{2GM}{r}-\frac{2GM}{R}$$
(b) Now write $r=R+s$ where $s$ is the height of the object above the surface
of the Earth, radius $R$ and mass $M$. Use the binomial series to expand the
factor $(1+s/R)^{-1}$ to show that, close to the surface of the Earth,
$$v^2\approx u^2-2gs,$$
for some constant $g$. Find the expression for $g$.
Reminder: The binomial series is $(1+x)^{-1}=1-x+x^2-x^3+\cdots$, which converges for $|x|\lt 1$.

(In case it is unclear, I am assuming that $G$ and $M$ are constants, and $v$ is purely a function of $r$, since that's what the question appears to mean.)
So far I have done the following:
I equated the two expressions for $\frac{d^2r}{dt^2}$ (which I'm not sure is correct, since if two functions have the same derivative, they may differ by a constant, so if their second derivatives are equal then I feel as though there should be two constants, but I haven't included any constants), then integrated both sides with respect to $r$.
$$\int \frac{d}{dr} \left(\frac12v^2\right) dr = -GM \int \frac{1}{r^2} dr$$
$$\implies\frac12v^2=\frac{GM}{r}+C$$
$$\implies v^2=\frac{2GM}{r}+C$$
$$\implies v=\sqrt{\frac{2GM}{r}+C}$$
$$u=v(R)=\sqrt{\frac{2GM}{R}+C}$$
$$\implies u^2=\frac{2GM}{R}+C$$
Since the constants are the same, they cancel when subtracted.
$$v^2-u^2=\frac{2GM}{r}-\frac{2GM}{R}$$
I'm doubtful if this method is correct because of the problem with the constants I referred to before, and also because I couldn't "determine the resulting constant of integration using the condition $u=v(R)$" as the question asked, rather I just cancelled the constants with subtraction. Is equating the two expressions for $\frac{d^2r}{dt^2}$ allowed?
As for part (b), I think I need the constant of integration from (a) to get the full expression for $v^2$, which I do not know how to find.
 A: The first part of your solution is correct. You have simply equated $\frac {d^2r}{dt^2}$ from two equations, and not $r(t)$. That is legitimate.
Moreover, $C$ from your work is indeterminate, it cannot be found out in the absence of further data, but since it is the same value it cancels, as you did.
The second part in fact follows from the first.
$$v^2-u^2=\frac {2GM}{r}-\frac {2GM}{R}$$
Since $r=R+s, s\lll R$-
$$v^2-u^2=\frac {2GM}{R}\left(\left(1+\frac sR \right)^{-1}-1\right)$$
From the binomial approximation, since $s\lll R$, $\left(1+\frac sR \right)^{-1}\approx 1-\frac sR$.
Hence, $$v^2-u^2 \approx -\frac {2GMs}{R^2}$$
Since $g=\frac {GM}{R^2}$, we get:
$$v^2\approx u^2-2gs$$
as required.
Perhaps it is useful to note that the second equation you had used in the first part of your solution is not a physical law, but a mathematical truth, as;
$$\frac {d^2r}{dt^2}=\frac {dv}{dt}=\frac {dr}{dt} \cdot \frac {dv}{dr}=v \frac {dv}{dr}=\frac {d\left(\frac 12 v^2\right)}{dv} \cdot \frac {dv}{dr}=\frac {d\left(\frac 12 v^2\right)}{dr}$$ from the definition of $v$.
But this makes little difference, even if it were a physical law which were valid for the conditions of this problem, the substitution would have been correct.
A: You have to find resulting constant of integration in first part , You have found it but not noticed it
You have
$$ v^2=\frac{2GM}{r}+C$$
When $r=R$ , $v=u$ therefore
$ u^2=\frac{2GM}{R}+C$ and equivalently
$C= u^2-\frac{2GM}{R}$
Substituting $C$ , you can show that
$v^2-u^2=\frac{2GM}{r}-\frac{2GM}{R}$
The second part can be now solved easily with hint in the question
