To 4. Let $f(x)=x^{2}-2 a x+a$ have the minimum value $g(a)$ on the interval $[-1$, 1]. Find the maximum value of $g(a)$.


Solve $f(x)=(x-a)^{2}+a-a^{2}$, and
$-1 \leqslant x \leqslant 1$. Therefore, when $a \geqslant 1$,
$$
g(a)=f(1)=1-a_{3}
$$

When $-11, \\ a-a^{2}, & -1<a<1, \\ 1+3 a, & a \leqslant-1 .\end{array}\right.$
- Since when $a \geq 1$, the maximum value of $g(a)$ is $g(1)=0$
When $-1<a<1$,
$$
g(a)=\frac{1}{4}-\left(\frac{1}{2}-a\right)^{2} \leqslant \frac{1}{4} \text {. }
$$

When $a \leqslant-1$, the maximum value of $g(a)$ is
$$
g(-1)=-2 \text {. }
$$

Therefore, the maximum value of $g(a)$ is $\frac{1}{4}$.