4. (1996 National College Entrance Examination) Given the functions $f(x)=a x^{2}+b x+c, g(x)=a x+b$, where $a, b, c$ are real numbers, and $a>0$. When $|x| \leqslant 1$, $|f(x)| \leqslant 1$ and the maximum value of $g(x)$ is 2. Find $f(x)$.
4. Since $a>0$, we know that $g(x)$ is an increasing function on $[-1,1]$. Also, the maximum value of $g(x)$ on $[-1,1]$ is 2, so $g(1)=2$, which means $a+b=2$.
Also, $f(1)=a+b+c, f(0)=c$, so $f(1)=2+f(0)$.
When $|x| \leqslant 1$, $|f(x)| \leqslant 1$, then $-1 \leqslant f(0) \leqslant 1$. Substituting $f(1)=2+f(0)$, we get $f(1) \geqslant 1$. Also, from the given information, it is easy to see that $f(1) \leqslant 1$, thus $1 \leqslant f(1) \leqslant 1$, so $f(1)=1$, which means $a+b+c=1$.

From (1) and (2), we get $c=-1$. Since $|x| \leqslant 1$, $f(x) \geqslant-1$, i.e., $f(x) \geqslant f(0)$. By the properties of a quadratic function, the axis of symmetry of the graph of $f(x)$ is $x=0$, so $b=0$. Substituting into (1) gives $a=2$, hence $f(x)=2 x^{2}-1$.