In this case, we need to evaluate the integrals:
\begin{equation*}
c_{j} = \frac{2j+1}{2}\int_{-1}^{1} q(x) P_{j}(x) \, dx
\end{equation*}
for \(j=0,1,2,3,4\text{,}\) and we doing this we get:
\begin{equation*}
\begin{aligned}c_{0}\amp =\frac{1}{2}(e-e^{-1})\\ c_{1}\amp = -3e^{-1}\\ c_{2}\amp = \frac{5}{2}(e-7e^{-1})\\ c_{3}\amp = \frac{7}{2}(5e-37e^{-1}) \\\ c_{4}\amp = \frac{5}{2}(36e-266e^{-1}) \\\end{aligned}
\end{equation*}
and the interpolating polynomial is
\begin{equation*}
\begin{aligned}q_{4}(x)\amp = \sum_{i=0}^{4} c_{j} P_{j}(x)\end{aligned}
\end{equation*}
which can be written as:
\begin{equation*}
\begin{aligned}q_{4}(x)\amp = \frac{5}{8e}\biggl( 96\,{e^{2}}-705+306\,x-966\,{e^{2}}{x}^{2}+ 7140\,{x}^{2}\\\amp \qquad +70\,{e^{2}}{x}^{3}-42\,x{e^{2}}-518\,{x}^{3}+1134\,{e^{2}}{x}^{4}-8379\,{x}^{4}\biggr)\end{aligned}
\end{equation*}
A plot of
\(|q_{4}(x)-f(x)|\) shows the result:
So it appears that this approximation is accurate to about 3 decimal places. Again, notice that the error pattern is similar to what we have seen before in that in the center of the interval, the error is small and the largest error is on the endpoints.