**3.7 An explicit expression of the approximation error of ordinary differential equations based on the moved node method**

Here discusses the issue of the possibility of calculating the approximation error. When replacing differential equations with discrete ones, one of the key issues is the closeness of the discrete solution to the exact solution. For the difference solution to the problem, a grid area is formed. The discrete solution is determined at the nodal points. Traditionally, in questions of replacing a differential equation with a descriptive one, one usually indicates the degree of approximation of the O(h<sup>p</sup> ) type. Here h is the grid step.

However, it is possible to calculate the approximation error at nodal points based on the method of moving nodes. The method of moving nodes allows for obtaining an approximate analytical expression. On the basis of the approximate form, it is possible to calculate the approximation error. On the other hand, at each node one can construct a differential analog of the difference equation. Using simple examples, the calculation of approximation errors is demonstrated and schemes of the collocation type are constructed.

#### *3.7.1 Introduction*

Here describes the application of the moving nodes method to the calculation of the approximation error. When a two-point boundary value problem is solved by different methods, the question of the degree of approximation usually appears. The closeness of the exact and approximation of the solution, and the quality of the difference scheme are evaluated based on the degree of this parameter. With such an analysis, other parameters (the coefficients of the differential equation) are not explicitly involved in the approximation error expression. Obtaining an explicit expression for the approximation error makes it possible to analyze it.

Consider the simplest ordinary differential equation with boundary conditions

$$\frac{d^2u}{dx^2} = \mathbf{C}, \ u(\mathbf{0}) = \mathbf{0}, \ u(\mathbf{1}) = \mathbf{1} \tag{101}$$

where С—const.

Create a uniform grid on segments [0,1] with step h. A uniform grid on a segment x ∈ [0, 1] with step h has the form:

$$\overline{\alpha}\_{\hbar} = \{ \mathbf{x}\_{\hbar} = \hbar \mathbf{k}, \ k = 0, 1, \dots, N, \hbar \cdot N = 1 \}$$

Let us replace the second-order derivative with the difference relation:

$$\frac{U\_{i+1} - 2U\_i + U\_{i-1}}{h^2} = \mathbb{C}, \quad \mathbb{1} \le i \le N - 1,\\ U\_0 = 0, \ U\_N = 1 \tag{102}$$

Difference scheme (102) traditionally has order O(h<sup>2</sup> ). However, if we solve system (102) by the Tomas algorithm, we obtain a numerical solution that coincides with the exact analytical solution for any grid steps h at the grid nodes. Those. scheme (102) approximates (101) exactly.

#### *3.7.2 Methodology*

Let us have a differential equation

$$L\mathfrak{u} = f,\tag{103}$$

where *L* is a differential operator, *f* is a known function, and *u* is an unknown function. (103) the equation is considered in some domain D with appropriate boundary conditions. The differential Eq. (103) is replaced by the difference equation:

$$L\_h u\_h = f\_h,\tag{104}$$

where Lh is the difference operator, uh is the unknown grid function, and fh is the approximation of the function f at the grid nodes.

Usually, the approximation error is given as [2, 3]:

$$Q\_h = L\_h[u]\_h - f\_h,\tag{105}$$

where [u]h is the exact solution of (103) at the grid nodes. Using the Taylor series, from (105) one obtains that, Qh = O(hm), where h is the grid step and m is the degree of approximation.

You can determine an explicit approximation error if you use the method of a moving node, which allows you to extend the definition to the entire area D. This allows you to introduce an approximation error like this:

$$R\_h = L\_h \{ u \}\_h - f\_h. \tag{106}$$

Here {u}h is a predefined continuous function by means of a moveable node. The approximate calculation of the approximation error of type (106) is demonstrated using simple examples.

### *3.7.3 Results and discussion*

As an application of the above approach, consider examples.

$$\textbf{1. Consider a simple boundary value problem:}$$

$$\frac{d^2u}{d\mathfrak{x}^2} = f(\mathfrak{x}), \ \ u(\mathfrak{0}) = u\_a, \ \mathfrak{u}(\mathfrak{1}) = u\_b \tag{107}$$

Let us build a non-uniform grid on segments [0; 1]:

$$\overline{a}\overline{a}\_{\hbar} = \{0 = \mathbf{x}\_0, \ <\mathbf{x}\_1 < \ldots < \mathbf{x}\_{N-1} < \mathbf{x}\_N = 1, k = 0, 1, \ldots, N\}$$

In the non-uniform grid, we replace (107) with the difference problem:

$$\frac{2}{\mathbf{x}\_{i+1} - \mathbf{x}\_{i-1}} \left( \frac{\mathbf{U}\_{i+1} - \mathbf{U}\_i}{\mathbf{x}\_{i+1} - \mathbf{x}\_i} - \frac{\mathbf{U}\_i - \mathbf{U}\_{i-1}}{\mathbf{x}\_i - \mathbf{x}\_{i-1}} \right) = f(\mathbf{x}\_i), \quad i = \mathbf{1}, 2, \dots, N - 1. \tag{108}$$

Here *Ui* is the grid solution of the problem. From here

*Moving Node Method for Differential Equations DOI: http://dx.doi.org/10.5772/intechopen.107340*

$$U\_i = \frac{U\_{i+1}(\mathbf{x}\_i - \mathbf{x}\_{i-1}) + U\_{i-1}(\mathbf{x}\_{i+1} - \mathbf{x}\_i)}{\mathbf{x}\_{i+1} - \mathbf{x}\_{i-1}} - \frac{1}{2} f(\mathbf{x}\_i)(\mathbf{x}\_i - \mathbf{x}\_{i-1})(\mathbf{x}\_{i+1} - \mathbf{x}\_i), \quad i = 1, 2, \dots, N - 1. \tag{109}$$

We redefine the value of the function at non-nodal points as follows. To do this, we consider in (109) *xi*þ1, *xi*�1, *Ui*�1, *Ui*þ1, to be fixed, and *xi* to be moved, and the function f(x) to be smooth. Thus, we will complete the grid function on each segment ð Þ *xi*�1, *xi*þ<sup>1</sup> . From (109) we get

$$U\_i''(\mathbf{x}\_i) = -\frac{1}{2}f''(\mathbf{x}\_i)(\mathbf{x}\_{i+1} - \mathbf{x}\_i)(\mathbf{x}\_i - \mathbf{x}\_{i-1}) - f'(\mathbf{x}\_i)(\mathbf{x}\_{i+1} + \mathbf{x}\_{i-1} - 2\mathbf{x}\_i) + f(\mathbf{x}\_i) \tag{110}$$

Then the approximation error for the nodal points looks like this:

$$R\_h(\mathbf{x}\_i) = -\frac{1}{2} f''(\mathbf{x}\_i)(\mathbf{x}\_{i+1} - \mathbf{x}\_i)(\mathbf{x}\_i - \mathbf{x}\_{i-1}) - f'(\mathbf{x}\_i)(\mathbf{x}\_{i+1} + \mathbf{x}\_{i-1} - 2\mathbf{x}\_i) \tag{111}$$

If the grid is uniform for the approximation error, we obtain the expression

$$R\_h(\mathbf{x}\_i) = -\frac{1}{2} f''(\mathbf{x}\_i) h^2, \ i = 1, 2, \ \dots, N - 1. \tag{112}$$

If on the segments ð Þ *xi*�1, *xi*þ<sup>1</sup> the function constant approximation error is identically equal to zero and we get the exact solution.

Based on expression (110), the following conclusion can be drawn.

Given a two-point boundary value problem

$$\frac{d^2u}{d\mathbf{x}^2} = f^\*\left(\mathbf{x}\right), \ u(\mathbf{0}) = u\_a, \ u(\mathbf{1}) = u\_b$$

and *<sup>f</sup>* <sup>∗</sup> ð Þ *<sup>x</sup>* can be represented as

$$f^\*(\mathbf{x}\_i) = -\frac{1}{2}f''(\mathbf{x}\_i)(\mathbf{x}\_{i+1} - \mathbf{x}\_i)(\mathbf{x}\_i - \mathbf{x}\_{i-1}) - f'(\mathbf{x}\_i)(\mathbf{x}\_{i+1} + \mathbf{x}\_{i-1} - 2\mathbf{x}\_i) + f(\mathbf{x}\_i)^2$$

then the difference scheme

$$\frac{2}{\varkappa\_{i+1} - \varkappa\_{i-1}} \left( \frac{U\_{i+1} - U\_i}{\varkappa\_{i+1} - \varkappa\_i} - \frac{U\_i - U\_{i-1}}{\varkappa\_i - \varkappa\_{i-1}} \right) = f(\varkappa\_i), \quad i = 1, 2, \dots, N - 1, 0$$

gives a grid solution coinciding with the exact solution at the nodal points.

If there is only one internal node point (the node being moved is one), then an approximate analytical solution can be obtained. Indeed, if we rewrite scheme (108) for one moving node, we have

$$2\left(\frac{U\_i - U\_{i-1}}{1 - \varkappa} - \frac{U(\varkappa) - U\_a}{\varkappa}\right) = f(\varkappa\_i). \tag{113}$$

From here we obtain an approximate analytical solution:

*Numerical Simulation – Advanced Techniques for Science and Engineering*

$$U(\mathbf{x}) = \frac{U\_b \mathbf{x} + U\_a(\mathbf{1} - \mathbf{x})}{\mathbf{x}\_{i+1} - \mathbf{x}\_{i-1}} - \frac{\mathbf{1}}{2} f(\mathbf{x}\_i)(\mathbf{1} - \mathbf{x})\mathbf{x}.\tag{114}$$

In this case, (114) represents the exact solution to the problem (107). if we put

$$f^\*\left(\mathbf{x}\right) = -\frac{1}{2}f''(\mathbf{x})(\mathbf{1}-\mathbf{x})\mathbf{x} - f'(\mathbf{x})(\mathbf{1}-\mathbf{2}\mathbf{x}) + f(\mathbf{x})\mathbf{.}$$

The form of the approximation error (111) allows the construction of new schemes of the collocation type. Indeed, if in problem (108) we replace the right side with the expression

$$f(\mathbf{x}\_i) + A(\mathbf{x}\_i - \mathbf{x}\_{i-1})(\mathbf{x}\_{i+1} - \mathbf{x}\_i),$$

Here A is still an unknown constant. Parameter A is determined so that the approximation error (111) for a uniform step at node *xi* is equal to zero, i.e. collocation type scheme. Then we have

$$A = \frac{1}{4^{\prime}} f''(x\_i)$$

2. Consider a stationary equation in which only convection and diffusion are present without a source.

$$
\epsilon v'' + v' = \mathbf{0},
\tag{115}
$$

with boundary conditions *v*ð Þ¼ 0 0, *v*ð Þ¼ 1 1*:*

There are various schemes for the difference solution (115). Based on the moving node technique, it is possible to explicitly express local errors in the approximation of differential equations. Using the moving node method, we will show the efficient calculation of local approximation errors for the model problem (115).

**Scheme with central-difference approximation of the convective term.** Take a segment ð Þ *xi*�1, *xi*þ<sup>1</sup> and any point *x*∈ð Þ *xi*�1, *xi*þ<sup>1</sup> . Consider the different analog (115).

$$\frac{2\varepsilon}{\varkappa\_{i+1} - \varkappa\_{i-1}} \left( \frac{u\_{i+1} - u}{\varkappa\_{i+1} - \varkappa} - \frac{u - u\_{i-1}}{\varkappa - \varkappa\_{i-1}} \right) + \frac{u\_{i+1} - u\_{i-1}}{\varkappa\_{i+1} - \varkappa\_{i-1}} = 0 \tag{116}$$

At *x* ¼ ð Þ *xi*�<sup>1</sup> þ *xi*þ<sup>1</sup> *=*2, we have a central difference approximation. Here, *u* is the approximate value of the solution at point *x*.

From (116) we find.

$$u = \frac{(\varkappa - \varkappa\_{i-1})(2\varepsilon + \varkappa\_{i+1} - \varkappa)u\_{i+1} + (\varkappa\_{i+1} - \varkappa)(2\varepsilon - \varkappa + \varkappa\_{i-1})u\_{i-1}}{2\varepsilon(\varkappa\_{i+1} - \varkappa\_{i-1})}.\tag{117}$$

From here we get,

$$u' = \frac{2\varepsilon + \varkappa\_{i+1} + \varkappa\_{i-1} - 2\varkappa}{2\varepsilon} \frac{u\_{i+1} - u\_{i-1}}{\varkappa\_{i+1} - \varkappa\_{i-1}},\tag{118}$$

*Moving Node Method for Differential Equations DOI: http://dx.doi.org/10.5772/intechopen.107340*

$$u'' = -\frac{1}{\varepsilon} \frac{u\_{i+1} - u\_{i-1}}{\varkappa\_{i+1} - \varkappa\_{i-1}}.\tag{119}$$

If the difference solution at nodal points is known, then formula (117) makes it possible to determine the unknown at points that are not nodal.

Using formulas (118) and (119), the derivatives are restored at any point of the segment. Multiplying (119) by and adding with (118), we obtain.

$$
\epsilon u'' + u' = \Psi\_1,\tag{120}
$$

where

$$
\Psi\_1 = \frac{\varkappa\_{i+1} + \varkappa\_{i-1} - 2\varkappa}{2\varepsilon} \frac{u\_{i+1} - u\_{i-1}}{\varkappa\_{i+1} - \varkappa\_{i-1}}.
$$

Eq. (120) can be called a differential analog of the difference Eq. (16); difference Eq. (116) is a collocation-type scheme.

Using (119), the approximation error can be written as.

$$\Psi\_1 = -\frac{\varkappa\_{i+1} + \varkappa\_{i-1} - 2\varkappa}{2} u''.$$

Then Eq. (120) takes the form

$$\left(\varepsilon + \frac{\mathfrak{x}\_{i+1} + \mathfrak{x}\_{i-1} - 2\mathfrak{x}}{2}\right)\mathfrak{u}'' + \mathfrak{u}' = \mathbf{0}.\tag{121}$$

Thus, difference Eq. (116) exactly approximates differential Eq. (121) on the segment ½ � *xi*�1, *xi*þ<sup>1</sup> *:*

Comparison of Eqs. (115) and (121) shows that when Eq. (115) is approximated by scheme (116), scheme diffusion appears with a variable coefficient ð Þ *xi*þ<sup>1</sup> þ *xi*�<sup>1</sup> � 2*x =*2*:*

**Upwind Scheme.** Let us consider the difference analog of Eq. (115), in which the convective term is approximated by the one-sided difference relation.

$$\frac{2\varepsilon}{\varkappa\_{i+1} - \varkappa\_{i-1}} \left( \frac{u\_{i+1} - u}{\varkappa\_{i+1} - \varkappa} - \frac{u - u\_{i-1}}{\varkappa - \varkappa\_{i-1}} \right) + \frac{u\_{i+1} - u}{\varkappa\_{i+1} - \varkappa} = \mathbf{0}.\tag{122}$$

From here we get

$$u = \frac{(\varkappa - \varkappa\_{i-1})(2\varepsilon + \varkappa\_{i+1} - \varkappa\_{i-1})}{(\varkappa\_{i+1} - \varkappa\_{i-1})(2\varepsilon + \varkappa - \varkappa\_{i-1})} \frac{u\_{i+1} + 2\varepsilon(\varkappa\_{i+1} - \varkappa)u\_{i-1}}{} \tag{123}$$

Determine the first and second derivatives:

$$u' = \frac{2\varepsilon \left(2\varepsilon + \varkappa\_{i+1} - \varkappa\_{i-1}\right)}{\left(2\varepsilon + \varkappa - \varkappa\_{i-1}\right)^2} \frac{u\_{i+1} - u\_{i-1}}{\varkappa\_{i+1} - \varkappa\_{i-1}},\tag{124}$$

*Numerical Simulation – Advanced Techniques for Science and Engineering*

$$u'' = \frac{-4\varepsilon \left(2\varepsilon + \varkappa\_{i+1} - \varkappa\_{i-1}\right)}{\left(2\varepsilon + \varkappa - \varkappa\_{i-1}\right)^3} \frac{u\_{i+1} - u\_{i-1}}{\varkappa\_{i+1} - \varkappa\_{i-1}} \tag{125}$$

Let us calculate the approximation error.

$$\Psi\_2 = \frac{2\varepsilon (\varkappa - \varkappa\_{i-1}) (2\varepsilon + \varkappa\_{i+1} - \varkappa\_{i-1})}{\left(2\varepsilon + \varkappa - \varkappa\_{i-1}\right)^3} \frac{u\_{i+1} - u\_{i-1}}{\varkappa\_{i+1} - \varkappa\_{i-1}}.$$

The differential analog of scheme (122) has the form.

$$(\left(\varepsilon + \frac{\mathfrak{x} - \mathfrak{x}\_{i-1}}{2}\right)u'' + u' = \mathbf{0},\tag{126}$$

those with a scheme against the flow, we have a scheme diffusion with a coefficient ð Þ *xi*þ<sup>1</sup> � *x =*2. Based on (123)—is a hyperbola, which is monotone on the segment, i.e. scheme (122) is monotonic.

Based on the form of the differential analog (126), we can conclude that the differential equation

$$
\left(\varepsilon + \frac{\varkappa}{2}\right)\mu'' + \mu' = 0\tag{127}
$$

is exactly approximated by the scheme

$$2\varepsilon \left( \frac{u\_b - u}{1 - \infty} + \frac{u - u\_a}{\infty} \right) + \frac{u\_b - u}{1 - \infty} = 0 \tag{128}$$

Thus solving (128) with respect to u, we obtain the exact solution of differential Eq. (127).

#### **3.8 On convergence of MNM**

Let us show the convergence of MNM on model problems. 1. Consider the Cauchy problem

$$\frac{du}{d\mathbf{x}} = -u, \quad u(\mathbf{0}) = \mathbf{1}.\tag{129}$$

Let us replace the derivative with the forward difference,

$$\frac{du}{d\mathbf{x}} \approx \frac{U\_1(\mathbf{x}) - U\_1(\mathbf{0})}{\mathbf{x} - \mathbf{0}} = \frac{U\_1(\mathbf{x}) - \mathbf{1}}{\mathbf{x}},\tag{130}$$

In (130) *U*1ð Þ *x* the approximate value of the unknown function at the moving point is if there is only one moving node.

Using (130) we write the difference Eq. (129)

$$\frac{U\_1(\mathbf{x}) - \mathbf{1}}{\mathbf{x}} = -U\_1(\mathbf{x}),\tag{131}$$

Take, now, two moving *x* nodes and *x=*2. For these points, we write difference equations of the type (131)

*Moving Node Method for Differential Equations DOI: http://dx.doi.org/10.5772/intechopen.107340*

$$\frac{U\_2(\mathbf{x}/2) - \mathbf{1}}{\mathbf{x}/2} = -U\_2(\mathbf{x}/2), \quad \frac{U\_2(\mathbf{x}) - U\_2(\mathbf{x}/2)}{\mathbf{x} - \mathbf{x}/2} = -U\_2(\mathbf{x}), \tag{132}$$

Eliminating these equations *U*2ð Þ *x=*2 , we get

$$U\_2(\mathbf{x}) = \frac{1}{\left(1 + \mathbf{x}/2\right)^2}.$$

For three moved nodes *x=*3, 2*x=*3 and *x* we get

$$U\_3(\mathbf{x}) = \frac{1}{\left(1 + \mathbf{x}/\mathbf{3}\right)^3} \cdot \mathbf{1}$$

If the number of nodes *n*, we get

$$U\_n(\mathbf{x}) = \frac{1}{\left(\mathbf{1} + \mathbf{x}/n\right)^n}.\tag{133}$$

If we strive for the number of nodes to infinity, we get

$$\lim\_{n \to \infty} U\_n(\mathbf{x}) = \lim\_{n \to \infty} \frac{1}{\left(1 + \mathbf{x}/n\right)^n} = e^{-\mathbf{x}}.$$

Thus, we obtain the exact solution to problem (129).

2. Consider the problem

$$\frac{d\Phi}{d\mathbf{x}} = \frac{1}{Pe} \frac{d^2\Phi}{d\mathbf{x}^2}, \quad \Phi(\mathbf{0}) = \mathbf{0}, \ \Phi(\mathbf{1}) = \mathbf{1}.\tag{134}$$

For this problem, the difference scheme with 2*<sup>k</sup>* � 1 moving nodes has the form (29):

$$a\_P^{\binom{2^k-1}{2}} U^{\binom{2^k-1}{2}} = a\_E^{\binom{2^k-1}{2}} U\_E^{\binom{2^k-1}{2}} + a\_W^{\binom{2^k-1}{2}} U\_W^{\binom{2^k-1}{2}} \tag{135}$$

where

$$\begin{split} a\_{E}^{\left(2^{k}-1\right)} &= \frac{2^{2k+1} (1-\tau\_{k})}{(1-x)\left(1-\tau\_{k}^{k}\right)}, a\_{W}^{\left(2^{k}-1\right)} = \frac{2^{2k+1} \mathsf{Pr}(1-\tau\_{k})}{x\left(1-\tau\_{k}^{k}\right)} + \frac{2^{2k+1} (1-\tau\_{k})}{x\left(1-\tau\_{k}^{k}\right)}, a\_{P}^{\left(2^{\prime}-1\right)} = a\_{W}^{\left(2^{\prime}-1\right)} + a\_{E}^{\left(2^{\prime}-1\right)}.\\ \tau\_{k} &= 2^{k}/\left(2^{k}+\sigma\right), \eta\_{k} = \left(2^{k}+\theta\right)/2^{k}, \; \theta = \mathsf{P}e\left(1-\infty\right). \end{split}$$

If we find from (135) *<sup>U</sup>* <sup>2</sup>*<sup>k</sup>* ð Þ �<sup>1</sup> and pass to the limit at *<sup>k</sup>* ! <sup>∞</sup>, we have

$$\lim\_{k \to \infty} U^{\left(2^k - 1\right)}(\infty) = \frac{e^{p\_{\ell^x}} - 1}{e^{p\_\ell} - 1}.$$

The obtained limit coincides with the exact solution.
