#### Abstract

The problem of solving several types of one-dimensional parabolic partial differential equations (PDEs) subject to the given initial and nonlocal boundary conditions is considered. The main idea is based on direct collocation and transforming the considered PDEs into their associated algebraic equations. After approximating the solution in the Legendre matrix form, we use Legendre operational matrix of differentiation for representing the mentioned algebraic equations clearly. Three numerical illustrations are provided to show the accuracy of the presented scheme. High accurate results with respect to the Bernstein Tau technique and Sinc collocation method confirm this accuracy.

#### 1. Introduction

In real world, many fundamental laws of applied sciences and engineering can be formulated as differential equations. In biology and economics, differential equations are used to model the behavior of complex systems. The mathematical theory of differential equations first developed together with the sciences where the equations had originated and where the results found application. However, diverse problems, sometimes originating in quite distinct scientific fields, may give rise to identical differential equations. Whenever this happens, mathematical theory behind the equations can be viewed as a unifying principle behind diverse phenomena. As a powerful mathematical tool for modeling many of the natural models in applied sciences, one can refer to the partial differential equations (PDEs). In mathematics, a PDE is a differential equation that contains unknown multivariable functions and their partial derivatives. PDEs are used to formulate problems involving functions of several variables and are usually difficult to solve. So it is necessary to apply high accurate numerical methods. One-dimensional parabolic PDEs have a wide range of applications for modeling of diverse phenomena in physics and chemistry. Numerical solutions of such PDEs together with traditional conditions were studied deeply by researchers in literature. However, these PDEs subject to nonclassical conditions were investigated by mathematicians, but improvements of the existing methods should be done to get more accurate solutions. The usual numerical methods for PDEs subject to these nonclassical conditions are finite difference methods (FDMs), Galerkin techniques [1], collocation approaches [2], and Tau schemes [3]. Moreover, one can point out to the new methods such as Bernstein Tau technique [4], Sinc collocation method [5], and also [6]. It should be noted that, in [5], two types of one-dimensional parabolic PDEs subject to nonlocal boundary conditions were considered; meanwhile in [4] a different problem was considered for obtaining the solution numerically.

One of the well-known numerical techniques for solving PDEs is to use the collocation methods. In other words, collocation techniques have an important role in the field of numerical solution of PDEs. As we have mentioned before, among collocation methods, one can refer to [2]. In [2], a double Chebyshev series is introduced to represent approximately functions of two independent variables and is then applied to analyse a class of parabolic PDEs with nonlocal conditions. It should be mentioned that spectral approximations usually are the best tool for obtaining the numerical solution of any applied mathematical problem such as neutral functional differential equations [7] in the case of solution smoothness. Spectral methods have high accuracy with respect to FDMs and also finite element methods (FEMs). Among all the existing basis, the Legendre basis is a simple one for approximating the solutions of different types of PDEs. In addition, Legendre collocation method has had few results in the case of nonlocal boundary PDEs. This is the basic motivation of this paper. In this paper, in the light of the methods [8, 9], we present the Legendre collocation method for solving parabolic time-dependent diffusion equation with the initial condition and different nonlocal boundary conditions.

*Case 1 (see [4]). *Consider the following:

*Case 2 (see [5]). *Consider the following:

*Case 3 (see [5]). *Consider the following:
where , , , , , , , , , , , and are known functions, while the function should be determined. It should be noted that we deal with three types of one-dimensional parabolic PDEs in the form of (1) (with initial condition (2)). The first kind contains the boundary conditions (3)-(4). The second kind contains the boundary conditions (5), and the third kind contains the boundary conditions (6). In the sequel, we just focus on the numerical solution of PDE (1) subject to the initial condition (2) and nonlocal boundary conditions (3)-(4). The other two kinds can be solved by a similar approach.

The remainder of the paper is organized as follows. In the next Section, the basic idea of this paper is presented, in which the basic equation (1), subject the initial condition (2) together with the boundary conditions (3)-(4) ((5) and (6)), will be reduced to the associated algebraic equation. Section 3 is devoted to report three numerical experiments which demonstrate the accuracy of the proposed numerical scheme for solving the considered PDEs. Robustness of the presented approach with respect to the Bernstein Tau technique [4] and Sinc collocation method [5] is illustrated in this section. Finally, the paper is ended with a brief conclusion in Section 4.

#### 2. Basic Idea

In this section, by using shifted Legendre polynomials, the basic equation (1) subject to the initial (2) and boundary conditions (3)-(4) will be collocated at a uniform mesh to transform it into the associated system of algebraic equations. In other words, we just apply the Legendre collocation method for Case 1 boundary conditions. Other two cases can be solved by using a similar idea. Moreover, for clarity of presentation, we use the Legendre operational matrix of differentiation in our computations. For this purpose, we should recall the shifted Legendre polynomials in the interval and also the corresponding Legendre operational matrix of differentiation as follows.

We assume that , where () denotes the th order shifted Legendre polynomial in the interval . Some of initial order shifted Legendre polynomials are

According to the following property [7]:

One can conclude that , where is the Legendre operational matrix of differentiation and if is an even number and if is an odd number.

We now turn into approximating the solution of the above-mentioned PDE subject to its initial and boundary conditions in the form wherein which denotes the Kronecker multiplication and . We note that is unknown and should be determined. Also, , where , because

By a similar idea one can conclude that , where . We now assume that is given and , , in which for . Before starting the collocation scheme, we approximate by . According to the structure of (1) (, ) one can collocate this equation as follows (see the purple rhombus in Figure 1):

In other words

We should collocate the initial condition (2) in the form (see the black squares in Figure 1)

Collocating the boundary condition (3) yields (see the red triangles ▲ in Figure 1)

Moreover, collocating the boundary condition (4) yields (see the blue down triangles *▼* in Figure 1)

The above-mentioned algebraic equations can be rewritten in the matrix form , where

We note that the algebraic system can be solved by direct or iterative solvers. In this paper, we will solve this equation directly. However, some robust Krylov subspace iterative methods may be chosen and suitable preconditioning techniques can be applied for this algebraic system. It should be mentioned that the other two kinds of parabolic PDEs with their nonlocal boundary conditions (Cases 2 and 3) can be transformed into their associated linear algebraic systems.

#### 3. Numerical Experiments

In this part of paper, three numerical examples are considered to show the efficiency of the presented method. In these examples, the associated algebraic matrix equations are solved by a direct method in MAPLE software. It should be noted that all of the programs of the proposed method were written in MAPLE 13 software with the Digits environment variable assigned to be 30 to determine the unknown vector and hence the approximated solution . All calculations are run on a Pentium 4 PC laptop with 2 GHz of CPU and 2 GB of RAM. It should be mentioned that the proposed scheme obtained high order of accuracy for dealing with the mentioned PDEs which are smooth enough. The readers can see the efficiency of the proposed method from the provided figures and table in the following examples. In Case 1, we provide the following example from [4] and give the absolute errors for and in Table 1. From this table one can see the efficiency of the proposed scheme with respect to the Bernstein Tau method (BTM) [4].

*Example 1 (Case 1 [4]). *We consider the PDE (1) subject to the initial condition (2) and nonlocal boundary conditions (3)-(4) with the assumptions
which has the exact solution . For solving this problem, we use different values of and obtain the numerical solution . Absolute values of error associated with the presented method (PM) and Bernstein Tau method (BTM) are provided in Table 1 for . These results confirm the efficiency of the proposed idea.

*Example 2 (Case 2 [5]). *We consider the PDE (1) subject to the initial condition (2) and nonlocal boundary conditions (5) with the assumptions
which has the exact solution . For solving this problem, we use different values of such as 5, 7, 9, 11, 13, and 15 and obtain the in definite CPU times for each of the mentioned values of . It should be recalled that, in [5], the authors used different values of such as 5, 10, 15, 20, 25, and 30 and obtained the for each of the chosen values of in some CPU times. For comparing the accuracy of our presented Legendre collocation method (LCM) and Sinc collocation method (SCM) [5], we plot Figure 2, in which the horizontal axis is CPU time and the vertical axis is the . From this figure, one can see the efficiency of our LCM with respect to the SCM.

*Example 3 (Case 3 [5]). *We consider the PDE (1) subject to the initial condition (2) and nonlocal boundary conditions (6) with the assumptions
which has the exact solution . Similar to the previous example, we use different values of such as 5, 7, 9, 11, 13, and 15 and obtain the in definite CPU times for each of the mentioned values of . It should be recalled that, in [5], the authors used different values of such as 5, 10, 15, 20, 25, and 30 and obtained the for each of the chosen values of in some CPU times. For comparing the accuracy of our LCM and SCM [5], we plot Figure 3, in which the horizontal axis is CPU time and the vertical axis is the . From this figure, one can see the sharp slope of our LCM with respect to the low slope of the SCM. This confirms the accuracy of our method.

#### 4. Conclusions

Legendre collocation method has been utilized to numerically solve a class of one-dimensional parabolic partial differential equations (PDEs) subject to the nonlocal boundary conditions by a new framework. The proposed approach reduces the main problem to the linear algebraic equations. By using Legendre operational matrix of differentiation, these equations are showed in a matrix form clearly. Three numerical examples have been illustrated to show the efficiency and applicably of the presented method.

#### Conflict of Interests

The authors declare that they do not have any conflict of interests in their submitted paper.

#### Acknowledgments

The authors gratefully acknowledge that this work partially supported by the University Putra Malaysia Grant No. 5527179.