Consider a solenoid of length 2l, radius r and carrying a current I and having n turns per unit length.
Consider a point P at a distance a from the centre O of solenoid. Consider an element of solenoid of length dx at a distance x from its centre. This element is a circular current loop having (ndx) turns. The magnetic field at axial point P due to this current loop is


The total magnetic field due to entire solenoid is

For a>>I and a>>r, we have {r2+(a - x)2}3/2 = a3

The magnetic moment of solenoid m = (= NIA) = (n2I)I. πr2

This is also the far axial magnetic field of a bar magnet. Hence, the magnetic field, due to current carrying solenoid along its axial line is similar to that of a bar magnet for far off axial points.