4. Given $\frac{1}{3} \leqslant a \leqslant 1$, if $f(x)=a x^{2}-2 x+1$ has a maximum value $M(a)$ and a minimum value $N(a)$ on the interval $[1,3]$, and let $g(a)=M(a)-N(a)$, then the minimum value of $g(a)$ is $\qquad$.
4. $f(x)=a x^{2}-2 x+1=a\left(x-\frac{1}{a}\right)^{2}+\left(1-\frac{1}{a}\right)$.

It is easy to know that $N(a)=1-\frac{1}{a}$.
(1) When $1 \leqslant \frac{1}{a} \leqslant 2$, $M(a)=f(3)=9 a-5$,
$$
g(a)=M(a)-N(a)=9 a+\frac{1}{a}-6 \text {. }
$$

It is easy to know that $g(a)$ is an increasing function on $\left[\frac{1}{2}, 1\right]$, $[g(a)]_{\min }=g\left(\frac{1}{2}\right)=\frac{1}{2}$.
(2) When $2 \leqslant \frac{1}{a} \leqslant 3$, $M(a)=f(1)=a-1$,
$$
g(a)=M(a)-N(a)=a+\frac{1}{a}-2 .
$$

It is easy to know that $g(a)$ is a decreasing function on $\left[\frac{1}{3}, \frac{1}{2}\right]$, $[g(a)]_{\text {min }}=g\left(\frac{1}{2}\right)=\frac{1}{2}$. In summary, the answer should be $\frac{1}{2}$.