Now we combine like terms and write
\begin{align}
f'(x_j) &= (\alpha_{-1} + \alpha_0 + \alpha_1)f(x_j)\\
& \,\,\, + (\color{var(--emphColor)}{-}h\alpha_{-1} \color{var(--emphColor)}{+} h \alpha_1) f'(x_j)\\
& \,\,\, + \big(\frac{h^2}{2} \alpha_{-1} + \frac{h^2}{2} \alpha_1\big) f'' (x_j)\\
& \,\,\, + (\alpha_{-1} + \alpha_1) O(h^3).
\end{align}
Finally, we compare coefficients on both sides to obtain a
system of equations.
- The coefficient of $f(x_j)$ on the LHS is $0$. On the RHS,
it is $\alpha_{-1} + \alpha_0 + \alpha_1$, so we must have
$$\alpha_{-1} + \alpha_0 + \alpha_1 = 0.$$
- The coefficient of $f'(x_j)$ on the LHS is $1$. On the RHS,
it is $-h\alpha_{-1} + h \alpha_1$,
so we must have
$$-h\alpha_{-1} + h \alpha_1 = 1.$$
- The term $f''(x_j)$ does not appear on the LHS, and
its coefficient on the RHS is
$\frac{h^2}{2} \alpha_{-1} + \frac{h^2}{2} \alpha_1$,
so we must have
$$\frac{h^2}{2} \alpha_{-1} + \frac{h^2}{2} \alpha_1 = 0.$$
(Continued.)
As a single matrix equation, our system reads
\begin{align}
\begin{bmatrix}
1 & 1 & 1\\
-1 & 0 & 1\\
1/2 & 0 & 1/2
\end{bmatrix}
\begin{bmatrix}
\alpha_{-1}\\
\alpha_0\\
\alpha_1
\end{bmatrix}=
\frac{1}{h}
\begin{bmatrix}
0\\
1\\
0
\end{bmatrix}
\end{align}
We can input $A$ and $e_2$ into MATLAB to find
$x= A\backslash e_2$. We may then set
$$\begin{bmatrix}
\alpha_{-1}\\
\alpha_0\\
\alpha_1
\end{bmatrix}
= \frac{1}{h}x.$$
Here $x$ has numerical values and $h$ is a symbol we use to write our formula.
(Continued.)
As a single matrix equation, our system reads
\begin{align}
\begin{bmatrix}
1 & 1 & 1\\
-1 & 0 & 1\\
1/2 & 0 & 1/2
\end{bmatrix}
\begin{bmatrix}
\alpha_{-1}\\
\alpha_0\\
\alpha_1
\end{bmatrix}=
\frac{1}{h}
\begin{bmatrix}
0\\
1\\
0
\end{bmatrix}.
\end{align}
In this case we don't need MATLAB!