Let the given statement be $P(n)$,i.e.,
$P(n): 1^{2}+3^{2}+5^{2}+\ldots+(2n-1)^{2}=\frac{n(2n-1)(2n+1)}{3}$
For $n=1$,we have
$P(1)=1^{2}=1=\frac{1(2(1)-1)(2(1)+1)}{3}=\frac{1 \times 1 \times 3}{3}=1$,which is true.
Let $P(k)$ be true for some positive integer $k$,i.e.,
$P(k): 1^{2}+3^{2}+5^{2}+\ldots+(2k-1)^{2}=\frac{k(2k-1)(2k+1)}{3}$ $(i)$
We shall now prove that $P(k+1)$ is true.
Consider the sum up to $(k+1)$ terms:
$\left\{1^{2}+3^{2}+5^{2}+\ldots+(2k-1)^{2}\right\}+\{2(k+1)-1\}^{2}$
$= \frac{k(2k-1)(2k+1)}{3} + (2k+1)^{2}$ [Using $(i)$]
$= \frac{k(2k-1)(2k+1) + 3(2k+1)^{2}}{3}$
$= \frac{(2k+1)\{k(2k-1) + 3(2k+1)\}}{3}$
$= \frac{(2k+1)\{2k^{2}-k+6k+3\}}{3}$
$= \frac{(2k+1)\{2k^{2}+5k+3\}}{3}$
$= \frac{(2k+1)\{2k^{2}+2k+3k+3\}}{3}$
$= \frac{(2k+1)\{2k(k+1)+3(k+1)\}}{3}$
$= \frac{(2k+1)(k+1)(2k+3)}{3}$
$= \frac{(k+1)\{2(k+1)-1\}\{2(k+1)+1\}}{3}$
Thus,$P(k+1)$ is true whenever $P(k)$ is true.
Hence,by the principle of mathematical induction,the statement $P(n)$ is true for all natural numbers $n \in N$.