1 Introduction

Although Einstein’s theory of general relativity (GR) is successful at present, and can forecast and elucidate increased observational data, there are strong reasons to expect that it must be modified due to its shortfall in the quantization of gravity and explaining the recent observational puzzles in modern cosmology leading to the study of amended theories of gravity.

The Lovelock gravitational theories [1] are of special interest since they are Lagrangian-based theories that can give conserved covariant field equations which do not include derivatives higher than the second degree. In this regard, Lovelock’s theories are the physical extensions of GR. The Gauss–Bonnet (GB) theory is considered the first physical nontrivial expansion of Einstein’s GR. This theory is meaningful if its spacetime is greater than four-dimensional, in which the GB invariant

$$\begin{aligned} \mathcal {G} = R^2-4R_{\alpha \beta }R^{\alpha \beta }+R_{\alpha \beta \rho \sigma }R^{\alpha \beta \rho \sigma }\, , \end{aligned}$$
(1)

can create a rich phenomenology. Through the use of Chern’s theorem [2], it can be shown that in four dimensions, the GB expression is a non-dynamical term because the GB invariant becomes a total derivative. To make the GB expression a dynamical one in four dimensions, we must invoke a novel scalar field with a canonical kinetic term coupling to the GB term [3,4,5,6,7,8,9,10,11,12] as stimulated, for example, by low-energy effective actions stemming from string theory, such as the Einstein–dilaton–GB models [5, 13,14,15]. Actually, because of Lovelock’s theorem, in principle, all amended gravitational theories in four dimensions will have extra degrees of freedom, which can be considered as new basic fields.

The exact solutions of the gravitational system supply scientific society with a simple test of spacetime and evaluation of observable forecasts. Nevertheless, amended gravitational theories with new basic field(s) usually provide equations of motion with high intractability so that the evaluations become analytically out of the question. To address such an issue, one is forced either to apply perturbation theory, which is not well qualified in the strong gravitational field, or to defy numerical methods [16]. However, the field equations of GR coupled with matter have conformal invariance since they possess the constant Ricci scalar curvature on-shell, limiting the spacetimes and permitting analytic solutions to be easily derived. An example of such a theory that has conformal invariance and yields simple analytic solutions is the electrovacuum, whose Reissner–Nordström (Kerr–Newman) solution was the first-ever discovered static (spinning) black hole (BH) with a matter source. Another model is the gravitational theory coupled with a conformal scalar field, in which the matter action obeys the conformal invariance and has the form

$$\begin{aligned} S_\xi = \int d^4x \sqrt{-g} \left( \frac{1}{6} R \xi ^2 +\left( \nabla \xi \right) ^2\right) \, , \end{aligned}$$
(2)

where R is the Ricci scalar and \(\xi \) is the scalar field. The field equations of the above action give a solution with the no-hair theorem (see, e.g., Ref. [17] for a review) and the static Bocharova–Bronnikov–Melnikov–Bekenstein BH [18,19,20], which has been much debated. Gravitational theory with a conformal scalar field and its solutions have been discussed in recent years because of its compelling properties (see, e.g., Refs. [21,22,23,24,25,26,27,28,29,30,31] and references therein).

As we discussed above, in four dimensions, the GB term is topological and does not yield any dynamical effect. Nevertheless, when the GB term is non-minimally coupled with any other field, such as a scalar field \(\xi \), the output dynamics are nontrivial. Many cosmological proposals have been presented in the recent literature ([32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87] and references therein). In the frame of astrophysics, however, to the best of our knowledge, the GB theory with a non-minimal coupling of a scalar field via potential and coefficient function has not been tackled, although there are some pioneering works such as [8]. It is the aim of the present study to derive exact spherically symmetric interior solutions of this theory and discuss the physical consequences. By using our formulation, we can construct a model which reproduces any given profile of the energy density \(\rho \) for an arbitrary equation of state (EoS) of matter. The mass M and the radius \(R_s\) of the compact star are determined by the profile of the energy density, and therefore we can obtain an arbitrary relation between the mass M and the radius \(R_s\) of the compact star by adjusting the scalar potential and the coefficient function of the GB term in the action of the Einstein–Gauss–Bonnet gravity coupled with a scalar field (EGBS), which could be a kind of degeneracy between the EoS and the functions characterizing the model. Therefore, we find that the mass–radius relation alone is not sufficient to constrain the model.

The remainder of the paper is organized as follows: In Sect. 2, we describe the fundamentals of the EGBS, and we apply the field equation of the EGBS theory to a spherically symmetric spacetime and derive the full system of the differential equation. Here we show that we can construct a model which reproduces any given profile of the energy density \(\rho \) for an arbitrary EoS of matter. Also in Sect. 3, we give the form of a polytropic EoS as an example and the form of one of the metric potentials as an input and then derive all the unknown functions including the profile of the scalar field, the coefficient function, the potential of the scalar field, and the form of another metric potential. Section 4 discusses the physical conditions that must be satisfied for any real stellar configuration. In Sect. 5, we discuss the physical properties analytically and graphically, showing that the solutions have realistic physical properties. In Sect. 7, we discuss the issue of stability by using the adiabatic index and show that our model satisfies the adiabatic index; that is, the value of the index is greater than 4/3, which is the condition of stability. The final section is reserved for the conclusion and discussion of the present study.

2 Gauss–Bonnet theory coupled with scalar through \(f(\xi )\)

Now we consider the EGBS in N dimensions. This theory takes the following amended action,

$$\begin{aligned} \mathcal {S}=\int d^N x \sqrt{-g}\left\{ \frac{1}{2\kappa ^2}R - \frac{1}{2} \partial _\mu \xi \partial ^\mu \xi +V(\xi )+ f(\xi ) \mathcal {G} \right\} + S_\textrm{M}\,, \end{aligned}$$
(3)

where \(\xi \) is the scalar field and V is the potential which is a function of \(\xi \), \(f(\xi )\) is an arbitrary function of the scalar field, and \(S_\textrm{M}\) is the matter action, where we assume that matter is to couple minimally to the metric, i.e., we are working in the so-called Jordan frame. In four dimensions, i.e., when \(N=4\), the aforementioned action is physically nontrivial because the GB invariant term \(\mathcal {G}\) is coupled with the real scalar field \(\xi \) through the coupling \(f(\xi )\). Because of this coupling, the Lagrangian is not a total derivative but contributes to the field equations of the system.

The variation of the action (3) w.r.t. the scalar field \(\xi \) yields the following equation

$$\begin{aligned} \nabla ^2 \xi -V'(\xi )+ f'(\xi )\mathcal {G}=0 . \end{aligned}$$
(4)

The variation of the action (3) w.r.t. the metric \(g_{\mu \nu }\) yields the following field equations

$$\begin{aligned} T^{\mu \nu }=\,&\frac{1}{2\kappa ^2}\left( - R^{\mu \nu } + \frac{1}{2} g^{\mu \nu } R\right) +\frac{1}{2} \partial ^\mu \xi \partial ^\nu \xi - \frac{1}{4}g^{\mu \nu } \partial _\rho \xi \partial ^\rho \xi \nonumber \\&+ \frac{1}{2} g^{\mu \nu }[f(\xi )G -V(\xi )] +2 f(\xi ) R R^{\mu \nu } \nonumber \\&+ 2 \nabla ^\mu \nabla ^\nu \left( f(\xi )R\right) - 2 g^{\mu \nu }\nabla ^2\left( f(\xi )R\right) \nonumber \\&+ 8f(\xi )R^\mu _{\ \rho } R^{\nu \rho }- 4 \nabla _\rho \nabla ^\mu \left( f(\xi )R^{\nu \rho }\right) \nonumber \\&- 4 \nabla _\rho \nabla ^\nu \left( f(\xi )R^{\mu \rho }\right) \nonumber \\&+ 4 \nabla ^2 \left( f(\xi ) R^{\mu \nu } \right) + 4g^{\mu \nu } \nabla _{\rho } \nabla _\sigma \left( f(\xi ) R^{\rho \sigma } \right) \nonumber \\&- 2f(\xi ) R^{\mu \rho \sigma \tau }R^\nu _{\ \rho \sigma \tau }+ 4 \nabla _\rho \nabla _\sigma \left( f(\xi ) R^{\mu \rho \sigma \nu }\right) . \end{aligned}$$
(5)

Through the use of the Bianchi identities,

$$\begin{aligned} \nabla ^\rho R_{\rho \tau \mu \nu }=\,&\nabla _\mu R_{\nu \tau } - \nabla _\nu R_{\mu \tau } \, , \nonumber \\ \nabla ^\rho R_{\rho \mu } =\,&\frac{1}{2} \nabla _\mu R\, , \nonumber \\ \nabla _\rho \nabla _\sigma R^{\mu \rho \nu \sigma } =\,&\nabla ^2 R^{\mu \nu } - {1 \over 2}\nabla ^\mu \nabla ^\nu R\nonumber \\&+ R^{\mu \rho \nu \sigma } R_{\rho \sigma }- R^\mu _{\ \rho } R^{\nu \rho }\, , \nonumber \\ \nabla _\rho \nabla ^\mu R^{\rho \nu } + \nabla _\rho \nabla ^\nu R^{\rho \mu } =\,&\frac{1}{2} \left( \nabla ^\mu \nabla ^\nu R + \nabla ^\nu \nabla ^\mu R\right) \nonumber \\&- 2 R^{\mu \rho \nu \sigma } R_{\rho \sigma } + 2 R^\mu _{\ \rho } R^{\nu \rho }\, , \nonumber \\ \nabla _\rho \nabla _\sigma R^{\rho \sigma } =\,&\frac{1}{2} \Box R \, , \end{aligned}$$
(6)

in Eq. (5), we obtain

$$\begin{aligned} T^{\mu \nu }&= \frac{1}{2\kappa ^2}\left( - R^{\mu \nu } +\frac{1}{2} g^{\mu \nu } R\right) \nonumber \\&+ \left( \frac{1}{2} \partial ^\mu \xi \partial ^\nu \xi - \frac{1}{4}g^{\mu \nu } \partial _\rho \xi \partial ^\rho \xi \right) \nonumber \\&+ \frac{1}{2} g^{\mu \nu } \left[ f(\xi ) G-V(\xi ) \right] \nonumber \\&-2 f(\xi ) R R^{\mu \nu } + 4f(\xi )R^\mu _{\ \rho } R^{\nu \rho } -2 f(\xi ) R^{\mu \rho \sigma \tau }R^\nu _{\ \rho \sigma \tau }\nonumber \\&-4 f(\xi ) R^{\mu \rho \sigma \nu }R_{\rho \sigma } \nonumber \\&+ 2 \left( \nabla ^\mu \nabla ^\nu f(\xi )\right) R - 2 g^{\mu \nu } \left( \nabla ^2f(\xi )\right) R\nonumber \\&- 4 \left( \nabla _\rho \nabla ^\mu f(\xi )\right) R^{\nu \rho } - 4 \left( \nabla _\rho \nabla ^\nu f(\xi )\right) R^{\mu \rho } \nonumber \\&+ 4 \left( \nabla ^2 f(\xi ) \right) R^{\mu \nu } + 4g^{\mu \nu } \left( \nabla _{\rho } \nabla _\sigma f(\xi ) \right) R^{\rho \sigma }\nonumber \\&- 4 \left( \nabla _\rho \nabla _\sigma f(\xi ) \right) R^{\mu \rho \nu \sigma }. \end{aligned}$$
(7)

The field equations (4) and (7) are the full system of equations describing the theory under consideration. In the four-dimensional case, i.e., \(N=4\), Eq. (7) yields

$$\begin{aligned} T^{\mu \nu }= \,&\frac{1}{2\kappa ^2}\left( - R^{\mu \nu } + \frac{1}{2} g^{\mu \nu } R\right) \nonumber \\&+ \left( \frac{1}{2} \partial ^\mu \xi \partial ^\nu \xi - \frac{1}{4}g^{\mu \nu } \partial _\rho \xi \partial ^\rho \xi \right) - \frac{1}{2} g^{\mu \nu }V(\xi ) \nonumber \\&+ 2 \left( \nabla ^\mu \nabla ^\nu f(\xi )\right) R - 2 g^{\mu \nu } \left( \nabla ^2f(\xi )\right) R \nonumber \\&- 4 \left( \nabla _\rho \nabla ^\mu f(\xi )\right) R^{\nu \rho } - 4 \left( \nabla _\rho \nabla ^\nu f(\xi )\right) R^{\mu \rho } \nonumber \\&+ 4 \left( \nabla ^2 f(\xi ) \right) R^{\mu \nu } \nonumber \\&+ 4g^{\mu \nu } \left( \nabla _{\rho } \nabla _\sigma f(\xi ) \right) R^{\rho \sigma } - 4 \left( \nabla _\rho \nabla _\sigma f(\xi ) \right) R^{\mu \rho \nu \sigma }. \end{aligned}$$
(8)

In the present study, we assume that the scalar field \(\xi \) is a function of the radial coordinate r and therefore the function \(f(\xi )\) depends only on r, i.e., \(f(r)\equiv f\left( \xi \left( r\right) \right) \), because we deal with static and spherically symmetric spacetime,

$$\begin{aligned} \mathrm{{d}}s^2 = -a(r)\mathrm{{d}}t^2 +\frac{\mathrm{{d}}r^2}{a_1(r)}+r^2 \left( \mathrm{{d}}\theta ^2 + \sin ^2 \left( \theta \right) \right) \mathrm{{d}}\phi ^2\,. \end{aligned}$$
(9)

In the following section, we study the system of field equations (4) and (8) and try to find the analytic form of the unknown functions when \(T^{\mu \nu }\ne 0\).

3 Four-dimensional spherically symmetric interior solution in EGBS

For the metric in (9), the (tt)-component of the field equation Eq. (8) has the following form

$$\begin{aligned} -\rho =\frac{16a_1\left( 1 -a_1\right) f'' + \left\{ 8\left( 1-3a_1 \right) f' +2r \right\} a'_1 +2a_1 +2V r^2 +r^2 \xi '^2 a_1 -2}{4r^2} \,, \end{aligned}$$
(10)

where the (rr)-component is given by

$$\begin{aligned} p=\frac{ 2\left( 4 \left( 1 -3a_1 \right) f' +r \right) a_1a'+a\left[ 2a_1 -r^2 a_1\xi '^2 -2 +2V r^2 \right] }{4 r^2 a}\,, \end{aligned}$$
(11)

and the \((\theta ,\theta )\)- and \((\phi ,\phi )\)-components are

$$\begin{aligned} p=\frac{2a_1 a \left( r - 8 f' a_1 \right) a'' -16 f''a_1^2 a a' + a_1\left( 8 f' a_1- r \right) a'^2 + \left\{ \left( r-24 f' a_1 \right) a'_1 +2 a_1 \right\} aa' +2a^2 \left( a'_1 + r\left[ \xi '^2a_1 +2V \right] \right) }{8a^2r} \,. \end{aligned}$$
(12)

The field equation of the scalar field (4) takes the following form

$$\begin{aligned} 0=\frac{8a_1 a f' \left( a_1-1 \right) a'' +2 \xi '' a_1 \xi ' a^2r^2 +4 a'f' \left[ a_1 a' \left( 1-a_1 \right) + a'_1 a\left( 3a_1 - 1 \right) \right] +ra\left( \left[ \,a_1 a' r+a \left\{ 4 a_1 +a'_1 r \right\} \right] \xi '^2 -2a rV' \right) }{2 r^2 a^2 \xi '} \,. \end{aligned}$$
(13)

Here, \(\rho \) is the energy density and p is the pressure of matter, which we assume to be a perfect fluid and which satisfies an EoS, \(p=p\left( \rho \right) \). The energy density \(\rho \) and the pressure p satisfy the following conservation law

$$\begin{aligned} 0 = \nabla ^\mu T_{\mu r} =\frac{1}{2}\frac{a'}{a} \left( \rho + p \right) + \frac{\mathrm{{d}}p}{\mathrm{{d}}r} \, . \end{aligned}$$
(14)

The conservation law is also derived from Eqs. (10), (11), (12), and (13). Here we have assumed that \(\rho \) and p depend only on the radial coordinate r. Other components of the conservation law are trivially satisfied. If the EoS \(\rho =\rho (p)\) is given, Eq. (14) can be integrated as

$$\begin{aligned} \frac{1}{2} \ln a = - \int ^r \mathrm{{d}}r \frac{\frac{\mathrm{{d}}p}{\mathrm{{d}}r}}{\rho + p} = - \int ^{p(r)}\frac{\mathrm{{d}}p}{\rho (p) + p} \, . \end{aligned}$$
(15)

Because Eq. (14) and therefore (15) can be obtained from Eqs. (10), (11), (12), and (13), as long as we use (15), we forget one equation in Eqs. (10), (11), (12), and (13). In the following, we do not use Eq. (13). Inside the compact star, we can use Eq. (15), but outside the star, we cannot use Eq. (15). Instead of using Eq. (15), we may assume the profile of \(a=a(r)\) so that a(r) and \(a'(r)\) are continuous at the surface of the compact star.

By Eq. (10) \(+\) Eq. (11), we obtain

$$\begin{aligned} V&= -\rho + p \nonumber \\&\quad +\frac{8\,a_1a \left( a_1-1 \right) f'' -4\left\{ \left( 1-3a_1 \right) f'+r \right\} \left( aa_1\right) ' +2a-2aa_1}{2a r^2} \, . \end{aligned}$$
(16)

On the other hand, Eq. (10) − Eq. (11) gives

$$\begin{aligned} \xi '&= \pm \Bigg \{ \frac{2}{a_1} \left( \rho + p \right) \nonumber \\&\quad + {\frac{8\,a a_1 \left( a_1 -1 \right) f'' - \left[ 4 \left( 1-3\,a_1 \right) f' +r \right] \left( a a'_1 -a_1 a' \right) }{a_1 r^2a }} \Bigg \}^\frac{1}{2}\, . \end{aligned}$$
(17)

Furthermore, Eq. (10) − Eq. (12) gives

$$\begin{aligned} 0 =&16\, \left[ a_1 a' r-2\,a \left( a_1-1 \right) \right] a a_1 f'' \nonumber \\&-2ra a_1 \left( r -8\,f' a_1 \right) a'' +ra_1 \left( r -8\, f' a_1\right) a'^2 \nonumber \\&- \left[ \left( r-24\,f' a_1 \right) a'_1 +2\,a_1 \right] a ra'\nonumber \\&+2\, \left\{ \left[ 8\left( 1-3\,a_1 \right) f' +r \right] a'_1 -2+2\,a_1 \right\} a^2 + 8a^2 r^2 \left( \rho + p \right) \, , \end{aligned}$$
(18)

which can be regarded with the differential equation for \(f'\) and therefore for f if \(a=a(r)\), \(a_1=a_1(r)\), \(\rho =\rho (r)\), and \(p=p(r)\) are given and the solution is given by

$$\begin{aligned}&f(r)=\, -\int \left( \int {\frac{\left[ a_1 a'^2 r^2 -2a_1 a'' a r^2-ra \left( a'_1 r+2\,a_1 \right) a' + {2\left\{ a'_1 r-2+2a_1 +4 \left( \rho +p \right) r^2 \right\} a^2} \right] }{2U(r) a_1 a \left( a_1a'r-2a \left( a_1-1 \right) \right) }}{\mathrm{{d}}r}-16 c_1 \right) U \mathrm{{d}}r +c_2 \, , \nonumber \\&\quad U(r) \equiv \, \textrm{e}^{\int \frac{r {a_1}^2 a'^2 -2ra {a_1}^2 a'' + \left( 2 a^2 \left( 3a_1-1 \right) -3 a_1 a' a r \right) a'_1 }{2a_1 a \left\{ a_1 a' r-2 a \left( a_1-1 \right) \right\} }{\mathrm{{d}}r}} \,. \end{aligned}$$
(19)

Here, \(c_1\) and \(c_2\) are constants of the integration.

Let us assume the r-dependencies of \(\rho \) and \(a_1\), \(\rho =\rho (r)\) and \(a_1=a_1(r)\). Then by using the EoS \(p=p(\rho )\), we find the r-dependence of p, \(p=p(r)=p\left( \rho \left( r\right) \right) \). Furthermore, by using (15), we find the r-dependence of a, \(a=a(r)\). However, Eq. (15) is not valid outside the compact star because \(\rho \) and p, of course, vanish there. Then outside the compact star we may properly assume the profile of a(r) so that a(r) and \(a'(r)\) are continuous at the surface, that is, the boundary of the compact star, and coincide with a(r) and \(a'(r)\) obtained from (15). Therefore, by using (19), we find the r-dependence of f, \(f=f(r)\), and by using Eqs. (16) and (17), we find the r dependencies of V and \(\xi \), \(V=V(r)\) and \(\xi =\xi (r)\). By solving \(\xi =\xi (r)\) with respect to r, \(r=r(\xi )\), we find f and V as functions of \(\xi \), \(f(\xi )=f\left( r \left( \xi \right) \right) \), \(V(\xi )=V\left( r \left( \xi \right) \right) \), which realize the model which has a solution given by \(\rho =\rho (r)\) and \(a_1=a_1(r)\).

We should note, however, that the expression of \(\xi \) in (17) gives a constraint,

$$\begin{aligned}&\frac{2}{a_1} \left( \rho + p \right) \nonumber \\&+ {\frac{8\,a a_1 \left( a_1 -1 \right) f'' - \left[ 4 \left( 1-3\,a_1 \right) f' +r \right] \left( a a'_1 -a_1 a' \right) }{a_1 r^2a }} \ge 0 \, , \end{aligned}$$
(20)

so that the ghost can be avoided. If Eq. (20) is not satisfied, the scalar field \(\xi \) becomes purely imaginary. We may define a new real scalar field \(\zeta \) by \(\xi =i\zeta \) \(\left( i^2=-1\right) \), but because the coefficient in front of the kinetic term of \(\zeta \) becomes negative, \(\zeta \) is a ghost, that is, a non-canonical scalar field. The existence of the ghost generates the negative norm states in the quantum theory, and therefore the theory becomes inconsistent.

When we consider compact stars like neutron stars, we often consider the following EoS

  1. 1.

    Energy-polytrope

    $$\begin{aligned} p = K \rho ^{1 + \frac{1}{n}}\,, \end{aligned}$$
    (21)

    with constants K and n. It is known that for the neutron stars, n can take the value \(0.5\le n \le 1\).

  2. 2.

    Mass-polytrope

    $$\begin{aligned} \rho = \rho _{m} + N p \, ,\qquad \qquad p = K_m \rho _m^{1+\frac{1}{n_{m}}} \, , \end{aligned}$$
    (22)

    where \(\rho _{m}\) is rest mass energy density and \(K_{m}\), N are constants.

Now let us study the case of the energy-polytrope (21) in detail, in which we can rewrite the EoS as follows

$$\begin{aligned} \rho = \tilde{K} p^{({1 + \frac{1}{\tilde{n}}})}\, , \quad \tilde{K} \equiv K^{-\frac{1}{1+\frac{1}{n}}} \, , \quad \tilde{n} \equiv \frac{1}{\frac{1}{1+\frac{1}{n}} - 1} = - 1 - n \, . \end{aligned}$$
(23)

For the energy-polytrope, Eq. (15) takes the following form

$$\begin{aligned} \frac{1}{2} \ln a&= - \int ^{p(r)}\frac{\mathrm{{d}}p}{\tilde{K} p^{1 + \frac{1}{\tilde{n}}} + p} = \frac{c}{2} + \tilde{n} \ln \left( 1+{\tilde{K}}^{-1}p^{-\frac{1}{\tilde{n}}} \right) \nonumber \\&= \frac{c}{2} - \left( 1+n\right) \ln \left( 1+ K \rho ^\frac{1}{n} \right) \, . \end{aligned}$$
(24)

Here, c is a constant of the integration. Similarly, in the case of the mass-polytrope (22), we obtain

$$\begin{aligned} \frac{1}{2} \ln a = \frac{\tilde{c}}{2} + \ln \left( 1 - K_m \rho ^\frac{1}{n_m}\right) \, . \end{aligned}$$
(25)

Here, \(\tilde{c}\) is again a constant of the integration.

Under one of the above EoS, we may assume the following profile of \(\rho =\rho (r)\) and \(a_1=a_1(r)\), just for an example,

$$\begin{aligned} \rho =\left\{ \begin{array}{cc} \rho _c \left( 1 - \frac{r^2}{{R_s}^2} \right) &{} \ \text{ when }\ r<R_s \\ 0 &{} \ \ \text{ when }\ r>R_s \end{array} \right. , \quad a_1= 1 - \frac{2Mr^2}{r^3 + {r_0}^3} \, . \end{aligned}$$
(26)

Here, \(r_0\) is a constant, \(\rho _c\) is a constant expressing the energy density at the center of the compact star, \(R_s\) is also a constant corresponding to the radius of the surface of the compact star, and M is a constant corresponding to the mass of the compact star,

$$\begin{aligned} M&=4\pi \rho _c \int _0^r \psi ^2 \rho (\psi ) \mathrm{{d}}\psi = 4\pi \rho _c \int _0^r \mathrm{{d}}\psi \psi ^2 \left( 1 - \frac{\psi ^2}{{R_s}^2} \right) \nonumber \\&= \frac{4\pi \rho _c r^3}{15}\left( 5 - \frac{3r^2}{{R_s}^2} \right) \,. \end{aligned}$$
(27)

When \(r\rightarrow \infty \), \(a_1\) behaves as \(a_1(r) \sim 1 - \frac{2M}{r}\), and therefore M can be regarded as the mass of the compact star. Equation (27) gives the Mr relation, that is, the relation between the mass and the radius of the compact star when \(r=R_s\). We also note that we need to choose \(r_0\) large enough that \(a_1\) is positive. In order for \(a_1\) in (26) to be positive, we require

$$\begin{aligned} \frac{2^\frac{5}{3}M}{3r_0}<1\, . \end{aligned}$$
(28)

We should also note that when \(r\rightarrow 0\), \(a_1\) behaves as \(a_1(r) \sim 1 - \frac{2Mr^2}{r_0^3}\).Footnote 1 Therefore, \(a_1'(r)\) vanishes at the center \(r=0\), \(a_1'(r=0)=0\), and thus there is no conical singularity.

As an example, we use the energy-polytope as the EoS by choosing \(n=1\) just for simplicity. Then Eq. (24) gives

$$\begin{aligned} a = \frac{\textrm{e}^c}{ \left( 1 + K \rho _c \left( 1 - \frac{r^2}{{R_s}^2} \right) \right) ^4} \, , \end{aligned}$$
(29)

which gives

$$\begin{aligned} a' = \frac{8 \textrm{e}^c K \rho _c r}{{R_s}^2\left( 1 + K \rho _c \left( 1 - \frac{r^2}{{R_s}^2} \right) \right) ^5} \, . \end{aligned}$$
(30)

Outside the star, we assume that \(a(r)=a_1(r)\) in (26), and therefore

$$\begin{aligned} a' = \frac{2Mr\left( r^3 - {r_0}^3\right) }{\left( r^3 + {r_0}^3\right) ^2} \, . \end{aligned}$$
(31)

Because a(r) and \(a'(r)\) should be continuous at the surface \(r=R_s\), we obtain

$$\begin{aligned} \textrm{e}^c = 1 - \frac{2M{R_s}^2}{{R_s}^3 + {r_0}^3} \, , \quad \frac{8 \textrm{e}^c K \rho _c}{R_s} = \frac{2M{R_s}\left( {R_s}^3 - {r_0}^3\right) }{\left( {R_s}^3 + {r_0}^3\right) ^2} \, . \end{aligned}$$
(32)

By deleting \(\textrm{e}^c\) in the two equations in (32), we obtain

$$\begin{aligned} 0=&\left( {r_0}^3\right) ^2 + \left( 2 {R_s}^3 - 2M{R_s}^2 + \frac{M{R_s}^2}{2K \rho _c} \right) {r_0}^3 \nonumber \\&+ {R_s}^6 - 2M{R_s}^5 - \frac{M{R_s}^5}{4K \rho _c} \nonumber \\ =&\left( {r_0}^3\right) ^2 + \left( 2 {R_s}^3 - \frac{16\pi \rho _c R_s^5}{15} + \frac{2\pi R_s^5}{15K} \right) {r_0}^3 \nonumber \\&+ {R_s}^6 - \frac{16\pi \rho _c R_s^8}{15} - \frac{2\pi R_s^8}{15K} \, , \end{aligned}$$
(33)

where we have used Eq. (27) when \(r=R_s\). Because \(r_0\) should be positive, we find

$$\begin{aligned}&{R_s}^6 - \frac{16\pi \rho _c R_s^8}{15} - \frac{4\pi R_s^8}{15K}<0 \nonumber \\&\text{ or } \nonumber \\&2 {R_s}^3 - \frac{16\pi \rho _c R_s^5}{15} + \frac{4\pi R_s^5}{15K} <0\quad \text{ and } \nonumber \\&\quad {R_s}^6 - \frac{16\pi \rho _c R_s^8}{15} - \frac{4\pi R_s^8}{15K} > 0 \, . \end{aligned}$$
(34)

Then, by using (19), we find the r-dependence of f, \(f=f(r)\), and by using Eqs. (16) and (17), the r dependencies of V and \(\xi \), \(V=V(r)\) and \(\xi =\xi (r)\), are determined. If we can solve \(\xi =\xi (r)\) with respect to r, \(r=r(\xi )\), we find f and V as functions of \(\xi \), \(f(\xi )=f\left( r \left( \xi \right) \right) \), \(V(\xi )=V\left( r \left( \xi \right) \right) \).

Just for further simplicity, we may choose

$$\begin{aligned} 2 r_0 = R_s = 4 M= \frac{32\pi \rho _c R_s^3}{15}\, , \quad K \rho _c = \frac{7}{258} \, , \quad \textrm{e}^c= \frac{5}{9}\, , \end{aligned}$$
(35)

which satisfy Eqs. (28), (32), and (33). For numerical calculation, we may further choose \(R_s=1\).

Inside the compact star, by using Eqs. (26) and (29), we find that the GB term \(\mathcal {G}\) behaves as

$$\begin{aligned} \mathcal {G}(r)=&\, -\frac{K\rho _cM }{64 \left( {R_s}^2+K\rho _c {R_s}^2-K\rho _cr^2 \right) ^2 \left( r^3 + {r_0}^3 \right) ^3}\nonumber \\&\quad \left\{ 9r^5{r_0}^3K\rho _c +3{r_0}^6K\rho _cr^2-4{r_0}^3Mr^4K\rho _c +r^5MK\rho _c{R_s}^2 \right. \nonumber \\&+3r^3{r_0}^3K \rho _c {R_s}^2 +3{r_0}^6K\rho _c{R_s}^2 -8{r_0}^3Mr^2K\rho _c{R_s}^2\nonumber \\ {}&+r^5 M {R_s}^2 +6r^8K\rho _c -13r^7MK\rho _c \nonumber \\&\left. +3r^3{r_0}^3{R_s}^2 +3{r_0}^6{R_s}^2-8{r_0}^3 Mr^2{R_s}^2 \right\} \nonumber \\&\approx \, - \frac{64{R_s}^2{r_0}^3 MK\rho _c}{{r_0}^6{R_s}^4 \left( K\rho _c+1 \right) }\nonumber \\ {}&+ \frac{64 \left( 8M{R_s}^2 +8MK\rho _c{R_s}^2 -9{r_0}^3 K\rho _c \right) MK\rho _cr^2}{{r_0}^6{R_s}^4 \left( K\rho _c+1 \right) ^2}\nonumber \\ {}&+\frac{384MK\rho _c r^3}{{R_s}^2{r_0}^6 \left( 1+K\rho _c \right) }\,. \end{aligned}$$
(36)

Equation (36) shows that the GB term does not vanish, and it depends on the mass of the star. Now we calculate the form of f(r) using the data given in Eqs. (29), (32), and (26). The explicit form of f(r) is displayed in Appendix A. The form of \(\xi (r)\), by using the data given in Eqs. (26), (29), and (32), is also displayed in Appendix A. Finally, we calculate the explicit form of V(r) using the data given in Eqs. (29), (32), and (26), and list the results in Appendix A.

To complete our study, we solve Eq. (A4) asymptotically and obtain

$$\begin{aligned} \xi (r\rightarrow 0) \approx&C_{11}+C_{12}\sqrt{r} \ \Rightarrow \ r \approx C_{13}+C_{14}\xi +C_{15}\xi ^2\, . \end{aligned}$$
(37)

The above equation is valid provided that the constant \(C_{12}<0\). Now, using Eq. (37) in (A2), we obtain \(f(\xi )\) as

$$\begin{aligned} f(\xi )\approx C_{16}+C_{17}\xi +C_{18}\xi ^2\,. \end{aligned}$$
(38)

Also using Eq. (37) in (A6), we obtain \(V(\xi )\) as

$$\begin{aligned} V(\xi )\approx C_{19}+C_{20}\xi +C_{21}\xi ^2\,. \end{aligned}$$
(39)

A final remark that we should stress is that using Eqs. (26), (29), (A2), and the constraints (35) with \(R_s=1\), one can easily show that the inequality (20) holds.

We have four differential equations for seven unknown functions, as shown in Eqs. (10), (11), (12), and (13), that is, \(\rho \), p, V, \(\xi \), f, a, and \(a_1\). As a result, we need to require three additional conditions to close such a system. One of these extra conditions is the continuity equation given by Eq. (14). The second condition is the polytropic EoS given by Eq. (21). The third is the profile of the energy density of matter given by Eq. (26). When these additional conditions are combined with Eqs. (10), (11), (12), and (13), the system is in a closed form, allowing all seven unknown functions to be explicitly fixed.

4 Ingredient requirements for a real physical stellar configuration

For a physically reliable isotropic stellar model, the solution has to satisfy the conditions inside the stellar configurations as follows:

  • The metric potentials a(r) and \(a_1(r )\), and the energy–momentum components \(\rho \) and p should be well defined at the center of the star and should have a regular behavior and have no singularity in the interior of the star.

  • The density \(\rho \) must be positive in the stellar interior, i.e., \(\rho \ge 0\). Moreover, its value at the center of the star must be finite, positive, and decreasing to the boundary of the star, i.e., \(\frac{\mathrm{{d}}\rho }{\mathrm{{d}}r}\le 0\).

  • The pressure p should have a positive value inside the fluid configuration, i.e., \(p\ge 0\). In addition, the derivative of the pressure should yield a negative value inside the star, i.e., \(\frac{\mathrm{{d}}p}{\mathrm{{d}}r}< 0\). At the surface of the star, \(r= R_s\), the pressure p should vanish.

  • For an isotropic fluid sphere, the inquiries of the energy conditions are given by the following inequalities in every point:

    1. 1.

      Null energy condition (NEC): \(\rho > 0\).

    2. 2.

      Weak energy condition (WEC): \(p+\rho > 0\).

    3. 3.

      Strong energy condition (SEC): \(\rho +3p > 0\).

  • The causality condition which should be satisfied to obtain a realistic model, i.e., the speed of sound should be less than 1 (provided that the speed of light is \(c = 1\)) in the interior of the star, i.e., \(1\ge \frac{\mathrm{{d}}p}{\mathrm{{d}}\rho }\ge 0\).

  • To obtain a stable model, the adiabatic index must be greater than \(\frac{4}{3}\).

It is time to analyze the above conditions to see whether we have a real isotropic star.

5 Physical behavior of our model

To test whether our model given by Eqs. (22) and (24) agrees with a real stellar construction, we discuss the following issues:

5.1 Non-singular model

  1. 1.

    The metric potentials of this model satisfy

    $$\begin{aligned} a(r\rightarrow 0)=\frac{\textrm{e}^c}{\left( 1+K\rho _c\right) ^4}\quad \text {and} \quad a_1(r\rightarrow 0)=1\, , \end{aligned}$$
    (40)

    which yields that the metric potentials have finite values at the center of the star configuration. Additionally, the derivatives of these metric potentials vanish at the center of the star, i.e., \(a'(r\rightarrow 0)=a'_1(r\rightarrow 0)=0\). If the derivatives do not vanish even if they are finite, there appear conical singularities at the center. The above constraints yield that the metric is regular at the center and that the metric has good behavior in the interior of the star.

  2. 2.

    Density (26) and pressure (21), at the center, have the form

    $$\begin{aligned} \rho (r\rightarrow 0)=\rho _c\, , \quad p(r\rightarrow 0)=K{\rho _c}^2\, . \end{aligned}$$
    (41)

    The above Eq. (41) clearly shows that the density and pressure at the center of the star always have positive values if \(\rho _c>0\) and \(K>0\); otherwise they become negative.

  3. 3.

    The gradients of density and pressure of our model are given respectively as

    $$\begin{aligned} \rho '=-\frac{2\rho _c r}{{R_s}^2}\, , \quad p'=-\frac{4K\rho _c r \left( 1-\frac{r^2}{{R_2}^2}\right) }{{R_2}^2}\,. \end{aligned}$$
    (42)

    Here, \(\rho '=\frac{\mathrm{{d}}\rho }{\mathrm{{d}}r}\) and \(p'=\frac{\mathrm{{d}}p}{\mathrm{{d}}r}\). Equation (42) shows that the derivatives of density and pressure are negative. Furthermore, because they vanish at the center of the star, the conical singularities do not appear.

  4. 4.

    The velocity of sound using relativistic units, i.e., \((c=G=1)\), are derived as [89]

    $$\begin{aligned} {v_r}^2=\frac{\mathrm{{d}}p}{\mathrm{{d}}\rho }=\frac{2\rho _c \left( {R_s}^2 -r^2 \right) }{{R_s}^2}\, . \end{aligned}$$
    (43)

Now we are ready to plot all the above conditions to examine their behaviors using the numerical constraints listed in Eq. (35).

In Fig. 1a and b, we present the behavior of metric potentials. As Fig. 1 shows, the metric potentials assume the values \(a_1(r\rightarrow 0)=1\) and \(a(r\rightarrow 0)=0.5\) for \(r=0\), which ensure that both of the metric potentials have finite and positive values at the center of the star.

Fig. 1
figure 1

Schematic plot of the metric potentials (26) and (29) vs. the radial coordinate r using the constraints (35)

Now we plot the energy density and pressure, listed by Eqs. (21) and (26) in Fig. 2.

Fig. 2
figure 2

Plot of the energy density and pressure of (21) and (26) vs. the radial coordinate r using the constraints (35)

Figure 2 shows that the energy density and pressure are positive, which is in agreement for a realistic stellar configuration. Additionally, as Fig. 2a and b indicate, the density and pressure have high values at the center and decrease toward the boundary, which is relevant for a realistic star.

Fig. 3
figure 3

Plot of the gradients of density and pressure of (21) and (26) vs. the radial coordinate r using the constraints (35)

Figure 3 shows that the derivatives of density and pressure have negative values, which ensure the decrease in density and pressure throughout the stellar configuration.

Fig. 4
figure 4

Plot of the speed of sound (a), mass–radius relation (b), and compactness of the stellar (c) via the radial coordinate r using the constraints (35)

In Fig. 4, we plot the speed of sound and the mass–radius relation. As Fig. 4a shows, the speed of sound is less than 1, which confirms the non-violations of causality condition in the interior of the stellar configuration. Moreover, Fig. 4c shows that the compactness of our model is constrained by \(0<C<0.55\), where \(C=\frac{M}{r}\) in the stellar configuration. As Fig. 4a shows, the causality condition is satisfied, which is one of the advantages in this study due to the procedure we follow, although in the frame of GR, it is shown that this condition is not satisfied [90]. We may infer that the procedure used in this study is responsible for the correction in the behavior of the causality condition. Moreover, also as in [90], it is shown that the maximum mass lies in the range \(0.2 \, M_\odot \). In our model, however, due to the procedure we follow in this study, the maximum mass is about \(0.25\, M_\odot \), as shown in Fig. 4b, which could be used to be compared with the recent data.

Fig. 5
figure 5

Plot of the null, weak, and strong energy conditions of (21) and (26) vs. the radial coordinate r using the constraints (35)

Figure 5 shows the behavior of the energy conditions. In particular, Fig. 5a–c indicate the positive values of the NEC, WEC, and SEC energy conditions, which ensure that all the conditions are verified through the stellar configuration as it should be for a physical stellar model.

Fig. 6
figure 6

Plot of the EoS vs. the radial coordinate r (a) and the red shift (b) using the constraints (35)

In Fig. 6, we plot the EoS. As Fig. 6a shows, the EoS is not linear. It was shown in [91] that the EoS of neutral compact stars is almost a linear one, in contrast to the EoS presented in this study, which shows a nonlinear form due to the form of the pressure given by Eq. (21).

6 Stability of the model

Now we are ready to test the stability issue on our model using the adiabatic index. The stable equilibrium of a spherically symmetric spacetime can be investigated through the adiabatic index, which is an ingredient tool to test the stability criterion. The adiabatic perturbation, i.e., the adiabatic index \(\Gamma \), is defined as [92,93,94]

$$\begin{aligned} \Gamma =\left( \frac{\rho +p(r)}{p(r)}\right) \left( \frac{\mathrm{{d}}p(r)}{\mathrm{{d}}\rho (r)}\right) \,. \end{aligned}$$
(44)

A Newtonian isotropic sphere has a stable equilibrium if the adiabatic index \(\Gamma >\frac{4}{3}\) [95]. If \(\Gamma =\frac{4}{3}\), the isotropic sphere is in neutral equilibrium.

Fig. 7
figure 7

Plot of the adiabatic index using the constraints (35)

Using Eq. (44), we obtain

$$\begin{aligned} \Gamma =\frac{2 \left( {R_s}^2 \left[ 1+\rho _c \right] -\rho _c r^2 \right) }{{R_s}^2}\, . \end{aligned}$$
(45)

In Fig. 7, we depict the adiabatic index \(\Gamma \). As is clear from Fig. 7, the value of \(\Gamma \) is greater than \(\frac{4}{3}\) throughout the stellar interior, and therefore the stability condition is satisfied.

7 Discussion and conclusions

In the present research, we considered the spherically symmetric and static configuration of the compact star by using the EGBS. In our formulation, for any given spherically symmetric and static profile of the energy density \(\rho \) and for an arbitrary EoS of matter, we can construct the model which reproduces the profile. Because the profile of the energy density determines the mass M and the radius \(R_s\) of the compact star, an arbitrary relation between the mass M and the radius \(R_s\) of the compact star can be realized by adjusting the potential \(V(\xi )\) and the coefficient function \(f(\xi )\) of the GB term in (3). This could be regarded as a degeneracy between the EoS and the functions \(V(\xi )\) and \(f(\xi )\) characterizing the model, which indicates that the mass–radius relation alone is insufficient to constrain the model.

As a concrete example, by using the polytrope EoS (21) and assuming the profile of the energy density \(\rho (r)\) in (26), we have constructed a model and discussed the properties. The derived analytic solution is investigated analytically and graphically using different tests to assess the physical relevance of the derived solution.

In this regard, we discovered that the energy density and pressure decrease as the radial coordinates approach the surface of the star Fig. 1. This clearly indicates that the center of the star is highly compact and the model under consideration is valid for the region outside the center of the star. Additionally, we have explained analytically and graphically in Fig. 5 that all the energy conditions are verified throughout the interior of the stellar configuration. According to Herrera [89], any stable solution must yield a square of sound speed, \(v^2\), to lie in the interval \(v^2\in [0, 1]\). In this model, we have shown that the speed of sound lies in the required interval, confirming that the solution obtained in our model is stable. Also, the calculation of the adiabatic index of our model is in excellent agreement with the stability condition as shown in Fig. 7 (right panel). We have depicted the mass–radius relation as shown in Fig. 4 (middle panel). As this figure shows, the mass M takes a positive value through the interior of the star. Additionally, it is easy to prove that as \(r\rightarrow 0\), we obtain \(M\rightarrow 0\), which ensures that M is regular at the core of the star. We also showed that the procedure used in this study can significantly enhance the mass, corroborating recent observations of some massive two-solar mass neutron stars. Moreover, as Buchdahl [96] has shown, for static spherically symmetric isotropic matter content, the ratio between the mass and the radius should be \(\frac{M}{R}<\frac{4}{9}\). In this study, the ratio \(\frac{M}{R_s}=\frac{1}{4}\) (see Fig. 4, middle panel) shows that the Buchdahl condition is satisfied. The compactification \(C=\frac{M}{R_s}\) has been depicted in Fig. 4 (right panel), which shows that the compactness should be \(0<C<0.55\). In Fig. 6 (right panel), we have shown that the profile of the surface redshift is less than 2 as required for an isotropic model without a cosmological constant. It has been shown that the upper limit of surface redshift is 2, which is in agreement with our stellar configuration [96,97,98].

In the present study, we have assumed that a physical energy density is given by Eq. (26), as it has a finite value at the center of the star \(\rho _c\) and it is finite at the surface of the star, which is consistent with realistic compact stars. Also, the metric potentials of this construction are physical because they are singularity-free, as \(r\rightarrow 0\), and have finite values at the surface of the star. Additionally, the mass of the star in the model under consideration has a finite value at the center as well as at the surface of the star. Moreover, the constructed model yields a consistent form of the GB term, and the scalar field \(\xi \), the potential \(V(\xi )\), and the coefficient function \(f(\xi )\) have finite value, as \(r\rightarrow 0\). Also, we have shown that the model under consideration is stable and its adiabatic index is greater than \(\frac{4}{3}\), which is consistent with observations.

Remarkably, NICER (Neutron star Interior Composition Explorer) observations of PSR J0030+0451 and PSR J0740+6020 offer indications against the more squeezable models. The latter has significantly more mass than the former, although they are nearly the same size. So it is reasonable to suppose some processes to rationalize the non-squeezability of a neutron star as its mass increases. On the other hand, the presence of high-mass pulsars\(\sim 2M_\odot \) such as PSR J0740+6020 is known to prefer violation of the upper sound speed conformal limit \(v^2\le 1/3\), posing another challenge for theoretical models even in low-density cases, as demonstrated by Bedaque and Steiner [99] (see also [100, 101]). In their study of the pulsar PSR J0740+6020, Legred et al. [102] concluded that the conformal sound speed is strongly violated at the neutron star core, where \(v^2= 0.75\) with density \( 3.60 {\rho }_\mathrm {nuc.}\). It is important to mention that such an issue does not appear in our constructed model, as shown in Fig. 4a.

To conclude, to the best of our knowledge, that this is the first study to derive an analytic isotropic spherically symmetric interior solution in the frame of EGBS theory. From the above analysis, we ensure that the derived solution in this study met all the physical requirements of any isotropic stellar configuration in the frame of this theory. An isotropic model in the frame of Rastall’s theory is derived using the technique of conformal killing vectors [103]. In this model, the authors showed that the maximum value of the compactness in their model was 0.028742 and the redshift was 0.09444. If we compare our results with those presented in [103], we see that the compactness and redshift of our model are greater than the ones presented in [103]. This means that the nonlinear form of the EoS has a greater effect on the structure of the model than the conformal killing vector. An isotropic model is also constructed in the framework of F(RT), where R is the Ricci scalar and T is the trace of the energy–momentum tensor. It was shown that the model constructed in [104] suffers from a violation of the dominant energy condition (DEC), whereas it is satisfied in the model under consideration. Moreover, it was shown that in the model constructed in [104], its energy density configuration is nonuniform, which corresponds to a quasi-constant density configuration, but our model did not possess a such defect.