In this case, different part of the rod does not elongate to the same extent. The element closer to the support elongates more as the stress is higher with respect to the elements closer to the free end of the rod.
To determine total elongation of the rod,let us consider a small element of defferential length `dx` at a distance `x` from the free end of the rod, as shown in the figure.
The stress at the position of this element is produced by the weight of the rod of length `x` lying below it i.e. `(W/L)x`
Therefore, stress at this section
`sigma=((W/L)x)/A=(Wx)/(AL)`
The elongation `ddelta` produced in the differential element `dx` is
`ddelta=sigma/Ydx=W/(YAL)xdx`
Thus, total elongation produced in the rod can be calculated as
`delta=intd delta`
`delta=S/(YAL)int_(0)^(L)xdx=W/(YAL)[(x^(2))/2]_(0)^(L)`
or `sigma=1/2(WL)/(YA)`.........v