1 Introduction

Many dynamical problems, in various sciences such as economics, medicine, biology, robotics, physics, control systems and other industrial applications, include a system of differential equations with initial or boundary conditions. Therefore, in dealing with these problems, there is a need for analytical or numerical solution of differential equations. Most cases of differential equations cannot be solved analytically and therefore researchers have sought to provide effective numerical methods to solve them. So far, numerous numerical methods have been proposed for differential equations, including homotopy methods, spectral and pseudospectral methods, tau methods, finite difference methods, finite element methods, and methods utilizing polynomial approximations, in particular, Hermit, Laguerre, Bernstein, Taylor, Bernoulli, and Jacobi approximations can be mentioned. To get acquainted with some of these techniques and methods, the reader can refer to the works [11, 15, 22, 25, 3740].

Among the differential equations, there are some that include time-delay and are known as delay differential equations. In fact, the behavior of unknown variable in the differential equation, in this class of equations, at a given time depends on the behavior of the variable at previous times and a kind of time-delay in the system can be seen. This class of differential equations has been considered by many researchers, and they have been looking for numerical and approximate solutions. Moreover, in the category of delay differential equations, functional differential equations or pantograph delay differential equations (PDDEs) have received much attention. At first, PDDEs have originated from the work of Ockendon and Tayler [23]. Some applications of PDDEs can be found in [1, 6, 9, 23].

After the emergence of pantograph delay differential equations and their many applications, their numerical solution has been considered by many researchers. We want to mention some of the proposed methods. In [2], Boubaker polynomials were used to solve PDDEs. Sedaghat et al. [30] presented a numerical method based on the transferred Chebyshev polynomials for a pantograph equation. Also, [36] focused on the Chebyshev polynomial method for PDDEs. In [29], a sequence of functions based on the variational iteration method was given for the generalized PDDEs. A compound technique, incorporating the perturbation method with an iteration algorithm, was suggested for solving PDDEs by Cevik [4]. Exponential polynomials were applied to approximate the solution of high-order PDDEs in [5, 45]. In [28], the Bessel polynomials were utilized to gain the estimated solution of a generalized pantograph equation with variable coefficients. The authors of [24] gave the multistage homotopy perturbation method for DDEs. In [27], the reproducing kernel was applied for a neutral functional differential equation. Tohidi et al. [34] and Akyuz-Dascioglu and Sezer [3] used the Bernoulli collocation method to solve generalized pantograph equations. Moreover, Jacobi rational Gauss collocation method was given to solve generalized pantograph equations in [8]. In [41, 47], the Runge–Kutta methods were presented for a class of neutral infinite delay-differential equations with different proportional delays. In [18, 20], Bernstein polynomials have been applied to approximately solve the generalized pantograph equations. Also, the Hermite polynomials were proposed in [43] to achieve approximate solutions of a generalized pantograph equation with variable coefficients. The authors of [12, 46] discussed the stability of θ-methods for the solution of a generalized pantograph equation. The Chebyshev polynomials and the tau method were suggested to solve pantograph equations in [36]. Xu and Huang [13, 42] found the discontinuous and continuous Galerkin solutions for the PDDEs. In [6], the trapezoidal rule discretization was investigated for numerical solution of the PDEs. In [8, 19], rational functions were applied to approximate a generalized pantograph equation on a semiinfinite interval. Furthermore, Taylor polynomials were used to estimate the solution of the pantograph equations in [21, 31, 32].

Despite the techniques mentioned above, there is a need for an efficient and convergent numerical method with high accuracy and less complexity to solve PDDEs. In recent decades, spectral and pseudospectral methods have been considered as some of the high-precision methods for numerical solution of continuous-time problems involving dynamical systems. The main reason for using spectral and pseudospectral methods is the exponential convergence rate of these methods in approximating analytical and smooth functions [7, 33, 35]. These methods usually deal with two steps: selecting a polynomial space to approximate the solution of problem and transferring the problem (or differential equation) into the polynomial space. The orthogonal polynomials such as those of Legendre and Chebyshev are utilized to approximate the solution that have derivatives of any order. Also, a set of points, as collocation or interpolating points, are considered to discretize the equations.

In this paper, we propose a transferred Legendre pseudospectral method to solve a class of PDDEs. The proposed method has the ability to be extended to all DDEs. We focus on the following PDDE:

$$ \textstyle\begin{cases} \dot{w}(r)=\alpha (r) w(r)+\beta (r) w(qr)+\chi (r),& 0 \le r\le R, \\ w(0)=\gamma , \end{cases} $$
(1)

where \(\alpha (\cdot )\), \(\beta (\cdot )\), and \(\chi (\cdot )\) are given differentiable functions, \(0< q<1\) is a constant, γ is a given vector, and \(w:{\mathbb{R}}^{n} \to {\mathbb{R}}\) is an unknown continuously differentiable function. We assume that equation (1) has a unique solution \(w(\cdot )\). Here we suggest a new transferred Legendre PS method for numerical solution of equation (1). The collocation is communicated to the transferred Legendre–Gauss–Lobatto (LGL) nodes. After discretization of the problem in these nodes, we have a nonlinear programming (NLP) problem. So, we estimate the solution of the major PDDEs. The convergence of estimate solutions is given, and the performance of technique by solving four test problems and a comparison of the method with other numerical techniques are presented.

2 Description of the technique

At the first step, we transform DDE (1) into the following CTO problem:

$$ \begin{aligned} &\text{Minimize} \quad I= \bigl\Vert {w}(0)-\gamma \bigr\Vert _{2}^{2} \\ &\text{subject to} \quad \dot{w}(r)=\alpha (r)w(r)+\beta (r)w(qr)+ \chi (r), \quad 0 \le r\le R. \end{aligned} $$
(2)

The accurate solution of equation (1) is an optimal solution to the problem (2). Since equation (1) has a unique solution, problem (2) is feasible and has a unique optimal solution. We estimate the solution of problem (2) as follows:

$$ w(r)\simeq w^{M} (r)=\sum_{j=0}^{M} \bar{w}_{j} L_{j} (r), \quad 0 \le r\le R, $$
(3)

where \(\bar{w}_{j}\), \(j=0,1,\dots ,M\) are unknown coefficients and \(L_{j} (\cdot )\), \(j=0,1,\dots ,M\) are the interpolating Lagrange polynomials, defined by

$$ L_{j} (r)=\prod_{{ i=0},{ i\ne j}}^{M} \frac{r-r_{i} }{r_{j} -r_{i} } , \quad j=0,1,\dots ,M. $$
(4)

The transferred LGL points, \(\{ r_{j} \} _{j=0}^{M} \) on \([0,R]\) are the roots of the polynomials \((1-(\frac{2}{R} r-1)^{2} ) \frac{dQ_{M} (r)}{dr} \) where \(Q_{M} (\cdot )\) is the transferred Legendre polynomial of order M defined on \([0,R ]\) by the following recurrence relation:

$$ \textstyle\begin{cases} Q_{0} (r)=1, \qquad Q_{1} (r)= \frac{2}{R} r-1,& \\ Q_{j+1} (r)= (\frac{2j+1}{j+1} ) (\frac{2}{R} r-1 )Q_{j} (r)-( \frac{j}{j+1} ) Q_{j-1} (r),& j=1,2,\dots ,M. \end{cases} $$
(5)

We note that

$$L_{j} (r_{k} )= \textstyle\begin{cases} 1, &j=k, \\ 0, & j \neq k. \end{cases} $$

So,

$$ w(r_{k} )\simeq w^{M} (r_{k} )= \bar{w}_{k}. $$
(6)

Now, by using relations (3) and (6), we discretize CTO (2) into the NLP problem

$$\begin{aligned}& \text{Minimize}\quad I= \Vert \bar{w}_{0}-\gamma \Vert _{2} ^{2} \\& \text{subject to} \quad \sum_{j=0}^{M} \bar{w}_{j} H_{kj} =\alpha (r_{k}) \bar{w}_{k}+ \beta (r_{k}) \sum _{j=0}^{M}\bar{w}_{j} L_{j}(qr_{k})+ \chi (r_{k}),\quad k=1,2,\dots ,M, \end{aligned}$$
(7)

where \(H_{kj} =\dot{L}_{j} (r_{k} )\), and we can display that

$$ H_{kj} = \textstyle\begin{cases} \frac{Q_{M} (r_{k} )}{Q_{M} (r_{j} )} \cdot \frac{1}{r_{k} -r_{j} },& k\ne j, \\ \frac{2}{R} \cdot \frac{-M(M+1)}{4},& k=j=0, \\ \frac{2}{R} \cdot \frac{M(M+1)}{4},& k=j=M, \\ 0,& \text{otherwise.} \end{cases} $$
(8)

We note that

$$ \frac{d}{dr} w(r_{k} )\simeq \frac{dw^{M} }{dr} (r_{k} )=\sum_{j=0}^{M} \bar{w}_{j} \dot{L}_{j} (r_{k})=\sum _{j=0}^{M}\bar{w}_{j}H_{k j}. $$
(9)

Having solved NLP problem (7), we attain the pointwise estimated solution \(\bar{w}^{*} = (\bar{w}^{*} _{0} ,\bar{w}^{*} _{1} , \dots , \bar{w}^{*} _{M} )\). Also,

$$ w^{M} (r)=\sum_{j=0}^{M} \bar{w}_{j}^{*} L_{j} (r),\quad 0\le r \le R, $$
(10)

is a continuous estimate solution for the CTO problem (2) (or the major equation (1)).

3 Convergence of method

In this part of the article, we present the convergence theorem of the presented method for PDDEs. Suppose \(V^{n,q}\), \(n\ge 2 \) is a Sobolev space containing all functions \(\rho : [0,R ]\to \mathbb{R}^{n} \) such that \(\rho ^{(j)} \), \(0\le j\le n\), is in \(L^{q} \) equipped with the norm

$$ \Vert \rho \Vert _{v^{n,q} } =\sum_{j=0}^{n} \biggl( \int _{0}^{R} \bigl\Vert \rho ^{(j)} (r) \bigr\Vert _{q} ^{q} \biggr) ^{\frac{1}{q} }. $$

Lemma 1

([7])

For any given function \(\rho (\cdot )\in V^{n,\infty }\), there is a polynomial \(p (\cdot ) \in P_{M}\) such that

$$ \bigl\Vert \rho (r)-p (r) \bigr\Vert _{\infty }\le CC_{0} M^{-n} , \quad 0\le r\le R, $$

where C is a fixed constant independent of M and \(C_{0} = \Vert \rho \Vert _{V^{n,\infty } } \).

To guarantee the feasibility of problem (7), we convert it into the following one:

$$ \begin{aligned} &\text{Minimize} \quad I= \Vert \bar{w}_{0} -\gamma \Vert ^{2} \\ &\text{subject to} \quad \Biggl\Vert \sum_{j=0}^{M} \bar{w}_{j} H_{kj} -\alpha (r_{k}) \bar{w}_{k}- \beta (r_{k}) \sum _{j=0}^{M}\bar{w}_{j} L_{j}(qr_{k})- \chi (r_{k}) \Biggr\Vert _{\infty }\\ &\hphantom{\text{subject to} \quad}\quad \le (M-1)^{\frac{3}{2} -n}, \quad k=1,2,\dots ,M. \end{aligned} $$
(11)

Theorem 1

Suppose that \(w(\cdot )\in V^{n,\infty } \), \(n\ge 2\) is a possible solution to the problem (2). There is a positive integer \({ M}_{1} \) such that for any integer \(M>{ M}_{1} \), problem (11) has a feasible solution \(\bar{w}= (\bar{w}_{0} ,\bar{w}_{1} ,\dots ,\bar{w}_{M} )\) satisfying

$$ \bigl\Vert w(r_{k} )-\bar{w}_{k} \bigr\Vert _{\infty } \le L(M-1)^{1-n} ,\quad k=0,1,\dots ,M, $$

where \(\{ r_{k} \} _{k=0}^{M} \) are the collocation points and L is a positive constant, independent of M.

Proof

There is a polynomial \(p (\cdot )\in P_{M-1}\) and fixed \(C_{1} \) independent of M, such that

$$ \bigl\Vert \dot{w}(r)-p(r) \bigr\Vert _{\infty } \le C_{1} (M-1 )^{1-n}. $$

Define

$$ w^{M} (r)= \int _{0}^{r}p(\zeta )\,d\zeta +w(0), \quad r \ge 0. $$

So we have

$$ \dot{w}^{M} (r)=p(r) , \qquad w^{M} (0)=w(0). $$

Hence,

$$ \begin{aligned} \bigl\Vert w(r)-w^{M} (r) \bigr\Vert _{\infty }&= \biggl\Vert \int _{0}^{r}\bigl(\dot{w}(z)-p(z)\bigr)\,dz \biggr\Vert _{\infty }\le \int _{0}^{r} \bigl\Vert \dot{w}(z)-p(z) \bigr\Vert _{\infty }\,dz \\ &\le C_{1} (M-1 )^{1-n} \int _{0}^{r}\,df \le C_{1} R (M-1 )^{1-n}. \end{aligned} $$
(12)

By (12), \(w(r_{k} )\) and \(\bar{w}_{k} \) for \(k=0,1,\dots ,M\) are in a dense set as \(\Psi \subseteq {\mathbb{R}}^{n} \). On the other hand, \(w^{M} (\cdot ) \in P_{M}\) is a polynomial. For any polynomial \(w(\cdot ) \in P_{M}\), its derivative at the transferred LGL nodes \(r_{0} ,r_{1 } ,\dots ,r_{{M} } \) can be computed accurately with differential matrix H. Therefore we get

$$ \sum_{j=0}^{M} \bar{w}_{j} H_{kj} =\dot{w}^{M} (r_{k} ). $$
(13)

So by (12) and (13), for \(k=1,2,\dots ,M \), we have

$$\begin{aligned} & \Biggl\Vert \sum_{j=0}^{M} \bar{w}_{j} H_{kj}-\alpha (r_{k})w(r_{k})- \beta (r_{k})w(qr_{k})-\chi (r_{k}) \Biggr\Vert _{\infty } \\ &\quad \leq \bigl\Vert \dot{w}^{M}(r_{k})-\dot{w}(r_{k}) \bigr\Vert _{\infty }+ \bigl\Vert \alpha (r_{k})w^{M}(r_{k})- \alpha (r_{k})w(r_{k}) \bigr\Vert _{\infty }\\ &\qquad {}+ \bigl\Vert \beta (r_{k})w^{M}(qr_{k})-\beta (r_{k})w(qr_{k}) \bigr\Vert _{\infty } \\ &\quad \leq \bigl\Vert \dot{w}^{M}(r_{k})-\dot{w}(r_{k}) \bigr\Vert _{\infty }+ \bigl\Vert \alpha (r_{k}) \bigr\Vert _{\infty } \bigl\Vert w^{M}(r_{k})-w(r_{k}) \bigr\Vert _{\infty }\\ &\qquad {}+ \bigl\Vert \beta (r_{k}) \bigr\Vert _{\infty } \bigl\Vert w^{M}(qr_{k})-w(qr_{k}) \bigr\Vert _{\infty } \\ &\quad \leq C_{1}(M-1)^{1-n}+N_{1}C_{1}R(M-1)^{1-n}+N_{2}C_{1}R(M-1)^{1-n} \\ &\quad =C_{1}(M-1)^{1-n}(1+N_{1}R+N_{2}R), \end{aligned}$$

where \(N_{1}\) and \(N_{2}\) are upper bounds for continuous functions \(a(\cdot )\) and \(b(\cdot )\) on the interval \([0,R]\). Thus by selecting \(M_{1} \in \mathbb{N}\) such that \(C_{1} (1+N_{1}R+N_{2}R)\le (M_{1}-1)^{\frac{1}{2} } \), we get

$$ \Biggl\Vert \sum_{j=0}^{M} \bar{w}_{j} H_{kj}-\alpha (r_{k})w(r_{k})- \beta (r_{k})w(qr_{k})-\chi (r_{k}) \Biggr\Vert _{\infty }\leq (M-1)^{ \frac{3}{2}-n}, \quad k=1,2,\dots , M, $$
(14)

for all integers \(M\ge M_{1} \). □

Let \((\bar{w}_{0}^{*} ,\bar{w}_{1}^{*} ,\dots ,\bar{w}_{M}^{*} )\) be an optimal solution to problem (11) defined by

$$ w_{M}^{*} (r)=\sum_{k=0}^{M} \bar{w}_{k}^{*} L_{k} (r), \quad r \in [0, R ], $$
(15)

where \(L_{k} (\cdot )\), \(k=0,1,\dots ,M\) are the Lagrange interpolating polynomials. We have a sequence of direct solutions \(\{ \bar{w}_{0}^{*} ,\bar{w}_{1}^{*} ,\ldots ,\bar{w}_{M}^{*} \} _{M=M_{1} }^{\infty } \) and corresponding sequences of interpolating functions \(\{ w_{M}^{*} (\cdot ) \} _{M=M_{1} }^{\infty }\).

Assumption 1

It is supposed that the sequence \(\{ \bar{w}_{0}^{*} ,\dot{w}^{*}_{M} (\cdot ) \} _{M=M_{1} }^{ \infty } \) has a subsequence that uniformly converges to \(\{ {w}_{0}^{\infty } ,q(\cdot ) \} \) where \(q(\cdot )\) is a continuous function and \({w}_{0}^{\infty } \in \mathbb{R}\).

Theorem 2

Let \(\{ \bar{w}_{0}^{*} ,\bar{w}_{1}^{*} ,\ldots ,\bar{w}_{M}^{*} \} _{M=M_{1} }^{\infty } \) be a sequence for optimal solutions of problem (11) and \(\{ w_{M}^{*} (\cdot ) \} _{M=M_{1} }^{\infty } \) be their interpolating sequence satisfying Assumption 1. Then,

$$ w^{*} (r)= \int _{0}^{r}q(\zeta )\,d\zeta + {w}_{0}^{\infty }, \quad 0 \le r\le R, $$
(16)

is an optimal solution to the problem (2).

Proof

Under Assumption 1, there exists a subsequence \(\{ \dot{w}^{*}_{M_{i}} (\cdot ) \} _{i=1}^{\infty } \) of sequence \(\{ \dot{w}^{*}_{M} (\cdot ) \} _{M=M_{1}}^{\infty } \) such that \(\lim_{i\to \infty } M_{i} =\infty \) and \(\lim_{i\to \infty } \dot{w}^{*}_{M_{i} }(\cdot ) =q( \cdot )\). From (16) and Assumption 1, we get

$$ \lim_{i\to \infty } \dot{w}^{*}_{M_{i} } (\cdot )= \dot{w}^{*} (\cdot ). $$

In the first step, we demonstrate that \(w^{*} (\cdot )\) is a feasible solution for problem (2). In the second step, we show that \(w^{*} (\cdot )\) is an optimal solution for the problem (2).

Step 1. Suppose that \(w^{*} (\cdot )\) does not satisfy the restriction of problem (2). There is a time \(\bar{r}\in [0,R ]\) such that

$$ \dot{w}^{*}(\overline{r})-\alpha (\overline{r})w^{*}( \overline{r})- \beta (\overline{r})w^{*}(q\overline{r})-\chi ( \overline{r})\ne 0. $$

Since nodes \(\{ r_{k} \} _{k=0}^{\infty } \) are dense in \([0,R ]\) (see [10]), there exists a subsequence \(k_{M_{i} } \) such that \(0< k_{M_{i} } < M_{i} \), \(\lim_{i\to \infty } r_{k_{M_{i} } } =\bar{r}\). Thus,

$$ \begin{aligned} &\dot{w}^{*}(\bar{r})-\alpha (\overline{r})w^{*}( \overline{r})-\beta ( \overline{r})w^{*}(q\overline{r})-\chi ( \overline{r})\\ &\quad =\lim_{i\to \infty } \bigl(\dot{w}_{M_{i}}^{*}(r_{k_{M_{i}}} )- \alpha (r_{k_{M_{i}}} ) w_{M_{i}}^{*}(r_{k_{M_{i}}} )- \beta (r_{k_{M_{i}}} )w_{M_{i}}^{*}(qr_{k_{M_{i}}} )-\chi (r_{k_{M_{i}}} ) \bigr)\ne 0. \end{aligned} $$
(17)

On the other hand, \(\lim_{i\to \infty } (M_{i} -1 )^{{ \frac{3}{2}} -n} =0\), so that for problem (11), we obtain

$$ \lim_{i\to \infty } \bigl(\dot{w}_{M_{i}}^{*}(r_{k_{M_{i} } } )-\alpha (r_{k_{M_{i}}} ) w_{M_{i}}^{*}(r_{k_{M_{i}}} )- \beta (r_{k_{M_{i}}} )w_{M_{i}}^{*}(qr_{k_{M_{i}}} )-\chi (r_{k_{M_{i}}} )\bigr)=0, $$

which is a contradiction to (17). So, \(w^{*}(\cdot )\) is a possible solution to problem (2).

Step 2. Let \(w^{**} (\cdot )\in V^{n,\infty } \), \(n\ge 2\) be an optimal solution to the problem (2). In view of Theorem 1, there exists a sequence of possible solutions \(\{ \tilde{w}=(\tilde{w}_{0}^{*} ,\tilde{w}_{1}^{*} ,\dots , \tilde{w}_{M}^{*}) \} _{M=M_{1} }^{\infty } \) for problem (11) which converges uniformly to \(w^{**} (\cdot )\). With optimality of \(w^{**} (\cdot )\) and \(\bar{w}^{*}= (\bar{w}_{0}^{*}, \bar{w}_{1}^{*}, \dots , \bar{w}_{M}^{*} )\), we obtain

$$\begin{aligned} 0&= \bigl\Vert w^{**} (0)-\gamma \bigr\Vert ^{2} \le \bigl\Vert w^{*} (0)- \gamma \bigr\Vert ^{2} =\lim _{i\to \infty } \bigl\Vert w_{M_{i} }^{*} (0)-\gamma \bigr\Vert ^{2} \\ &= \bigl\Vert \bar{w}_{0}^{*} -\gamma \bigr\Vert ^{2} \le \bigl\Vert \tilde{w}_{0}^{*} -\gamma \bigr\Vert ^{2} = \bigl\Vert w^{**} (0)- \gamma \bigr\Vert ^{2} =0. \end{aligned}$$

So \(\| w^{*}(0)-\gamma \|^{2}=0 \). Therefore, \(w^{*} (\cdot )\) is an optimal solution for problem (2). □

4 Test problems

In this part of the article, in order to illustrate the performance and precision of presented method, we solve four PDDEs.

Example 1

Consider the following PDDE:

$$ \textstyle\begin{cases} \dot{w}(r)=\frac{1}{2} w(r)+\frac{1}{2} e^{ \frac{r}{2}}w(\frac{r}{2}), \quad 0 \leq r \leq R, \\ w(0)=1. \end{cases} $$

The accurate solution of this pantograph equation is \(w(r)=e^{r} \). We assume that \(R=1 \). The estimated and accurate solutions with \(M=9 \) are illustrated in Fig. 1. The absolute errors of estimated solutions with \(M=6, 9, 12 \) in Fig. 2 are given in Table 1. It appears that when M increases, the absolute errors vanish and the obtained estimated solutions converge to the accurate solution. Also, in Table 1 we compare the absolute error of the obtained estimated solution with that found using Taylor methods in [31]. It can be seen that our method is more accurate.

Figure 1
figure 1

The accurate and estimated solutions with \(M=9 \) for Example 1

Figure 2
figure 2

The absolute errors for Example 1

Table 1 Comparison of the absolute errors for Example 1

Example 2

Consider the following PDDE:

$$ \textstyle\begin{cases} \dot{w}(r)=aw(r)+bw(qr)+\cos (r)-a\sin (r)-b\sin (qr), \quad 0 \leq r \leq R, \\ w(0)=0. \end{cases} $$

The accurate solution of this pantograph equation is \(w(r)=\sin (r) \) for any \(a, b \in \mathbb{R} \), \(0 < q <1 \). We assume that \(a=-1\), \(b=0.5\), \(q=0.5\), and \(R=1 \). The estimated and accurate solutions are shown with \(M=9 \) in Fig. 3. Also, the absolute errors of estimated solutions for \(M=5, 7, 9 \) are illustrated in Fig. 4. It can see that when M increases, the absolute error tends to zero. In Table 2 we compare the maximum of absolute errors of the presented method with discontinuous Galerkin (DG) method [14]. The results of the presented method are better than those of DG method for this example.

Figure 3
figure 3

The accurate and estimated solutions with \(M=9 \) for Example 2

Figure 4
figure 4

The absolute errors for Example 2

Table 2 Comparison of the maximum absolute errors for Example 2

Example 3

Consider the following PDDE:

$$ \textstyle\begin{cases} \dot{w}(r)=\frac{1}{2} w(qr)-w(r)-\frac{1}{2} e^{-qr}, \quad 0 \leq r \leq R, \\ w(0)=1. \end{cases} $$

The accurate solution of this pantograph equation is \(w(r)=e^{-r} \), \(0< q<1 \). We illustrate the accurate and estimated solutions for \(M=8 \) and \(q=0.5 \) in Fig. 5. The absolute errors of the estimated solutions with \(M=8, 10, 12 \) and \(q=0.5 \) are given in Fig. 6. By increasing M, the absolute errors decrease. In Table 3 we compare the maximum errors of the presented method and see that the error of the presented method is less than that of the method of [17].

Figure 5
figure 5

The accurate and estimated solutions with \(M=8 \) for Example 3

Figure 6
figure 6

The absolute errors for Example 3

Table 3 Comparison of the maximum absolute errors for Example 3

Example 4

Consider the following nonlinear PDDE:

$$ \textstyle\begin{cases} \dot{w}(r)=-w(r)-w(0.8r), \\ w(0)=1,\quad 0\le r \le 1. \end{cases} $$

So far, no researchers have reported the exact solution to this equation. But, several authors [3, 16, 20, 26, 32, 43, 44] have presented some numerical solutions. Hence, we also apply our method to numerically solve this equation and compare the obtained results with those of others. The obtained numerical solutions for different M are given in Fig. 7. It can be seen that the solutions are stable and tend to the specified function (which can be a solution for the equation). Also, in Fig. 8 we show the residual errors for different vales of M. By increasing M, the residual errors decrease. So our numerical solutions are acceptable. Moreover, for further confirmation, we compare the results of the Walsh series (WS) method [26], Laguerre series (LS) approach [16], Taylor series (TS) scheme [32], Hermit series collocation (HSC) approach [43], Bernstein polynomial (BP) method [20], Bernoulli collocation (BC) method [3], and modified Chebyshev collocation (MCC) technique [44]. Tables 4 and 5 indicate that our results are close and consistent with the solutions of others. Furthermore, Table 5 shows that, by increasing M, our estimated solutions come close to some constants and are more trustworthy.

Figure 7
figure 7

The estimated solutions for Example 4

Figure 8
figure 8

The absolute errors for Example 4

Table 4 Estimated solutions of other methods for Example 4
Table 5 Estimated solutions of the presented method for Example 4

5 Conclusions and suggestions

In this manuscript, we presented a transferred Legendre pseudospectral method for PDDEs. The feasibility and convergence of obtained estimated solutions have been discussed. The technique has been successfully utilized for solving some pantograph DDEs. A comparison of the obtained results with those of other techniques showed that our method is more precise than some existing approaches. One of the advantages of this method is that by selecting a small number of points, an acceptable accuracy can be achieved for the solution of the equation. For future work, we will suggest the implementation of the method to the numerical solution of other types of DDE, such as fractional DDEs, fractional delay integro-differential equations and fractional delay partial differential equations.