Let NS be a bar magnet of magnetic length 2l and having each pole of magnetic strength m . O is the center of magnet and P is a point on axial line at a distance r from the center O of magnet , at which magnetic field has to be measured .
The magnetic field B1 at P due to N pole of magnet ,
or B1=μ04π.m(r−l)2 (along PX) .......................eq1
And , the magnetic field B2 at P due to S pole of magnet ,
or B2=μ04π.m(r+l)2 (along PS) ......................eq2
Therefore , resultant magnetic field at point P ,
B=B1−B2 (-ive sign is due to opposite directionS of B1 and B2)
It is clear from eq1 and eq2 that B1>B2 ,therefore the direction of B will be along PX .
or B=μ04π.m(r−l)2−μ04π.m(r+l)2 (alongPX)
or B=μ04π.m(4rl)(r2−l2)2 (alongPX)
Now , m(2l)=M (magnetic dipole moment of magnet)
Hence , B=μ04π.2Mr(r2−l2)2 (alongPX)