1 Introduction

In theoretical astrophysics there is a growing interest to discuss the stellar structures in which the matter content is an anisotropic fluid. The effect of anisotropy can be studied both in Newtonian gravity and general relativity. For the configurations with not extremely high densities, the presence of an anisotropy factor has been discussed in the Newtonian regime [13] and otherwise general relativity must be used.

In 1972 Ruderman [4] for the first time argued that the nuclear matter may have anisotropic features in the very high density regime (\({>}10^{15} \frac{\mathrm{gr}}{\mathrm{{cm}}^3}\)) and thus the nuclear interaction needs to be treated from a relativistic point of view. After the pioneering work of Bowers and Liang [5] in 1974, the study of anisotropic distribution of matter got wide attention. Anisotropy arises due to the existence of solid stellar core or by the presence of type-IIIA superfluid [6, 7], phase transitions, pion condensation in a star [8], electromagnetic field [911], rotation, etc. For an exhaustive review on the anisotropic pressure see [12], and a comprehensive study of this topic may be found in [13].

Most studies assume that the matter of the anisotropic star is described by an equation of state relating the radial pressure \(P_\mathrm{r}\) or transversal pressure \(P_\perp \) to the energy density \(\rho \). The polytropic equation of state is one of the most important choices for a state equation which has a wide range of applications [1417]. There are two possible cases of the polytropic equation of state, namely: the radial pressure is proportional to the baryonic density, or it is proportional to the total energy density. Here we consider the latter case, \(P_\mathrm{r}=K\rho ^\gamma \), where \(\gamma =1+\frac{1}{n}\) is the polytropic exponent, \(\rho \) is the total energy density and n to the energy density For \(n=2\), the exact solutions of Einstein’s field equations for an anisotropic sphere have been obtained by Thirukkanesh and Ragel [18].

The anisotropic model has been investigated for uniform matter density in [19] and for variable density distribution in [20, 21].

Anisotropic pressure can affect the stability of the stellar objects. Following the Bondi formalism, the stability of a locally anisotropic fluid was first studied in [22].A general study of this issue, following the Chandrasekhar formalism [23], was reported in [2426]. Dev and Gleiser [2, 27, 28] have extended the variational formalism of Chandrasekhar for an isotropic star to study the stability of anisotropic general relativistic spheres against radial perturbations. Assuming some specific density profiles and the adiabatic exponent, they have found that there can exist stable relativistic anisotropic spheres leading to instability in isotropic spheres.

Here our main purpose is to obtain the exact solutions of general relativistic star equations in the presence of anisotropic pressure. Maharaj and Sharma [29] have obtained some exact solutions of compact anisotropic stars analytically by assuming a linear equation of state with an appropriate ansatz.

The investigation of anisotropic configurations was not restricted to static spherically symmetric cases. All possible static cylindrical symmetric solutions are analyzed in [30], satisfying the conformal flatness condition. Also in [31], the stationary case is studied in detail. A general study of this issue has been presented in [32].

Also the modeling of dense charged gravitating objects in strong gravitational fields has attracted much interest in recent years because of its relevance to relativistic astrophysics [33]. The investigation of these objects requires an exact solution of the Einstein–Maxwell system. An anisotropic fluid with a linear, quadratic, and polytropic equation of state in the presence of an electromagnetic field is studied in [3438].

The importance of an equation of state in a stellar model has been emphasized by Varela et al. [39] who provided a mechanism of dealing with charged anisotropic matter in a general approach. Also the exact solutions for a charged anisotropic quark star have been reported by Sunzu et al. [40].

Anisotropy can exist not only in ordinary compact stars but also in hypothetical objects like boson stars [41] and gravastars [42]. Besides the isolated objects in astrophysics, anisotropy is present in globular clusters, galactic bulges, and dark halos [43, 44].

In this paper we want to discuss the anisotropic polytropes in the context of general relativity. In the next section we derive the relativistic Lane–Emden equations in the presence of anisotropy factor. Then we obtain their boundary conditions and generalize the Chandrasekhar’s theorem [45] to the anisotropic case. In Sect. 3, first we find a series expansion for the dimensionless Lane–Emden function, \(\theta \), and the anisotropy factor, \(\Delta \), near the center of star. Then in order to obtain the exact solutions, we have assumed that the presence of anisotropy factor does not change the general form of the relativistic hydrostatic equilibrium equations. This ansatz leads us to find a new class of exact solutions for the anisotropic Lane–Emden equations for constant density. This procedure is different from the usual approach [2, 18, 46] which is to suppose an ansatz on the form of anisotropy factor and try to get the physical solution of the equations. At the end in Sect. 4, we present a summary of the main conclusions.

2 Relativistic anisotropic polytropes

Since we deal with the static and spherically symmetric configurations, we use the following metric:

$$\begin{aligned} \mathrm{d}s^2=\exp {[\nu (r)]}\mathrm{d}t^2-\exp [{\kappa (r)}]\mathrm{d}r^2-r^2\mathrm{d}\Omega ^2\,, \end{aligned}$$
(1)

The components of the energy-momentum tensor for anisotropic matter are

$$\begin{aligned} T^0_0=\rho c^2; \quad T^1_1=-P_\mathrm{r}; \quad T^2_2=T^3_3=-P_{\perp }; \end{aligned}$$
(2)
$$\begin{aligned} T^j_k=0 \quad if \quad j\ne k. \end{aligned}$$

So the Einstein field equations become

$$\begin{aligned} \exp {(-\kappa )} \left[ \frac{1}{r}\frac{\mathrm{d}\nu }{\mathrm{d}r}+\frac{1}{r^2} \right] -\frac{1}{r^2}=\frac{{8\pi G} P_\mathrm{r}}{c^4}, \end{aligned}$$
(3)
$$\begin{aligned} \exp {(-\kappa )} \left[ \frac{1}{r}\frac{\mathrm{d}\kappa }{\mathrm{d}r}-\frac{1}{r^2} \right] +\frac{1}{r^2}=\frac{{8\pi G}\rho }{c^2}, \end{aligned}$$
(4)
$$\begin{aligned}&\frac{1}{2}\exp {(-\kappa )} \left[ \frac{\mathrm{d}^2 \nu }{\mathrm{d}r^2}+\frac{1}{2} \left( \frac{\mathrm{d}\nu }{\mathrm{d}r} \right) ^2 +\frac{1}{r} \left( \frac{\mathrm{d}\nu }{\mathrm{d}r}-\frac{\mathrm{d}\kappa }{\mathrm{d}r} \right) \right. \nonumber \\&\qquad \left. -\frac{1}{2} \left( \frac{\mathrm{d}\nu }{\mathrm{d}r} \right) \left( \frac{\mathrm{d}\kappa }{\mathrm{d}r} \right) \right] =\frac{{8\pi G} P_{\perp }}{c^4}, \end{aligned}$$
(5)

and the radial component of the Bianchi identities reduces to the equation of hydrostatic equilibrium:

$$\begin{aligned} \frac{\mathrm{d}P_\mathrm{r}}{\mathrm{d}r}=\frac{-1}{2}\frac{\mathrm{d}\nu }{\mathrm{d}r}(P_\mathrm{r}+\rho c^2)+\frac{2\Delta }{r}, \quad \Delta =P_{\perp }-P_\mathrm{r}. \end{aligned}$$
(6)

In fact this equation can be obtained from Eq. (3)–(5) and usually it is convenient to use it instead of (5). The set of equations (3), (4), and (6) contain five unknown functions, \(\kappa (r)\), \(\nu (r)\), \(P_\mathrm{r}(r)\), \(P_{\perp }(r)\), and \(\rho (r)\), and we have to add two more equations to make the set of equations closed. To do this, we use the polytropic equation of state and introduce a new ansatz for the anisotropy factor, which is explained in the next section.

To obtain a unique solution of the Einstein equations, one must also specify the boundary conditions. Outside the star, the spacetime geometry is described by the Schwarzschild metric. Thus we have

$$\begin{aligned} \kappa =-\nu =-\ln {\left( 1-\frac{2GM}{c^2 r} \right) } \quad \mathrm{for} \quad r \ge R \end{aligned}$$
(7)

where R is the radius of star and M is its mass. By integrating (4) with initial condition \(\kappa (0)=0\) (in order to avoid a singularity, \(\kappa \) must tend to zero at least as \(r^2\) for \(r \rightarrow 0\)), we get

$$\begin{aligned} \kappa =-\ln \left[ 1-\left( \frac{8\pi G}{r c^2} \right) \int _0^r\rho r^2 \mathrm{d}r \right] . \end{aligned}$$
(8)

By defining the auxiliary function

$$\begin{aligned} u(r)=c^2 r\frac{[1-\exp {(-\kappa )}]}{2GM}=\frac{M(r)}{M}; (u(0)=0 , u(R)=1),\nonumber \\ \end{aligned}$$
(9)

Equation (4) becomes

$$\begin{aligned} M\frac{\mathrm{d}u(r)}{\mathrm{d}r}=4\pi \rho r^2, \end{aligned}$$
(10)

where M(r) is the relativistic mass inside the radius r:

$$\begin{aligned} M(r)=4\pi \int _0^r \rho r^2 \mathrm{d}r. \end{aligned}$$
(11)

By using (6) and (9), we can obtain the Tolman–Oppenheimer–Volkov (TOV) equation of hydrostatic equilibrium for the spherically static anisotropic star from (3):

$$\begin{aligned} \frac{\mathrm{d}P_\mathrm{r}}{\mathrm{d}r}=\frac{-G \left( \rho +\frac{P_\mathrm{r}}{c^2} \right) \left[ M(r)+\frac{4\pi P_\mathrm{r}}{c^2} r^3 \right] }{r^2 \left[ 1-\frac{2GM(r)}{c^2r} \right] }+\frac{2\Delta }{r} \end{aligned}$$
(12)

As is obvious, vanishing \(\Delta \) recovers the TOV equation for isotropic star. Moreover, in the non-relativistic limit (\(c\rightarrow \infty \)), one can easily obtain the anisotropic Jeans equation for the radial pressure:

$$\begin{aligned} \frac{\mathrm{d}P_\mathrm{r}}{\mathrm{d}r}=\frac{-G\rho M(r)}{r^2}+\frac{2\Delta }{r} \,. \end{aligned}$$
(13)

The boundary conditions of (12) are

$$\begin{aligned} M(0)=0, \quad P_\mathrm{r}(0)=P_0 \,, \end{aligned}$$
(14)
$$\begin{aligned} M(R)=M, \quad P_\mathrm{r}(R)=0 \,. \end{aligned}$$
(15)

These conditions imply that the radial pressure is finite at the origin and vanishes at the surface of star. The mass function M(r) goes to zero at the origin and reduces to the total mass at the surface. For a specified \(\Delta \) and implicating the equation of state

$$\begin{aligned} P_\mathrm{r}=P_\mathrm{r}(\rho ), \end{aligned}$$
(16)

we obtain a closed system of equations, (11), (12), and (16). Then the metric coefficients are given by (6) and (10).

As we have mentioned before, for many astrophysical applications, assuming the polytropic equation of state enables one to make an approximate model of a star. One can always parametrize this equation by introducing the Lane–Emden function defined by

$$\begin{aligned} P_\mathrm{r}=P_0\theta ^{n+1}, \quad \rho =\rho _0\theta ^n \end{aligned}$$
(17)

where \(\rho _0\) and \(P_0\) are the central values of relativistic density and pressure. With respect to this new function, Eq. (6) becomes

$$\begin{aligned} 2q_0(n+1)\frac{\mathrm{d}\theta }{\mathrm{d}r}-\frac{4\Delta }{r\theta ^n\rho _0}+(q_0\theta +1)\frac{\mathrm{d}\nu }{\mathrm{d}r}=0, \end{aligned}$$
(18)

where

$$\begin{aligned} q_0=\frac{P_0}{\rho _0 c^2}\,. \end{aligned}$$
(19)

This equation yields

$$\begin{aligned} \nu =\nu _0+\ln { \left( \frac{1+q_0}{1+q_0\theta } \right) ^{2(n+1)}}-\frac{4}{\rho _0c^2}\int _0^r\frac{\Delta \mathrm{d}r}{r\theta ^n (q_0\theta +1)}, \end{aligned}$$
(20)

where the integration constant \(\nu _0\) is the central value of \(\nu \). To find it, we use the fact that the value of the above expression is given by Eq. (7) at the surface of the star. This yields

$$\begin{aligned} \nu _0=\ln {\frac{1-\frac{2GM}{Rc^2}}{(1+q_0)^{2(n+1)}}}+\frac{4}{\rho _0 c^2}\int _0^R\frac{\Delta \mathrm{d}r}{r\theta ^n (q_0\theta +1)}. \end{aligned}$$
(21)

So we can write the metric coefficient \(\nu (r)\) in terms of \(\theta \) and \(\Delta \) as

$$\begin{aligned} \nu (r)=\ln {\frac{1-\frac{2GM}{Rc^2}}{(1+q_0\theta )^{2(n+1)}}}+\frac{4}{\rho _0 c^2}\int _r^R\frac{\Delta \mathrm{d}r}{r\theta ^n (q_0\theta +1)}. \end{aligned}$$
(22)

Substituting \(e^{-\kappa }\) from (9) and \(\frac{\mathrm{d}\nu }{\mathrm{d}r}\) from (18) into Eq. (3), and using (10), the above equation reduces to

$$\begin{aligned}&\frac{q_0 (n+1)\frac{\mathrm{d}\theta }{\mathrm{d}r} r}{(1+q_0\theta )} \left( 1-\frac{2GM}{rc^2}u \right) +\frac{GMu}{rc^2}+\frac{GMq_0\theta }{c^2}\frac{\mathrm{d}u}{\mathrm{d}r}\nonumber \\&\quad +\frac{2\Delta }{\rho _0 c^2 \theta ^n (1+q_0\theta )}\left( 1-\frac{2GMu}{rc^2} \right) =0. \end{aligned}$$
(23)

Now defining the dimensionless parameters \(\xi \) and \(\eta \):

$$\begin{aligned} \eta =\frac{M}{4\pi \rho _0 \alpha ^3}u \,, \quad r=\alpha \xi , \end{aligned}$$
(24)

whereFootnote 1 \(\alpha ^2=\pm \frac{(n+1)P_0}{4\pi G \rho _0^2}\), Eqs. (10) and (23) take the following form:

$$\begin{aligned}&\frac{\pm \xi -2q_0(n+1){\eta }}{1+q_0\theta } \left( \xi \frac{\mathrm{d}\theta }{\mathrm{d}\xi }+2\frac{\Delta }{\rho _0 c^2 \theta ^n (n+1)q_0}\right) \nonumber \\&\quad +\eta +q_0\theta \xi \frac{\mathrm{d}\eta }{\mathrm{d}\xi }=0,\end{aligned}$$
(25)
$$\begin{aligned}&\frac{\mathrm{d}\eta }{\mathrm{d}\xi }=\theta ^n\xi ^2, \end{aligned}$$
(26)

which are the general relativistic Lane–Emden equations for anisotropic polytropes. In the non-relativistic limit, according to (19), \(q_0 \sim 0\) and one can recover the Newtonian anisotropic Lane–Emden equation [3]. Also setting \(\Delta =0\), the isotropic Lane–Emden equation is obtained.

In Eq. (25) if \(\xi \) tends to zero, we will have

$$\begin{aligned} \frac{\mathrm{d}\theta }{\mathrm{d}\xi }|_{\xi \rightarrow 0}=\frac{\mp 2\Delta (0)}{\rho _0c^2(n+1)q_0 \xi }|_{\xi \rightarrow 0}. \end{aligned}$$
(27)

So we arrive at the following theorem.

Theorem

The finite solutions of relativistic anisotropic Lane–Emden equations at the origin have to satisfy the following relations:

$$\begin{aligned} \frac{\mathrm{d}\theta }{\mathrm{d}\xi }|_{\xi \rightarrow 0}=\frac{\mp 2\Delta (0)}{\rho _0c^2(n+1)q_0 \xi }|_{\xi \rightarrow 0}, \quad \theta (0)=1, \quad \eta (0)=0. \end{aligned}$$
(28)

This is the generalization of Theorem 1 in [3] for the relativistic anisotropic case.

3 Analytical solutions of relativistic Lane–Emden equation

In this section we shall discuss how one can solve the Lane–Emden equations (25), (26) with the boundary conditions (28). These are a system of two equations for three unknowns, the function \(\theta (\xi )\), \(\Delta (\xi )\), and \(\eta (\xi )\). To solve these equations, we need another equation. One can assume either a special form for one of the above functions or a mathematical relation between these functions in order for the set of equations to be closed. Here we use the latter approach, which is explained in Sect. 3.2.

First in Sect. 3.1 we find a series expansion of \(\theta (\xi )\), \(\Delta (\xi )\), and \(\eta (\xi )\) near the center of anisotropic star. For the isotropic case one can find the corresponding series expansion in [14] and the references in it. That is,

$$\begin{aligned} \theta \approx 1+ a \xi ^2 + b \xi ^4+ \cdots , \end{aligned}$$
(29)
$$\begin{aligned} \eta =\frac{\xi ^3}{3}+na\frac{\xi ^5}{5}+\frac{[nb+n(n-1)\frac{a^2}{2}]\xi ^7}{7}, \end{aligned}$$
(30)

where

$$\begin{aligned} a=\mp \frac{(\frac{1}{3}+4\frac{q_0}{3}+q_0^2)}{2}, \end{aligned}$$
(31)
$$\begin{aligned} b= & {} \left[ \frac{n}{15}+\frac{2nq_0}{9}+\left( \frac{16n}{45}+\frac{2}{3}\right) q_0^2\right. \nonumber \\&\left. +\left( \frac{6n}{5}+\frac{8}{3}\right) q_0^3+(n+2)q_0^4 \right] /8\,. \end{aligned}$$
(32)

In Sect. 3.2 we shall solve the Lane–Emden equations assuming the density is constant throughout the star. A similar calculation for an isotropic star has been derived by Tooper [47]. In this case, the variables \(\theta \) and \(\eta \) are separable and the exact analytical solutions of (25) and (26) for \(\Delta =0\), are [47]

$$\begin{aligned} \theta= & {} \frac{\left[ (1+3q_0)\sqrt{1-\frac{2q_0\xi ^2}{3}}-(1+q_0) \right] }{q_0 \left[ 3(1+q_0)-(1+3q_0)\sqrt{1-\frac{2q_0\xi ^2}{3}} \right] }, \end{aligned}$$
(33)
$$\begin{aligned} \eta= & {} \frac{\xi ^3}{3}. \end{aligned}$$
(34)

3.1 Series expansion

Near the center of star, we assume that

$$\begin{aligned} \theta (\xi ) = \sum _{k=0}^{\infty } a_k \xi ^k, \end{aligned}$$
$$\begin{aligned} \Delta (\xi ) = \sum _{k=0}^{\infty } b_k \xi ^k, \end{aligned}$$
(35)
$$\begin{aligned} \eta (\xi ) = \sum _{k=0}^{\infty } d_k \xi ^k. \end{aligned}$$

Inserting these expressions into the Lane–Emden equations (25) and (26), we get

$$\begin{aligned} a_0=1, \quad a_1=\frac{\pm 2 \Delta '(0)}{\rho c^2 (n+1)q_0 }, \quad a_2=\mp \frac{1}{2} \left( \frac{1}{3}+q_0^2+\frac{4}{3}q_0 \right) , \end{aligned}$$
(36)
$$\begin{aligned} b_0=0, \quad b_1=\Delta '(0), \end{aligned}$$
(37)
$$\begin{aligned} d_1=0, \quad d_2=0, \quad d_3=\frac{1}{3}, \quad d_4=\frac{\mp 2n \Delta '(0)}{4c^2(n+1)q_0}\,, \end{aligned}$$
(38)

provided that the pressure and density gradient (and also \(\Delta (0)\) according to Eq. (28)) are finite at the center of star. Thus if \(r\rightarrow 0\), \(\eta \approx \xi ^3\), \(\Delta \approx \xi \), and \(\theta \approx 1\). Comparing Eqs. (36)–(38) with (31) and (32), one can find how the anisotropy factor affects the behavior of quantities near the center of star.

3.2 An exact solution

Following [3], we assume that the presence of \(\Delta \) does not change the forms of the isotropic Lane–Emden equations and it only modifies the coefficients of these equations. To do this, noting Eq. (18), we introduce a constant m such that (hereafter we set \(c=1\))

$$\begin{aligned} 2q_0 (n+1) \mathrm{d}\theta -\frac{4\Delta }{r\rho _0{\theta }^n}\mathrm{d}r=2q_0(m+1)\mathrm{d}\theta . \end{aligned}$$
(39)
Fig. 1
figure 1

Anisotropy factor as a function of \(\xi \) for different values of k and \(q_0\)

Substituting this into Eq. (18) and integrating it, the metric coefficient \(\nu (r)\) becomes

$$\begin{aligned} \nu (r)=\ln \left[ \frac{(1-\frac{2GM}{R})}{(1+q_0\theta )^{2(m+1)}} \right] , \end{aligned}$$
(40)

which is identical to the isotropic one [14] in which the coefficient n has changed to m. Using Eqs. (9) and (40) and defining a dimensionless parameter \(\xi \) such that

$$\begin{aligned} r=\tilde{\alpha }\xi \qquad (m\ne -1,\pm \infty ), \end{aligned}$$
(41)

where \( \tilde{\alpha }=[\pm \frac{(m+1)P_0}{4\pi G \rho _0^2}]^{\frac{1}{2}}\). Equations (25) and (26) reduce to

$$\begin{aligned}&\left\{ \frac{[\pm 1 - 2q_0(m+1)\frac{\eta }{\xi }]}{1+q_0 \theta } \right\} \xi ^2 \frac{\mathrm{d}\theta }{\mathrm{d}\xi }+\eta + q_0\xi \theta \frac{\mathrm{d}\eta }{\mathrm{d}\xi }=0, \end{aligned}$$
(42)
$$\begin{aligned}&\frac{\mathrm{d}\eta }{\mathrm{d}\xi }=\theta ^n\xi ^2. \end{aligned}$$
(43)

Equations (42) and (43) are the extended forms of the relativistic Lane–Emden equations for anisotropic configurations, resulting by our ansatz described above.

Here we want to obtain the analytical solution of anisotropic Lane–Emden equations for constant density. For \(n=0\), a solution of Eqs. (42) and (43) satisfying the initial conditions (28) is

$$\begin{aligned} \theta =\frac{(1+3q_0){(1-\frac{q_0\xi ^2}{2k})}^{\frac{2k}{3}}-(1+q_0)}{q_0[3(1+q_0)-(1+3q_0){(1-\frac{q_0\xi ^2}{2k})}^{\frac{2k}{3}}]}, \end{aligned}$$
(44)

in which \(k=\frac{3}{4(m+1)}\) is a natural number and \(q_0 > 0\). This solution vanishes at

$$\begin{aligned} \xi _R=\sqrt{\frac{2k}{q_0}\left[ 1-\left( \frac{q_0+1}{3q_0+1}\right) ^{\frac{3}{2k}} \right] }, \end{aligned}$$
(45)

which is the dimensionless value of the radial coordinate at the boundary. Thus we find that

$$\begin{aligned} \frac{\Delta }{P_0}= \frac{(1+q_0)(1+3 q_0) (3-4 k) \xi ^2 \left( 1-\frac{q_0 \xi ^2}{2 k}\right) ^{-1+\frac{2 k}{3}} }{6 k \left( -3 (1+q_0)+(1+3 q_0) \left( 1-\frac{q_0 \xi ^2}{2 k}\right) ^{2 k/3}\right) ^2}. \end{aligned}$$
(46)

With suitable choices of k and \(q_0\), the equations of (44) and (46) present a new class of solutions for an anisotropic constant-density star.

This solution can be considered as a well-defined solution if the physical quantities like the anisotropy factor are finite inside the star. It can easily be shown that for all values of \(q_0\) and k, the anisotropy factor (46) is finite. Also if \(q_0\ge 1\), the anisotropy factor has a local maximum inside the star but this is not true for \(q_0 < 1\). Here in Fig. 1 we have plotted \(\frac{\mid \Delta \mid }{P_0}\) as a function of \(\xi \) for some values of \(q_0\) and k. For any choice, the plots are from the center to the corresponding radius of the star. The radial pressure is plotted in Fig. 2 for the same values of k and \(q_0\) as in Fig. 1. Now it becomes clear that it is a positive regular function everywhere inside the star. It starts with its local maximum value at the center of the star and gradually decreases until it vanishes at the surface of star.

Fig. 2
figure 2

Radial pressure as a function of \(\xi \) for different values of k and \(q_0\)

Fig. 3
figure 3

Dominant energy condition as a function of \(\xi \) for different values of k and \(q_0\)

In [48], it is shown that all static anisotropic spherically symmetric solutions of Einstein’s equations can be produced by two generating functions. One of them is proportional to the anisotropy factor, \(\Pi (\xi )=-8\pi G \Delta (\xi )\), and the other, \(z(\xi )\), is defined by

$$\begin{aligned} \exp {[\nu (\xi )]}=\exp {\int { \left[ 2z(\xi )-\frac{2}{\alpha \xi }\right] \alpha \mathrm{d}\xi }}. \end{aligned}$$
(47)

Using (40) and (46), the generating functions of our solution are

$$\begin{aligned}&\Pi (\xi )\nonumber \\&\quad =-8\pi G P_0 \frac{(1+q_0)(1+3 q_0) (3-4 k) \xi ^2 \left( 1-\frac{q_0 \xi ^2}{2 k}\right) ^{-1+\frac{2 k}{3}} }{6 k \left( -3 (1+q_0)+(1+3 q_0) \left( 1-\frac{q_0 \xi ^2}{2 k}\right) ^{2 k/3}\right) ^2},\nonumber \\ \end{aligned}$$
(48)
$$\begin{aligned} z(\xi )= & {} \frac{1}{2 \alpha } \nonumber \\&\times \left[ \frac{2}{\xi }+\frac{2q_0 (1+3 q_0)\xi (1-\frac{q_0 \xi ^2}{2 k})^{2 k/3}}{(-2 k+q_0 \xi ^2)(-3+(1-\frac{q_0\xi ^2}{2 k})^{2 k/3}+3 q_0 (-1+(1-\frac{q_0 \xi ^2}{2 k})^{2k/3}))}\right] .\nonumber \\ \end{aligned}$$
(49)

Now let us to discuss the validity of the energy conditions. Since \(q_0\) is positive, the weak, null, and strong energy conditions hold for every positive value of central pressure. A simple calculation shows that for cases with \(0 < q_0 \le 1\), the dominant energy condition is satisfied in the same way as the other conditions. But for cases with \(q_0 > 1\), this condition is not satisfied within a radius of \(\sqrt{\frac{2k}{q_0}\{1-\frac{1}{2}[(1+\frac{2}{3}k)\sqrt{\frac{2(1+q_0)}{1+3q_0}}]^{\frac{3}{k}}\}}\) from the center of the star. In Fig. 3, we have plotted the dominant energy condition as a function of \(\xi \) for different values of \(q_0\) and k. While the dashed lines in each cases represent \(-\frac{1}{q_0}\) and \(\frac{1}{q_0}\), it is clear that for \(q_0=\frac{3}{2}\) there is a violation of the dominant energy condition.

Fig. 4
figure 4

Mass–radius relation as a function of \(\xi \) for different values of k and \(q_0\)

Other quantities of physical interest are the stellar radius and mass. To find these, one needs to find the radius of the star, \(R'\), measured by an external observer. This radius for an anisotropic polytropic sphere with constant density is

$$\begin{aligned} R'= & {} \int _0^R \exp \left[ \frac{\kappa (r)}{2}\right] \mathrm{d}r=\tilde{\alpha } \int _0^{\xi _R} \frac{\mathrm{d}\xi }{\sqrt{1-2q_0(m+1)\frac{\xi ^2}{3}}}\nonumber \\= & {} \tilde{\alpha } \left( \frac{3}{2q_0(m+1)} \right) ^{1/2}\arcsin {\left( \frac{2q_0(m+1)\xi _R^2}{3}\right) ^{1/2}}.\nonumber \\ \end{aligned}$$
(50)

For \(m=0\), Eq. (50) reduces to the corresponding radius in the case of isotropic star [14]. Now one can find the mass–radius relationship from (11):

$$\begin{aligned} M=4\pi \rho _0\tilde{\alpha }^3 \int _0^{\xi _R} \xi ^2 \mathrm{d}\xi =\frac{4\pi \rho _0\tilde{\alpha }^3 \xi _R^3}{3}, \end{aligned}$$
(51)

then according to Eq. (41)

$$\begin{aligned} M=\frac{(m+1)q_0 \xi _R^2 R}{3G}, \end{aligned}$$
(52)

and using the value of \(\xi _R\) (45), one can find the mass of an anisotropic star:

$$\begin{aligned} M=\frac{1}{3} \left( \frac{G}{4\pi \rho _0} \right) ^{\frac{1}{2}} \left\{ \frac{3}{2}\left[ 1-\left( \frac{q_0+1}{3q_0+1}\right) ^{\frac{3}{2k}}\right] \right\} ^{\frac{3}{2}}. \end{aligned}$$
(53)

To get the mass–radius relationship, one is required to evaluate the integrals of (50) and (51) with arbitrary radial coordinate which now appears as the upper limit of integrals. We thus get

$$\begin{aligned} \frac{M(r)}{r'}=\sqrt{\frac{128 (\rho _0 \pi G)^3}{27}}\frac{r^3}{\arcsin {[\frac{8}{3}\pi G \rho _0 r^2]^{1/2}}}. \end{aligned}$$
(54)

Here in order to plot the mass–radius relation we replace both M(r) and r with their dimensionless parameters \(\eta (\xi )\) and \(\xi \). Figure 4 shows the dimensionless form of the mass–radius relation (54) as a function of \(\xi \) for specified values of k and \(q_0\).

Also the internal compactness of the star can be written as follows:

$$\begin{aligned} \frac{M(r)}{r}=\sqrt{\frac{(4\pi G \rho _0)^3}{q_0(m+1)}}r^2, \end{aligned}$$
(55)

and correspondingly the surface redshift z(r) is given by

$$\begin{aligned} 1+z(r)=\left[ 1-2\frac{M(r)}{r}\right] ^{-1/2}= \left[ 1-2\sqrt{\frac{(4\pi G \rho _0)^3}{q_0(m+1)}}r^2 \right] ^{-1/2}. \end{aligned}$$
(56)

4 Concluding remarks

In this paper, we have discussed the relativistic Lane–Emden equations and their boundary conditions for an anisotropic star. We made a new proposal to find the exact solution of these equations for constant density. Noting Eq. (18), we assume that the effect of anisotropy is changing the coefficient of the first term from \(2 q_0(n+1)\) to \(2 q_0(m+1)\) or alternatively changing the coefficient of the third term from \((q_0\theta +1)\) to \(m(q_0\theta +1)\) where m is different from the polytropic index in general. The first case is studied in Sect. (3.2) in detail. For the second case using Eq. (18), one can introduce m such that

$$\begin{aligned} \frac{m}{2}[P_0\theta +\rho _0]\frac{\mathrm{d}\nu }{\mathrm{d}r}=\frac{1}{2}\frac{\mathrm{d}\nu }{\mathrm{d}r}(P_0\theta +\rho _0)+\frac{-2\Delta }{r}. \end{aligned}$$
(57)

So the resulting Lane–Emden equations will be

$$\begin{aligned} \left\{ \frac{[\pm 1 -\frac{2q_0(n+1)}{m}\frac{\eta }{\xi }]}{1+q_0\theta } \right\} \xi ^2 \frac{\mathrm{d}\theta }{\mathrm{d}\xi }+\eta +q_0\xi \theta \frac{\mathrm{d}\eta }{\mathrm{d}\xi }=0, \frac{\mathrm{d}\eta }{\mathrm{d}\xi }=\xi ^2 \theta ^n \end{aligned}$$
(58)

where the plus sign holds if \(-1<\frac{n+1}{m}<\infty \) and the minus sign if \(-\infty<\frac{n+1}{m}<-1\). In this case the dimensionless parameter \(\xi \) is introduced as r=\((\frac{\pm \frac{n+1}{m} q_0}{4\pi G \rho _0 })^{1/2}{\xi }\). These equations for \(n=0\) yield the same solution (44) and (46) in which \(k=\frac{3}{4}m\).