I know this question has been answered many times, but I wanted to verify another method to solve this that I couldn’t find elsewhere. So I did the following:
I fixed a point P distant $d$ from one end of the line(of length $L$). Now, we’re free to choose the second point anywhere on the line. The first point divides the line into two parts of length $d$ and $L-d$.
$\mathbf{Case \space 1: Second\space point \space lies \space in\space the \space first \space part}$
By symmetry, the ‘average’ point will be exactly in the middle of the part, that is, at a distance $d/2$.
$\therefore$ Average distance between the $2$ points = $d/2$
$\mathbf{Case\space 2: \space It \space lies \space in\space the\space latter\space part}$
Using a similar argument,
Average distance in this case = $\frac{L-d}{2}$
Combining the two cases,
Effective Average distance $=P(Case 1)\cdot \frac{d}{2} + P(Case 2)\cdot \frac{L-d}{2}$
$=\frac{d}{L}\cdot \frac{d}{2} + \frac{L-d}{L}\cdot \frac{L-d}{2}$
$=\frac{d^2+(L-d)^2}{2L}$
Now, I tried to account for the fact that the initial first point could be situated anywhere on the line, by making $d$ a variable.
Let $f(d)=\frac{d^2 + (L-d)^2}{2L}$ , $0\le d\le L$
And then I found the average value of $f(d)$ in the interval $[0,L]$.
$$\bar{f(d)} = \frac{1}{L} \int_0^L \frac{d^2+(L-d)^2}{2L}dd$$
$$= {\frac{L}{3}}$$ Is what I did a valid way to do averages (i.e. taking care of one parameter at a time) or did I just get lucky? I want to know how averages really work.