1 Introduction

Image inpainting, or image interpolation, is the process of filling in the missing parts of an image such that the result looks like the original image. Its applications include restoration of old paintings by museum artists, and removing scratches from photographs. For a long time, artists have been using manual inpainting to restore images. They restored the damaged or missing parts of the images, using the information from the structure of the surrounding regions of missing parts. With the progress of digital processing of images, the need for unsupervised restoration of images was stimulated which lead to digital image inpainting.

The nonlinear Cahn–Hilliard equation is a stiff parabolic partial differential equation which is used in the digital image inpainting for fast inpainting of degraded text, as well as super resolution of high contrast images. The smoothing property of Cahn–Hilliard equation provides a natural connection of the contours across missing parts [1, 2].

The Cahn–Hilliard equation was originally introduced in the mathematical modeling of the spinodal decomposition of a binary fluid. Spinodal decomposition under shear flow is a problem of great industrial importance and describes the process of phase separation by which a quenched homogeneous mixture spontaneously separates into distinct phases [3]. The investigation of the solutions of partial differential equations is an important field of research in mathematics and physics and the behavior of the solution of Cahn–Hilliard equation has been studied using various mathematical techniques [4, 5, 25,26,27,28].

Recently, fractional order differential equations have drawn increasing attention since fractional calculus has the ability to describe different physical phenomena in a more flexible way than the traditional integer-order calculus [6,7,8, 19, 20]. This is due to the fact that fractional calculus is, in fact, an extension of the traditional calculus to noninteger (fractional) order such that the fractional order system response ultimately converges to the integer-order system response. The most important advantage of using fractional order differential equation in mathematical modeling is their nonlocal property. Due to the nonlocal property, fractional operators give a perfect aid to characterize the memory and hereditary properties of various processes and materials. The Cahn–Hilliard equation has many applications in image processing and materials science. Due to the nonlocal property of the fractional derivative, the fractional order Cahn–Hilliard equation can describe these physical processes in more flexible way. As a result, and motivated by the increasingly important role played by fractional calculus, fractional order Cahn–Hilliard has caught the attention of many researchers in recent years [9,10,11].

In this paper, the time-fractional Cahn–Hilliard equation is considered as

$$\begin{aligned} D^{\beta }_{t}u-a u_{x}-6u(u_{x})^{2}-(3u^{2}-1)u_{xx}+u_{xxxx}=0, \end{aligned}$$
(1)

subject to the initial condition

$$\begin{aligned} u(x,0)= & {} \pm \frac{\eta }{\sqrt{2}}+\left[ \mp \frac{\eta }{\sqrt{2}}\mp \frac{\sqrt{\eta ^{2} \mp (\eta ^{2}-2)}}{\sqrt{2}}\right. \nonumber \\&\left. \times \tanh \left( \frac{\sqrt{\eta ^{2} \mp (\eta ^{2}-2)}x}{2}+C \right) \right] , \end{aligned}$$
(2)

where \(\eta\) and C are arbitrary constants and the fractional order time derivative is taken in the Caputo’s sense.

The exact solution of the integer-order Cahn–Hilliard equation is obtained by Manafian et al. [12] as

$$\begin{aligned} u(x,t)= & {} \pm \frac{\eta }{\sqrt{2}}+\left[ \mp \frac{\eta }{\sqrt{2}}\mp \frac{\sqrt{\eta ^{2} \mp (\eta ^{2}-2)}}{\sqrt{2}}\right. \nonumber \\&\left. \times \tanh \left( \frac{\sqrt{\eta ^{2} \mp (\eta ^{2}-2)}(x+a t)}{2}+C \right) \right] . \end{aligned}$$
(3)

The purpose of this paper is to find new analytical approximate solutions of time-fractional Cahn–Hilliard equation. The approximate analytical solutions of time-fractional Cahn–Hilliard equation are obtained using a new modified homotopy analysis method and the residual power series method. The main usefulness of analytic approximations lies in the fact that, being analytic expressions, they reveal qualitative behavior (such as dependence of parameters) in ways that numerical solutions cannot.

Homotopy analysis method (HAM) was first proposed by Liao. Homotopy is a topological concept defining a connection between different things in mathematics, which contain same characteristics in some aspects. Homotopy analysis method has useful characteristics which distinguish it from the other traditional analytical techniques. It is independent of any small or large parameter at all, provides an extremely large freedom to choose an auxiliary linear operator and base functions, and a convenient way to guarantee the convergence of the solution series. HAM has great generality and logically contains the Adomian decomposition method, Lyapunov’s small artificial parameter method, the \(\delta\)-expansion method and the Euler transform. These characteristics provide an easier way to solve a wide range of nonlinear problems in science and engineering [13]. The flexibility and generality of the homotopy analysis method has motivated many researchers to develop various useful applications and improved methods [14, 23, 24, 29,30,31,32,33,34,35,36,37].

Residual power series method was proposed by Abu Arqub [15] for the solution of fractional differential equations. The residual power series method has small computational requirements with high precision in less time. It obtains Taylor’s expansion of the solution; hence the exact solution is obtained when the solution is polynomial. The solution and all its derivatives are applicable at each point in the given interval. This method can be applied directly to the given problem by choosing an appropriate value for the initial approximation since it does not require any modification while switching from the first order to the higher order [38]. Residual power series method has been successfully applied on a wide class of linear and nonlinear fractional differential equation and is proved to be an efficient tool for the approximate analytical solutions of fractional differential equations.

2 Fundamentals of fractional calculus

There are many definitions of fractional derivatives and integrals such as Caputo, Weyl, Riesz, Riemann–Liouville, Grunwald–Letnikov etc. The Riemann–Liouville and Caputo’s are commonly used definitions. But Caputo’s approach is suitable for real-world physical problems because it defines integer-order initial conditions for fractional differential equations.

Definition

The Caputo’s time-fractional derivative of order \(\alpha\) of y(xt) is defined as

$$\begin{aligned} D^\alpha _ty(x,t)=\left\{ \begin{array}{ll}\frac{1}{\Gamma (m-\alpha )} \int ^t_s(t-\eta )^{m-\alpha -1 }\frac{\partial ^m y(x,\eta )}{\partial \eta ^m},~~0\le m-1<\alpha <m,~ x\in I,\\ \frac{\partial ^m y(x,t)}{\partial t^m}, ~~~\alpha =m\in N. \end{array}\right. \end{aligned}$$
(4)

Definition

The Riemann–Liouville time-fractional integral of order \(\alpha\) of y(xt) is defined as

$$\begin{aligned} I^\alpha _ty(x,t)=\left\{ \begin{array}{ll}\frac{1}{\Gamma (\alpha )} \int ^t_s(t-\eta )^{\alpha -1 } y(x,\eta )d\eta ,~~\alpha> 0,~ t>\eta > s\ge 0,~ x\in I,\\ y(x,t), ~~~\alpha =0. \end{array}\right. \end{aligned}$$
(5)

3 Solution of time-fractional Cahn–Hilliard equation using MHAM

In this section, the analytical approximate solution of the time-fractional Cahn–Hilliard equation is obtained using a modified homotopy analysis method (MHAM). The proposed modification simplifies the computations involved in each iteration and hence is easier to implement than the standard homotopy analysis method. The time-fractional Cahn–Hilliard equation can be written as

$$\begin{aligned} Lu(x,t)+Nu(x,t)=0, \end{aligned}$$
(6)

where L is a linear operator and N is a nonlinear operator.

Using the modified homotopy analysis method, the nonlinear term in Eq. (6) can be simplified as

$$\begin{aligned} N[U(x,t;p)]=\sum _{i=0}^{\infty }N_{i}[U_{0}(x,t;p), U_{1}(x,t;p),\ldots ,U_{i}(x,t;p)], \end{aligned}$$
(7)

which yields the modified higher order deformation equations as

$$\begin{aligned} {\mathcal {L}}[U_{1}(x,t;p)]~=~\hbar H(L[U_{0}(x,t;p)]+N_{0}[U_{0}(x,t;p)]), \end{aligned}$$
(8)

and for \(k=1,2,3,...\)

$$\begin{aligned} {\mathcal {L}}[U_{k+1}(x,t;p)]&={\mathcal {L}}[U_{k}(x,t;p)]+\hbar H(L[U_{k}(x,t;p)] \nonumber \\&+ N_{k}[U_{0}(x,t;p),U_{1}(x,t;p),\ldots ,U_{k}(x,t;p)]). \end{aligned}$$
(9)

Taking \({\mathcal {L}}=\frac{\partial ^{\beta }}{\partial t^{\beta }}\), the deformation equations can be written as

$$\begin{aligned} \frac{\partial ^{\beta }}{\partial t^{\beta }}[U_{1}(x,t;p)]~=~\hbar H(L[U_{0}(x,t;p)]+N_{0}[U_{0}(x,t;p)]), \end{aligned}$$
(10)

and for \(k=1,2,3,\ldots .\)

$$\begin{aligned}&\frac{\partial ^{\beta }}{\partial t^{\beta }}[U_{k+1}(x,t;p)]=\frac{\partial ^{\beta }}{\partial t^{\beta }}[U_{k}(x,t;p)]+\hbar H(L[U_{k}(x,t;p)] \nonumber \\&\quad + N_{k}[U_{0}(x,t;p),U_{1}(x,t;p),\ldots ,U_{k}(x,t;p)]). \end{aligned}$$
(11)

Solving the zeroth-, first- and second-order deformation equations and taking the values of the arbitrary constants as \(\eta =\sqrt{2}\) and \(C=0\), the second-order approximate solution can be calculated as

$$\begin{aligned} u_{2^{*}}(x,t)=u_{0}(x,t)+u_{1}(x,t)+u_{2}(x,t), \end{aligned}$$
(12)

where

$$\begin{aligned} u_{0}(x,t)= & {} \pm \frac{\eta }{\sqrt{2}}+\left[ \mp \frac{\eta }{\sqrt{2}} \mp \frac{\sqrt{\eta ^{2} \mp (\eta ^{2}-2)}}{\sqrt{2}}\right. \nonumber \\&\left. \times \tanh \left( \frac{\sqrt{\eta ^{2} \mp (\eta ^{2}-2)}x}{2}+C \right) \right] , \end{aligned}$$
(13)
$$\begin{aligned} u_{1}(x,t)= & {} \hbar \frac{t^{\beta }}{\Gamma (\beta +1)} \left( -\frac{a}{\sqrt{2}}\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-2} -\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-2}\tanh \frac{x}{\sqrt{2}}\right. \nonumber \\&\left. +\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-4}\tanh \frac{x}{\sqrt{2}} +\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-2}\left( \tanh \frac{x}{\sqrt{2}}\right) ^{3} \right) \nonumber \\ \end{aligned}$$
(14)

and

$$\begin{aligned}&u_2(x,t)= \hbar \frac{t^{\beta }}{\Gamma (\beta +1)} \left( -\frac{a}{\sqrt{2}}\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-2} -\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-2}\tanh \frac{x}{\sqrt{2}}\right. \nonumber \\&\quad \left. +\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-4}\tanh \frac{x}{\sqrt{2}} +\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-2}\left( \tanh \frac{x}{\sqrt{2}}\right) ^{3} \right) \nonumber \\&\quad +\hbar ^{2}\frac{t^{\beta }}{\Gamma (\beta +1)} \left( -\frac{a}{\sqrt{2}}\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-2} -\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-2}\tanh \frac{x}{\sqrt{2}}\right. \nonumber \\&\quad \left. +\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-4}\tanh \frac{x}{\sqrt{2}} +\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-2}\left( \tanh \frac{x}{\sqrt{2}}\right) ^{3} \right) \nonumber \\&\quad +\hbar ^{2}\frac{t^{2\beta }}{(\Gamma (\beta +1))^{2}} \left( \sqrt{2}a\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-4}-\sqrt{2}a\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-6}\right. \nonumber \\&\quad \left. -a^{2}\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-2}\tanh \frac{x}{\sqrt{2}} +4\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-4}\tanh \frac{x}{\sqrt{2}} \right. \nonumber \\&\quad \left. -29\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-6}\tanh \frac{x}{\sqrt{2}} +25\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-8}\tanh \frac{x}{\sqrt{2}} \right. \nonumber \\&\quad \left. -2\sqrt{2}a\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-2}\left( \tanh \frac{x}{\sqrt{2}}\right) ^{2}\right. \nonumber \\&\quad \left. +\sqrt{2}a\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-4}\left( \tanh \frac{x}{\sqrt{2}}\right) ^{2} \right. \nonumber \\&\quad \left. -2\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-2}\left( \tanh \frac{x}{\sqrt{2}}\right) ^{3} +20\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-4}\left( \tanh \frac{x}{\sqrt{2}}\right) ^{3} \right. \nonumber \\&\quad \left. +3\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-6}\left( \tanh \frac{x}{\sqrt{2}}\right) ^{3} +2\sqrt{2}a\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-2}\left( \tanh \frac{x}{\sqrt{2}}\right) ^{4} \right. \nonumber \\&\quad \left. +4\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-2}\left( \tanh \frac{x}{\sqrt{2}}\right) ^{5} -24\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-4}\left( \tanh \frac{x}{\sqrt{2}}\right) ^{5} \right. \nonumber \\&\quad \left. -2\left( \cosh \frac{x}{\sqrt{2}}\right) ^{-2}\left( \tanh \frac{x}{\sqrt{2}}\right) ^{7} \right) . \end{aligned}$$
(15)

4 Preliminaries for RPSM

In this section, some preliminaries for the residual power series method are given [16].

Definition

A fractional power series about \(t=t_0\) is defined as

$$\begin{aligned}&\sum _{j=0}^{\infty }\sigma _j (t-t_0)^{j\beta }=\sigma _0+\sigma _1(t-t_0)^{\beta }+\sigma _2(t-t_0)^{2\beta }\nonumber \\&\quad +...,~ 0\le k-1 <\beta \le k,~t\ge t_0. \end{aligned}$$
(16)

Theorem

If the fractional power series representation of g about \(t = t_0\) has the form

$$\begin{aligned} g(t)=\sum _{j=0}^{\infty }\sigma _j (t-t_0)^{j\beta },~ 0\le k-1<\beta \le k,~t_0\le t< t_0+ {\mathcal {R}} \end{aligned}$$
(17)

and fractional order derivatives \(D^{j\beta } g (t)\) are continuous on \(]t_0, t_0 + {\mathcal {R}}[\) for \(j = 0, 1, 2, \ldots\), then the values of the coefficients \(\sigma _j\)s can be calculated as

$$\begin{aligned} \sigma _j=\frac{D^{j\beta } g (t_0)}{\Gamma {(j\beta +1)}}, \end{aligned}$$

where \({\mathcal {R}}\) is the radius of convergence of the fractional power series.

Definition

A multiple fractional power series about \(t=t_0\) is defined as

$$\begin{aligned}&\sum _{j=0}^{\infty }\nu _j(x) (t-t_0)^{j\beta }=\nu _0(x)+\nu _1(x) (t-t_0)^{\beta }\nonumber \\&\quad +\nu _2(x)(t-t_0)^{2\beta }+\cdots , \nonumber \\&\quad t\ge t_0,~0\le k-1 <\beta \le k, \end{aligned}$$
(18)

where \(\nu _j\)’s are functions of x.

5 Solution of time-fractional Cahn–Hilliard equation using RPSM

The time-fractional Cahn–Hilliard equation is considered, subject to the initial condition

$$\begin{aligned} u(x,0)=\psi (x), \end{aligned}$$
(19)

where

$$\begin{aligned} \psi (x)= & {} \pm \frac{\eta }{\sqrt{2}}+\left[ \mp \frac{\eta }{\sqrt{2}} \mp \frac{\sqrt{\eta ^{2} \mp (\eta ^{2}-2)}}{\sqrt{2}}\right. \nonumber \\&\left. \times \tanh \left( \frac{\sqrt{\eta ^{2} \mp (\eta ^{2}-2)}x}{2}+C \right) \right] . \end{aligned}$$
(20)

The fractional power series expansion of u(xt) about the initial point \(t=0\) is considered as

$$\begin{aligned} u(x,t)= \sum _{j=0}^{\infty } \nu _j(x)\frac{t^{j\beta }}{\Gamma (j\beta +1)},~0<\beta \le 1,~x\in I,~0\le t< {\mathcal {R}} \end{aligned}$$
(21)

and the residual function Res(xt) is defined as

$$\begin{aligned} Res(x,t)= & {} D^{\beta }_{t}u-a u_{x}-6u(u_{x})^{2}+u_{xx}-3u^{2}u_{xx}+u_{xxxx}, \end{aligned}$$
(22)

then k-th residual function can be written in the form

$$\begin{aligned} Res_{k}(x,t)= & {} \frac{\partial ^\beta u_k(x,t)}{\partial t^\beta }- a \frac{\partial u_{k}(x,t)}{\partial x}\nonumber \\&-6u_{k}(x,t) \left( \frac{\partial u_{k}(x,t)}{\partial x}\right) ^{2} +\frac{\partial ^{2} u_{k}(x,t)}{\partial x^{2}} \nonumber \\&-3(u_{k}(x,t))^{2}\frac{\partial ^{2} u_{k}(x,t)}{\partial x^{2}} +\frac{\partial ^{4} u_{k}(x,t)}{\partial x^{4}},~~~~~~k=1,2,3,.... \end{aligned}$$
(23)

From the results available in literature [17,18,19,20,21,22], it is evident that \(Res(x,t)=0\) and \(\lim _{k \rightarrow \infty } Res_k(x,t) = Res(x,t)\) \(\forall ~ x\in I\), \(t\ge 0\). Moreover, \(D^{j\beta }_t Res(x,0)=D^{j\beta }_t Res_k(x,0)\) for \(j= 0,1,2,...,k\).

Substituting the k-th truncated series of u(xt) into Eq. (23) and calculating the fractional derivative \(D^{(k-1)\beta }_t\) of \(Res_k(x,t),~k=1,2,3,...\) at \(t=0\) yields a system of equation as

$$\begin{aligned} D^{(k-1)\beta }_t Res_k(x,0)=0,~~ k=1,2,3,...,~~ 0<\beta \le 1. \end{aligned}$$
(24)

The coefficients \(\nu _j(x)\) can be calculated by solving the system of equations (24).

For \(k=0\), the zeroth residual power series solution can be calculated using the initial condition as

$$\begin{aligned} u_0(x,t)=\pm \frac{\eta }{\sqrt{2}}+\left[ \mp \frac{\eta }{\sqrt{2}} \mp \frac{\sqrt{\eta ^{2} \mp (\eta ^{2}-2)}}{\sqrt{2}}\right. \nonumber \\ \left. \times \tanh \left( \frac{\sqrt{\eta ^{2} \mp (\eta ^{2}-2)}x}{2}+C \right) \right] . \end{aligned}$$
(25)

For \(k=1\), the first residual power series solution can be expressed as

$$\begin{aligned} u_1(x,t)=\nu _{0}(x)+\nu _1(x)\frac{t^\beta }{\Gamma (\beta +1)}. \end{aligned}$$
(26)

Using Eq. (26), the first residual function can be written as

$$\begin{aligned}&Res_1(x,t)=\nu _{1}(x) -a \left( \frac{\partial \nu _{0}(x)}{\partial x}+\frac{\partial \nu _{1}(x)}{\partial x}\frac{t^{\beta }}{\Gamma (\beta +1)}\right) \nonumber \\&\quad -6\left( \nu _{0}(x)+\nu _{1}(x)\frac{t^{\beta }}{\Gamma (\beta +1)}\right) \nonumber \\&\quad \left( \frac{\partial \nu _{0}(x)}{\partial x}+\frac{\partial \nu _{1}(x)}{\partial x} \frac{t^{\beta }}{\Gamma (\beta +1)}\right) ^{2} \nonumber \\&\quad -3 \left( \nu _{0}(x)+\nu _{1}(x)\frac{t^{\beta }}{\Gamma (\beta +1)}\right) ^{2}\nonumber \\&\quad \left( \frac{\partial ^{2} \nu _{0}(x)}{\partial x^{2}}+\frac{\partial ^{2} \nu _{1}(x)}{\partial x^{2}} \frac{t^{\beta }}{\Gamma (\beta +1)}\right) \nonumber \\&\quad +\left( \frac{\partial ^{2} \nu _{0}(x)}{\partial x^{2}} +\frac{\partial ^{2} \nu _{1}(x)}{\partial x^{2}} \frac{t^{\beta }}{\Gamma (\beta +1)}\right) \nonumber \\&\quad +\left( \frac{\partial ^{4} \nu _{0}(x)}{\partial x^{4}} +\frac{\partial ^{4} \nu _{1}(x)}{\partial x^{4}} \frac{t^{\beta }}{\Gamma (\beta +1)}\right) . \end{aligned}$$
(27)

Since Eqs. (24) and (27) imply

$$\begin{aligned} \nu _{1}(x)= & {} a \frac{\partial \nu _{0}(x)}{\partial x}+6\nu _{0}(x)\left( \frac{\partial \nu _{0}(x)}{\partial x}\right) ^{2}\nonumber \\&+3 (\nu _{0}(x))^{2}\frac{\partial ^{2}\nu _{0}(x)}{\partial x^{2}} -\frac{\partial ^{2}\nu _{0}(x)}{\partial x^{2}}-\frac{\partial ^{4}\nu _{0}(x)}{\partial x^{4}}, \end{aligned}$$
(28)

therefore, the first-order approximate solution is obtained as

$$\begin{aligned} u_{1}(x,t)= & {} \psi (x)+\frac{t^{\beta }}{\Gamma (\beta +1)} \left( a\frac{\partial \psi (x)}{\partial x}+6\psi (x) \left( \frac{\partial \psi (x)}{\partial x}\right) ^{2}\right. \nonumber \\&\left. +3(\psi (x))^{2}\frac{\partial ^{2}\psi (x)}{\partial x^{2}} -\frac{\partial ^{2}\psi (x)}{\partial x^{2}} -\frac{\partial ^{4}\psi (x)}{\partial x^{4}}\right) . \end{aligned}$$
(29)

For \(k=2\), the 2-nd residual power series solution can be expressed as

$$\begin{aligned} u_2(x,t)=\nu _{0}(x)+\nu _1(x)\frac{t^\beta }{\Gamma (\beta +1)} +\nu _2(x)\frac{t^{2\beta }}{\Gamma (2\beta +1)}. \end{aligned}$$
(30)
Fig. 1
figure 1

Plots of \(\hbar\)-curves taking u(0.1, 0.1) at \(\beta =0.75\) (dashed line) and \(\beta =1\) (solid line)

Using Eq. (30), the second residual function can be written as

$$\begin{aligned} Res_{2}(x,t)= & {} \nu _{1}(x)+\nu _{2}(x)\frac{t^{\beta }}{\Gamma (\beta +1)} \nonumber \\&-a\left( \frac{\partial \nu _{0}(x)}{\partial x} +\frac{\partial \nu _{1}(x)}{\partial x}\frac{t^{\beta }}{\Gamma (\beta +1)} +\frac{\partial \nu _{2}(x)}{\partial x}\frac{t^{2\beta }}{\Gamma (2\beta +1)}\right) \nonumber \\&-6\left( \nu _{0}(x)+\nu _{1}(x)\frac{t^{\beta }}{\Gamma (\beta +1)} +\nu _{2}(x)\frac{t^{2\beta }}{\Gamma (2\beta +1)}\right) \nonumber \\&\times \left( \frac{\partial \nu _{0}(x)}{\partial x} +\frac{\partial \nu _{1}(x)}{\partial x}\frac{t^{\beta }}{\Gamma (\beta +1)} +\frac{\partial \nu _{2}(x)}{\partial x}\frac{t^{2\beta }}{\Gamma (2\beta +1)}\right) ^{2} \nonumber \\&-3\left( \nu _{0}(x)+\nu _{1}(x)\frac{t^{\beta }}{\Gamma (\beta +1)} +\nu _{2}(x)\frac{t^{2\beta }}{\Gamma (2\beta +1)}\right) ^{2} \nonumber \\&\times \left( \frac{\partial ^{2} \nu _{0}(x)}{\partial x^{2}} +\frac{\partial ^{2} \nu _{1}(x)}{\partial x^{2}}\frac{t^{\beta }}{\Gamma (\beta +1)} +\frac{\partial ^{2} \nu _{2}(x)}{\partial x^{2}}\frac{t^{2\beta }}{\Gamma (2\beta +1)}\right) \nonumber \\&+\left( \frac{\partial ^{2} \nu _{0}(x)}{\partial x^{2}} +\frac{\partial ^{2} \nu _{1}(x)}{\partial x^{2}}\frac{t^{\beta }}{\Gamma (\beta +1)} +\frac{\partial ^{2} \nu _{2}(x)}{\partial x^{2}}\frac{t^{2\beta }}{\Gamma (2\beta +1)}\right) \nonumber \\&+\left( \frac{\partial ^{4} \nu _{0}(x)}{\partial x^{4}} +\frac{\partial ^{4} \nu _{1}(x)}{\partial x^{4}}\frac{t^{\beta }}{\Gamma (\beta +1)} +\frac{\partial ^{4} \nu _{2}(x)}{\partial x^{4}}\frac{t^{2\beta }}{\Gamma (2\beta +1)}\right) .\nonumber \\ \end{aligned}$$
(31)

Since Eq. (24) and Eq. (31) imply

$$\begin{aligned} \nu _{2}(x)= & {} a\frac{\partial \nu _{1}(x)}{\partial x}+6\nu _{1}(x) \left( \frac{\partial \nu _{0}(x)}{\partial x}\right) ^{2} \nonumber \\&+12\nu _{0}(x)\frac{\partial \nu _{0}(x)}{\partial x}\frac{\partial \nu _{1}(x)}{\partial x} +6\nu _{0}(x)\nu _{1}(x)\frac{\partial ^{2}\nu _{0}(x)}{\partial x^{2}} \nonumber \\&+3(\nu _{0}(x))^{2}\frac{\partial ^{2}\nu _{1}(x)}{\partial x^{2}} -\frac{\partial ^{2}\nu _{1}(x)}{\partial x^{2}} -\frac{\partial ^{4}\nu _{1}(x)}{\partial x^{4}} \end{aligned}$$
(32)

therefore, the second-order approximate solution is obtained as

$$\begin{aligned}&u_{2}(x,t)=\psi (x)+\frac{t^{\beta }}{\Gamma (\beta +1)} \left( a \frac{\partial \psi (x)}{\partial x}+6\psi (x)\left( \frac{\partial \psi (x)}{\partial x}\right) ^{2}\right. \nonumber \\&\quad \left. +3 (\psi (x))^{2}\frac{\partial ^{2}\psi (x)}{\partial x^{2}} \right. \nonumber \\&\quad \left. -\frac{\partial ^{2}\psi (x)}{\partial x^{2}}-\frac{\partial ^{4}\psi (x)}{\partial x^{4}}\right) +\frac{t^{2\beta +1}}{\Gamma (2\beta +1)} \left( a\frac{\partial }{\partial x} \nonumber \right. \\&\quad \left. \left( a \frac{\partial \psi (x)}{\partial x}+6\psi (x)\left( \frac{\partial \psi (x)}{\partial x}\right) ^{2} \right. \right. \nonumber \\&\quad \left. +3 (\psi (x))^{2}\frac{\partial ^{2}\psi (x)}{\partial x^{2}} -\frac{\partial ^{2}\psi (x)}{\partial x^{2}}-\frac{\partial ^{4}\psi (x)}{\partial x^{4}}\right) \nonumber \\&\quad +6\left( a \frac{\partial \psi (x)}{\partial x}+6\psi (x)\left( \frac{\partial \psi (x)}{\partial x}\right) ^{2} \right. \nonumber \\&\quad \left. +3 (\psi (x))^{2}\frac{\partial ^{2}\psi (x)}{\partial x^{2}} -\frac{\partial ^{2}\psi (x)}{\partial x^{2}}-\frac{\partial ^{4}\psi (x)}{\partial x^{4}}\right) \left( \frac{\partial \psi (x)}{\partial x}\right) ^{2} \nonumber \\&\quad \left. +12\psi (x)\frac{\partial \psi (x)}{\partial x}\frac{\partial }{\partial x} \left( a \frac{\partial \psi (x)}{\partial x}+6\psi (x)\left( \frac{\partial \psi (x)}{\partial x}\right) ^{2}\right. \right. \nonumber \\&\quad \left. \left. +3 (\psi (x))^{2}\frac{\partial ^{2}\psi (x)}{\partial x^{2}} \right. \right. \nonumber \\&\quad \left. -\frac{\partial ^{2}\psi (x)}{\partial x^{2}}-\frac{\partial ^{4}\psi (x)}{\partial x^{4}}\right) +6\psi (x)\nonumber \\&\quad \left( a \frac{\partial \psi (x)}{\partial x}+6\psi (x)\left( \frac{\partial \psi (x)}{\partial x}\right) ^{2} \right. \nonumber \\&\quad \left. +3 (\psi (x))^{2}\frac{\partial ^{2}\psi (x)}{\partial x^{2}} -\frac{\partial ^{2}\psi (x)}{\partial x^{2}}-\frac{\partial ^{4}\psi (x)}{\partial x^{4}}\right) \frac{\partial ^{2}\psi (x)}{\partial x^{2}} \nonumber \\&\quad +3(\psi (x))^{2}\frac{\partial ^{2}}{\partial x^{2}}\left( a \frac{\partial \psi (x)}{\partial x} +6\psi (x)\left( \frac{\partial \psi (x)}{\partial x}\right) ^{2}\right. \nonumber \\&\quad \left. +3 (\psi (x))^{2}\frac{\partial ^{2}\psi (x)}{\partial x^{2}} \right. \nonumber \\&\quad \left. -\frac{\partial ^{2}\psi (x)}{\partial x^{2}} -\frac{\partial ^{4}\psi (x)}{\partial x^{4}}\right) \nonumber \\&\quad -\frac{\partial ^{2}}{\partial x^{2}}\left( a \frac{\partial \psi (x)}{\partial x}+6\psi (x)\left( \frac{\partial \psi (x)}{\partial x}\right) ^{2} \right. \nonumber \\&\quad \left. +3 (\psi (x))^{2}\frac{\partial ^{2}\psi (x)}{\partial x^{2}}-\frac{\partial ^{2}\psi (x)}{\partial x^{2}}-\frac{\partial ^{4}\psi (x)}{\partial x^{4}}\right) \nonumber \\&\quad -\frac{\partial ^{4}}{\partial x^{4}}\left( a \frac{\partial \psi (x)}{\partial x} \right. \nonumber \\&\quad \left. \left. +6\psi (x)\left( \frac{\partial \psi (x)}{\partial x}\right) ^{2}\right. \right. \nonumber \\&\quad \left. \left. +3 (\psi (x))^{2}\frac{\partial ^{2}\psi (x)}{\partial x^{2}}-\frac{\partial ^{2}\psi (x)}{\partial x^{2}}-\frac{\partial ^{4}\psi (x)}{\partial x^{4}}\right) \right) \nonumber \\ \end{aligned}$$
(33)
Fig. 2
figure 2

Plots of \(\hbar\)-curves taking \(u'(0.1,0.1)\) at \(\beta =1\)

6 Results and discussion

Fig. 3
figure 3

Effect of \(\beta\) on u(xt) using MHAM (\(\beta =0.8\) \(\rightarrow\) solid line, \(\beta =0.9\) \(\rightarrow\) dot-dashed line, \(\beta =1.0\) \(\rightarrow\) dotted line)

Fig. 4
figure 4

Effect of \(\beta\) on u(xt) using RPSM (\(\beta =0.8\) \(\rightarrow\) solid line, \(\beta =0.9\) \(\rightarrow\) dot-dashed line, \(\beta =1.0\) \(\rightarrow\) dotted line)

The appropriate value of the auxiliary parameter \(\hbar\) for MHAM is to be chosen to guarantee the convergence of the solution series. This is done by plotting \(\hbar\)-curves corresponding to different values of time t. Figures 1 and 2 show that for convergent solution series, the value of \(\hbar\) must be chosen between \(-0.9\) and \(-1\). It is clear from the \(\hbar\)-curves that the convergence of the solution series is highly sensitive to the value of \(\hbar\).

To confirm the accuracy of the obtained results using MHAM, the absolute errors in the second-order approximate solution are calculated for \(\beta =1\) corresponding to different values of independent variables x and t. The time-fractional Cahn–Hilliard equation is considered for \(a=2\). The value of \(\hbar\) is taken as \(-0.95\), as suggested by the \(\hbar\)-curves. The results are summarized in Table 1.

Table 1 Absolute errors for time-fractional Cahn–Hilliard equation at \(\beta =1\) using MHAM

The effect of fractional order \(\beta\) on the solution is graphically illustrated in Fig. 3 by plotting \(u_{2^{*}}(x,t)\) corresponding to different values of \(\beta\) at \(t=0.05\).

To confirm the accuracy of the obtained results using RPSM, the absolute errors in the second-order RPS approximate solution are calculated for \(\beta =1\) corresponding to different values of independent variables x and t. The time-fractional Cahn–Hilliard equation is considered for \(a=2\). The values of arbitrary constants are taken as \(\nu =\sqrt{2}\) and \(C=0\). The results are summarized in Table 2.

Table 2 Absolute errors for time-fractional Cahn–Hilliard equation at \(\beta =1\) using RPSM

The effects of fractional order \(\beta\) on the solution are graphically illustrated in Fig. 4 by plotting \(u_{2}(x,t)\) corresponding to different values of \(\beta\) at \(t=0.05\).

Fig. 5
figure 5

Approximate solution using MHAM at \(\beta =1\)

Fig. 6
figure 6

Approximate solution using RPSM at \(\beta =1\)

Fig. 7
figure 7

Exact solution

The graphical illustrations of the obtained results exhibit kink solitary wave solutions. The graphical demonstration and comparison of analytical approximate solutions obtained using MHAM and RPSM are shown in Figs. 5, 6 and 7. All our derived solutions are novel and have not been formulated before in literature to the best of our knowledge.

7 Conclusion

The Cahn–Hilliard equation is used in binary image inpainting. In this paper, the analytical approximate solutions of time-fractional Cahn–Hilliard equation are obtained using a modified homotopy analysis method and the residual power series method. The effects of fractional order \(\beta\) on the solution of the equation are graphically illustrated in Figs. 3 and 4. To check the accuracy of the results, the second-order analytical approximate solutions, corresponding to different values of x and t, are calculated for \(\beta =1\) and the results are summarized in Tables 1 and 2. The exact solution and the analytical approximate solutions are graphically expressed for \(\beta =1\) in Figs. 5, 6 and 7. The numerical results and graphical illustrations show that the approximate solutions are in good agreement with the exact solutions.