A finite difference approximation to the solution of the two-point boundary value problem
\begin{aligned} & y^{\prime \prime}=f(x) y+g(x), x \in[a, b] \\ & y(a)=A, y(b)=B \end{aligned}
is defined by
-h^{-2}\left(y_{n-1}-2 y_{n}+y_{n+1}\right)+f\left(x_{n}\right) y_{n}=-g\left(x_{n}\right), 1 \leq n \leq N-1,
and y_0=A, y_N=B,
where N is an integer greater than 1, h=(b-a) / N, x_{n}=a+n h, and y_{n} denotes the approximation to y\left(x_{n}\right).
(i) Prove that if f(x) \geq 0, x \in[a, b] and y(x) \in C^{4}[a, b], then
\left|y\left(x_{n}\right)-y_{n}\right| \leq \frac{h^{2}}{24} M_{4}\left(x_{n}-a\right)\left(b-x_{n}\right)
where M_{4}=\max _{x \in[a, b]}\left|y^{(4)}(x)\right|.
(ii) Show that with N=3, the difference scheme gives an approximation to the solution of
\begin{aligned} y^{\prime \prime}-y & =1, x \in[0,1] \\ y(0) & =0, y(1)=e-1, \end{aligned}
for which \left|y\left(x_{n}\right)-y_{n}\right| \leq \frac{e}{864}, 0 \leq n \leq 3.
(i) The difference equation at x=x_{n} is defined by
-y_{n-1}+2 y_{n}-y_{n+1}+h^{2} f_{n} y_{n}=-g_{n} h^{2}, n=1(1) N-1 .
Incorporating the boundary conditions y_{0}=A and y_{N}=B into the difference equations, we write the system of equations in matrix notation as
J y +h^2 F y = D
Exact solution satisfies the equation
\mathrm{J} \mathrm{y}\left(x_{n}\right)+h^{2} \mathrm{F} \mathrm{y}\left(x_{n}\right)=\mathrm{D}-\mathrm{T}
where \mathrm{T}=\left[\begin{array}{llll}T_{1} & T_{2} & \ldots & T_{N-1}\end{array}\right]^{T} is the truncation error.
In order to find the error equation, we put y_{n}=y\left(x_{n}\right)+\varepsilon_{n} in the difference equation and obtain
\mathrm{J} \boldsymbol{\varepsilon}+h^{2} \mathrm{F} {\varepsilon}=\mathrm{T}where {\varepsilon}=\left[\begin{array}{llll}\varepsilon_{1} & \varepsilon_{2} & \ldots & \varepsilon_{N-1}\end{array}\right]^{T} .
The truncation error is given by
\begin{aligned} T_{n} & =y\left(x_{n+1}\right)-2 y\left(x_{n}\right)+y\left(x_{n-1}\right)-h^{2} f\left(x_{n}\right) y\left(x_{n}\right)-h^{2} g\left(x_{n}\right) \\ & =\frac{h^{4}}{12} y^{(4)}(\xi), x_{n-1}<\xi<x_{n+1} . \end{aligned}
Hence, \left|T_{n}\right| \leq \frac{h^{4}}{12} M_{4}, M_{4}=\max _{x \in[a, b]}\left|y^{(4)}(x)\right|.
Since f(x) \geq 0, x \in[a, b] we have
\mathrm{J}+h^{2} \mathrm{F}>\mathrm{J}.
The matrices \mathrm{J} and \mathrm{J}+h^{2} \mathrm{F} are irreducibly diagonal dominent with non-positive off diagonal elements and positive diagonal elements. Hence, \mathrm{J} and \mathrm{J}+h^{2} \mathrm{F} are monotone matices.
If follows that \left(\mathrm{J}+h^{2} \mathrm{F}\right)^{-1}<\mathrm{J}^{-1}.
Hence, we get \quad \boldsymbol{\varepsilon}=\left(\boldsymbol{J}+h^{2} \mathrm{F}\right)^{-1} \mathrm{T} \leq \mathrm{J}^{-1} \mathrm{T}.
We now determine \mathrm{J}^{-\mathrm{1}}=\left(j_{i, j}\right) explicitly. On multiplying the rows of \mathrm{J} by the j th column of \mathrm{J}^{-1}, we have the following difference equations.
\begin{aligned} & (i)-2 j_{1, j}-j_{2, j}=0, \\ & (\text { ii })-j_{i-1, j}+2 j_{i, j}-j_{i+1, j}=0, \quad 2 \leq i \leq j-1, \\ & (i i i)-j_{j-1, j}+2 j_{j, j}-j_{j+1, j}=1, \\ & (i v)-j_{i-1, j}+2 j_{i, j}-j_{i+1, j}=0, \quad j+1 \leq i \leq N-2, \\ & (v)-j_{N-2, j}+2 j_{N-1, j}=0. \end{aligned}
On solving the difference equations, we get
j_{i, j}=\left|\begin{array}{ll} \frac{i(N-j)}{N}, & i \leq j, \\ \frac{j(N-i)}{N}, & i \geq j, \end{array}\right.
Note that the matrix \mathrm{J}^{-1} is symmetric. The row sum of the nth row of \mathrm{J}^{-1} is
\sum_{j=1}^{N-1} j_{n, j}=\frac{n(N-n)}{2}=\frac{\left(x_{n}-a\right)\left(b-x_{n}\right)}{2 h^{2}}.
Thus, we have
\left|\varepsilon_n\right| \leq \frac{h^4}{12} M_4 \frac{\left(x_n-a\right)\left(b-x_n\right)}{2 h^2}
or \left|y\left(x_n\right)-y_n\right| \leq \frac{h^2}{24} M_4\left(x_n-a\right)\left(b-x_n\right).
(ii) We are given that
\begin{aligned} & N=3, f(x)=1, g(x)=1, A=0 ,\\ & B=e-1, a=0, b=1, h=1 / 3. \end{aligned}
We have
y^{(4)}(x)=y^{\prime \prime}(x)=y(x)+1.
Therefore, M_4=\max _{x \in[0,1]}\left|y^{(4)}(x)\right|=\max _{x \in[0,1]}|y(x)+1|=e-1+1=e .
Maximum of \left(x_{n}-a\right)\left(b-x_{n}\right) occurs for x_{n}=(a+b) / 2 and its maximum magnitude is (b-a)^{2} / 4=1 / 4. Hence
\left|y\left(x_{n}\right)-y_{n}\right| \leq \frac{e}{864}, 0 \leq n \leq 3.