1. Introduction
Fractional integral and differential operators are the most important elements of fractional calculus [
1,
2,
3,
4]. Many researchers are still looking for physical and geometrical interpretations for these operators. Fractional-order differential and/or integral equations are naturally related to modeling systems with memory (history), because the fractional operators used in them are usually nonlocal operators. In order to calculate, for example, the time or space fractional integrals and/or derivatives at a given time or a given point, then knowledge of the function at all previous times or positions is required. There are many applications of fractional calculus in the fields of science and engineering (see, e.g., recent works [
5,
6,
7,
8,
9,
10,
11]), and it is impossible to list all their applications.
There are many kinds of definitions for fractional integrals and derivatives [
1,
2,
3,
4,
12,
13]. It is impossible to mention and characterize all of them. Generally speaking, these definitions are not equivalent to each other. This work focuses exclusively on the definitions of the left- and right-sided Riemann–Liouville fractional integrals (
and
) and the left- and right-sided Caputo fractional derivatives (
and
). The mentioned operators of order
acting on a function
on the interval
are defined as follows:
where
, and
denotes the Euler Gamma function. If
, then
.
With the development of fractional calculus, there is a need to develop more and more accurate methods for calculating the values of fractional operators for the given functions. If the exact forms of fractional operators (derivatives and integrals) acting on a function are not known, then their approximate values can be determined using numerical methods. The general rule in approximate calculations of the values of these operators is to replace the integrand function with simple interpolation functions for which known analytical forms of the fractional operators can be used. Often, piecewise-polynomial interpolants on the grid of points are used for this purpose. The fractional integration or differentiation of the polynomial interpolant instead of the given function has the consequence that approximation errors may occur, and hence, the errors must also be estimated.
The development of new and more accurate numerical methods for the approximation of fractional operators has been very popular in recent years. Here, it is worth mentioning the book written in 1974 by Oldham and Spanier [
1], which describes several numerical schemes known as, for example, the
,
,
and
formulas. In later years, numerical methods of fractional integration and differentiation were developed and improved; reviews of different methods can be found in [
13,
14,
15,
16,
17,
18].
The polynomial interpolation of a finite set of data points resulting from the discretization of integrand functions is most often used in interpolating algorithms. This can lead to the construction of high-degree polynomials that, however, have a tendency to oscillate. Hence, splines [
19,
20,
21,
22] become useful for this purpose, especially those of odd degree. By definition, a spline is a set of combined piecewise polynomials. The most commonly used splines are of degree 3, but higher-degree splines allow more flexibility, and more data are required to determine them. However, such splines have a higher degree of smoothness, and it is worth using them in the interpolation. The application of second-degree splines for the approximation of fractional integral operators was considered, for example, in [
18,
23]. Ciesielski and Grodzki [
24] developed numerical integration schemes for the left- and right-sided Riemann–Liouville and Riesz fractional integrals using, among other methods, cubic spline interpolation techniques. Also, the computational errors were estimated using analytical methods and then validated on examples by determining the experimental orders of convergence. In [
25], numerical algorithms for evaluating the left- and right-sided Riemann–Liouville fractional integrals using Akima cubic spline interpolations [
26] were derived. The coefficients of spline segments for the Akima cubic spline are determined locally, and there is no need to solve the system of linear equations to determine the spline coefficients.
The main contribution of this work consists of providing numerical algorithms for the approximation of the previously mentioned fractional integrals and derivatives (
1)–(
4), which are based on quintic spline interpolation, because it seems necessary to develop numerical algorithms with high accuracy and fast convergence. After this introduction, in
Section 2, a general introduction to splines of any degree is presented, and three algorithms for constructing interpolation splines of the first, third and fifth degrees are derived in detail, along with an analysis of approximation errors.
Section 3 presents numerical approaches to the fractional integration and differentiation of the considered kinds of splines. In
Section 4, sample numerical calculations of the fractional operators, along with computational errors and experimental orders of convergence, are presented. Finally,
Section 5 provides concluding remarks.
2. Algorithms for Spline Interpolation
Suppose that the integrand function
in Equations (
1)–(
4) is defined on the interval
and is sufficiently smooth. Let us assume that the considered interval
is split into
N equispaced sub-intervals
for
, with the length
. The coordinates of the nodal points are equal to
for
, wherein
. The values of the function
at the set of nodal points
are tabulated as
for
.
The function
is replaced by an interpolation spline [
26,
27] that is a set of piecewise polynomials linked in the set of points
,
,
,
, defined as
where
are polynomials of degree
p in each sub-interval. The coefficients
, for
, are the coefficients of polynomial
in the
i-th sub-interval
. In further considerations, the number of segments (i.e., equispaced sub-intervals)
N, the spline degree
p, the location of nodes
, for
, and the tabulated function values
are assumed to be known. It is easy to see that (for
)
An important feature of the spline
is the fulfillment of the following interpolation conditions:
In addition, the spline is m-times () continuously differentiable at the nodal points. In this paper, three kinds of splines are considered, depending on the degree p:
: The particular polynomials are line segments (linear spline), and ;
: The particular polynomials are polynomials of degree 3 (cubic spline), and ;
: The particular polynomials are polynomials of degree 5 (quintic spline), and .
The determination of the spline coefficients
in Equation (
6) depends on the degree of spline interpolation that is used. For splines of degree
, the following continuity conditions (also known as smoothness conditions) at the nonboundary data points
for
and
must be satisfied. The
l-th derivative of the spline segments
of degree
p is defined as
In order to construct the complete spline
(
5) of degree
p, a total of
coefficients
, for
and
, need to be determined, and hence, the same number of equations should be created. The interpolation conditions (
10) and the values
and
, for
, provide
equations in total from the nonboundary data points. The
missing equations are formed on the basis of the colloquially named endpoint conditions, where two of them result from the relations
and
. The
remaining equations can be provided by the choice of some derivatives of the polynomials at the boundary points, i.e.,
and
, for
. Such spline constructions, in which derivative information is involved, are called clamped spline interpolations. In the case of the quintic spline (
), it is necessary to set the values of four additional derivatives, and in this research,
,
,
and
are selected. Similarly, in the case of the cubic spline (
), the values of two additional derivatives of the first order
and
are chosen. In contrast, for the linear spline, there is no need to specify additional dependencies. Often, in scientific and engineering works, the so-called natural splines are considered. Such splines are built by setting the highest-order derivatives to zero at the boundary nodes up to the required number of equations (e.g., for the quintic spline,
). Basically, natural splines are characterized by lower approximation accuracy than the so-called clamped splines, and therefore, their consideration is omitted in this work. The appropriate choice of the endpoint conditions plays an important role in the quality of the spline approximation.
In the definition of the spline segment (
6), one can also take
instead of
using the property of symmetry on the
i-th interval
. The shapes of both complete splines will be the same, but the coefficients creating the particular segments of splines will have different values.
Below, detailed methods for constructing each kind of spline are presented. Based on the theoretical considerations in [
26,
27], certain simplifications were made, and the mathematical formulas were adapted for fractional integration and differentiation.
2.1. Quintic Spline Interpolation
First, the construction of the spline of degree five (
) is considered. In general, the values of
coefficients
(for
and
) need to be determined. In accordance with the above-mentioned considerations, here, a system of
linear equations is constructed that satisfies both dependencies defined by Equation (
9), written out using (
7) and (
8) as
and dependencies (
10), for
, as
for
.
To solve a system of
equations, four endpoint conditions also need to be taken into account:
but the details of their implementation will be provided later.
The system of Equations (
12)–(17) is first reduced to a smaller number of equations by applying substitutions. Taking Equations (
13)–(15) (where the coefficients
from Equation (
12) are first inserted into Equation (
13)), the following system of equations is obtained:
for
. The solution of this system for the assumed unknowns
,
and
is as follows:
Replacing
i by
in Equations (16) and (17) and reducing the constant numbers, these equations take the form
Substituting Equations (
23)–(
25) into Equations (
26) and (
27), after simplifications, the following system of equations is obtained:
for
. This can also be written in the matrix form:
The above system of equations consists of
equations and
unknown coefficients
and
for
. The missing four equations result from the endpoint conditions (
18) and (
19). By inserting Equation (
11) into Equation (
18), for node
, one directly obtains
while, for node
, one obtains
Next, by inserting Equations (
23)–(
25), for
, into Equations (
32) and (
33), after simplifications, these equations are reduced to the following forms:
Both relationships (
31) and (
34) can also be written in matrix form as
In summary, based on the above relationships, the particular coefficients of the quintic spline segment
, for
in Equation (
6), are as follows: coefficients
result directly from Equation (
12), and the values of coefficients
and
, for
, result from solving the following system of linear equations:
where
whereas the remaining coefficients,
,
and
, can be calculated on the basis of prior knowledge of coefficients
and
using Equations (
23)–(
25).
The above system of equations (
36) is characterized by a block tridiagonal and diagonal dominant matrix of coefficients. Such a construction of the system of equations in which two sets of coefficients,
and
, are simultaneously determined makes it difficult to create a symmetric matrix of coefficients. One can notice an important feature of this matrix: it is a block tridiagonal-constant matrix (except the first and last rows) that involves 2 × 2-block sub-matrices. To numerically solve such a system of equations, one can use, e.g., the Thomas algorithm [
20,
21], which can be adapted to block tridiagonal matrices, or the Gaussian elimination algorithm with necessary pivoting (because the coefficient matrix contains zeros on the main diagonal resulting from matrix
). The additional coefficients
and
(not occurring in the general spline construction) are only used to determine the remaining coefficients
c.
One can also notice in
and
(
39) that the values of the first and second derivatives of the function
y at the boundary nodes (i.e.,
,
,
and
) need to be specified and inserted into the system of equations. These values can be assumed as exact (if they can be calculated analytically for any functions whose first and second derivatives are known) or can be determined numerically based on the known values of the function
, for
, in each node (e.g., in the case of functions having complicated forms). In the case of a numerical approach, the forward and backward finite difference schemes of sixth-order accuracy (with uniform grid spacing) [
28] are proposed to be used as follows:
for
.
2.2. Cubic Spline Interpolation
Compared to the quintic spline construction approach, the construction of the cubic spline (
) is a bit simpler because the method requires taking into account fewer interpolation conditions, as well as fewer terms of the interpolation polynomial. Other approaches to the construction of systems of equations for determining cubic spline coefficients have been presented in, e.g., [
24,
26].
In the case of cubic spline interpolation, the values of
coefficients
(for
and
) in Equation (
6) should be determined. Hence, a system of
linear equations should be built based on the conditions (
9)
and on two relations (
10), for
,
for
.
Additionally, the following two endpoint conditions are included:
Here, the method of solving the system of equations is much simpler. From Equations (
45) and (
46) (after the previous insertion of the coefficients
from Equation (
44) into Equation (
45)), the following system of linear equations is created:
for
, whose solution with respect to the unknowns
and
has the form
Next, the index
i is replaced by
in Equation (47) and hence yields
After inserting Equations (
52) and (
53) into Equation (
54) and after performing simplifications, the following system of
equations is obtained:
with
unknown coefficients
. Based on the endpoint conditions (
48) and (
49), two missing equations can be created (using a principle similar to that in the quintic spline construction), which finally take the form
Equations (
55)–(
57) constitute the system of equations written in the matrix form:
where
One can notice that the coefficient matrix of system (
58) is positive definite. Moreover, when omitting the first and last rows and columns of this matrix, it is symmetric and tridiagonal, in which the non-zero entries are on only the diagonal and adjacent sub-diagonals.
The values of the coefficients
, for
, are determined on the basis of the solution of the above system of equations, and the coefficients
, for
, are given in Equation (
44), while the remaining coefficients
and
are calculated using Equations (
52) and (
53), knowing the values of the coefficients
. In order to solve the tridiagonal system of equations, the Thomas algorithm is best to use in practice and has the computational complexity O(
N). There is also one additional coefficient
here, which is used to calculate the remaining coefficients. Therefore, the knowledge of all coefficients is sufficient to construct the complete cubic spline
for
.
The values of the derivatives
and
occurring in (
59) can be inserted directly if the first derivatives of the function
in the nodes
and
can be derived analytically. Otherwise, numerical methods can be used. Here, the forward/backward finite difference schemes of fourth-order accuracy (with uniform grid spacing) in the form [
28]
for the grid size
are proposed for the application. Finite difference schemes of sixth-order accuracy (
40) and (
41) can also be used here, or even higher orders of accuracy, while a lower order of accuracy significantly reduces the accuracy of the approximation of the complete spline.
2.3. Linear Spline Interpolation
This kind of spline is the simplest form of interpolation. The linear interpolation polynomial in the sub-interval
, for
, passes through the data points
and
, which means that the adjacent data points are connected by straight lines. Maintaining the same spline construction methodology as for the previous kinds of splines, based on (
9) for
, one obtains
for
. However, the dependencies (
10) for
are omitted here. From the above system of equations, it directly follows that
Therefore, the set of coefficients (for and ) in the complete spline is established.
2.4. Errors of Spline Interpolations
Based on the theorems in [
29,
30], one can determine the interpolation errors for the presented spline approximations. Here, the contents of these theorems have been adapted to a uniform grid and to the considered endpoint conditions for every kind of spline. The detailed proofs are quite lengthy, but the reader can deduce them from the proofs in [
29].
Theorem 1. Let be the quintic spline that interpolates the function on a uniform mesh with the step size , fulfilling the endpoint conditions (18) and (19). Then,where Theorem 2. Let be the cubic spline that interpolates the function on a uniform mesh with the step size , fulfilling the endpoint conditions (48) and (49). Then,where Theorem 3. Let be the linear spline that interpolates the function on a uniform mesh with the step size . Then,where The above relations (
65), (
67) and (
69) can be collectively written as
where
.
3. Numerical Approximations of Fractional Operators
After specifying the splines of various degrees (
) that approximate the finite set of values of the function, the integrand functions in fractional operators (
1)–(
4) are replaced by piecewise-polynomial interpolants defined on the given grid of
points. Next, instead of the fractional integration or differentiation of the original function
, the spline
is integrated or differentiated. At this stage, these calculations of the fractional integrals and derivatives have already been performed analytically (i.e., the exact values have been obtained). Numerical errors in the calculation of these operators mainly result from the quality of the approximation of the integrand functions by the splines.
The numerical values of fractional calculus operators are determined in the set of data points . Let , for , denote any data point from this set.
3.1. Left- and Right-Sided Riemann–Liouville Fractional Integrals
The fractional integrals (
1) and (
2) are replaced by the formulas
and then, substituting the general form of the spline (
5) into Equations (
72) and (
73) for
, one obtains
In further considerations, the cases in which the values of integrals are equal to zero are omitted.
By inserting Equation (
6) into Equations (
74) and (
75), the formulas become
or are written in the form
where the integrals
and
, for
, relating to the point
in the
i-th sub-interval, can be determined analytically as
Remark: For example, in the case of
, the particular integrals can be written by using the appropriate substitution:
Next, integration by reduction is used; i.e.,
k-times (repeated) integration by parts takes place until
raised to a power becomes one. Finally, one obtains (
80). Calculations for (
81) are performed in a similar way.
3.2. Left- and Right-Sided Caputo Fractional Derivatives
Here, two cases are considered, depending on the value of .
3.2.1. Case of ,
Both fractional derivatives (
3) and (
4) are approximated as follows:
Putting formula (
5) into Equations (
83) and (
84) for
, one obtains
Further, the appropriate cases for
and
are omitted. Here, the
n-th-order derivative of the spline defined by Equation (
11) is inserted in place of
into Equations (
85) and (
86). Hence, the approximations of the fractional differential operators take the form
or are written as
where the integrals
and
are defined by Equations (
80) and (
81), respectively.
For the linear spline (
) and
, the numerical scheme (
89) corresponds to the algorithm named
in [
1].
3.2.2. Case of
Here, the Caputo fractional derivatives (
3) and (
4) correspond to the dependencies
Hence, taking
, it follows that
The application of splines for the approximation of Caputo fractional derivatives has some limitations. As can be seen, if the order of this derivative is , then the -th-order derivative of the spline, where , (as well as when ), and higher-order derivatives are equal to zero. Hence, the choice of the appropriate kind of spline (here, ), depending on the derivative order that satisfies the condition , is important.
3.3. Error Estimates for the Numerical Schemes
As is widely known, numerical methods may contain computational errors. Based on knowledge of the approximation errors of functions by using splines (see previous section), the error estimations for the calculation of fractional integrals and derivatives can be determined.
The approximation error for the left-sided Riemann–Liouville fractional integral
(for
) can be determined in the following way:
where
. Assuming that
, for
, the further estimation of
takes the form
After the insertion of relationship (
71), for
, into Equation (
96), one obtains
where
. In the particular case of
, the term
in the above equation is replaced by
, and then the error value is the highest.
On the other hand, the approximation error for the calculation of the left-sided Caputo fractional derivative at the nodes
,
, is estimated as
By using the concept of repeated integration by parts, the integral in the interval
can be written as
and when the properties
, for
and
, are applied, then all terms under the sum sign disappear. Taking advantage of this fact, the error
can be estimated as
where
. Assuming that
,
, the further estimation of
takes the form
In the case of the second part of the error (
98), the following estimation is used:
By inserting
and
into Equation (
98) and using relationship (
71), for
and
, respectively, the following formula for error estimation is obtained:
for
.
If , then , and hence, .
For the right-sided fractional operators, the formulas are analogous.
4. Examples of Computations
The correctness and quality of the proposed numerical schemes have been verified on the first computational example. A polynomial of the seventh degree as the integrand function
in all fractional operators is taken into account in the form
This polynomial is of a higher degree than the quintic spline. The endpoints of the considered interval
are as follows:
and
. The values of the function
and its first and second derivatives at these endpoints are equal to
,
,
,
,
and
. These values can be used directly in the proposed methods, but in the computational example, they are calculated numerically using the finite difference schemes (
60) and (
61) or (
40)–(
43).
For functions of the polynomial type, one can easily find the analytical forms of the left- and right-sided Riemann–Liouville fractional integrals and Caputo fractional derivatives. For this purpose, the properties of the fractional integration and differentiation of the power functions
and
, for
and
, are recalled [
3,
13]:
where
,
and
It should be noted that the values of , for , are equal to zero.
In order to apply properties (
105)–(
108), the function
(
104) should be transformed and rewritten to include the expressions
and
(here,
and
, respectively) as
and then, using (
105)–(
108), the analytical forms of all fractional operators are as follows:
where
Hence, certain terms in Equations (
114) and (
115) may vanish.
In
Figure 1, the plots of the left- and right-sided fractional integrals
and
, (
112) and (
113), respectively, for
, are shown. The cases for
correspond to the plot of the function
(i.e.,
), and, e.g., for
:
, which is identical to the classical integration of the function
in the interval
. Also, it can be seen that, for
,
and
hold. In
Figure 2, the plots related to the fractional derivatives
and
are presented. As before, it can be noted that
. On the other hand, for, e.g.,
,
,
and
,
occur. Moreover, for
,
and
occur.
For each derived numerical scheme, the experimental order of convergence has been examined. Such tests make it possible to show the correctness and quality of these schemes based on sample calculations depending on, among other factors, the grid size
N and order
. If the exact/analytical solutions of fractional integrals and derivatives are known, then one can determine the computational error of the numerical scheme. In the case of
, the error is as follows:
where
denotes the approximate value of
that has been obtained on a grid of size
N at a given data point
by using the spline constructed by polynomials of degree
p. The errors for the remaining operators are defined similarly. Based on the determined error values, the experimental order of convergence can be calculated using the following formula:
In
Table 1, the numerical errors (
117) and the experimental orders of convergence (
118) for the calculations of
and
, for
and
, using three kinds of splines are shown. Additionally, this table also provides the exact values of the calculated integrals. When
, then the values of the left- and right-sided fractional integrals are identical. On the other hand,
Table 2 contains the same set of data for the left- and right-sided Caputo fractional derivatives, but they are calculated for the same internal point
, i.e.,
and
(which corresponds to
,
). It is not possible to calculate fractional derivatives of order
in the case of the linear spline (
) or, analogously,
using the cubic spline and
using the quintic spline. Calculations for
have also been performed, but the results are omitted from both tables (due to lack of space).
Remarks on numerical calculations: All calculations were performed with quadruple floating-point precision. The numerical algorithms were implemented in C++11 using the quadmath library and compiled in the GCC (MinGW-w64) compiler. The mentioned library enables the use of the 128-bit floating-point type _ _float128 for real variables and allows calculations with 34 significant decimal digits. This is mainly visible in the case of calculations for using the quintic spline, where the error values are at the level of . When the single or double floating-point precision types were used, then the calculations (especially regarding the order of convergence) were imprecise.
In the second example, for all fractional operators, the integrand function
is of the form
Here, in the considered interval
, for
and
, this function is symmetric about the midpoint of the interval (
), i.e.,
, and moreover,
. So far, the analytical forms of fractional integrals and derivatives for the above function
are not known. In
Figure 3, the plots of the fractional integrals
and
, for
, are shown. To create these plots, numerical values calculated by the method using the quintic spline for the grid size
were used. The plots of the integrand function
are represented by the case for
. As can be seen in the presented plots of the left- and right-sided fractional integrals of the symmetric function about the midpoint of the interval
, both solutions are symmetrical; i.e., the following relationship occurs:
or in the discrete form as
, for
. By analogy, in
Figure 4, the plots related to the fractional derivatives
and
are shown. Here, one can also notice the presence of symmetry, i.e.,
Moreover, for , one can see that and .
5. Conclusions
Numerical schemes for evaluating the left- and right-sided integrals and derivatives of fractional order based on the interpolation of the integrand function by splines have been derived. The primary purpose of this work was to research the application of the quintic spline, but two remaining lower-degree splines (linear and cubic) were used for comparison purposes. The quintic spline creates a curve that appears to be seamless and has smooth characteristics compared to the cubic spline. Generally, if the spline is built with higher degrees of polynomials, then the curve is smoother and the approximation of the function by such a spline has smaller differences.
The analysis of the sample results presented in two tables (and others, but not shown in this paper) allows the conclusion that the absolute values of numerical errors tend to 0 as the grid size
N increases in all cases, which means that the numerical results are in good agreement with the exact analytical solutions. Moreover, one can observe that as
N increases, the values of the experimental order of convergence are stabilized and take the specified values: see
Table 3. It should be pointed out that the numerical schemes that use the quintic spline give a higher order of convergence than other schemes. For example, the scheme of sixth order means that by doubling the number of nodes in the grid, the calculation errors decrease by
times, which significantly affects the quality of the calculations compared to other schemes. Furthermore, it can be stated that the experimental orders of convergence are consistent with analytical estimates (
97) and (
103).
In the case of schemes that use the quintic and cubic splines, a system of linear equations (in order to determine the spline interpolation coefficients) needs to be solved. From the computational point of view, such a procedure can be computationally time-consuming, which may indicate a disadvantage of these schemes. But one can use the Thomas algorithm of linear complexity to solve the block tridiagonal system of equations. Moreover, the global approximation properties of the cubic and quintic splines mean that the polynomial coefficients in each segment of any spline depend on all data points. The perturbation of one arbitrary data point or a slight change in the values of the endpoint conditions affect the construction of the whole spline . Hence, it is worth taking more precise numerical values of the endpoint conditions or, preferably, taking their exact values in the considered systems of linear equations.
Summing up, the developed approximation methods for the considered fractional operators that use the quintic spline interpolation seem to be correct, and they have a qualitative advantage over methods that use other splines of lower degrees. This confirms the efficiency and applicability of the derived methods. In future works, it will be worth focusing on applications of the developed numerical methods to solve differential or integral equations.