1 Introduction

In this paper, we consider the generalized form of Klein–Gordon (KG) equations with full nonlinearity in the form (Biswas et al. 2012; Sassaman and Biswas 2010, 2009; Fabian et al. 2009)

$$\begin{aligned} \left( q^{m}\right) _{tt}-k^{2}\left( q^{m}\right) _{xx} +aq^{m}-bq^{n}+cq^{2n-m}=0 \end{aligned}$$
(1)

and

$$\begin{aligned} \left( q^{m}\right) _{tt}-k^{2}\left( q^{m}\right) _{xx} +aq^{m}-bq^{m-n}+cq^{n+m}=0, \end{aligned}$$
(2)

where the dependent variable \(q(x,t)\) represents the wave profile. Also, \(k,~a,~b\) and \(c\) are real valued constants and \(m\) is a positive integer with \(m\ge 1.\) In fact, if \(m=1,\) Eq. (2) reduces to the KG equation (Wazwaz 2006)

$$\begin{aligned} q_{tt}-k^{2}q_{xx} +aq-bq^{n}+cq^{2n-1}=0. \end{aligned}$$
(3)

When \(n=3,\) Eq. (3) becomes the known KG equation with quintic nonlinearity (Wazwaz 2006; Abazari 2013)

$$\begin{aligned} q_{tt}-k^{2}q_{xx} +aq-bq^{3}+cq^{5}=0. \end{aligned}$$
(4)

The KG equation is one of the most important equations that is studied in the area of quantum physics. This equation appears in relativistic quantum mechanics. The KG equation also appears in relativistic physics and is used to describe dispersive wave phenomena in general. In addition, it appears in nonlinear optics and plasma physics. The KG equation arises in physics in linear and nonlinear forms. The nonlinear form comes from the quantum field theory and describes nonlinear wave interactions (Infeld and Rowlands 2000).

Solving nonlinear evolution equations (NLEEs) is one of the absolute necessities in the area of nonlinear waves. It is difficult to make progress without a closed form analytical solution to these NLEEs. Thus, solving NLEEs is an important task in this area of research. Recently, a new method has been proposed by Wang et al. (2008) called the \(\left( \frac{G^{\prime }}{G}\right) \)-expansion method to study traveling wave solutions of NLEEs. This useful method is developed successfully by many authors (Ebadi and Biswas 2011; Zayed and Gepreel 2009; Zhang et al. 2008; Zhang 2009) and the reference therein. The \(\left( \frac{G^{\prime }}{G}\right) \)-expansion method (Wang et al. 2008; Ebadi and Biswas 2011; Zayed and Gepreel 2009; Zhang et al. 2008; Zhang 2009) is based on the assumptions that the traveling wave solutions can be expressed by a polynomial in \(\left( \frac{G^{\prime }}{G}\right) \) such that \(G=G(\xi )\) satisfies a second order linear ordinary differential equation (ODE). In this paper, we describe the \(\left( \frac{G^{\prime }}{G}\right) \)-expansion method (Zhang 2009) for finding traveling wave solutions of nonlinear partial differential equations (PDEs), the balance numbers of which are not positive integers and then subsequently it will be applied to solve the generalized form of the KG equation with full nonlinearity.

2 The \(\left( \frac{G^{\prime }}{G}\right) \)-expansion method

We suppose that the given NLPDE for \(u(x,t)\) is in the form

$$\begin{aligned} P(u,u_{t},u_{x},u_{xx},u_{xt},u_{tt}\ldots )=0, \end{aligned}$$
(5)

where \(P\) is a polynomial. The essence of the \(\left( \frac{G^{\prime }}{G}\right) \)-expansion method can be presented in the following steps:

Step 1. To find the traveling wave solutions of Eq. (5), we introduce the wave variable

$$\begin{aligned} u(x,t)=U(\xi ),~~~\xi =x-vt. \end{aligned}$$
(6)

Substituting Eq. (6) into Eq. (5), we obtain the following ODE

$$\begin{aligned} Q\left( U,U^{\prime },U^{\prime \prime },\ldots \right) =0. \end{aligned}$$
(7)

Step 2. Eq. (7) is then integrated as long as all terms contain derivatives where integration constants are considered zero.

Step 3. Introduce the solution \(U(\xi )\) of Eq. (7) in the finite series form

$$\begin{aligned} U(\xi )=\sum ^{N}_{l=0}a_{l}\left( \frac{G^{\prime }(\xi )}{G(\xi )}\right) ^{l}, \end{aligned}$$
(8)

where \(a_{l}\) are real constants with \(a_{N}\ne 0\) and \(N\) is a positive integer to be determined. The function \(G(\xi )\) is the solution of the auxiliary linear ordinary differential equation

$$\begin{aligned} G^{\prime }(\xi )+\lambda G^{\prime }(\xi )+\mu G(\xi )=0, \end{aligned}$$
(9)

where \(\lambda \) and \(\mu \) are real constants to be determined.

Step 4. Determining \(N\) can be accomplished by balancing the linear term of highest order derivatives with the highest order nonlinear term in Eq. (7).

Step 5. Substituting the general solution of (9) together with (8) into Eq. (7) yields an algebraic equation involving powers of \(\frac{G^{\prime }}{G}\). Equating the coefficients of each power of \(\frac{G^{\prime }}{G}\) to zero gives a system of algebraic equations for \(a_{l},~\lambda ,~\mu \) and \(v.\) Then, we solve the system with the aid of a computer algebra system, such as Maple, to determine these constants. Next, depending on the sign of the discriminant \(\Delta =\lambda ^{2}-4\mu ,\) we get solutions of Eq. (7). So, we can obtain exact solutions of the given Eq. (5).

3 Application to the generalized Klein–Gordon equation with full nonlinearity

Form-I

We first consider the following KG equation:

$$\begin{aligned} \left( q^{m}\right) _{tt}-k^{2}\left( q^{m}\right) _{xx} +aq^{m}-bq^{n}+cq^{2n-m}=0. \end{aligned}$$
(10)

Suppose that

$$\begin{aligned} q(x,t)=U(\xi ),\quad \xi =x-vt, \end{aligned}$$
(11)

where \(v\) is a constant to be determined later.

Then Eq. (11) is converted to an ODE

$$\begin{aligned} (v^2-k^2)\left( U^{m}\right) ^{\prime \prime }+aU^{m}-bU^{n}+cU^{2n-m}=0. \end{aligned}$$
(12)

Balancing the \((U^{m})^{\prime \prime }\) with \(U^{2n-m}\) in Eq. (12) gives

$$\begin{aligned} (m-1)N+N+2=(2n-m)N\Leftrightarrow mN-N+N+2=2nN-mN\Leftrightarrow N=\frac{1}{n-m}. \end{aligned}$$

We then assume that Eq. (12) has the following formal solutions:

$$\begin{aligned} U(\xi )=B\left( \frac{G^{\prime }}{G}\right) ^{\frac{1}{n-m}},~~~~B\ne 0, \end{aligned}$$
(13)

where \(B\) is a constant to be determined later and \(G\) satisfies Eq. (9).

Thus, we obtain

$$\begin{aligned} \left( U^{m}\right) ^{\prime }\!=\!-\frac{m}{n-m}B^{m}\left( \frac{G^{\prime }}{G}\right) ^{\frac{m}{n-m}+1}- \frac{m}{n-m}B^{m}\lambda \left( \frac{G^{\prime }}{G}\right) ^{\frac{m}{n-m}} -\frac{m}{n-m}B^{m}\mu \left( \frac{G^{\prime }}{G}\right) ^{\frac{m}{n-m}-1},\nonumber \\ \end{aligned}$$
(14)
$$\begin{aligned} \left( U^{m}\right) ^{\prime \prime }&= \left( \frac{m^{2}}{(n-m)^{2}}+\frac{m}{n-m}\right) B^{m}\left( \frac{G^{\prime }}{G}\right) ^{\frac{m}{n-m}+2}\nonumber \\&+\left( \frac{2m^{2}}{(n-m)^{2}}+\frac{m}{n-m}\right) B^{m}\lambda \left( \frac{G^{\prime }}{G}\right) ^{\frac{m}{n-m}+1}\nonumber \\&+\left( \frac{2m^{2}}{(n-m)^{2}}B^{m}\mu +\frac{m^{2}}{(n-m)^{2}}B^{m}\lambda ^{2}\right) \left( \frac{G^{\prime }}{G}\right) ^{\frac{m}{n-m}}\nonumber \\&+\left( \frac{2m^{2}}{(n-m)^{2}}-\frac{m}{n-m}\right) B^{m}\mu \lambda \left( \frac{G^{\prime }}{G}\right) ^{\frac{m}{n-m}-1}\nonumber \\&+\left( \frac{m^{2}}{(n-m)^{2}}-\frac{m}{n-m}\right) B^{m}\mu ^{2}\left( \frac{G^{\prime }}{G}\right) ^{\frac{m}{n-m}-2}. \end{aligned}$$
(15)

Substituting Eqs. (13)–(15) into Eq. (12) and collecting all terms with the same order of \(\frac{G^{\prime }}{G}\) together, we convert the left-hand side of Eq. (12) into a polynomial in \(\frac{G^{\prime }}{G}\). Setting each coefficient of each polynomial to zero, we derive a set of algebraic equations for \(\lambda ,~\mu ,~v\) and \(B:\)

\(\left( \frac{G^{\prime }}{G}\right) ^{\frac{m}{n-m}+2}\) coeff.:

$$\begin{aligned} (v^2-k^2)\left( \frac{m^{2}}{(n-m)^{2}}+\frac{m}{n-m}\right) B^{m}+cB^{2n-m}=0, \end{aligned}$$

\(\left( \frac{G^{\prime }}{G}\right) ^{\frac{m}{n-m}+1}\) coeff.:

$$\begin{aligned} (v^2-k^2)\left( \frac{2m^{2}}{(n-m)^{2}}+\frac{m}{n-m}\right) B^{m}\lambda -bB^{n}=0, \end{aligned}$$

\(\left( \frac{G^{\prime }}{G}\right) ^{\frac{m}{n-m}}\) coeff.:

$$\begin{aligned} (v^2-k^2)\left( \frac{2m^{2}}{(n-m)^{2}}B^{m}\mu +\frac{m^{2}}{(n-m)^{2}}B^{m}\lambda ^{2}\right) +aB^{m}=0, \end{aligned}$$
(16)

\(\left( \frac{G^{\prime }}{G}\right) ^{\frac{m}{n-m}-1}\) coeff.:

$$\begin{aligned} (v^2-k^2)\left( \frac{2m^{2}}{(n-m)^{2}}-\frac{m}{n-m}\right) B^{m}\mu \lambda =0, \end{aligned}$$

\(\left( \frac{G^{\prime }}{G}\right) ^{\frac{m}{n-m}-2}\) coeff.:

$$\begin{aligned} (v^2-k^2)\left( \frac{m^{2}}{(n-m)^{2}}-\frac{m}{n-m}\right) B^{m}\mu ^{2}=0. \end{aligned}$$

The solution of the above system is

$$\begin{aligned} B&= \left( \mp \frac{(m+n)\sqrt{a(k^2-v^2)}}{(m-n)b}\right) ^{\frac{1}{n-m}},\quad k\ne v, \quad \mu =0,\quad \lambda =\mp \frac{n-m}{m}\sqrt{\frac{a}{k^{2}-v^{2}}},\nonumber \\ c&= \frac{mnb^{2}}{a(n+m)^2}. \end{aligned}$$
(17)

From Eqs. (9), (11), (13) and (17), we obtain the exact traveling wave solution of the KG equation (10) as follows:

$$\begin{aligned} q(x,t)=\left\{ \mp \frac{a(m+n)}{mb}\frac{c_{2}e^{\mp \frac{n-m}{m}\sqrt{\frac{a}{k^{2}-v^{2}}}(x-vt)}}{c_{1}+c_{2}e^{\mp \frac{n-m}{m}\sqrt{\frac{a}{k^{2}-v^{2}}}(x-vt)}}\right\} ^{\frac{1}{n-m}}, \end{aligned}$$
(18)

where \(c_{1}\) and \(c_{2}\) are arbitrary constants.

Equation (18) is a new type of exact traveling wave solution to the KG equation (10). Especially, if we choose \(c_{1}=c_{2}\) in (18), we obtain the solitary wave solution of the KG equation (10), namely

$$\begin{aligned} q(x,t)=\left\{ \pm \frac{a(m+n)}{2mb}\left( 1\pm \tanh \left[ \frac{n-m}{2m}\sqrt{\frac{a}{k^{2}-v^{2}}}(x-vt) \right] \right) \right\} ^{\frac{1}{n-m}}. \end{aligned}$$
(19)

Remark 2

In Eqs. (18) and (19), if we take \(m=1,\) then we obtain the following solitary wave solutions

$$\begin{aligned} q(x,t)=\left\{ \mp \frac{a(1+n)}{b}\frac{c_{2}e^{\mp (n-1)\sqrt{\frac{a}{k^{2}-v^{2}}}(x-vt)}}{c_{1}+c_{2}e^{\mp (n-1)\sqrt{\frac{a}{k^{2}-v^{2}}}(x-vt)}}\right\} ^{\frac{1}{n-1}} \end{aligned}$$
(20)

and

$$\begin{aligned} q(x,t)=\left\{ \pm \frac{a(1+n)}{2b}\left( 1\pm \tanh \left[ \frac{n-1}{2}\sqrt{\frac{a}{k^{2}-v^{2}}}(x-vt) \right] \right) \right\} ^{\frac{1}{n-1}}. \end{aligned}$$
(21)

Thus, Eqs. (20) and (21) are the solitary wave solutions of the following KG equation

$$\begin{aligned} q_{tt}-k^{2}q_{xx}+aq-bq^{n}+cq^{2n-1}=0. \end{aligned}$$
(22)

Remark 3

In Eqs. (20) and (21), if we take \(n=3,\) then we obtain the following solitary wave solutions

$$\begin{aligned} q(x,t)=\left\{ \mp \frac{4a}{b}\frac{c_{2}e^{\mp 2\sqrt{\frac{a}{k^{2}-v^{2}}}(x-vt)}}{c_{1}+c_{2}e^{\mp 2\sqrt{\frac{a}{k^{2}-v^{2}}}(x-vt)}}\right\} ^{\frac{1}{2}} \end{aligned}$$
(23)

and

$$\begin{aligned} q(x,t)=\left\{ \pm \frac{2a}{b}\left( 1\pm \tanh \left[ \sqrt{\frac{a}{k^{2}-v^{2}}}(x-vt) \right] \right) \right\} ^{\frac{1}{2}}. \end{aligned}$$
(24)

Thus, Eqs. (23) and (24) are the solitary wave solutions of the following KG equation

$$\begin{aligned} q_{tt}-k^{2}q_{xx} +aq-bq^{3}+cq^{5}=0. \end{aligned}$$
(25)

Remark 4

The exact solutions (21) and (24) that we obtained for the KG equations (22) and (25) are the same as the solutions that were obtained by Wazwaz (2006) who used the tanh method. Form-II

Let us consider the following KG equation:

$$\begin{aligned} \left( q^{m}\right) _{tt}-k^{2}\left( q^{m}\right) _{xx} +aq^{m}-bq^{m-n}+cq^{n+m}=0. \end{aligned}$$
(26)

Using the wave transformation

$$\begin{aligned} q(x,t)=U(\xi ),\quad \xi =x-vt. \end{aligned}$$
(27)

Eq. (26) is carried out to the following ODE:

$$\begin{aligned} (v^2-k^2)\left( U^{m}\right) ^{\prime \prime }+aU^{m}-bU^{m-n}+cU^{n+m}=0. \end{aligned}$$
(28)

Balancing the \((U^{m})^{\prime \prime }\) with \(U^{n+m}\) gives

$$\begin{aligned} (m-1)N+N+2=(n+m)N\Leftrightarrow mN-N+N+2=nN+mN\Leftrightarrow N=\frac{2}{n}. \end{aligned}$$

We then assume that Eq. (28) has the following formal solutions:

$$\begin{aligned} U(\xi )=H\left( \frac{G^{\prime }}{G}\right) ^{\frac{2}{n}},~~~~H\ne 0, \end{aligned}$$
(29)

where \(H\) is a constant to be determined later and \(G\) satisfies Eq. (9). Therefore, we obtain

$$\begin{aligned} \left( U^{m}\right) '=-\frac{2m}{n}H^{m}\left( \frac{G^{\prime }}{G}\right) ^{\frac{2m}{n}+1}- \frac{2m}{n}H^{m}\lambda \left( \frac{G^{\prime }}{G}\right) ^{\frac{2m}{n}} -\frac{2m}{n}H^{m}\mu \left( \frac{G^{\prime }}{G}\right) ^{\frac{2m}{n}-1}, \end{aligned}$$
(30)
$$\begin{aligned} \left( U^{m}\right) ^{\prime \prime }&= \left( \frac{4m^{2}}{n^{2}}+\frac{2m}{n}\right) H^{m}\left( \frac{G^{\prime }}{G}\right) ^{\frac{2m}{n}+2} +\left( \frac{8m^{2}}{n^{2}}+\frac{2m}{n}\right) H^{m}\lambda \left( \frac{G^{\prime }}{G}\right) ^{\frac{2m}{n}+1}\nonumber \\&+\left( \frac{8m^{2}}{n^{2}}H^{m}\mu +\frac{4m^{2}}{n^{2}}H^{m}\lambda ^{2}\right) \left( \frac{G^{\prime }}{G}\right) ^{\frac{2m}{n}}+ \left( \frac{8m^{2}}{n^{2}}-\frac{2m}{n}\right) H^{m}\mu \lambda \left( \frac{G^{\prime }}{G}\right) ^{\frac{2m}{n}-1}\nonumber \\&+\left( \frac{4m^{2}}{n^{2}}-\frac{2m}{n}\right) H^{m}\mu ^{2}\left( \frac{G^{\prime }}{G}\right) ^{\frac{2m}{n}-2}. \end{aligned}$$
(31)

Substituting Eqs. (29)–(31) into Eq. (28) and collecting all terms with the same order of \(\frac{G^{\prime }}{G}\) together, we convert the left-hand side of Eq. (28) into a polynomial in \(\frac{G^{\prime }}{G}\). Setting each coefficient of each polynomial to zero, we derive a set of algebraic equations for \(\lambda ,~\mu ,~v\) and \(H:\)

\(\left( \frac{G^{\prime }}{G}\right) ^{\frac{2m}{n}+2}\) coeff.:

$$\begin{aligned} (v^2-k^2)\left( \frac{4m^{2}}{n^{2}}+\frac{2m}{n}\right) H^{m}+cH^{m+n}=0, \end{aligned}$$

\(\left( \frac{G^{\prime }}{G}\right) ^{\frac{2m}{n}+1}\) coeff.:

$$\begin{aligned} (v^2-k^2)\left( \frac{8m^{2}}{n^{2}}+\frac{2m}{n}\right) H^{m}\lambda =0, \end{aligned}$$

\(\left( \frac{G^{\prime }}{G}\right) ^{\frac{2m}{n}}\) coeff.:

$$\begin{aligned} (v^2-k^2)\left( \frac{8m^{2}}{n^{2}}H^{m}\mu +\frac{4m^{2}}{n^{2}}H^{m}\lambda ^{2}\right) +aH^{m}=0, \end{aligned}$$
(32)

\(\left( \frac{G^{\prime }}{G}\right) ^{\frac{2m}{n}-1}\) coeff.:

$$\begin{aligned} (v^2-k^2)\left( \frac{8m^{2}}{n^{2}}-\frac{2m}{n}\right) H^{m}\mu \lambda =0, \end{aligned}$$

\(\left( \frac{G^{\prime }}{G}\right) ^{\frac{2m}{n}-2}\) coeff.:

$$\begin{aligned} (v^2-k^2)\left( \frac{4m^{2}}{n^{2}}-\frac{2m}{n}\right) H^{m}\mu ^{2}-bH^{m-n}=0. \end{aligned}$$

The solution of the above system is

$$\begin{aligned} H&= \left\{ \frac{32bm^3}{a^2n^2(n-2m)}(k^2-v^2)\right\} ^{\frac{1}{n}},\quad k\ne v, \quad \mu =\frac{an^{2}}{8m^2(k^2-v^2)},\quad \lambda =0,\nonumber \\ c&= \frac{a^2(n^2-4m^2)}{16bm^2}. \end{aligned}$$
(33)

Substituting the solution set (33) into (29), the solution formulae of Eq. (28) can be written as

$$\begin{aligned} U(\xi )=\left\{ \pm \frac{4m}{an}\sqrt{\frac{2bm(k^2-v^2)}{n-2m}}\left( \frac{G^{\prime }}{G}\right) \right\} ^{\frac{2}{n}}. \end{aligned}$$
(34)

Substituting the general solutions of second order linear ODE into Eq. (28) gives two types of traveling wave solutions.

Case I When \(\mu <0,\) we obtain the hyperbolic function traveling wave solution

$$\begin{aligned} q(x,t)=\left\{ \pm 2\sqrt{\frac{bm}{a(2m-n)}}\frac{c_{1}\sinh \left[ \frac{n}{2m}\sqrt{\frac{a}{2(v^2-k^2)}}(x-vt)\right] +c_{2}\cosh \left[ \frac{n}{2m}\sqrt{\frac{a}{2(v^2-k^2)}}(x-vt)\right] }{c_{1}\cosh \left[ \frac{n}{2m}\sqrt{\frac{a}{2(v^2-k^2)}}(x-vt)\right] +c_{2} \sinh \left[ \frac{n}{2m}\sqrt{\frac{a}{2(v^2-k^2)}}(x-vt)\right] }\right\} ^{\frac{2}{n}},\nonumber \\ \end{aligned}$$
(35)

where \(c_{1}\) and \(c_{2}\) are arbitrary constants. On the other hand, assuming \(c_{1}=0\) and \(c_{2}\ne 0,\) the traveling wave solution of (35) can be written as:

$$\begin{aligned} q(x,t)=\left\{ \pm 2\sqrt{\frac{bm}{a(2m-n)}}\coth \left[ \frac{n}{2m}\sqrt{\frac{a}{2(v^2-k^2)}}(x-vt)\right] \right\} ^{\frac{2}{n}}. \end{aligned}$$
(36)

Assuming \(c_{2}=0\) and \(c_{1}\ne 0,\) then we obtain

$$\begin{aligned} q(x,t)=\left\{ \pm 2\sqrt{\frac{bm}{a(2m-n)}}\tanh \left[ \frac{n}{2m}\sqrt{\frac{a}{2(v^2-k^2)}}(x-vt)\right] \right\} ^{\frac{2}{n}}. \end{aligned}$$
(37)

Case II When \(\mu >0,\) we obtain the trigonometric function traveling wave solutions

$$\begin{aligned} q(x,t)=\left\{ \pm 2\sqrt{\frac{bm}{a(n-2m)}}\frac{-c_{1}\sin \left[ \frac{n}{2m}\sqrt{\frac{a}{2(k^2-v^2)}}(x-vt)\right] +c_{2}\cos \left[ \frac{n}{2m}\sqrt{\frac{a}{2(k^2-v^2)}}(x-vt)\right] }{c_{1}\cos \left[ \frac{n}{2m}\sqrt{\frac{a}{2(k^2-v^2)}}(x-vt)\right] +c_{2} \sin \left[ \frac{n}{2m}\sqrt{\frac{a}{2(k^2-v^2)}}(x-vt)\right] }\right\} ^{\frac{2}{n}},\nonumber \\ \end{aligned}$$
(38)

where \(c_{1}\) and \(c_{2}\) are arbitrary constants. If assume \(c_{1}=0\) and \(c_{2}\ne 0,\) then

$$\begin{aligned} q(x,t)=\left\{ \pm 2\sqrt{\frac{bm}{a(n-2m)}}\cot \left[ \frac{n}{2m}\sqrt{\frac{a}{2(k^2-v^2)}}(x-vt)\right] \right\} ^{\frac{2}{n}}, \end{aligned}$$
(39)

and when \(c_{2}=0\) and \(c_{1}\ne 0,\) the solution of Eq. (38) will be

$$\begin{aligned} q(x,t)=\left\{ \mp 2\sqrt{\frac{bm}{a(n-2m)}}\tan \left[ \frac{n}{2m}\sqrt{\frac{a}{2(k^2-v^2)}}(x-vt)\right] \right\} ^{\frac{2}{n}}. \end{aligned}$$
(40)

Remark 5

In Eqs. (36), (37), (39) and (40), if we take \(m=1,\) then we obtain the following exact solutions

$$\begin{aligned} q(x,t)=\left\{ \pm 2\sqrt{\frac{b}{a(2-n)}}\coth \left[ \frac{n}{2}\sqrt{\frac{a}{2(v^2-k^2)}}(x-vt)\right] \right\} ^{\frac{2}{n}},\end{aligned}$$
(41)
$$\begin{aligned} q(x,t)=\left\{ \pm 2\sqrt{\frac{b}{a(2-n)}}\tanh \left[ \frac{n}{2}\sqrt{\frac{a}{2(v^2-k^2)}}(x-vt)\right] \right\} ^{\frac{2}{n}}, \end{aligned}$$
(42)

for \(\frac{a}{v^{2}-k^{2}}<0.\)

$$\begin{aligned} q(x,t)=\left\{ \pm 2\sqrt{\frac{b}{a(n-2)}}\cot \left[ \frac{n}{2}\sqrt{\frac{a}{2(k^2-v^2)}}(x-vt)\right] \right\} ^{\frac{2}{n}},\end{aligned}$$
(43)
$$\begin{aligned} q(x,t)=\left\{ \mp 2\sqrt{\frac{b}{a(n-2)}}\tan \left[ \frac{n}{2}\sqrt{\frac{a}{2(k^2-v^2)}}(x-vt)\right] \right\} ^{\frac{2}{n}}, \end{aligned}$$
(44)

for \(\frac{a}{k^{2}-v^{2}}>0.\)

Remark 6

The exact solutions (41)–(44) that we obtained for the KG equations (26) are the same as the solutions that were obtained by Wazwaz (2006) who used the tanh method.

4 Conclusions

Many powerful methods (Biswas et al. 2012; Sassaman and Biswas 2010, 2009; Fabian et al. 2009; Wazwaz 2006; Abazari 2013; Infeld and Rowlands 2000; Wang et al. 2008; Ebadi and Biswas 2011; Zayed and Gepreel 2009; Zhang et al. 2008; Zhang 2009) are used in solitary waves theory to examine exact soliton solutions for nonlinear PDEs. In this paper, we studied the new application of the \(\left( \frac{G^{\prime }}{G}\right) \)-expansion method to derive the exact soliton solutions of the generalized form of KG equations with full nonlinearity. These results will be immensely useful in the area of quantum physics. The \(\left( \frac{G^{\prime }}{G}\right) \)-expansion method is not only efficient, but also has the merit of being widely applicable. The results show that the proposed method is direct, effective and can be applied to many other nonlinear PDEs in mathematical physics.