Given,
Length of the rod \(=1\)
Linear charge density of the rod, \(\rho(x)=\rho_{0}\left(\frac{x}{l}\right)\)
Rotations per second \(=\mathrm{n}\)
A rotating charge constitutes a current. Hence, a rotating charged rod behaves like a current carrying coil.
If charge q rotates with a frequency \(\mathrm{n}\), then equivalent current is \(\mathrm{I}=\mathrm{qn}\)
Magnetic moment associated with this current is \(\mathrm{M}=\mathrm{IA}\).
Where, \(\mathrm{A}=\) area of coil or area swept by rotating rod.
Let dq be the charge on \(\mathrm{dx}\) length of rod at a distance \(\mathrm{x}\) from origin as shown in the figure below.

The magnetic moment \(d m\) of this portion \(\mathrm{dx}\) is given as
\(\Rightarrow \mathrm{dm}=(\mathrm{dl}) \mathrm{A}\)
\(\because[I=q n \Rightarrow d \mid=n d q]\)
\(\Rightarrow \mathrm{dm}=\mathrm{ndqA}\)
\(\Rightarrow \mathrm{dm}=\mathrm{n} \lambda \mathrm{dxA}\)
Where, \(\lambda=\) charge density of rod \(=\rho(x)=\rho_{0} \frac{x}{l}\)
So,
\(\Rightarrow d m=\frac{n \rho_{0} x d x \pi x^{2}}{l}=\frac{\pi n \rho_{0}}{l} x^{3} d x\)
Here,
Area \(\mathrm{A}=\pi r^{2}=\pi \mathrm{x}^{2}\)
Total magnetic moment associated with rotating rod is sum of all the magnetic moments of differentiable elements of rod.
So, magnetic moment associated with complete rod is
\(\Rightarrow M=\int_{x=0}^{x=l} d m\)
\(\Rightarrow M=\int_{0}^{l} \frac{\pi n \rho_{0}}{l} \cdot x^{3} d x\)
\(\Rightarrow M=\frac{\pi n \rho_{0}}{l} \cdot \int_{0}^{l} x^{3} d x\)
\(\Rightarrow M=\frac{\pi n \rho_{0}}{l}\left[\frac{x^{4}}{4}\right]_{0}^{l}\)
\(\Rightarrow M=\frac{\pi n \rho_{0}}{l}\left[\frac{l^{4}}{4}\right]\)
\(\Rightarrow M=\frac{\pi n \rho_{0} l^{3}}{4}\)
At \(\rho_{0}=\rho\)
\(\Rightarrow M=\frac{\pi n \rho x l^{2}}{4}\)
At \(x=1\)
\(\therefore M=\frac{\pi}{4} n \rho l^{3}\)