1 Introduction

A stellar object is worthless if it is not stable against perturbations in its physical variables (e.g. energy density and pressure anisotropy). The stability analysis of such objects is an interesting issue in general relativity and astrophysics. Bondi [1] was the pioneer to develop a hydrostatic equilibrium equation to examine the stability of self-gravitating spheres. Herrera [2] introduced the concept of cracking as well as overturning to describe the behavior of an isotropic and anisotropic matter distribution just after its deviation from an equilibrium state. Cracking is observed when the radial force is positive in the inner regions but negative at outer ones while overturning is produced for the reverse situation. In general, cracking and overturning occur when the total radial forces change their signs within the matter distribution.

In stellar objects, the pressure anisotropy is an important matter ingredient which affects their evolution and can be produced via different physical processes such as a phase transition and a mixture of two fluids, etc. [36]. Bowers and Liang [7] studied the static spherically symmetric anisotropic matter configuration and found an increase in surface redshift as well as equilibrium mass of the system. Gokhroo and Mehra [8] obtained solutions of anisotropic Einstein field equations by considering a variable energy density and observed larger redshifts of spherical objects. Mak and Harko [9] discussed static anisotropic spherical stars and concluded that the energy density, and the radial and tangential pressures are positive in the interior regions. Cosenza et al. [10] found solutions of the field equations with a spherically symmetric anisotropic matter distribution.

The polytropic equation of state (EoS) has captivated the attention of many researchers discussing the internal structure of compact objects. It is a power-law relationship between energy density and pressure, defined as

$$\begin{aligned} P=k\rho ^\gamma =k\rho ^{1+\frac{1}{n}}, \end{aligned}$$

where \(P,~\rho ,~\gamma ,~k\), and n denote pressure, energy density, polytropic exponent, polytropic constant, and polytropic index, respectively. Tooper [11] proposed the idea of a relativistic study of polytropes and formulated two non-linear differential equations describing the stellar structure. He found the physical variables (mass, pressure and density) of polytropes using a numerical technique. Herrera and Barreto [12] discussed a general formalism for relativistic isotropic as well as anisotropic polytropes of a spherically symmetric matter distribution and constructed the Lane–Emden equation, which represents the inner structure of compact objects. Herrera et al. [13] examined the stability of spherically symmetric anisotropic conformally flat polytropes using the Tolman mass and found that the considered polytropic models are stable.

The perturbation technique plays a crucial role in the stability of astrophysical objects. A star can collapse, expand, crack or overturn depending upon the nature of the perturbation. Di Prisco et al. [14] discussed the cracking of a spherical compact object and concluded that a departure from the equilibrium state leads to cracking only for a local (non-constant) anisotropic perturbation. Abreu et al. [15] examined the impact of the energy density as well as a local anisotropic perturbation on the stability of the local and non-local anisotropic matter distributions. They found that, for \(P_{r}=0,~P_{\bot }\ne 0\), the matter configuration is always stable whereas it can experience cracking (or overturning) when \(P_{\bot }=0~ \text {and}~ P_{r}\ne 0\). Gonzalez et al. [16] investigated the effect of local density perturbations for isotropic as well as anisotropic spheres satisfying a barotropic EoS. They showed that the isotropic configuration also presents cracking which is in contrast to the result obtained for a non-local density perturbation. Recently, Herrera et al. [17] observed the cracking and overturning for anisotropic polytropes by perturbing the energy density as well as the local anisotropy of the system.

The study of charge in self-gravitating spherically symmetric matter distributions started with the contributions of Rosseland and Eddington [18]. Since then numerous efforts have been made to explore the effects of charge on the structure and evolution of self-gravitating systems. Bekenstein [19] discussed the gravitational collapse of a charged spherically symmetric perfect fluid by introducing the idea of hydrostatic equilibrium. Bonnor [20] investigated the role of charge in the collapse of a spherical dust cloud and found that it halts the process of collapse. Ray et al. [21] examined the effects of charge on compact stars and obtained \(10^{10}\) coulumbs charge present in high density compact objects. Takisa and Maharaj [22] formulated exact solutions of the Einstein–Maxwell field equations with a polytropic EoS which can be used to model charged anisotropic compact objects. We have studied the modeling of a charged conformally flat polytropic sphere and checked the viability through energy conditions [23]. Azam et al. [24] examined the occurrence of cracking in charged static spherically symmetric compact objects with quadratic EoS and concluded that stability regions increase by the increase of charge.

In this paper, we study the cracking of spherically symmetric anisotropic polytropes in the presence of charge. The format of this paper is as follows. In the next section, we study matter distribution for charged sphere and construct the generalized Tolman–Oppenheimer–Volkoff (TOV) equation as well as the mass equation for two cases of a polytropic EoS. Section 3 is devoted to the observation of cracking by perturbing the energy density and the local anisotropy via polytropic parameters. We formulate the force distribution function for each case and plot the results numerically to discuss the stability of the corresponding models. Finally, we conclude our results in the last section.

2 Matter distribution and generalized TOV equation

We consider a static spherically symmetric spacetime as follows:

$$\begin{aligned} \mathrm{d}s^2=-e^{\nu (r)} \mathrm{d}t^{2}+e^{\lambda (r)} \mathrm{d}r^{2}+r^{2}\left( \mathrm{d}\theta ^{2}+\sin ^{2}\theta \mathrm{d}\phi ^2\right) . \end{aligned}$$
(1)

The matter distribution is considered to be anisotropic in pressure bounded by hypersurface \(\Sigma \) so that \(r=r_{\Sigma }=constant \). The energy-momentum tensor for such a matter distribution is given by

$$\begin{aligned} T_{\mu \nu }=(\rho +P_{\bot })V_\mu V_\nu +P_\bot g_{\mu \nu } + (P_r - P_\bot )S_\mu S_\nu , \end{aligned}$$
(2)

where \(P_{r},~P_{\perp },~V_{\mu },~S_\mu \) are the radial pressure, tangential pressure, four-velocity, and four-vector, respectively. We consider the fluid to be comoving as

$$\begin{aligned} S^{\mu }=e^{-\lambda /2}\delta ^{\mu }_{1},\quad V^{\mu }=e^{-\nu /2}\delta ^{\mu }_{0}, \end{aligned}$$

satisfying

$$\begin{aligned} V^{\mu }V_{\mu }=-1,\quad S^{\mu }S_{\mu }=1, \quad S^{\mu }V_{\mu }=0. \end{aligned}$$

The energy-momentum tensor for electromagnetic field is defined as

$$\begin{aligned} E_{\mu \nu }=\frac{1}{4\pi }\left( F_{\mu }~^{\alpha }F_{\nu \alpha }- \frac{1}{4}F^{\alpha \beta }F_{\alpha \beta }g_{\mu \nu }\right) , \end{aligned}$$
(3)

where \(F_{\mu \nu }=\phi _{\nu ,\mu }-\phi _{\mu ,\nu }\) and \(\phi _\mu \) are the Maxwell field tensor and four potential, respectively. The Maxwell field tensor satisfies the following field equations:

$$\begin{aligned} F^{\mu \nu }_{~~;\nu }={\mu }_{0}J^{\mu },\quad F_{[\mu \nu ;\gamma ]}=0, \end{aligned}$$

here \(\mu _0\) is the magnetic permeability and \(J^{\mu }\) is the four-current. In comoving coordinates, we have

$$\begin{aligned} \phi _{\mu }={\phi } {\delta ^{0}_{\mu }},\quad J_{\mu }=\zeta V_{\mu }, \end{aligned}$$

where \(\zeta =\zeta (r)\) and \(\phi =\phi (r)\) represent the scalar potential and charge density, respectively.

The Maxwell field equation for our spacetime yields

$$\begin{aligned} \phi ^{\prime \prime }+\left( \frac{2}{r}-\frac{\nu '}{2}-\frac{\lambda '}{2}\right) \phi '= 4\pi \zeta e^{\frac{\nu }{2}+\lambda }, \end{aligned}$$

where a prime denotes differentiation with respect to r. Integration of the above equation yields

$$\begin{aligned} {\phi }'=\frac{e^{\frac{\nu +\lambda }{2}}q(r)}{r^{2}}. \end{aligned}$$

Here \(q(r)=4\pi \int ^r_{0}{\zeta }e^{\frac{\lambda }{2}}{r^2}\mathrm{d}r\) indicates the total charge inside the sphere. The corresponding Einstein–Maxwell field equations turn out to be

$$\begin{aligned}&8{\pi }{\rho }+\frac{q^2}{r^{4}} =\frac{e^{-\lambda }\lambda '}{r}-\frac{e^{-\lambda }-1}{r^{2}}, \end{aligned}$$
(4)
$$\begin{aligned}&8{\pi }{P_r }-\frac{q^2}{r^{4}} =\frac{e^{-\lambda }\nu '}{r}+\frac{e^{-\lambda }-1}{r^{2}}, \end{aligned}$$
(5)
$$\begin{aligned}&8{\pi }{P_\bot }+\frac{q^2}{r^{4}} =e^{-\lambda }\left( \frac{\nu ''}{2}+\frac{\nu '^{2}}{4}-\frac{\nu '\lambda '}{4} +\frac{\nu '}{2r}-\frac{\lambda '}{2r}\right) . \end{aligned}$$
(6)

The corresponding Misner–Sharp mass leads to [25]

$$\begin{aligned} m(r)=\frac{r}{2}\left( 1-e^{-\lambda }\right) +\frac{q^2}{2r}. \end{aligned}$$
(7)

The conservation law, \(T^{\mu }_{~\nu ;\mu }+E^{\mu }_{~\nu ;\mu } = 0\), yields

$$\begin{aligned} {P_r}'+\frac{\nu '}{2}\left( \rho +P_r\right) -\frac{2}{r}\left( P_\bot -P_r+\frac{qq'}{8{\pi }r^{3}}\right) =0. \end{aligned}$$
(8)

This is termed a generalized TOV equation; it represents a charged sphere in hydrostatic equilibrium. Using Eqs. (5) and (7), we have

$$\begin{aligned} \frac{\nu '}{2}=\frac{4{\pi }r^{4}{P_r}-q^{2}+{r}{m}}{r(r^{2}-2{r}{m}+q^{2})}. \end{aligned}$$

Consequently, Eq. (8) becomes

$$\begin{aligned} {P_r}'+\frac{4{\pi }r^{4}{P_r}-q^{2}+{r}{m}}{r^{3}-2{r^2}{m} +rq^{2}}(\rho +P_r)-\frac{2\Delta }{r}-\frac{qq'}{4{\pi }r^{4}}=0, \end{aligned}$$
(9)

where \(\Delta =P_\bot -P_r\). The polytropic EoS has two possible cases [12]. The first case gives

$$\begin{aligned} P_{r}=k\rho _{0}^{\gamma }=k\rho _{0}^{1+\frac{1}{n}},\quad \rho -\rho _{0}=nP_{r}, \end{aligned}$$
(10)

where \(\rho _{0}\) is baryonic density. The polytropic EoS for the second case is

$$\begin{aligned} P_{r}=k\rho ^{\gamma }=k\rho ^{1+\frac{1}{n}},\quad \rho \left( 1-k\rho _{0}^{\frac{1}{n}}\right) ^{n}=\rho _{0}, \end{aligned}$$
(11)

where \(\rho _{0}\) is replaced by \(\rho \).

In the following, we evaluate a generalized TOV and the mass equations for the above two cases of polytropic EoS.

2.1 Case 1

We consider the first polytropic EoS (10) and construct a generalized TOV equation. For this purpose, we take [13]

$$\begin{aligned}&P_{rc}=\alpha \rho _{c},\quad \xi =rA,\quad A^{2}=\frac{4 \pi {\rho _{c}}}{\alpha {(n+1)}}, \quad \Phi _{0}^{n}=\frac{\rho _{0}}{\rho _{0c}},\quad \nonumber \\&m(r)=\frac{4{\pi }\rho _{c}\eta (\xi )}{A^{3}}, \end{aligned}$$
(12)

where the subscript c indicates the value at the center, \(\alpha ,~\xi ,~\Phi _{0},~\eta \) are dimensionless variables and A is constant. Using the variables along with Eq. (10) in (9), we obtain

$$\begin{aligned}&\left\{ \frac{1-\frac{2\eta \alpha (n+1)}{\xi }+\frac{4\pi \rho _{c}{q}^{2}}{{\xi }^{2}\alpha (n+1)}}{\alpha (n+1)\Phi _{0}+1- n\alpha }\right\} \nonumber \\&\quad \times \,\left( \xi ^2\frac{\mathrm{d}\Phi _{0}}{\mathrm{d}\xi } -\,2\Phi _{0}^{-n}\frac{\alpha ^4 (n+1)^2\xi ^3\Delta +2\pi \alpha ^2\rho _{c}^{2}q\frac{\mathrm{d}q}{\mathrm{d}\xi }}{\alpha ^5\rho _{c} (n+1)^3\xi ^2}\right) \nonumber \\&\quad +\,\alpha \xi ^{3}\Phi _{0}^{n+1}+\eta -\frac{4\pi \rho _{c}q^2}{\xi \alpha ^2 (n+1)^2}=0. \end{aligned}$$
(13)

Differentiating Eq. (7) and using (4), we obtain the mass equation as follows:

$$\begin{aligned} m'=4 \pi r^{2}\rho +\frac{qq'}{r}. \end{aligned}$$
(14)

Using Eqs. (10) and (12) in the above equation, we have

$$\begin{aligned} \frac{\mathrm{d}\eta }{\mathrm{d}\xi }=\xi ^{2}\Phi _{0}^{n}(1+n\alpha \Phi _{0}-n\alpha ) +\frac{4\pi \rho _{c}q}{\xi \alpha ^2 (n+1)^2}\frac{\mathrm{d}q}{\mathrm{d}\xi }. \end{aligned}$$
(15)

The coupling of the generalized TOV equation (13) with mass equation (15) yields the Lane–Emden equation, which provides simple models for polytropes in hydrostatic equilibrium.

2.2 Case 2

In this case, we construct the TOV equation for Eq. (11) by taking

$$\begin{aligned} \Phi ^{n}=\rho /\rho _{c}. \end{aligned}$$

Consequently, Eq. (9) turns out to be

$$\begin{aligned}&\left\{ \frac{1-\frac{2\eta \alpha (n+1)}{\xi }+\frac{4\pi \rho _{c}{q}^{2}}{{\xi }^{2}\alpha (n+1)}}{1+\alpha \Phi }\right\} \nonumber \\&\quad \times \,\left( \xi ^2\frac{\mathrm{d}\Phi }{\mathrm{d}\xi } -2\Phi ^{-n}\frac{\alpha ^4 (n+1)^2\xi ^3\Delta +2\pi \alpha ^2\rho _{c}^{2}q\frac{\mathrm{d}q}{\mathrm{d}\xi }}{\alpha ^5\rho _{c} (n+1)^3\xi ^2}\right) \nonumber \\&\quad +\,\alpha \xi ^{3}\Phi ^{n+1} +\eta -\frac{4\pi \rho _{c}q^2}{\xi \alpha ^2 (n+1)^2}=0. \end{aligned}$$
(16)

Using Eqs. (11) and (12) in (14), it follows that

$$\begin{aligned} \frac{\mathrm{d}\eta }{\mathrm{d}\xi }=\xi ^{2}\Phi ^{n}+\frac{4\pi \rho _{c}q}{\xi \alpha ^2 (n+1)^2}\frac{\mathrm{d}q}{\mathrm{d}\xi }. \end{aligned}$$
(17)

Again, the coupling of the above two equations provides the Lane–Emden equation corresponding to this case. We see that Eqs. (13), (15) and (16), (17) form two systems of differential equations in three unknowns for case 1 and 2, respectively. In order to reduce one unknown, we consider the following EoS [17]:

$$\begin{aligned} \Delta =\frac{B(4{\pi }r^{4}{P_r}-q^{2}+{r}{m})}{r^{2}-2{r}{m} +q^{2}}(\rho +P_r), \end{aligned}$$
(18)

where B is a constant.

3 Cracking of anisotropic polytrope

In astrophysical objects, the matter distribution may depart from equilibrium state when perturbations are introduced. We analyze the stability of a polytropic compact object using the concept of cracking. For this purpose, we use Eq. (18) in (9), which yields

$$\begin{aligned} \mathcal {R}=\frac{\mathrm{d}P_{r}}{\mathrm{d}r}+\beta \left[ \frac{4{\pi }r^{4}{P_r} -q^{2}+{r}{m}}{r^{3}-2{r^2}{m} +rq^{2}}\right] (\rho +P_r)-\frac{qq'}{4{\pi }r^{4}}; \end{aligned}$$
(19)

here \(\beta =1-2B\) and \(\mathcal {R}\) represents the force distribution function. In order to observe cracking in our system, we perturb the matter variables for both cases of polytropic EoS through a set of parameters (\(k,\beta \)) and (\(n,\beta \)).

3.1 Perturbations in case 1

In this case, we construct the force distribution function by perturbing the energy density and anisotropy via \(k~ \text {and}~ \beta \) as follows:

$$\begin{aligned} k\rightarrow \tilde{k}=k+\delta k,\quad \beta \rightarrow \tilde{\beta }=\beta +\delta \beta . \end{aligned}$$

After perturbation, Eq. (10) takes the form

$$\begin{aligned} \tilde{P_{r}}=\tilde{k}\rho _{0}^{1+\frac{1}{n}}=\omega P_{r},\quad \tilde{\rho }=\rho _{0}+n\omega P_{r}, \end{aligned}$$
(20)

where \(\omega =\frac{\tilde{k}}{k}\). Introducing the dimensionless variable \(\hat{\tilde{\mathcal {R}}}=\frac{A}{4\pi \rho _{c}^{2}}\tilde{\mathcal {R}}\) and using the perturbed parameters along with Eq. (12) in (19), we have

$$\begin{aligned} \hat{\tilde{\mathcal {R}}}= & {} \frac{\tilde{\beta }\Phi _{0}^{n}(1-n\alpha +\alpha \omega (n+1)\Phi _{0})}{\xi ^{2}}\nonumber \\&\times \left\{ \frac{\tilde{\eta }+\alpha \omega \xi ^{3}\Phi _{0}^{n+1}- \frac{4\pi \rho _{c}q^2}{\xi \alpha ^2 (n+1)^2}}{1-\frac{2\tilde{\eta }\alpha (n+1)}{\xi }+\frac{4\pi \rho _{c}{q}^{2}}{{\xi }^{2}\alpha (n+1)}}\right\} \nonumber \\&+\,\omega \Phi _{0}^{n}\frac{\mathrm{d}\Phi _{0}}{\mathrm{d}\xi }-\frac{qq'}{4{\pi }r^{4}}. \end{aligned}$$
(21)

In the equilibrium state, the system has no perturbation, which yields \(\hat{\tilde{\mathcal {R}}}(\xi ,1+\delta \omega , \beta +\delta \beta ,\eta +\delta \eta )=0\). Applying Taylor’s expansion, we obtain

$$\begin{aligned} \mathcal {\delta \hat{R}}= & {} \hat{\tilde{\mathcal {R}}}(\xi ,1+\delta \omega , \beta +\delta \beta ,\eta +\delta \eta )= \frac{\partial \hat{\tilde{\mathcal {R}}}}{\partial \omega }\Bigg |_ {\omega =1, \tilde{\beta }=\beta , \tilde{\eta }=\eta }\delta \omega \nonumber \\&+\,\frac{\partial \hat{\tilde{\mathcal {R}}}}{\partial \tilde{\beta }}\Bigg |_ {\omega =1, \tilde{\beta }=\beta , \tilde{\eta }=\eta }\delta \beta + \frac{\partial \hat{\tilde{\mathcal {R}}}}{\partial \tilde{\eta }}\Bigg |_ {\omega =1, \tilde{\beta }=\beta , \tilde{\eta }=\eta }\delta \eta . \end{aligned}$$
(22)

Using Eq. (21), we evaluate

$$\begin{aligned}&\frac{\partial \hat{\tilde{\mathcal {R}}}}{\partial \omega }\Bigg |_ {\omega =1, \tilde{\beta }=\beta , \tilde{\eta }=\eta }\nonumber \\&\quad =\Phi _{0}^{n}\frac{\mathrm{d}\Phi _{0}}{\mathrm{d}\xi }+\frac{\beta \Phi _{0}^{n+1}\alpha }{\xi ^2\left( 1-\frac{2\xi \eta \alpha (n+1)}{\xi }+\frac{4\pi \rho _{c}{q}^{2}}{{\xi }^{2}\alpha (n+1)}\right) } \nonumber \\&\quad \times \,\left[ \phantom {\left. \left. 1-n\right) +(n+1)\left\{ \eta -\frac{4\pi \rho _{c}q^2}{\xi \alpha ^2 (n+1)^2}\right\} \right] }\alpha \xi ^3\Phi _{0}^n \left( 2(n+1)\Phi _{0}\right. \right. \nonumber \\&\quad +\left. \left. 1-n\right) +(n+1)\left\{ \eta -\frac{4\pi \rho _{c}q^2}{\xi \alpha ^2 (n+1)^2}\right\} \right] ,\end{aligned}$$
(23)
$$\begin{aligned}&\quad \frac{\partial \hat{\tilde{\mathcal {R}}}}{\partial \tilde{\beta }}\Bigg |_ {\omega =1, \tilde{\beta }=\beta , \tilde{\eta }=\eta }=\frac{\Phi _{0}^{n}}{\xi ^2}\left\{ \frac{1-n\alpha +\alpha \Phi _{0}(n+1) }{1-\frac{2\eta \alpha (n+1)}{\xi }+\frac{4\pi \rho _{c}{q}^{2}}{{\xi }^{2}\alpha (n+1)}}\right\} \nonumber \\&\quad \times \,\left[ \eta +\alpha \xi ^3\Phi _{0}^{n+1}-\frac{4\pi \rho _{c}q^2}{\xi \alpha ^2 (n+1)^2}\right] ,\end{aligned}$$
(24)
$$\begin{aligned}&\frac{\partial \hat{\tilde{\mathcal {R}}}}{\partial \tilde{\eta }}\Bigg |_ {\omega =1, \tilde{\beta }=\beta , \tilde{\eta }=\eta }=\frac{\beta \Phi _{0}^{n}}{\xi ^2}\left\{ \frac{1-n\alpha + \alpha \Phi _{0}(n+1)}{\left( 1-\frac{2\eta \alpha (n+1)}{\xi }+\frac{4\pi \rho _{c}{q}^{2}}{{\xi }^{2}\alpha (n+1)}\right) ^2}\right\} \nonumber \\&\quad \times \,\left[ 1+ 2\alpha ^2(n+1)\xi ^2\Phi _{0}^{n+1}-\frac{4\pi \rho _{c}{q}^{2}}{{\xi }^{2}\alpha (n+1)}\right] . \end{aligned}$$
(25)

Making use of perturbed parameters in Eq. (15), we obtain

$$\begin{aligned} \tilde{\eta }=\int _{0}^{\xi }\left\{ \hat{\xi }^2\Phi _{0}^{n} (1-n\alpha +n\alpha \omega \Phi _{0})+\frac{4\pi \rho _{c}q}{\hat{\xi }\alpha ^2 (n+1)^2}\frac{\mathrm{d}q}{\mathrm{d}\hat{\xi }}\right\} \mathrm{d}\hat{\xi }. \end{aligned}$$

Moreover, we have

$$\begin{aligned} \delta \eta =\frac{\partial \tilde{\eta }}{\partial \omega }\Big |_ {\omega =1}\delta \omega =n\alpha f_{1}(\xi )\delta \omega , \end{aligned}$$
(26)

where

$$\begin{aligned} f_{1}(\xi )=\int _{0}^{\xi }\hat{\xi }^2\Phi _{0}^{n+1}\mathrm{d}\hat{\xi }. \end{aligned}$$

Substituting Eqs. (23)–(26) in (22), it follows that

$$\begin{aligned} \delta \mathcal {\hat{R}}_{1}= & {} \Phi _{0}^{n}\left[ \frac{\mathrm{d}\Phi _{0}}{\mathrm{d}\xi } +\frac{\alpha \beta }{\xi ^2\left( 1-\frac{2\eta \alpha (n+1)}{\xi }+\frac{4\pi \rho _{c}{q}^{2}}{{\xi }^{2}\alpha (n+1)}\right) }\right. \\&\times \,\left\{ \phantom {\left. \left. \left. \frac{4\pi \rho _{c}{q}^{2}}{{\xi }^{2}\alpha (n+1)}\right) \left( \frac{1-n\alpha +\alpha \Phi _{0}(n+1)}{1-\frac{2\eta \alpha (n+1)}{\xi }+\frac{4\pi \rho _{c}{q}^{2}}{{\xi }^{2}\alpha (n+1)}}\right) nf_{1}(\xi )\right\} \right] \delta \omega }\alpha \xi ^3\Phi _{0}^{n+1} \left( 2(n+1)\Phi _{0}\right. \right. \\&+\left. \left. 1-n\right) +(n+1)\Phi _{0}\left\{ \eta -\frac{4\pi \rho _{c}q^2}{\xi \alpha ^2 (n+1)^2}\right\} \right. \\&+\left( \phantom {\frac{4\pi \rho _{c}{q}^{2}}{{\xi }^{2}\alpha (n+1)})}1+ 2\alpha ^2(n+1)\xi ^2\Phi _{0}^{n+1}-\frac{4\pi \rho _{c}{q}^{2}}{{\xi }^{2}\alpha (n+1)}\right) \\&\left. \left. \times \left( \frac{1-n\alpha +\alpha \Phi _{0}(n+1)}{1-\frac{2\eta \alpha (n+1)}{\xi }+\frac{4\pi \rho _{c}{q}^{2}}{{\xi }^{2}\alpha (n+1)}}\right) nf_{1}(\xi )\right\} \right] \delta \omega \\&+\frac{\Phi _{0}^{n}}{\xi ^2}\left( 1-n\alpha +\alpha (n+1)\Phi _{0}\right) \\&\times \left\{ \frac{\eta +\alpha \xi ^3\Phi _{0}^{n+1}-\frac{4\pi \rho _{c}q^2}{\xi \alpha ^2 (n+1)^2}}{1-\frac{2\eta \alpha (n+1)}{\xi }+\frac{4\pi \rho _{c}{q}^{2}}{{\xi }^{2}\alpha (n+1)}}\right\} \delta \beta . \end{aligned}$$

Using the variables \(x=\frac{\xi }{\bar{A}},~ \bar{A}=r_{\Sigma }A=\xi _{\Sigma }\), the above equation yields

$$\begin{aligned} \delta \mathcal {\hat{R}}_{1}= & {} \Phi _{0}^{n}\left[ \frac{\mathrm{d}\Phi _{0}}{\bar{A}\mathrm{d}x} +\frac{\alpha \beta }{\bar{A}^2x^2G_{1}} \left\{ \phantom {\frac{4\pi \rho _{c}q^2}{\bar{A}x\alpha ^2 (n+1)^2}\}}\alpha \bar{A}^3x^3\Phi _{0}^{n+1} \left( 2(n+1)\Phi _{0}\right. \right. \right. \nonumber \\&\left. +1-n\right) +(n+1)\Phi _{0}\left\{ \eta -\frac{4\pi \rho _{c}q^2}{\bar{A}x\alpha ^2 (n+1)^2}\right\} \nonumber \\&\left. \left. +\frac{G_{2}}{G_{1}}\left( 1+ 2\alpha ^2(n+1)x^2\bar{A}^2\Phi _{0}^{n+1} \right. \right. \right. \nonumber \\&\left. \left. \left. -\,\frac{4\pi \rho _{c}{q}^{2}}{x^{2}\bar{A}^2\alpha (n+1)}\right) nf_{1}(x)\right\} \right] \delta \omega +\frac{\Phi _{0}^{n}G_{2}G_{3}}{x^2\bar{A}^{2}G_{1}}\delta \beta ,\nonumber \\ \end{aligned}$$
(27)

where

$$\begin{aligned} G_{1}= & {} 1-\frac{2\alpha (n+1)\eta }{\bar{A}x}+\frac{4\pi \rho _{c}{q}^{2}}{\bar{A}^{2}x^2\alpha (n+1)},\\ G_{2}= & {} 1-n\alpha +\alpha \Phi _{0}(n+1),\\ G_{3}= & {} \eta +\alpha x^3\bar{A}^3\Phi _{0}^{n+1}-\frac{4\pi \rho _{c}q^2}{x\bar{A}\alpha ^2 (n+1)^2}. \end{aligned}$$

In cracking, \(\delta \hat{\mathcal {R}}>0\) inside the sphere, while \(\delta \hat{\mathcal {R}}<0\) for outer regions, so \(\delta \hat{\mathcal {R}}=0\) for some value of \(\xi \). This condition implies that

$$\begin{aligned} \delta \omega =-\frac{\delta \beta }{\Gamma }, \end{aligned}$$

where \(\Gamma =\frac{\frac{\partial \hat{\tilde{\mathcal {R}}}}{\partial \omega }+ \frac{\partial \hat{\tilde{\mathcal {R}}}}{\partial \tilde{\eta }}f_{1}(\xi )}{\frac{\partial \hat{\tilde{\mathcal {R}}}}{\partial \tilde{\beta }}}\Bigg |_ {\omega =1, \tilde{\beta }=\beta , \tilde{\eta }=\eta }\).

We study the phenomenon of cracking by perturbing the energy density and anisotropy via the parameters \(n~\text {and}~\beta \) as follows:

$$\begin{aligned} n\rightarrow \tilde{n}=n+\delta n,\quad \beta \rightarrow \tilde{\beta }=\beta +\delta \beta . \end{aligned}$$

Equation (19) in terms of the perturbed parameters can be written as

$$\begin{aligned} \hat{\tilde{\mathcal {R}}}= & {} \Phi _{0}^{\tilde{n}}\frac{\mathrm{d}\Phi _{0}}{\mathrm{d}\xi }+ \frac{\tilde{\beta }\Phi _{0}^{\tilde{n}}\left( 1-\tilde{n}\alpha +\alpha (\tilde{n}+1)\Phi _{0}\right) }{\xi ^{2}}\nonumber \\&\times \,\left\{ \frac{\tilde{\eta }+\alpha \xi ^{3}\Phi _{0}^{\tilde{n}+1} -\frac{4\pi \rho _{c}q^2}{\xi \alpha ^2 (\tilde{n}+1)^2}}{1-\frac{2\tilde{\eta }\alpha (\tilde{n}+1)}{\xi }+\frac{4\pi \rho _{c}{q}^{2}}{{\xi }^{2}\alpha (\tilde{n}+1)}}\right\} - \frac{qq'}{4{\pi }r^{4}}. \end{aligned}$$
(28)

In this scheme, Taylor’s expansion yields

$$\begin{aligned} \delta \hat{\mathcal {R}}= & {} \frac{\partial \hat{\tilde{\mathcal {R}}}}{\partial \tilde{n}}\Bigg |_ {\tilde{n}=n, \tilde{\beta }=\beta , \tilde{\eta }=\eta }\delta n +\frac{\partial \hat{\tilde{\mathcal {R}}}}{\partial \tilde{\eta }}\Bigg |_ {\tilde{n}=n, \tilde{\beta }=\beta , \tilde{\eta }=\eta }\delta \eta \\&+\,\frac{\partial \hat{\tilde{\mathcal {R}}}}{\partial \tilde{\beta }}\Bigg |_ {\tilde{n}=n, \tilde{\beta }=\beta , \tilde{\eta }=\eta }\delta \beta . \end{aligned}$$

Making use of Eq. (28), the above equation turns out to be

$$\begin{aligned} \delta \mathcal {\hat{R}}_{2}= & {} \Phi _{0}^{n}\left[ \frac{\ln \Phi _{0}}{\bar{A}}\frac{\mathrm{d}\Phi _{0}}{\mathrm{d}x}+\frac{\beta }{\bar{A}^{2}x^2G_{1}} \right. \nonumber \\&\times \,\left. \left\{ \phantom {\left. \frac{G_{2}}{G_{1}}\left( G_{1} + \frac{2\alpha (n+1)}{\bar{A}x}G_{3}\right) f_{2}(x)\right\} }\ln \Phi _{0}G_{2}G_{3} +\alpha (\Phi _{0}-1)G_{3}+G_{2}\bigg (\alpha A^{3}x^3\right. \right. \nonumber \\&\times \,\left. \left. \Phi _{0}^{n+1}\ln \Phi _{0} +\frac{8\pi \rho _{c}q^2}{\bar{A}x\alpha ^{2}(n+1)^3}\bigg ) \right. \right. \nonumber \\&\left. \left. +\,\frac{G_{2}G_{3}}{G_{1}} \left( \frac{2\eta \alpha }{\bar{A}x}+ \frac{4\pi \rho _{c}q^2}{\bar{A}^2x^2\alpha (n+1)^2}\right) \right. \right. \nonumber \\&+\,\left. \phantom {\left[ \frac{\ln \Phi _{0}}{\bar{A}}\frac{\mathrm{d}\Phi _{0}}{\mathrm{d}x}+\frac{\beta }{\bar{A}^{2}x^2G_{1}} \right. }\left. \frac{G_{2}}{G_{1}}\left( G_{1} + \frac{2\alpha (n+1)}{\bar{A}x}G_{3}\right) f_{2}(x)\right\} \right] \delta n\nonumber \\&+\frac{\Phi _{0}^{n}}{\bar{A}^2x^2}\frac{G_{2}G_{3}}{G_{1}}\delta \beta , \end{aligned}$$
(29)

where

$$\begin{aligned} f_{2}(x)=\int _{0}^{x}\bar{A}^3\hat{x}^2\Phi _{0}^{n}\left\{ \alpha (\Phi _{0}^{1-n}-1)+(1-n\alpha )\ln \Phi _{0}\right\} \mathrm{d}\hat{x}. \end{aligned}$$
(30)

Again, for cracking to occur, \(\delta \hat{\mathcal {R}}=0\), implying that

$$\begin{aligned} \delta n=-\frac{\delta \beta }{\Gamma }, \end{aligned}$$

where \(\Gamma =\frac{\frac{\partial \hat{\tilde{\mathcal {R}}}}{\partial \tilde{n}}+ \frac{\partial \hat{\tilde{\mathcal {R}}}}{\partial \tilde{\eta }}f_{2}(\xi )}{\frac{\partial \hat{\tilde{\mathcal {R}}}}{\partial \tilde{\beta }}}\Bigg |_ {\tilde{n}=n, \tilde{\beta }=\beta , \tilde{\eta }=\eta }\).

Fig. 1
figure 1

Left plot for \(\delta \hat{\mathcal {R}_{1}}\) versus x with \(n=1,\alpha =0.85,\beta =1.5,\Gamma =1.6,q=0.2M_{0}\) (purple), \(q=0.4M_{0}\) (red), \(q=0.64M_{0}\) (green). Right plot for \(\delta \hat{\mathcal {R}_{2}}\) versus x with \(n=1.5,\alpha =0.90,\beta =0.5,\Gamma =1.4,q=0.2M_{0}\) (purple), \(q=0.4M_{0}\) (red), \(q=0.64M_{0}\) (green)

3.2 Perturbations in case 2

Here, we develop force distribution function for the second kind of polytropic EoS using perturbed parameters (\(k,\beta \)). After perturbation, the energy density takes the form

$$\begin{aligned} \tilde{\rho }=\rho +\delta \rho =\rho +\frac{\partial \tilde{\rho }}{\partial \omega }\Big |_{\omega =1}, \end{aligned}$$

which yields

$$\begin{aligned} \tilde{\rho }=\rho +nP_{r}(1-\omega ), \end{aligned}$$

where we have used \(\omega =1+\delta \omega \). Using perturbed parameters in Eq. (19), we have

$$\begin{aligned} \hat{\tilde{\mathcal {R}}}= & {} \omega \Phi ^{n}\frac{\mathrm{d}\Phi }{\mathrm{d}\xi }+ \frac{\tilde{\beta }\Phi ^{n}\left[ 1+\alpha \Phi \{n+\omega (1-n)\}\right] }{\xi ^{2}\left( 1-\frac{2\eta \alpha (n+1)}{\xi }+\frac{4\pi \rho _{c}{q}^{2}}{{\xi }^{2}\alpha (n+1)}\right) }\\&\times \,\left\{ \tilde{\eta }+\alpha \omega \xi ^{3}\Phi ^{n+1}-\frac{4\pi \rho _{c}q^2}{\xi \alpha ^2 (n+1)^2}\right\} -\frac{qq'}{4{\pi }r^{4}}. \end{aligned}$$

Applying Taylor’s expansion on the above equation, it follows that

$$\begin{aligned} \delta \mathcal {\hat{R}}_{3}= & {} \Phi ^{n}\left[ \frac{\mathrm{d}\Phi }{\bar{A}\mathrm{d}x} +\frac{\alpha \beta }{\bar{A}^2x^2G_{1}}\left\{ \Phi (1-n)\left( \eta -\frac{4\pi \rho _{c}q^2}{x\bar{A}\alpha ^2 (n+1)^2}\right) \right. \right. \nonumber \\&+\, x^3\bar{A}^3\alpha (1-n)\Phi ^{n+2} -n(1+\alpha \Phi )\nonumber \\&\times \,\left. \left. \left( \frac{1+2\alpha ^2\bar{A}^2x^2(n+1)\Phi ^{n+1}}{G_{1}}\right) f_{3}(x)\right\} \right] \delta \omega \nonumber \\&+\,\frac{\Phi ^{n}}{x^2\bar{A}^2}\left( 1+\alpha \Phi \right) \frac{G_{3}}{G_{1}}\delta \beta , \end{aligned}$$
(31)

where \(f_{3}(x)=\int _{0}^{x}\bar{A}^3\hat{x}^2\Phi ^{n+1}\mathrm{d}\hat{x}\). Similarly, perturbation of \(n~ \text {and}~ \beta \) leads to

$$\begin{aligned} \delta \mathcal {\hat{R}}_{4}= & {} \Phi ^{n}\left[ \phantom {+\,\frac{G_{5}}{G_{1}^{2}}(G_{1}+ \frac{2\alpha (n+1)}{\bar{A}x}\bar{G}_{4})f_{2}(x)\}]}\frac{\ln \Phi }{\bar{A}}\frac{\mathrm{d}\Phi }{\mathrm{d}x}+\frac{\beta }{\bar{A}^{2}x^2}\left\{ \phantom {\frac{G_{5}}{G_{1}^{2}}(G_{1}+ \frac{2\alpha (n+1)}{\bar{A}x}\bar{G}_{4})f_{2}(x)\}}\frac{\ln \Phi G_{4}G_{5}}{G_{1}}\right. \right. \nonumber \\&+\frac{G_{5}}{G_{1}}\left( \alpha A^{3}x^3\Phi ^{n+1}\ln \Phi +\frac{8\pi \rho _{c}q^2}{\bar{A}x\alpha ^{2}(n+1)^3}\right) \nonumber \\&-\frac{G_{4}G_{5}}{G_{1}^2} \left( -\frac{2\eta \alpha }{\bar{A}x}- \frac{4\pi \rho _{c}q^2}{\bar{A}^2x^2\alpha (n+1)^2}\right) \nonumber \\&+\,\left. \left. \frac{G_{5}}{G_{1}^{2}}\left( G_{1}+ \frac{2\alpha (n+1)}{\bar{A}x}{G}_{4}\right) f_{2}(x)\right\} \right] \delta n \nonumber \\&+\,\frac{\Phi ^{n}}{\bar{A}^2x^2}\frac{G_{4}G_{5}}{G_{1}}\delta \beta , \end{aligned}$$
(32)

where

$$\begin{aligned}&G_{4}=\eta +\alpha x^3\bar{A}^3\Phi ^{n+1}-\frac{4\pi \rho _{c}q^2}{x\bar{A}\alpha ^2 (n+1)^2},\quad G_{5}=1+\alpha \Phi ,\\&f_{4}(x)=\int _{0}^{x}\bar{A}^{3}\hat{x}^2\Phi ^{n}\ln \Phi \mathrm{d}\hat{x}. \end{aligned}$$

Now we analyze the occurrence of cracking in the polytropic models through a numerical method. We examine the charged compact models for both cases of polytropic EoS with perturbations through (\(k,\beta \)) and (\(n,\beta \)). First, we evaluate \(\Phi _{0}~,\Phi ~ \text {and}~ \eta \) for both cases by integrating Eqs. (13), (15), (16), and (17) with boundary conditions [13]

$$\begin{aligned}&\eta (0)=0,\quad \Phi _{0}(0)=1,\quad \Phi _{0}(\xi _{\Sigma })=0,\quad \Phi (0)=1,\\&\Phi (\xi _{\Sigma })=0, \end{aligned}$$

and we use these results to plot the force distribution functions. The graphical behavior of the force distribution function for case 1 is shown in Fig. 1. The left graph shows the behavior of \(\delta \mathcal {\hat{R}}_{1}\), indicating that, for all considered values of q, it is positive in the inner regions and becomes negative for the outer ones, thus ensuring the occurrence of the strongest cracking in the corresponding model. The right graph is plotted for \(\delta \mathcal {\hat{R}}_{2}\), which shows that there is neither cracking nor overturning for all values of q. Thus, the presence of charge in polytropes leads to stable models.

For case 2, the plots of the force function in Eqs. (31) and (32) for different values of the parameters are shown in Fig. 2. The left graph is plotted for \(\delta \mathcal {\hat{R}}_{3}\), which indicates stable behavior for \(q=0.2M_{0}\) while the strongest overturning appears for other two values of q. The graphical analysis of \(\delta \mathcal {\hat{R}}_{4}\) for different values of charge shows a stable configuration as shown in Figs. 2 (right) and 3. It is observed that within an uncharged matter distribution both cracking and overturning appear. However, the inclusion of charge in the matter configurations leads to stability of the spherically symmetric polytrope.

Fig. 2
figure 2

Left plot for \(\delta \hat{\mathcal {R}_{3}}\) versus x with \(n=0.5,\alpha =0.98,\beta =1.5,\Gamma =0.6,q=0.2M_{0}\) (purple), \(q=0.4M_{0}\) (red), \(q=0.64M_{0}\) (green). Right plot for \(\delta \hat{\mathcal {R}_{4}}\) versus x with \(n=1.5,\alpha =0.7,\beta =1.5,\Gamma =-0.5,q=0.2M_{0}\)

Fig. 3
figure 3

Plot for \(\delta \hat{\mathcal {R}_{4}}\) versus x with \(n=1.5,\alpha =0.7,\beta =1.5,\Gamma =-0.5\). Left plot for \(q=0.4M_{0}\). Right plot for \(q=0.64M_{0}\)

4 Concluding remarks

The stability analysis of stellar objects is an interesting area of research. The concept of cracking refers to the appearance of total radial forces of different signs within the matter distribution. If there is no cracking (or overturning) within a particular configuration, then the system is not completely stable since other types of perturbation can lead to its cracking, overturning, expansion or collapse. We have considered a spherically symmetric star with charged anisotropic matter distribution satisfying a polytropic EoS and constructed the corresponding Einstein–Maxwell equations. We have considered two cases of polytropic EoS and formulated the TOV as well as mass equations in terms of dimensionless variables for each case. The coupling of these two equations represents a charged polytrope in hydrostatic equilibrium.

In order to observe cracking, perturbation is a necessary ingredient to take the system out of the equilibrium state. We have perturbed the energy density and pressure anisotropy of a system in two ways. First of all, we have introduced perturbations through the parameters (\(k,\beta \)) and constructed the force distribution function \((\delta \mathcal {\hat{R}}_{1})\) in terms of perturbed parameters describing total radial forces present in a system. The graphical analysis of \(\delta \mathcal {\hat{R}}_{1}\) indicates the appearance of cracking for all choices of parameters, thus leading to unstable configurations for this case. Second, we have used (\(n,\beta \)) as perturbation parameters and constructed \(\delta \mathcal {\hat{R}}_{2}\). It is found that the resulting models are stable against perturbations.

We have followed the same procedure for case 2 of the polytropic EoS and constructed \(\delta \mathcal {\hat{R}}_{3}~ \text {as well as} ~\delta \mathcal {\hat{R}}_{4}\). It is found that polytropic models are unstable against a perturbation in (\(k,\beta \)), while the perturbation of (\(n,\beta \)) leads to a stable matter configuration representing a relativistic polytrope. The stability of compact objects depends upon the choice of EoS. It was found that spherically symmetric charged compact objects with quadratic EoS [24] lead to stable models, while the linear EoS [26] provides unstable configurations. For uncharged spherical anisotropic polytropes, both cracking and overturning appear for a wide range of parameters under (\(k,\beta \)) as well as (\(n,\beta \)) perturbations [17]. We have observed that the charged matter distribution leads to stable configurations for a (\(n,\beta \)) perturbation, while polytropic models remain unstable by perturbing (\(k,\beta \)). We conclude that the inclusion of charge in an anisotropic fluid distribution has a dominant effect on polytropes, which leads to stable models.