If we denote the shearing force by S and the bending moment by M, using the differential equations for a beam we have,
where w is the weight per unit length.
A is an arbitrary constant.
Using the boundary conditions
The bending moment and the vertical deflection is related by the Euler-Bernoulli equation,
Substituting the value obtained for M and using the boundary conditions you can obtain,
Hope this will help you.