Introduction

In recent decades, using the computer systems has led to great changes in many fields of life. These changes are many important and wonderful where we cannot leave applying the computer systems.

Computer viruses are a malicious software program that can be written with different aims. These softwares help the user to enter the victim computer without permission. The virus should never be considered to be harmless and remain in the system. There are several types of viruses that can be categorized according to their source, technique, file type that infects, where they are hiding, the type of damage they enter, the type of operating system or the design on which they are attacking. Several computer viruses such as ILOVEYOU, Melissa, My Doom, Code Red, Sasser have been recognized. Also, in recent years, the Stuxnet virus targeted the Siemens hardware and software industry. Claims and statements allege that the virus was part of spy campaign to hit Iran’s nuclear plant, Natanz. These viruses have been able to infect thousands of computers and have hurt billions dollar in computers around the world.

Thus, scientists start to work on finding methods to analyze, track, model and protect against viruses. Computer viruses are similar to biological viruses, and we can study it in two case, microscopic and macroscopic models. Therefore, many studies have proposed solutions that help us to understand how computer viruses operate. In order to control the growth and reproduction of computer viruses, many dynamical model have been presented [7, 18, 19, 29, 33,34,35, 40, 42]. In this study, the following modified SIR model of computer viruses

$$\begin{aligned} \frac{{{\text{d}}S(t)}}{{{\text{d}}t}} & = f_{1} - \lambda S(t)I(t) - {\text{d}}S(t), \\ \frac{{{\text{d}}I(t)}}{{{\text{d}}t}} & = f_{2} + \lambda S(t)I(t) - \varepsilon I(t) - {\text{d}}R(t), \\ \frac{{{\text{d}}R(t)}}{{{\text{d}}t}} & = f_{3} + \varepsilon I(t) - {\text{d}}R(t). \\ \end{aligned}$$
(1)

is illustrated where the initial conditions are in the following form

$$\begin{aligned} \begin{aligned} S(0)&= S_0(t) = S_0, \\ I(0)&= I_0(t) = I_0, \\ R(0)&= R_0(t) = R_0.\\ \end{aligned} \end{aligned}$$
(2)

In recent years, many applicable methods have been applied to solve the linear and nonlinear problems [13,14,15,16, 27, 28, 31, 39, 41]. Also, many numerical and semi-analytical methods presented to solve the nonlinear epidemiological model (1) such as multi-step homotopy analysis method [17], collocation method with Chebyshev polynomials [32] and variational iteration method [29]. In this paper, the HAM [22,23,24,25,26] is applied to solve the nonlinear system of Eq. (1). This method has many applications to solve various problems arising in the mathematics, physics and engineering [1,2,3,4,5,6, 8,9,10,11,12, 14,15,16, 20, 21, 30, 31, 36,37,38]. The \(\hbar\)-curves are demonstrated to find the region of convergence. It is one of important abilities of HAM that the other methods do not have this ability. In order to show the efficiency and accuracy of presented approach, the residual error functions for different values of \(\hbar , m\) are estimated. Several graphs of error functions are demonstrated to show the capabilities of method. List of functions, variables and initial assumptions of system (1) are presented in Table 1.

Table 1 List of parameters and functions

Main idea

Let \(L_S, L_I\) and \(L_R\) are the linear operators which are defined in the following form

$$\begin{gathered} L_{S} = \frac{{{\text{d}}S}}{{{\text{d}}t}}, \hfill \\ ~L_{I} = \frac{{{\text{d}}I}}{{{\text{d}}t}},~ \hfill \\ ~L_{R} = \frac{{{\text{d}}R}}{{{\text{d}}t}} \hfill \\ \end{gathered}$$
(3)

and for constant values \(c_1, c_2\) and \(c_3\) we obtain

$$\begin{aligned} L_S (c_1) = 0, ~~~L_I(c_2) = 0, ~~~L_R (c_3) = 0. \end{aligned}$$
(4)

Now, the following homotopy maps can be defined as

$$\begin{aligned} \displaystyle H_S \left( {\tilde{S}}(t;q),{\tilde{I}}(t;q),{\tilde{R}}(t;q)\right)&= (1-q) L_S\left[ {\tilde{S}}(t;q)-S_0(t)\right] - q\hbar H_S(t) N_S \left[ {\tilde{S}}(t;q), {\tilde{I}}(t;q), {\tilde{R}}(t;q)\right] ,\\ \displaystyle H_I \left( {\tilde{S}}(t;q),{\tilde{I}}(t;q),{\tilde{R}}(t;q)\right)&= (1-q) L_I\left[ {\tilde{I}}(t;q)-I_0(t)\right] -q\hbar H_I(t) N_I \left[ {\tilde{S}}(t;q), {\tilde{I}}(t;q), {\tilde{R}}(t;q)\right] ,\\ \displaystyle H_R \left( {\tilde{S}}(t;q),{\tilde{I}}(t;q),{\tilde{R}}(t;q)\right)&= (1-q) L_R\left[ {\tilde{R}}(t;q)-R_0(t)\right] - q\hbar H_R(t) N_R \left[ {\tilde{S}}(t;q), {\tilde{I}}(t;q), {\tilde{R}}(t;q)\right] , \end{aligned}$$
(5)

where \(q\in [0,1]\) is an embedding parameter, \(\hbar \ne 0\) is a convergence control parameter, \(H_S(t), H_I(t)\) and \(H_R(t)\) are the auxiliary functions, \(L_S, L_I\) and \(L_R\) are the linear operators, and finally \(N_S, N_I\) and \(N_R\) are the nonlinear operators which are defined as follows

$$\begin{aligned} \begin{aligned} \displaystyle N_S[{\tilde{S}}(t;q),{\tilde{I}}(t;q),{\tilde{R}}(t;q)]&= \frac{\partial {\tilde{S}}(t;q)}{\hbox {d}t} - f_1 +\lambda {\tilde{S}}(t;q) {\tilde{I}}(t;q) + \hbox {d} {\tilde{S}}(t;q),\\ \displaystyle N_I[{\tilde{S}}(t;q),{\tilde{I}}(t;q),{\tilde{R}}(t;q)]&= \frac{\partial {\tilde{I}}(t;q)}{\hbox {d}t}- f_2 - \lambda {\tilde{S}}(t;q) {\tilde{I}}(t;q) +\varepsilon {\tilde{I}}(t;q) + \hbox {d} {\tilde{R}}(t;q), \\ \displaystyle N_R[{\tilde{S}}(t;q),{\tilde{I}}(t;q),{\tilde{R}}(t;q)]&= \frac{\partial {\tilde{R}}(t;q)}{\hbox {d}t} - f_3 - \varepsilon {\tilde{I}}(t;q) + \hbox {d} {\tilde{R}}(t;q). \end{aligned} \end{aligned}$$
(6)

According to [22,23,24] the zero-order deformation, equations can be defined as

$$\begin{aligned} \begin{aligned}&(1-q) L_S\left[ {\tilde{S}}(t;q)-S_0(t)\right] - q\hbar H_S(t) N_S \left[ {\tilde{S}}(t;q),{\tilde{I}}(t;q),{\tilde{R}}(t;q)\right] =0,\\&(1-q) L_I\left[ {\tilde{I}}(t;q)-I_0(t)\right] - q\hbar H_I(t) N_I \left[ {\tilde{S}}(t;q),{\tilde{I}}(t;q),{\tilde{R}}(t;q)\right] =0,\\&(1-q) L_R\left[ {\tilde{R}}(t;q)-R_0(t)\right] - q\hbar H_R(t) N_R \left[ {\tilde{S}}(t;q),{\tilde{I}}(t;q),{\tilde{R}}(t;q)\right] =0. \end{aligned} \end{aligned}$$
(7)

Now, we can write the Taylor series for \({\tilde{S}}(t;q), {\tilde{I}}(t;q)\) and \({\tilde{R}}(t;q)\) with respect to q in the following form

$$\begin{aligned} \begin{aligned} \displaystyle {\tilde{S}}(t;q)&= S_0(t) + \sum _{m=1}^\infty S_m(t) q^m,\\ \displaystyle {\tilde{I}}(t;q)&= I_0(t) + \sum _{m=1}^\infty I_m(t) q^m,\\ \displaystyle {\tilde{R}}(t;q)&= R_0(t) + \sum _{m=1}^\infty R_m(t) q^m, \end{aligned} \end{aligned}$$
(8)

where

$$\begin{aligned} \begin{array}{lll} \displaystyle S_m = \frac{1}{m!} \frac{\partial ^m {\tilde{S}}(t;q) }{\partial q^m}\bigg |_{q=0},&\displaystyle I_m = \frac{1}{m!} \frac{\partial ^m {\tilde{I}}(t;q) }{\partial q^m}\bigg |_{q=0},&\displaystyle R_m = \frac{1}{m!} \frac{\partial ^m {\tilde{R}}(t;q) }{\partial q^m}\bigg |_{q=0}. \end{array} \end{aligned}$$

For more analysis, the following vectors are defined

$$\begin{aligned} \begin{aligned} \displaystyle {\tilde{S}}_m(t)&= \bigg \{ S_0(t), S_1(t), \ldots , S_m(t) \bigg \}, \\ \displaystyle {\tilde{I}}_m(t)&= \bigg \{ I_0(t), I_1(t), \ldots , I_m(t) \bigg \}, \\ \displaystyle {\tilde{R}}_m(t)&= \bigg \{ R_0(t), R_1(t), \ldots , R_m(t) \bigg \}. \end{aligned} \end{aligned}$$

Differentiating Eq. (7) m-times with respect to q, dividing by m! and putting \(q=0\) the mth-order deformation equations can be obtained as follows

$$\begin{gathered} L_{S} \left[ {S_{m} (t) - \chi _{m} S_{{m - 1}} (t)} \right] = \hbar H_{S} (t)\Re _{{m,S}} \left( {{\mathbf{S}}_{{m - 1}} ,{\mathbf{I}}_{{m - 1}} ,{\mathbf{R}}_{{m - 1}} } \right), \hfill \\ L_{I} \left[ {I_{m} (t) - \chi _{m} I_{{m - 1}} (t)} \right] = \hbar H_{I} (t)\Re _{{m,I}} \left( {{\mathbf{S}}_{{m - 1}} ,{\mathbf{I}}_{{m - 1}} ,{\mathbf{R}}_{{m - 1}} } \right), \hfill \\ L_{R} \left[ {R_{m} (t) - \chi _{m} R_{{m - 1}} (t)} \right] = \hbar H_{R} (t)\Re _{{m,R}} \left( {{\mathbf{S}}_{{m - 1}} ,{\mathbf{I}}_{{m - 1}} ,{\mathbf{R}}_{{m - 1}} } \right), \hfill \\ \end{gathered}$$
(9)

where

$$\begin{aligned} S_m(0) = 0,~~~~~ I_m(0) = 0,~~~~~ R_m(0) = 0, \end{aligned}$$

and

$$\begin{gathered} \Re _{{m,S}} (t) = \frac{{{\text{d}}S_{{m - 1}} (t)}}{{{\text{d}}t}} - (1 - \chi _{m} )f_{1} + \lambda \sum\limits_{{i = 0}}^{{m - 1}} {S_{i} } (t)I_{{m - 1 - i}} (t) + {\text{d}}S_{{m - 1}} (t), \hfill \\ \Re _{{m,I}} (t) = \frac{{{\text{d}}I_{{m - 1}} (t)}}{{{\text{d}}t}} - (1 - \chi _{m} )f_{2} - \lambda \sum\limits_{{i = 0}}^{{m - 1}} {S_{i} } (t)I_{{m - 1 - i}} (t) + \varepsilon I_{{m - 1}} (t) + {\text{d}}R_{{m - 1}} (t), \hfill \\ \Re _{{m,R}} (t) = \frac{{{\text{d}}R_{{m - 1}} (t)}}{{{\text{d}}t}} - (1 - \chi _{m} )f_{3} - \varepsilon I_{{m - 1}} (t) + {\text{d}}R_{{m - 1}} (t), \hfill \\ \end{gathered}$$
(10)

and

$$\chi _{m} = \left\{ {\begin{array}{*{20}l} {0,} \hfill & {m \le 1} \hfill \\ {1,} \hfill & {m > 1.} \hfill \\ \end{array} } \right.$$
(11)

By putting \(H_S(t)= H_I(t) = H_R(t) = 1\) and applying the inverse operators \(L_S^{-1}, L_I^{-1}\) and \(L_R^{-1}\), we have

$$\begin{gathered} S_{m} (t) = \chi _{m} S_{{m - 1}} (t) + \hbar \int\limits_{0}^{t} {\Re _{{m,S}} } (t){\text{d}}t, \hfill \\ I_{m} (t) = \chi _{m} I_{{m - 1}} (t) + \hbar \int\limits_{0}^{t} {\Re _{{m,I}} } (t){\text{d}}t, \hfill \\ R_{m} (t) = \chi _{m} R_{{m - 1}} (t) + \hbar \int\limits_{0}^{t} {\Re _{{m,R}} } (t){\text{d}}t. \hfill \\ \end{gathered}$$
(12)

Finally, the mth-order approximate solution of nonlinear system (1) can be obtained as

$$\begin{aligned} \begin{array}{lll} \displaystyle S_m(t) = \sum _{j=0}^{m} S_j(t),~~~~~&\displaystyle I_m(t) = \sum _{j=0}^{m} I_j(t),~~~~~&\displaystyle R_m(t) = \sum _{j=0}^{m} R_j(t). \end{array} \end{aligned}$$
(13)

Numerical illustration

In this section, the numerical results based on the HAM are presented. The approximate solutions for \(m=5, 10, 15\) are obtained in the following form

$$\begin{aligned} S_5(t)=&\, {} 20 + 11.5 h t + 23 h^2 t + 23 h^3 t + 11.5 h^4 t + 2.3 h^5 t + 1.5425 h^2 t^2 + 3.085 h^3 t^2 \\&+\, 2.31375 h^4 t^2 + 0.617 h^5 t^2 + 0.0790458 h^3 t^3 + 0.118569 h^4 t^3 + 0.0474275 h^5 t^3 \\&+\, 0.00154855 h^4 t^4 + 0.00123884 h^5 t^4 + 7.74864\times 10^{-6} h^5 t^5, \\ I_5(t)=&\, {} 15 + 11 h t + 22 h^2 t + 22 h^3 t + 11 h^4 t + 2.2 h^5 t + 0.4575 h^2 t^2 + 0.915 h^3 t^2 \\&+\, 0.68625 h^4 t^2 + 0.183 h^5 t^2 - 0.0573792 h^3 t^3 - 0.0860688 h^4 t^3 - 0.0344275 h^5 t^3\\&-\, 0.00203085 h^4 t^4 - 0.00162468 h^5 t^4 - 9.82135\times 10^{-6} h^5 t^5,\\ R_5(t)=&\, {} 10 - 2.5 h t - 5 h^2 t - 5 h^3 t - 2.5 h^4 t - 0.5 h^5 t - 1.35 h^2 t^2 - 2.7 h^3 t^2 \\&-\, 2.025 h^4 t^2 - 0.54 h^5 t^2 - 0.06025 h^3 t^3 - 0.090375 h^4 t^3 - 0.03615 h^5 t^3\\&-\, 0.0000358854 h^4 t^4 - 0.0000287083 h^5 t^4 + 7.97984\times 10^{-6} h^5 t^5, \\ S_{10}(t)=&\, {} 20 + 23 h t + 103.5 h^2 t + 276 h^3 t + 483 h^4 t + 579.6 h^5 t + 483 h^6 t + 276 h^7 t \\&+\, \cdots - \,3.32927\times 10^{-10} h^9 t^9 - 2.99635\times 10^{-10} h^{10} t^9 - 5.68453\times 10^{-13} h^{10} t^{10}, \\ I_{10}(t)=&\, {} 15 + 22 h t + 99 h^2 t + 264 h^3 t + 462 h^4 t + 554.4 h^5 t + 462 h^6 t + 264 h^7 t \\&+\,\cdots + 3.2067\times 10^{-10} h^9 t^9 + 2.88603\times 10^{-10} h^{10} t^9 + 4.21668\times 10^{-13} h^{10} t^{10}, \\ R_{10}(t)=&\, {} 10 - 5 h t - 22.5 h^2 t - 60 h^3 t - 105 h^4 t - 126 h^5 t - 105 h^6 t - 60 h^7 t \\&+\cdots - 1.34528\times 10^{-10} h^9 t^9 - 1.21075\times 10^{-10} h^{10} t^9 - 4.55198\times 10^{-13} h^{10} t^{10}, \\ S_{15}(t )=&\, {} 20 + 34.5 h t + 241.5 h^2 t + 1046.5 h^3 t + 3139.5 h^4 t + 6906.9 h^5 t \\&+\cdots + 5.68303\times 10^{-17} h^{14} t^{14} + 5.30416\times 10^{-17} h^{15} t^{14} + 1.56646\times 10^{-20} h^{15} t^{15}, \\ I_{15}(t )=&\, {} 15 + 33 h t + 231 h^2 t + 1001 h^3 t + 3003 h^4 t + 6606.6 h^5 t \\&+\cdots - 5.44064\times 10^{-17} h^{14} t^{14} - 5.07793\times 10^{-17} h^{15} t^{14} - 7.423\times 10^{-21} h^{15} t^{15}, \\ R_{15}(t )=&\, {} 10 - 7.5 h t - 52.5 h^2 t - 227.5 h^3 t - 682.5 h^4 t - 1501.5 h^5 t \\&+ \cdots + 1.61197\times 10^{-17} h^{14} t^{14} + 1.50451\times 10^{-17} h^{15} t^{14} + 3.13449\times 10^{-20} h^{15} t^{15}, \end{aligned}$$

where \(\hbar\) is the convergence control parameter of the HAM. In order to show the regions of convergence, several \(\hbar\)-curves are demonstrated in Figs. 1, 2 and 3. These regions are the parallel parts of \(\hbar\)-curves with axiom x. The regions of convergence for \(m=5, 10, 15\) and \(t=1\) are presented in Table 2.

Table 2 Regions of convergence and the optimal values of \(\hbar\) for \(m=5, 10, 15\) and \(t=1\)
Table 3 Residual errors of \(S_5(t), I_5(t)\) and \(R_5(t)\) for different values of \(\hbar\)

In order to show the efficiency and accuracy of presented method, the following residual error functions are applied as follows

$$\begin{aligned} \begin{aligned} \displaystyle E_{m,S}(t)&= S'_m(t) - f_1 + \lambda S_m(t) I_m(t) + \hbox {d} S_m(t), \\ \displaystyle E_{m,I}(t)&= I'_m(t) - f_2 - \lambda S_m(t) I_m(t) + \varepsilon I_m(t) + \hbox {d} R_m(t), \\ \displaystyle E_{m,R}(t)&= R'_m(t) - f_3 - \varepsilon I_m(t) + \hbox {d} R_m(t), \end{aligned} \end{aligned}$$
(14)

and the numerical results for different values of tm based on the presented convergence regions are obtained in Tables 3, 4 and 5. Also, the norm of residual errors \(E_{m,S}(t), E_{m,I}(t)\) and \(E_{m,R}(t)\) is given in these tables. In Figs. 4, 5 and 6 the residual errors for \(t=1\) and versus \(\hbar\) are demonstrated. By using these figures, the optimal values of convergence control parameter \(\hbar\) can be obtained which are presented in Table 2. Also, in Figs. 7, 8, 9, 10, 11 and 12 the plots of square residual errors

$$\begin{aligned} \begin{aligned} \displaystyle E'_{m,S}&= \int _0^{+\infty } \left\{ N_S \left[ \sum _{j=0}^m S_j(\xi )\right] \right\} ^2 \hbox {d}\xi , \\ \displaystyle E'_{m,I}&= \int _0^{+\infty } \left\{ N_I \left[ \sum _{j=0}^m I_j(\xi )\right] \right\} ^2 \hbox {d}\xi ,\\ \displaystyle E'_{m,R}&= \int _0^{+\infty } \left\{ N_R \left[ \sum _{j=0}^m R_j(\xi )\right] \right\} ^2 \hbox {d}\xi , \end{aligned} \end{aligned}$$
(15)

based on the optimal homotopy analysis method (OHAM) are shown. Figure 13 shows the approximate solution for \(m=15\) and \(t \in [0,10]\). In Fig. 14, the phase portraits of \(S-I, S-R, I-R\) and \(S-I-R\) for 15th-order approximation of the HAM and \(\hbar =-\,1\) are shown.

Table 4 Residual errors of \(S_{10}(t), I_{10}(t)\) and \(R_{10}(t)\) for different values of \(\hbar\)
Table 5 Residual errors of \(S_{15}(t), I_{15}(t)\) and \(R_{15}(t)\) for different values of \(\hbar\)
Fig. 1
figure 1

\(\hbar\)-curves of S(t), I(t) and R(t) for \(m=5, t=1\)

Fig. 2
figure 2

\(\hbar\)-curves of S(t), I(t) and R(t) for \(m=10, t=1\)

Fig. 3
figure 3

\(\hbar\)-curves of S(t), I(t) and R(t) for \(m=15, t=1\)

Fig. 4
figure 4

Averaged residual errors \(E_{5,S}, E_{5,I}, E_{5,R}\) versus \(\hbar\) for \(t=1\)

Fig. 5
figure 5

Averaged residual errors \(E_{10,S}, E_{10,I}, E_{10,R}\) versus \(\hbar\) for \(t=1\)

Fig. 6
figure 6

Averaged residual errors \(E_{15,S}, E_{15,I}, E_{15,R}\) versus \(\hbar\) for \(t=1\)

Fig. 7
figure 7

Square residual errors of a \(E'_{5,S}\) and b \(E'_{10,S}\) versus \(\hbar\) based on the OHAM

Fig. 8
figure 8

Square residual errors of a \(E'_{5,I}\) and b \(E'_{10,I}\) versus \(\hbar\) based on the OHAM

Fig. 9
figure 9

Square residual errors of a \(E'_{5,R}\) and b \(E'_{10,R}\) versus \(\hbar\) based on the OHAM

Fig. 10
figure 10

Residual error functions for \(E_{5,S}, E_{5,I}, E_{5,R}\) and the optimal values \(\hbar ^*\)

Fig. 11
figure 11

Residual error functions for \(E_{10,S}, E_{10,I}, E_{10,R}\) and the optimal values \(\hbar ^*\)

Fig. 12
figure 12

Residual error functions for \(E_{15,S}, E_{15,I}, E_{15,R}\) and the optimal values \(\hbar ^*\)

Fig. 13
figure 13

Approximate solutions of S(t), I(t) and R(t) for \(m=15, \hbar =-1\) and \(t \in [0,10]\)

Fig. 14
figure 14

Phase portraits of \(S_{15}(t), I_{15}(t), R_{15}(t)\) by using the HAM

Conclusion

In this study, the modified nonlinear SIR epidemiological model of computer viruses was illustrated and the HAM was applied to solve the presented model. It is important to note that in this method we have some auxiliary parameters and functions. One of these parameters is the convergence control parameter \(\hbar\) which can be applied to adjust and control the convergence region of obtained solutions. Thus, by plotting several \(\hbar\)-curves and finding the regions of convergence, we showed the advantages and abilities of method. The residual errors were applied to show the efficiency and accuracy of method.