#### Abstract

Nowadays, fractional derivative is used to model various problems in science and engineering. In this paper, a new numerical method to approximate the generalized Hattaf fractional derivative involving a nonsingular kernel is proposed. This derivative included several forms existing in the literature such as the Caputo–Fabrizio fractional derivative, the Atangana–Baleanu fractional derivative, and the weighted Atangana–Baleanu fractional derivative. The new proposed method is based on Lagrange polynomial interpolation, and it is applied to solve linear and nonlinear fractional differential equations (FDEs). In addition, the error made during the approximation of the FDEs using our proposed method is analyzed. By comparing the approximate and exact solutions, it is noticed that the new numerical method is very efficient and converges very quickly to the exact solution. Furthermore, our proposed numerical method is also applied to nonlinear systems of FDEs in virology.

#### 1. Introduction

Recently, fractional differential equations (FDEs) are used to describe the dynamics of different phenomena with memory effect in science and engineering. For instance, Cheneke et al. [1] modeled the dynamics of cholera transmission by formulating a nonlinear system of FDEs with the new generalized Hattaf fractional (GHF) derivative [2] that covers the most famous fractional derivatives with nonsingular kernels existing in the literature such as the Caputo–Fabrizio fractional derivative [3], the Atangana–Baleanu fractional derivative [4], and the weighted Atangana–Baleanu fractional derivative [5].

Most FDEs are very complex and cannot be solved analytically. Therefore, many numerical methods have been developed and proposed to approximate the solutions of these FDEs. For example, Shiri et al. [610] proposed collocation and predictor-corrector methods to obtain numerical solutions of FDEs with singular fractional Caputo derivative [11] and Atangana–Baleanu fractional derivative. Another numerical method for FDEs with Atangana–Baleanu fractional derivative was introduced in [12]. However, there is no method to solve numerically the FDEs involving GHF derivative. So, the original contribution of this paper is to develop a new numerical method for nonlinear and nonautonomous FDEs with GHF derivative. To do this, the next section deals with preliminary results for GHF derivative. The numerical method and the error analysis are presented in Sections 3 and 4. Several examples are given in Section 5 to illustrate our method. Finally, Section 6 outlines the conclusion.

#### 2. Preliminary Results

In this section, we recall some basic definitions and properties of GHF derivative that are useful in the next sections. So, let be the Sobolev space of order one defined as follows:

Definition 1. Let , , and . The GHF derivative of order in Caputo sense of the function with respect to the weight function is defined as follows [2]:where , on [a,b], is a normalization function obeying , , and is the Mittag-Leffler function of parameter .
For simplicity, denote C by . It follows from [2] that the generalized fractional integral associated to is given by the following definition.

Definition 2 (see [2]). The generalized fractional integral operator associated to is defined bywhere is the standard weighted Riemann–Liouville fractional integral of order defined byIn addition, we need the following fundamental theorem that extends the Newton–Leibniz formula introduced in [13, 14].

Theorem 1 (see [15]). Let , , and . Then, we have the following properties:

#### 3. Numerical Method

In this section, we propose a numerical method to approximate the solution of the following nonlinear and nonautonomous FDE with GHF derivative given by

According to Theorem 1, the above equation can be converted to the following fractional integral equation:

Let , with . We havewhich leads towhere . The function can be approximated over the interval as in [12] by using the Lagrange polynomial interpolation passing through the two points and as follows:

Thus,

Therefore, we deduce the following numerical scheme:where

Remark 1. The numerical approximation of fractional derivative with nonlocal and nonsingular kernel presented in [12] is a particular case of (12), and it suffices to take and .

#### 4. Error Analysis

In this section, we study the numerical error of our approximation scheme presented in (15).

Theorem 2. Let be a FDE with GHF derivative, such that has a bounded second derivative. Then, the numerical solution of is given bywhere

Proof. According to (8), we haveThen,Hence,Thus,Since the function is positive on , we deduce that there exists a such thatHence,We haveTherefore,This completes the proof.

#### 5. Applications

In this section, we apply our method to FDEs with exact solutions as well as to nonlinear FDEs which describe the dynamics of HIV infection.

Example 1. Consider the following FDE:Let . By applying the fractional Hattaf integral to both sides of (27) and using (5), we get the exact solution of (27) as follows:Next, we apply our method to approximate the solution of (27). For all numerical simulations, we choose the normalization function as follows:The comparison between the exact and numerical (approximate) solutions of (27) is displayed in Figure 1 for different values of , , and . In addition, Table 1 presents the maximum error for and and various values of .

Example 2. Consider the following FDE:For , the exact solution of (30) is given byFigures 2 and 3 show the comparison between the exact and numerical (approximate) solutions of (30) for different values of , , and . Furthermore, Table 2 presents the maximum error for Example 2 with and and various values of .

Example 3. Consider the following nonlinear systems of FDEs modeling the HIV infection:where , , and denote the concentrations of healthy T cells, infected cells, and free virus at time , respectively. Healthy cells are produced at rate , die at rate , and become infected by free virus at rate . Free virus is produced by an infected cell at rate . Finally, the parameters and are the death rate of infected cells and the clearance rate of virus, respectively.
By a simple computation, is an infection-free equilibrium of (23), and the basic reproduction number is given byFor the numerical simulations, we first choose , , , , , , , and . In this case, , and the solution of (32) converges to the infection-free equilibrium (see Figure 4).
Now, we choose and do not change the other parameter values. By computation, we get . In this case, the solution of (32) converges to a chronic infection equilibrium, which means that the virus persists in the host and the HIV infection becomes chronic. Figure 5 illustrates this observation.

#### 6. Conclusion

In this paper, we have developed a new explicit numerical method based on Lagrange polynomial interpolation for solving fractional differential equation defined in so called generalized Hattaf fractional derivative. This derivative generalized the famous fractional derivatives including the Caputo–Fabrizio fractional derivative, the Atangana–Baleanu fractional derivative, and the weighted Atangana–Baleanu fractional derivative. The developed method was applied to two FDEs with exact solutions as well as to nonlinear FDEs which describe the dynamics of HIV infection. From the analytical and numerical results, we conclude that our method is easy to program, efficient, and quickly converges to the exact solution. Moreover, the recent numerical method and results presented in [12] are improved and generalized. On the other hand, the construction of implicit and collocation methods for FDEs with generalized Hattaf fractional derivative will be the subject of our future work.

#### Data Availability

No data were used to support this study.

#### Conflicts of Interest

The authors declare that they have no conflicts of interest.