1 Introduction

The study of the vast universe offers insights into its origin and puzzling nature. In the present era, different astrophysical phenomena such as the formation and evolution of cosmic structures have captured the attention of many researchers. Among the cosmic entities, stars are considered as the elementary constituents of galaxies which are organized systematically in a cosmic web. The collapse of stars due to the inward pull of gravity results in the formation of new compact objects. In order to explore the interior geometry of these objects, we need analytical solutions of the non-linear field equations. Despite the non-linearity of these partial differential equations, many researchers have constructed exact viable astrophysical and cosmological solutions. Schwarzschild [1], developed the first solution of Einstein filed equations for an isotropic sphere in the vacuum.

It has been observed that the presence of interacting nuclear matter in dense celestial objects leads to the generation of anisotropy [2]. Fluid configurations with condensed pion like neutron stars are also anisotropic in nature [3]. The impact of pressure anisotropy on features of stellar structures is apparent in various studies of charged or uncharged compact objects. In 1974, the effects of anisotropy on relativistic spherical objects were studied by using specific equations of state (EoS) and an increase in redshift was noted in static models with particular forms of anisotropy [4]. Santos and Herrera [5] examined the origin of anisotropy in general relativity (GR) and studied its impact on the stability of self-gravitating systems. Harko and Mak [6] developed well-behaved anisotropic spherical solutions and examined their physical properties. In 2002, Dev and Gleiser [7] discussed the factors contributing to pressure anisotropy in stellar objects. Hossein et al. [8] constructed anisotropic models for different values of the cosmological constant and used cracking approach to check their stability. Paul and Deb [9] examined feasible anisotropic solutions in hydrostatic equilibrium and showed that the anisotropic stars corresponding to these solutions represent viable behavior. In 2016, Arbañil and Malheiro [10] considered the MIT bag model and discussed the stability of a strange star comprising of anisotropic fluid. Murad [11] developed a model of anisotropic strange star by incorporating the effects of charge for particular forms of radial metric function.

It is a difficult task to extract an anisotropic solution of the non-linear system of field equations due to the greater number of unknowns as compared to the number of equations. To overcome this problem, various techniques have been introduced which aid in the construction of feasible solutions. In this regard, the gravitational decoupling technique through minimal geometric deformation (MGD), proposed by Ovalle [12, 13], determines new solutions corresponding to different relativistic distributions in astrophysics. This approach deforms the radial metric component and generates two sets of differential equations from the system of field equations. One system incorporates the seed source while the other one is governed by the impact of the additional source. Both sets are solved separately and the solution of the whole system is obtained by using the superposition principle. The MGD technique prevents the exchange of energy between matter sources and preserves the spherical symmetry of the self-gravitating system.

Following the MGD scheme, Ovalle and Linares [14] evaluated a solution in braneworld and deduced that the compactness factor reduces due to the bulk effects of fluid distribution. Later, in 2018, Ovalle and his collaborators [15] developed an anisotropic interior solution for perfect fluid distribution by the inclusion of an additional gravitational source. Gabbanelli et al. [16] inspected the salient features of the anisotropic extension of Durgapal–Fuloria model via gravitational decoupling. Sharif and Sadiq [17] devised charged anisotropic models through this scheme and examined the physical features of stellar bodies. Morales and Tello-Ortiz [18] used Heintzmann solution as a seed source and examined the static spherical anisotropic model under the influence of electromagnetic field. Graterol [19] adopted this approach to extend the domain of isotropic Buchdahl solution via some physical constraints. Contreras and Bargueño [20] obtained an anisotropic static BTZ model by employing MGD in \((2+1)\)-dimensional spacetime. Estrada and Prado [21] explored the higher-dimensional extension of MGD approach to construct well-behaved analytical solutions corresponding to anisotropic star models. Maurya and Tello-Ortiz [22] graphically analyzed the physical characteristics of an anisotropic solution formulated via the MGD approach. Sharif and Ama-Tul-Mughani [23] discussed the \((2+1)\)-dimensional charged string cloud through this technique. They also formulated analytical solutions of axially symmetric geometry in the framework of cosmic strings through gravitational decoupling technique [24].

Although the MGD technique has facilitated the study of self-gravitating objects, it transforms radial coordinate only while the temporal coordinate remains invariant which gives rise to certain shortcomings in the decoupling procedure. Since there is no transfer of energy between matter sources, therefore the interaction between them is purely gravitational. To resolve these issues, Casadio et al. [25] proposed an extension of the MGD technique by implementing radial as well as temporal transformations and constructed a solution for a static spherical object. However, the extended method is applicable only in vacuum and fails in the presence of matter as the conservation law does not hold. Therefore, the intrinsic features of astrophysical systems cannot be examined via this approach. Later, in 2019, Ovalle [26] introduced a novel extension of the MGD approach known as extended geometric deformation (EGD). He successfully decoupled two static spherically symmetric gravitational sources and examined its efficiency by recreating the Reissner–Nordström solution. Contreras and Bargueño [27] used this technique in \((2+1)\)-dimensional gravity and obtained exterior charged BTZ solution from its vacuum counterpart. Sharif and Ama-Tul-Mughani employed EGD approach to compute anisotropic solutions corresponding to Tolman IV [28] and Krori–Barua [29] solutions.

Recent study of the universe suggests that strange dark energy is causing cosmic expansion. The modification of GR helps us to investigate the mysterious nature of this repulsive energy. The f(R) theory is one of the simplest modification as it generalizes GR by replacing Ricci scalar (R) with its generic function in the action integral [30]. Starobinsky [31] introduced a model of higher curvature terms \((R+\sigma R^{2})\) to study the inflationary epoch. Many astrophysicists have discussed other forms of f(R) to resolve different cosmic problems such as accelerated cosmic expansion [32] and history of the universe [33, 34]. In the last decade, numerous work has been done on the viability and dynamical stability of astrophysical objects in f(R) gravity. Effects of this theory on the dynamical instability of expansion free fluid were investigated [35,36,37]. Later, Capozziello et al. [38, 39] discussed the hydrostatic equilibrium and dynamics of collisionless self-gravitating systems. Researchers have extensively discussed the collapsing behavior of neutron stars in f(R) theory [40,41,42,43,44]. In 2015, the dynamics of a static spherically symmetric object was investigated by using the Tolman–Oppenheimer–Volkoff equation [45]. Zubair and Abbas [46] explored the stability and dynamics of anisotropic compact stars in f(R) background. Recently, researchers have adopted various EoS to describe the mechanism and salient features of different compact anisotropic spheres [47,48,49].

In 2019, Sharif and Waseem [50, 51] used the isotropic Krori–Barua model for both charged and uncharged spherically symmetric systems in the f(R) framework to construct viable and stable anisotropic solutions via MGD. Recently, EGD and MGD approaches have extensively been used in other modified theories as well [52,53,54,55]. This paper explores the efficiency of the EGD method in the framework of f(R) gravity. We consider the Krori–Barua solution as a seed source to construct a new anisotropic solution and inspect salient features of the extended version. The paper is arranged in the following format. The next section provides the f(R) field equations with an additional gravitational source. The gravitational decoupling of f(R) field equations via EGD technique is presented in Sect. 3. In Sect. 4, the junction conditions are computed by matching the interior with exterior Schwarzschild solution. In Sect. 5, we construct two anisotropic static models by applying physical constraints on the additional gravitational source and analyze the validity of both solutions. Finally, Sect. 6 summarizes the obtained results.

2 Field equations in f(R) gravity

The modified Einstein–Hilbert action for f(R) gravity has the form [56]

$$\begin{aligned} {\mathcal {I}}_{f(R)}=\int \sqrt{-g}\left[ \frac{f(R)}{2 \kappa }+{\mathcal {L}}_m+\chi {\mathcal {L}}_{\Theta }\right] d^4x, \end{aligned}$$
(1)

where g and f(R) represent determinant of the metric tensor and arbitrary function of Ricci scalar, respectively. Also, \(\kappa =1\) (in relativistic units) represents the coupling constant, while \(\chi \) symbolizes the decoupling parameter. Furthermore, \({\mathcal {L}}_{m}\) and \(~{\mathcal {L}}_{\Theta }\) are the Lagrangian densities for seed source and additional source, respectively. The field equation obtained by varying Eq. (1) with respect to the metric is given as

$$\begin{aligned} f_RR_{\xi \eta }-\frac{1}{2}g_{\xi \eta }f(R)-(\nabla _\xi \nabla _\eta -g_{\xi \eta }\Box )f_R=T^{(m)}_{\xi \eta }, \end{aligned}$$
(2)

where \(f_{R}=\frac{\partial f}{\partial R}\),  \(\Box \) is the d’Alembertian operator defined as \(\Box =g^{\xi \eta }\nabla _\xi \nabla _\eta \)\(\nabla _\xi \) represents the covariant derivative and \(T^{(m)}_{\xi \eta }\) is the standard energy-momentum tensor for perfect fluid given as

$$\begin{aligned} T^{(m)}_{\xi \eta }=(\rho +p)u_{\xi }u_{\eta }-pg_{\xi \eta }. \end{aligned}$$
(3)

Here, \(\rho ,~p\) and \(u_{\xi }\) denote the energy density, pressure and four velocity of the fluid, respectively. An alternative form of Eq. (2) is

$$\begin{aligned} R^{\xi }_{\eta }-\frac{1}{2}R\delta ^{\xi }_{\eta }=\frac{1}{f_R}T^{\xi (tot)}_{\eta }, \end{aligned}$$
(4)

where \(T^{\xi (tot)}_{\eta }\) is the energy-momentum tensor describing the internal configuration of the stellar object and is given as

$$\begin{aligned} T^{\xi (tot)}_{\eta }=T^{\xi (m)}_{\eta }+\chi \Theta ^{\xi }_{\eta }+T^{\xi (F)}_{\eta } ={{\widetilde{T}}}^{\xi }_{\eta }+\chi \Theta ^{\xi }_{\eta }, \end{aligned}$$
(5)

where \({\widetilde{T}}^{\xi }_{\eta }=T^{\xi (m)}_{\eta }+T^{\xi (F)}_{\eta }\) and \(T^{\xi (F)}_{\eta }=\left( \frac{f(R)-Rf_R}{2}\right) \delta ^{\xi }_{\eta } +(\nabla ^\xi \nabla _\eta -\delta ^{\xi }_{\eta }\Box )f_R.\) Moreover, \(\Theta ^{\xi }_{\eta }\) represents the additional source which is coupled to gravity through a free parameter \(\chi \). This source term comprises of new fields which induce anisotropy in self-gravitating bodies.

The interior line element describing the spherical structure of a static spacetime has the form

$$\begin{aligned} ds^2_{-}=e^{\mu (r)}dt^2-e^{\lambda (r)}dr^2-r^2(d\theta ^2+\sin ^2\theta d\phi ^2), \end{aligned}$$
(6)

where \(\mu (r)\) and \(\lambda (r)\) are unknown metric potentials. Here, subscript “−” represents the interior spacetime. The f(R) field equations corresponding to Eq. (4) turn out to be

$$\begin{aligned} \rho +\chi \Theta ^{0}_{0}= & {} e^{-\lambda }\left[ \left( \frac{\mu ''}{2}+\frac{\mu '}{r}+\frac{\mu ^{'2}}{4} -\frac{\mu '\lambda '}{4}\right) f_{R}\nonumber \right. \\&\left. -\left( \frac{2}{r} -\frac{\lambda '}{2}\right) f_{R}'-f_{R}''\right] \nonumber \\&-\frac{f}{2}, \end{aligned}$$
(7)
$$\begin{aligned} p-\chi \Theta ^{1}_{1}= & {} e^{-\lambda }\left[ \left( \frac{\lambda '}{r}-\frac{\mu ^{'2}}{4}-\frac{\mu ''}{2} +\frac{\mu '\lambda '}{4}\right) f_{R}\nonumber \right. \\&\left. +\left( \frac{\mu '}{2} +\frac{2}{r}\right) f_{R}'\right] \nonumber \\&+\frac{f}{2}, \end{aligned}$$
(8)
$$\begin{aligned} p-\chi \Theta ^{2}_{2}= & {} e^{-\lambda }\left[ \left( \frac{\lambda '}{2r}-\frac{\mu '}{2r}-\frac{1}{r^2} +\frac{e^\lambda }{r^2}\right) f_{R}\nonumber \right. \\&\left. -\left( \frac{\lambda ' -\mu '}{2}-\frac{1}{r}\right) f_{R}'\right. \nonumber \\&+\left. f_{R}''\right] +\frac{f}{2}, \end{aligned}$$
(9)

where prime denotes derivative with respect to r. In f(R) theory, the conservation of the considered setup is expressed as

$$\begin{aligned} p'+\frac{\mu '}{2}(\rho +p)-\chi \left[ (\Theta ^{1}_{1})' +\frac{\mu '}{2}(\Theta ^{1}_{1}-\Theta ^{0}_{0})+\frac{2}{r}(\Theta ^{1}_{1}-\Theta ^{2}_{2})\right] =0.\nonumber \\ \end{aligned}$$
(10)

We can regain the conservation equation for the perfect fluid by setting \(\chi =0\).

Scalar fields consistent with theories of superstring and supergravity have been utilized to formulate several inflationary models representing the primordial universe. The inflationary model suggested by Starobinsky [31] is given as

$$\begin{aligned} f(R)=R+\sigma R^2, \end{aligned}$$
(11)

where \(\sigma \) is a constant (\(\sigma >0\)) and \(f_{RR}>0\). In this model, the term \(\sigma R^{2}\) describes the exponential expansion of the universe. Moreover, this model is consistent with the anisotropic temperature detected in Cosmic Microwave Background. Thus, it can be used as a reliable alternative for the inflationary models [57]. Researchers have determined that the value of \(\sigma \) corresponding to celestial objects lies between 0 and 6 [46]. It is worth mentioning here that the results of GR can be recovered for \(\sigma =0\).

The field equations corresponding to Eq. (11) are expressed as

$$\begin{aligned} \rho +\chi \Theta ^{0}_{0}= & {} \frac{1}{r^{2}}-e^{-\lambda }\left( \frac{1}{r^{2}}- \frac{\lambda '}{r}\right) -\sigma F_{1}, \end{aligned}$$
(12)
$$\begin{aligned} p-\chi \Theta ^{1}_{1}= & {} e^{-\lambda }\left( \frac{\mu '}{r} +\frac{1}{r^{2}}\right) -\frac{1}{r^{2}}-\sigma F_{2}, \end{aligned}$$
(13)
$$\begin{aligned} p-\chi \Theta ^{2}_{2}= & {} e^{-\lambda }\left( \frac{\mu ''}{2} -\frac{\lambda '}{2r}+\frac{\mu '}{2r}-\frac{\mu '\lambda '}{4} +\frac{\mu ^{'2}}{4}\right) -\sigma F_{3},\nonumber \\ \end{aligned}$$
(14)

where \(F_{1},~F_{2}\) and \(F_{3}\) contain the modified terms as

$$\begin{aligned} F_{1}= & {} -\frac{R^2}{2}+2e^{-\lambda }\left[ R''-\left( \frac{\lambda '}{2} -\frac{2}{r}\right) R'\right] \\&-2R\left[ e^{-\lambda }\left( \frac{\lambda '}{r} -\frac{1}{r^2}\right) +\frac{1}{r^2}\right] ,\\ F_{2}= & {} \frac{R^2}{2}-2e^{-\lambda }\left( \frac{\mu '}{2}+\frac{2}{r}\right) R'\\&-2R\left[ e^{-\lambda }\left( \frac{\mu '}{r}+\frac{1}{r^2}\right) -\frac{1}{r^2}\right] ,\\ F_{3}= & {} \frac{R^2}{2} +2e^{-\lambda }\left[ R'\left( \frac{\lambda '-\mu '}{2} -\frac{1}{r}\right) \right. \\&-R\left( \frac{\mu ''}{2}-\frac{\lambda '-\mu '}{2r}+\frac{\mu '^2-\lambda ' \mu '}{4}\right) \\&-\left. R''\right] . \end{aligned}$$

We identify the effective energy density and effective pressure components as

$$\begin{aligned} {{\widetilde{\rho }}}^{~eff}=\rho +\chi \Theta ^{0}_{0},\quad {{\widetilde{p}}}^{~eff}_{r}=p-\chi \Theta ^{1}_{1},\quad {{\widetilde{p}}}^{~eff}_{t}=p-\chi \Theta ^{2}_{2}. \end{aligned}$$
(15)

It is clear through direct analysis that the addition of new source generates anisotropy in self-gravitating systems. The effective anisotropic parameter \({{\widetilde{\Delta }}}^{eff}\) in the interior of stellar objects is defined as

$$\begin{aligned} {{\widetilde{\Delta }}}^{eff}={{\widetilde{p}}}^{~eff}_{t} -{{\widetilde{p}}}^{~eff}_{r}=\chi (\Theta ^{1}_{1}-\Theta ^{2}_{2}), \end{aligned}$$
(16)

which vanishes if we set \(\chi =0\). The system of three differential equations (12)–(14) interlink seven unknowns \((\mu , \lambda , \rho , p, \Theta ^{0}_{0}, \Theta ^{1}_{1}, \Theta ^{2}_{2})\). In order to compute these unknowns, we follow a systematic scheme proposed by Ovalle [26].

3 The extended geometric deformation approach

In this section, we formulate a solution of non-linear field equations through the EGD approach [26]. This scheme transforms the system of field equations corresponding to the additional source \(\Theta ^{\xi }_{\eta }\) into a system of quasi-field equations. The effects of additional source \(\Theta ^{\xi }_{\eta }\) are analyzed by applying geometric deformation on the metric functions (\(\mu \) and \(\lambda \)) as

$$\begin{aligned} e^{-\lambda }=\nu +\chi h(r),\quad \mu =\alpha +\chi g(r), \end{aligned}$$
(17)

where the temporal and radial deformation functions are represented by g(r) and h(r), respectively. Plugging these decompositions in Eqs. (12)–(14), we split them into two arrays. The first system is obtained for \(\chi =0\) and provides the following standard field equations

$$\begin{aligned} \rho= & {} \frac{1}{r^{2}}-\frac{\nu }{r^{2}}-\frac{\nu '}{r}-\frac{1}{8r^{4}}\sigma Y_{1}, \end{aligned}$$
(18)
$$\begin{aligned} p= & {} {\nu }\left( \frac{\alpha '}{r} +\frac{1}{r^{2}}\right) -\frac{1}{r^{2}}+\frac{1}{8r^{4}}\sigma Y_{2}, \end{aligned}$$
(19)
$$\begin{aligned} p= & {} {\nu }\left( \frac{\alpha ''}{2} +\frac{\alpha '}{2r}+\frac{\alpha ^{'2}}{4}\right) \nonumber \\&+\frac{\nu '}{2r} +\frac{\nu '\alpha '}{4}+\frac{1}{8r^{4}}\sigma Y_{3}, \end{aligned}$$
(20)

where \(Y_{1}\), \(Y_{2}\) and \(Y_{3}\) contain the modified terms defined in Appendix A. The second set of equations, comprising of the additional source, leads to

$$\begin{aligned} \Theta ^{0}_{0}= & {} -\frac{h}{r^{2}}-\frac{h'}{r}+\frac{1}{8r^{4}}\sigma Z_{1}, \end{aligned}$$
(21)
$$\begin{aligned} \Theta ^{1}_{1}= & {} -h\left( \frac{\alpha '+\chi g'}{r}+\frac{1}{r^2}\right) -\frac{\nu g'}{r}+\frac{1}{8r^{4}}\sigma Z_{2}, \end{aligned}$$
(22)
$$\begin{aligned} \Theta ^{2}_{2}= & {} -h\left( \frac{\alpha ''+\chi g''}{2}+\frac{{(\alpha '+\chi g')}^{2}}{4} \nonumber \right. \\&\left. +\frac{\alpha '+\chi g'}{2 r}\right) -\frac{h'}{2r}-\nu \left( \frac{g''}{2}\right. \nonumber \\&+\left. \frac{\alpha 'g'}{2}+\frac{\chi g'^2}{4}+\frac{g'}{2 r}\right) \nonumber \\&-\frac{h'}{4} \left( \alpha '+\chi g'\right) -\frac{\nu 'g'}{4}-\frac{1}{8r^{4}}\sigma Z_{3}. \end{aligned}$$
(23)

The terms \(Z_{1}\), \(Z_{2}\) and \(Z_{3}\), appearing due to the function f(R), are expressed in Appendix A.

The Bianchi identity is preserved for the perfect fluid distribution in the \((\alpha ,\nu )\)-frame as

$$\begin{aligned} \nabla ^{(\alpha ,\nu )}_{\xi }{{\widetilde{T}}}^{\xi }_{\eta }=0, \end{aligned}$$
(24)

while the divergence of \({{\widetilde{T}}}^{\xi }_{\eta }\) associated with metric (6) turns out to be

$$\begin{aligned} \nabla _{\xi }{{\widetilde{T}}}^{\xi }_{\eta }=\nabla ^{(\alpha ,\nu )}_{\xi } {{\widetilde{T}}}^{\xi }_{\eta }+\frac{\chi g'}{2}(\rho +p)\delta ^{1}_{\eta }. \end{aligned}$$
(25)

For the gravitational source \(\Theta ^{\xi }_{\eta }\), the conservation equation takes the form

$$\begin{aligned} \nabla _{\xi }\Theta ^{\xi }_{\eta }=-\frac{g'}{2}(\rho +p)\delta ^{1}_{\eta }. \end{aligned}$$
(26)

We conclude from Eqs. (25) and (26) that the matter sources (perfect fluid source and the additional source) exchange energy in contrast to the MGD scheme where interaction is purely gravitational. Here, it is noteworthy that the EGD technique is applicable when there is no exchange of energy in two particular scenarios: vacuum (\({\widetilde{T}}^{\xi }_{\eta }=0\)) and barotropic (\({\widetilde{T}}^{0}_{0}={\widetilde{T}}^{1}_{1}\)) fluid distributions.

4 Junction conditions

In order to investigate the physical features of self-gravitating system, the junction conditions must be fulfilled at the hypersurface \((\Sigma )\) of stellar body. A hypersurface is a boundary between interior and exterior spacetimes that separates them from each other. These matching conditions describe a connection between interior and exterior spacetimes at \(r={\mathcal {R}}\), where \({\mathcal {R}}\) denotes the radius of stellar body. In GR, the exterior vacuum of a static spherical object is represented by the Schwarzschild spacetime. However, in the present work, the contributions from f(R) gravity as well as the deformed metric potentials may modify the exterior manifold. The vacuum solution in f(R) theory coincides with the Schwarzschild metric if the function f(R) belongs to class \(C^{3}\) (a function whose first three derivatives are continuous) with [58]

$$\begin{aligned} f(0)=0, \quad f_{R}(0)\ne 0. \end{aligned}$$
(27)

The model \(f(R)=R+\sigma R^2\) is consistent with these conditions. Thus, we can use Schwarzschild spacetime to represent the exterior vacuum.

We consider the interior geometry as

$$\begin{aligned} ds^2_{-}= & {} e^{\mu _{-}(r)}dt^2-\left( 1-\frac{2m(r)}{r}+\chi h(r)\right) ^{-1}dr^2\nonumber \\&-r^2(d\theta ^2+\sin ^2\theta d\phi ^2), \end{aligned}$$
(28)

where m(r) is the mass of interior geometry. The line element describing the exterior geometry takes the following form

$$\begin{aligned} ds^2_{+}= & {} \left( 1-\frac{2{\bar{m}}(r)}{r}+\chi g^{*}(r)\right) dt^2\nonumber \\&-\left( 1-\frac{2{\bar{m}}(r)}{r}+\chi h^{*}(r)\right) ^{-1}dr^2-r^2\nonumber \\&\times \left( d\theta ^2+\sin ^2\theta d\phi ^2\right) . \end{aligned}$$
(29)

Here, subscript “\(+\)” represents the exterior spacetime. Moreover, \({\bar{m}}\), \(h^{*}\) and \(g^{*}\) represent the exterior mass, radial and temporal geometric deformations in the exterior Schwarzschild, respectively. The smooth matching between interior and exterior spacetimes at the hypersurface \(\Sigma :r={\mathcal {R}}\) specifies the unknown constants. The continuity of the first fundamental form (\([ds^{2}]_{\Sigma }=0\)) yields

$$\begin{aligned} \alpha ({\mathcal {R}})+\chi g({\mathcal {R}})= & {} 1-\frac{2{\bar{m}}({\mathcal {R}})}{{\mathcal {R}}}+\chi g^{*}({\mathcal {R}}), \end{aligned}$$
(30)
$$\begin{aligned} 1-\frac{2m({\mathcal {R}})}{{\mathcal {R}}}+\chi h({\mathcal {R}})= & {} 1-\frac{2{\bar{m}}({\mathcal {R}})}{{\mathcal {R}}}+\chi h^{*}({\mathcal {R}}). \end{aligned}$$
(31)

The second fundamental form of continuity, expressed as \([T_{\xi \eta }^{tot}X^{\eta }]_{\Sigma }=0\) (\(X^{\eta }\) is a unit four vector in radial direction), leads to

$$\begin{aligned} p({\mathcal {R}})-\chi \Theta ^{1}_{1}({\mathcal {R}})_{-}=-\chi \Theta ^{1}_{1}({\mathcal {R}})_{+}. \end{aligned}$$

Using Eq. (22), the above expression is rewritten as

$$\begin{aligned}&p({\mathcal {R}})+\chi \left( h({\mathcal {R}})\left( \frac{1}{{\mathcal {R}}^{2}}+\frac{\mu '}{{\mathcal {R}}}\right) +\frac{\nu g'}{{\mathcal {R}}}-\frac{\sigma }{8r^{4}} Z_{2}\right) \nonumber \\&\quad =\frac{\chi h^{*}({\mathcal {R}})}{{\mathcal {R}}^{2}}\left( 1+\frac{2{\bar{m}}}{{\mathcal {R}}-2{\bar{m}}}\right) \nonumber \\&\qquad +\frac{\chi \nu {g^{*}}'}{{\mathcal {R}}}-\frac{\chi \sigma }{8r^{4}} Z_{2}^{*}, \end{aligned}$$
(32)

We assume that \(h^{*}=g^{*}=0\) so that the exterior manifold reduces to Schwarzschild metric and the pressure remains unaffected at the boundary of the star, i.e.,

$$\begin{aligned} {\widetilde{p}}^{~eff}({\mathcal {R}})= & {} p({\mathcal {R}})+\chi \left( h({\mathcal {R}})\left( \frac{1}{{\mathcal {R}}^{2}}+\frac{\mu '}{{\mathcal {R}}}\right) \nonumber \right. \\&\left. +\frac{\nu g'}{{\mathcal {R}}}-\frac{\sigma }{8r^{4}} Z_{2}\right) =0. \end{aligned}$$
(33)

In f(R) gravity, two additional conditions related to Ricci scalar must hold to ensure a smooth junction between interior and exterior manifolds [59,60,61]. These conditions read

$$\begin{aligned} {[}R]_{\Sigma }=0, \quad [\nabla _{\xi }R]_{\Sigma }=0, \end{aligned}$$
(34)

where scalar curvature R is a function of r only. The conditions in Eq. (34) hold for the stellar model constructed in the current work.

5 Anisotropic interior solutions

In order to solve the system of field equations associated with the anisotropic distribution, we need known isotropic solutions. Thus, we choose Krori–Barua solution for perfect matter configuration [62]. This solution is known for its singularity free nature and was initially used to study charged relativistic objects. However, later on, this solution has also been used in the absence of charge in GR as well as in other modified theories [63, 64]. The Krori–Barua solution is isotropic in the presence of electromagnetic field but it may not correspond to an isotropic spacetime in the absence of charge. The metric potentials of Krori–Barua solution generate a purely isotropic fluid distribution in f(R) theory, if and only if \(p_{r}=p_{t}\). Therefore, in order to evaluate the expression of isotropic pressure, we employ this condition \(p_{r}=p_{t}\). Thus, the Krori–Barua solution in f(R) gravity takes the form

$$\begin{aligned} e^{\alpha (r)}= & {} e^{{\mathcal {B}}r^{2}+{\mathcal {C}}}, \end{aligned}$$
(35)
$$\begin{aligned} e^{\lambda (r)}= & {} \nu ^{-1}(r)=e^{{\mathcal {A}}r^{2}}, \end{aligned}$$
(36)
$$\begin{aligned} \rho= & {} e^{-{\mathcal {A}} r^2} \left( 2 {\mathcal {A}}-\frac{1}{r^2}\right) +\frac{1}{r^2}\nonumber \\&-\frac{2 \sigma e^{-2 {\mathcal {A}} r^2}}{r^4} \left[ e^{2 {\mathcal {A}} r^2}-{\mathcal {B}}^4 r^8-6 {\mathcal {B}}^3 r^6\right. \nonumber \\&-6e^{{\mathcal {A}}r^2}+3 {\mathcal {B}}^2 r^4+5\nonumber \\&-12 {\mathcal {A}}^3 r^6 \left( {\mathcal {B}} r^2+2\right) +{\mathcal {A}}^2 r^4 \left( 11 {\mathcal {B}}^2 r^4\right. \nonumber \\&+\left. 68{\mathcal {B}}r^2+40\right) +2 {\mathcal {A}} r^2 \left( {\mathcal {B}}^3 r^6\nonumber \right. \\&\left. \left. -13 {\mathcal {B}}^2 r^4-24 {\mathcal {B}} r^2+2\right) \right] , \end{aligned}$$
(37)
$$\begin{aligned} p= & {} \frac{e^{-2{\mathcal {A}}r^2}}{2r^2}\left[ -e^{2{\mathcal {A}}r^2} +e^{{\mathcal {A}}r^2}\left\{ 1+{\mathcal {B}}^2r^4\nonumber \right. \right. \\&-{\mathcal {A}}\left( {\mathcal {B}}r^4 +r^2+12\sigma \right) +4{\mathcal {B}}\left( r^2\right. \nonumber \\&+\left. \left. 3\sigma \right) \right\} -4\sigma \left\{ 6 {\mathcal {A}}^3r^4\left( {\mathcal {B}}r^2+2\right) \nonumber \right. \nonumber \\&+{\mathcal {A}}\left( 4{\mathcal {B}}^3 r^6+34{\mathcal {B}}^2r^4+35{\mathcal {B}}r^2-3\right) \nonumber \\&-{\mathcal {A}}^2 r^2 \left( 10 {\mathcal {B}}^2 r^4+43 {\mathcal {B}} r^2+20\right) \nonumber \\&\left. \left. +{\mathcal {B}} \left( -5 {\mathcal {B}}^2 r^4-11 {\mathcal {B}} r^2+3\right) \right\} \right] , \end{aligned}$$
(38)

where \({\mathcal {A}}\), \({\mathcal {B}}\) and \({\mathcal {C}}\) are constants that can be computed through matching conditions on the hypersurface. The smooth matching of external and internal regions on the hypersurface determine the unknown constants of the anisotropic solution and contribute to the investigation of its physical features. Here, we consider Schwarzschild as an exterior spacetime described by the line element

$$\begin{aligned} ds^2_{+}= & {} \left( 1-\frac{2{\bar{m}}(r)}{r}\right) dt^2-\frac{1}{\left( 1-\frac{2{\bar{m}}(r)}{r}\right) }dr^2\nonumber \\&-r^2(d\theta ^2+\sin ^2\theta d\phi ^2), \end{aligned}$$
(39)

The continuity of the metric components \(g_{00},~g_{11}\) and \(g_{00,1}\) at the boundary (\(r={\mathcal {R}}\) and total mass\(={\mathcal {M}}\)) yields

$$\begin{aligned} {\mathcal {A}}= & {} -\frac{1}{{\mathcal {R}}^{2}}\ln \left( 1-\frac{2{\mathcal {M}}}{{\mathcal {R}}}\right) , \end{aligned}$$
(40)
$$\begin{aligned} {\mathcal {B}}= & {} \frac{{\mathcal {M}}}{{\mathcal {R}}^{2}({\mathcal {R}} -2{\mathcal {M}})}, \end{aligned}$$
(41)
$$\begin{aligned} {\mathcal {C}}= & {} \ln \left( 1-\frac{2{\mathcal {M}}}{{\mathcal {R}}}\right) -\frac{{\mathcal {M}}}{{\mathcal {R}}-2{\mathcal {M}}}. \end{aligned}$$
(42)

with the compactness parameter \(\frac{{\mathcal {M}}}{{\mathcal {R}}}<\frac{4}{9}\left( 1+\frac{\beta }{6}\right) \), where \(\beta \) (with \(0\le \beta \ll 1\)) denotes small modification in the Buchdahl–Bondi limit [65]. The model is also consistent with the conditions in Eq. (34). For anisotropic model, the expressions of effective matter variables are evaluated as follows

$$\begin{aligned} {{\widetilde{\rho }}}^{~eff}= & {} \frac{1}{r^{2}}-\frac{\nu }{r^{2}}-\frac{\nu '}{r}-\frac{1}{8r^{4}}\sigma Y_{1}\nonumber \\&+\chi \left[ -\frac{h}{r^{2}}-\frac{h'}{r}+\frac{1}{8r^{4}}\sigma Z_{1}\right] , \end{aligned}$$
(43)
$$\begin{aligned} {{\widetilde{p}}}_{r}^{~eff}= & {} {\nu }\left( \frac{\alpha '}{r} +\frac{1}{r^{2}}\right) -\frac{1}{r^{2}}+\frac{1}{8r^{4}}\sigma Y_{2}\nonumber \\&-\chi \left[ -h\left( \frac{\alpha '+\chi g'}{r}+\frac{1}{r^2}\right) -\frac{\nu g'}{r}\right. \nonumber \\&+\left. \frac{1}{8r^{4}}\sigma Z_{2}\right] , \end{aligned}$$
(44)
$$\begin{aligned} {{\widetilde{p}}}_{t}^{~eff}= & {} {\nu }\left( \frac{\alpha ''}{2} +\frac{\alpha '}{2r}+\frac{\alpha ^{'2}}{4}\right) +\frac{\nu '}{2r} +\frac{\nu '\alpha '}{4}\nonumber \\&+\frac{1}{8r^{4}}\sigma Y_{3}-\chi \left[ -h\left( \frac{\alpha ''+\chi g''}{2}\right. \right. \nonumber \\&+\left. \left. \frac{{(\alpha '+\chi g')}^{2}}{4} +\frac{\alpha '+\chi g'}{2 r}\right) -\frac{h'}{2r}\nonumber \right. \\&-\nu \left( \frac{g''}{2} +\frac{\alpha 'g'}{2}+\frac{\chi g'^2}{4}+\frac{g'}{2 r}\right) \nonumber \\&-\left. \frac{h'}{4}\left( \alpha '+\chi g'\right) -\frac{\nu 'g'}{4}-\frac{1}{8r^{4}}\sigma Z_{3}\right] , \end{aligned}$$
(45)

with anisotropic factor

$$\begin{aligned} {\widetilde{\Delta }}^{eff}= & {} \chi \left[ -h\left( \frac{\alpha '+\chi g'}{r}+\frac{1}{r^2}\right) -\frac{\nu g'}{r}\nonumber \right. \\&+\frac{1}{8r^{4}}\sigma Z_{2}-\left\{ -h\left( \frac{\alpha ''+\chi g''}{2}\right. \right. \nonumber \\&+\left. \frac{{(\alpha '+\chi g')}^{2}}{4} +\frac{\alpha '+\chi g'}{2 r}\right) -\frac{h'}{2r}\nonumber \\&-\nu \left( \frac{g''}{2} +\frac{\alpha 'g'}{2}+\frac{\chi g'^2}{4}+\frac{g'}{2 r}\right) \nonumber \\&-\left. \left. \frac{h'}{4}\left( \alpha '+\chi g'\right) -\frac{\nu 'g'}{4}-\frac{1}{8r^{4}}\sigma Z_{3}\right\} \right] . \end{aligned}$$
(46)

The system (21)–(23) interlinks the components of additional source with the deformation functions. In order to solve this system of quasi-field equations, we need additional constraints to close the system. In this regard, we implement a barotropic equation of state on \(\Theta ^{\xi }_{\eta }\) as

$$\begin{aligned} \Theta ^{0}_{0}=\delta \Theta ^{1}_{1}+\gamma \Theta ^{2}_{2}, \end{aligned}$$
(47)

For simplicity, we set \(\gamma =0\) and \(\delta =1\) which forms the relation \(\Theta ^{0}_{0}=\Theta ^{1}_{1}\). We also employ two additional constraints (density-like and pressure-like) and formulate corresponding solutions.

Fig. 1
figure 1

Plots of \({{\widetilde{\rho }}}^{~eff}\), \({{\widetilde{p}}}^{~eff}_{r}\), \({{\widetilde{p}}}^{~eff}_{t}\) and \({{\widetilde{\Delta }}}^{eff}\) for the solution I

Fig. 2
figure 2

Plots of \({\widetilde{\rho }}^{~eff}-{\widetilde{p}}_r^{~eff}\) and \({\widetilde{\rho }}^{~eff}-{\widetilde{p}}_{t}^{~eff}\) for solution I

5.1 Solution I

In this section, we apply an additional constraint on the temporal component of source term in order to close the system. We adopt density-like constraint such as

$$\begin{aligned} \Theta ^{0}_{0}=\rho . \end{aligned}$$
(48)

The deformation functions are evaluated numerically through Eqs. (47) and (48) by plugging the metric potentials of Krori–Barua spacetime. For this constraint, the presence of higher order derivatives of unknown functions hinders the extraction of numerical solutions. Therefore, we assume quadratic deformation functions and solve the corresponding system of differential equations for the initial conditions \(g(0.01)=g'(0.01)=h(0.01)=h'(0.01)=0\). The values of constants \({\mathcal {A}}\) and \({\mathcal {B}}\) evaluated in Eqs. (40) and (41) are used to evaluate the numerical solution. We discuss physical characteristics of the stellar bodies through graphical analysis corresponding to the star Her X-I with radius \({\mathcal {R}}=8.10\) km and mass \({\mathcal {M}}=1.25375\) km [66, 67]. We compute values of \(\sigma \) for \(\chi =0.04,~0.06\) through the condition \({\widetilde{p}}^{~eff}_r({\mathcal {R}})=0\).

Fig. 3
figure 3

Plots of hydrostatic equilibrium with \(\chi =0~(\text {dotted})\), \(0.04~(\text {dashed})\), \(0.06~(\text {solid})\) for solution I

Fig. 4
figure 4

Plots of \(v_{sr}^2\), \(v_{st}^2\) and \(|v_{st}^2-v_{sr}^2|\) for the solution I

The energy density and pressure (radial as well as temporal) of a well-behaved stellar structure must be finite, positive and maximum at the center. The plots of physical parameters (\({{\widetilde{\rho }}}^{~eff}\), \({{\widetilde{p}}}^{~eff}_{r}\), \({{\widetilde{p}}}^{~eff}_{t}\)) along with anisotropy factor are displayed in Fig.  1. The profile of effective energy density indicates that it is maximum at \(r=0\) and declines gradually with increasing r. It is found that an increase in \(\chi \) and \(\sigma \) causes a decrease in \({{\widetilde{\rho }}}^{~eff}\). The graph of effective radial pressure \({{\widetilde{p}}}^{~eff}_{r}\) depicts that it vanishes at the star’s surface and decreases monotonically as \(\sigma \) and \(\chi \) decrease. The trend of \({{\widetilde{p}}}^{~eff}_{r}\) gradually decreases with respect to r. It is observed that the behavior of \({{\widetilde{p}}}^{~eff}_{t}\) decreases towards the boundary and at the center of the star, it increases for larger values of \(\chi \). The plot of effective anisotropic factor shows that \({{\widetilde{\Delta }}}^{~eff}>0\) away from the center. Moreover, it violates the regularity condition as radial and tangential pressures are not same at the center of the celestial object. We observe that the anisotropic factor vanishes for \(\chi =0\).

To measure the viability of the resulting solution, four energy conditions (null (NEC), weak (WEC), strong (SEC) and dominant (DEC)) must be satisfied. These energy conditions indicate the presence of ordinary matter in a compact celestial system. In f(R) scenario, these energy bounds are given in terms of \({\widetilde{\rho }}^{~eff}\), \({\widetilde{p}}_r^{~eff}\) and \({\widetilde{p}}_t^{~eff}\) as

$$\begin{aligned}&\text {NEC:}\quad {\widetilde{\rho }}^{~eff}+{\widetilde{p}}_r^{~eff}\ge 0, \quad {\widetilde{\rho }}^{~eff}+{\widetilde{p}}_{t}^{~eff}\ge 0,\\&\text {WEC:}~~{\widetilde{\rho }}^{~eff}\ge 0,\quad {\widetilde{\rho }}^{~eff}+{\widetilde{p}}_r^{~eff}\ge 0,\\&\qquad \qquad \quad {\widetilde{\rho }}^{~eff}+{\widetilde{p}}_{t}^{~eff}\ge 0,\\&\text {SEC:}\quad {\widetilde{\rho }}^{~eff}+{\widetilde{p}}_r^{~eff} +2{\widetilde{p}}_{t}^{~eff}\ge 0,\\&\text {DEC:}~~{\widetilde{\rho }}^{~eff}-{\widetilde{p}}_r^{~eff}\ge 0,\quad {\widetilde{\rho }}^{~eff}-{\widetilde{p}}_{t}^{~eff}\ge 0. \end{aligned}$$

As Fig. 1 illustrates the positive behavior of \({\widetilde{\rho }}^{~eff}\), \({\widetilde{p}}_r^{~eff}\) and \({\widetilde{p}}_t^{~eff}\), the null, weak and strong energy conditions are satisfied. Therefore, we only display the plots of DEC which also exhibit positive behavior as shown in Fig.  2. Hence, the graphical behavior assures the physical viability of the constructed solution.

In order to determine the equilibrium state of the constructed anisotropic model, we use the Tolman–Oppenheimer–Volkoff (TOV) equation [68, 69]. This equation demonstrates that sum of all physical forces acting on the system must be equal to zero. In the considered setup these forces are classified as gravitational (\(f_{g}\)), anisotropic (\(f_{a}\)) and hydrostatic (\(f_{h}\)) forces. Corresponding to the spherical spacetime, the TOV equation becomes

$$\begin{aligned}&-[p'-\chi (\Theta ^{1}_{1})']-\bigg [\frac{\alpha '}{2}(\rho +p)+\frac{\chi g'}{2}(\rho +p)\\&\qquad +\frac{\mu '\chi }{2}(\Theta ^{0}_{0} -\Theta ^{1}_{1})\bigg ]+\bigg [\frac{2\chi }{r}(\Theta ^{2}_{2}-\Theta ^{1}_{1})\bigg ]=0. \end{aligned}$$
Fig. 5
figure 5

Plot of \(\Gamma \) and \(\Gamma _{critical}\) for solution I

Fig. 6
figure 6

Plots of \({{\widetilde{\rho }}}^{~eff}\), \({{\widetilde{p}}}^{~eff}_{r}\), \({{\widetilde{p}}}^{~eff}_{t}\) and \({{\widetilde{\Delta }}}^{eff}\) for solution II

The hydrostatic, gravitational and anisotropic forces are, respectively expressed as

$$\begin{aligned} f_{h}= & {} -[p'-\chi (\Theta ^{1}_{1})'],\\ f_{g}= & {} -\bigg [\frac{\alpha '}{2}(\rho +p)+\frac{\chi g'}{2}(\rho +p)+\frac{\mu '\chi }{2}(\Theta ^{0}_{0} -\Theta ^{1}_{1})\bigg ],\\ f_{a}= & {} \bigg [\frac{2\chi }{r}(\Theta ^{2}_{2}-\Theta ^{1}_{1})\bigg ]. \end{aligned}$$

The graphical analysis of these forces in Fig.  3 exhibits that gravitational force is balanced by the remaining forces. Moreover, for \(\chi =0\), the gravitational force vanishes and the other two force counter balance each other. This depicts that the constructed model is in hydrostatic equilibrium. We now check the stability of the constructed anisotropic model.

Fig. 7
figure 7

Plots of \({\widetilde{\rho }}^{~eff}-{\widetilde{p}}_r^{~eff}\) and \({\widetilde{\rho }}^{~eff}-{\widetilde{p}}_{t}^{~eff}\) for solution II

Fig. 8
figure 8

Plots of hydrostatic equilibrium with \(\chi =0~(\text {dotted})\), \(0.3~(\text {dashed})\), \(0.5~(\text {solid})\) for solution II

The stability of a self-gravitating body is an important feature that ensures its existence and realistic matter configuration. In this regard, causality condition [70] (squared speed of sound \(v_{s}^2\) must lie in the range [0, 1]) is a substantial tool to examine the stability of celestial objects. Herrera [71] proposed the idea of cracking by analyzing potentially stable or unstable regions of celestial objects. According to this idea, these regions are defined as

$$\begin{aligned}&\bullet \quad -1\le v_{st}^2-v_{sr}^2\le 0\Longrightarrow \text {Potentially stable mode}\\&\bullet \quad \quad 0<v_{st}^2-v_{sr}^2\le 1\Longrightarrow \text {Potentially unstable mode} \end{aligned}$$

where \(v_{st}^2\) and \(v_{sr}^2\) are the tangential and radial components of squared speed of sound, respectively and are defined as

$$\begin{aligned} v_{sr}^2=\frac{d{\widetilde{p}}_r^{~eff}}{d{\widetilde{\rho }}^{~eff}},\quad v_{st}^2=\frac{d{\widetilde{p}}_t^{~eff}}{d{\widetilde{\rho }}^{~eff}}. \end{aligned}$$

The cracking conditions are expressed in combined form as \(|v_{st}^2-v_{sr}^2|<1\). Figure 4 illustrates the graphical behavior of \(v_{sr}^2\) and \(v_{st}^2\) which indicates that the anisotropic extension is not stable. On the other hand, cracking condition \(|v_{st}^2-v_{sr}^2|\) yields stable behavior of system for the chosen values of parameters.

The system obeys a stiff equation of state (EoS) if an increase in density causes an effective increase in pressure. A structure associated with a stiff EoS is harder to compress and more stable as compared to a setup corresponding to a soft EoS. The stiffness of EoS is measured through adiabatic index (\(\Gamma \)). According to the condition proposed by Heintzmann and Hillebrandt [72], the adiabatic index must be greater than \(\frac{4}{3}\) for a stable model in equilibrium. However, the inclusion of local anisotropies in the system changes the upper limit. So, in the anisotropic case, the adiabatic index should satisfy [73]

$$\begin{aligned} \Gamma >\frac{4}{3}+\left[ \frac{r}{3}\frac{{\widetilde{\rho }}_{0}^{~eff} {\widetilde{p}}_{r0}^{~eff}}{|({{\widetilde{p}}_{r0}}^{~eff})'|} +\frac{4}{3}\frac{({\widetilde{p}}_{t0}^{~eff}-{\widetilde{p}}_{r0}^{~eff})}{r|({{\widetilde{p}}_{r0}}^{~eff})'|}\right] , \end{aligned}$$

where \({\widetilde{p}}_{r0}^{~eff}\), \({\widetilde{p}}_{r0}^{~eff}\) and \({\widetilde{p}}_{t0}^{~eff}\) denote effective initial density, effective initial radial and tangential pressures. The above expression involves the contributions from local anisotropies and represents relativistic corrections in the adiabatic index. However, Chandrasekhar [74, 75] pointed out that relativistic corrections to the adiabatic index could induce instabilities within the stellar interior. To resolve this problem, Moustakidis [76] introduced a more strict condition on \(\Gamma \) and proposed a critical value of adiabatic index (\(\Gamma _{critical}\)). The value of critical adiabatic index depends on the amplitude of Lagrangian displacement \((\zeta (r))\) from equilibrium and the compactness parameter \(2{\mathcal {M}}/{\mathcal {R}}\). Considering a particular value of the parameter \(\zeta (r)\), we obtain the critical adiabatic index as

$$\begin{aligned} \Gamma _{critical}=\frac{4}{3}+\frac{19}{21}\left( \frac{{\mathcal {M}}}{{\mathcal {R}}}\right) . \end{aligned}$$

Thus, the stability condition becomes \(\Gamma \ge \Gamma _{critical}\), where the \(\Gamma \) is defined as

$$\begin{aligned} \Gamma =\frac{{\widetilde{p}}_r^{~eff}+{\widetilde{\rho }}^{~eff}}{{\widetilde{p}}_r^{~eff}} \frac{d{\widetilde{p}}_r^{~eff}}{d{\widetilde{\rho }}^{~eff}} =\frac{{\widetilde{p}}_r^{~eff}+{\widetilde{\rho }}^{~eff}}{{\widetilde{p}}_r^{~eff}}v_{sr}^2. \end{aligned}$$
Fig. 9
figure 9

Plots of \(v_{sr}^2\), \(v_{st}^2\) and \(|v_{st}^2-v_{sr}^2|\) for solution II

Fig. 10
figure 10

Plot of \(\Gamma \) and \(\Gamma _{critical}\) for solution II

A compact star with an increasing and positive anisotropy factor, behaves stable for the limit given above. The positive anisotropy generates a repulsive force that counteracts against the inward gravitational pull. This implies that a star does not collapse for \({\widetilde{p}}_t^{~eff}>{\widetilde{p}}_r^{~eff}\). Thus, the analysis of adiabatic index in radial direction is sufficient to gauge the stability of the spherical system. The rapid decrease in the radial pressure near the boundary of the star causes \(\Gamma \) to increase at a faster rate. Moreover, radial adiabatic index behaves asymptotically near the star’s surface as \({\widetilde{p}}_r^{~eff}({\mathcal {R}})=0\). The profiles of radial and critical adiabatic index in Fig.  5 are not consistent with the inequality \(\Gamma \ge \Gamma _{critical}\). Thus, the extended solution is locally unstable in the presence of higher curvature terms of f(R).

5.2 Solution II

In order to obtain the second anisotropic solution, we apply a constraint on radial component of \(\Theta ^{\xi }_{\eta }\). The matching of Schwarzschild exterior and deformed interior metric on the boundary stipulates \(p({\mathcal {R}})\sim \chi ({\Theta ^{1}_{1}}({\mathcal {R}}))_{-}\). Thus,

$$\begin{aligned} \Theta ^{1}_{1}=p, \end{aligned}$$
(49)

is considered as a suitable constraint. We solve Eqs. (47) and (49) simultaneously by employing Eqs. (35), (36), (40) and (41). The unknown functions h(r) and g(r) are determined numerically for the initial conditions \(g(0.01)=1\times 10^{-9}\), \(g'(0.01)=g''(0.01)=1\times 10^{-7}\), \(g'''(0.01)=1\times 10^{-10}\), \(h(0.01)=9\times 10^{-8}\), \(h^\prime (0.01)=1\times 10^{-8}\) and \(h''(0.01)=1\times 10^{-6}\). The physical behavior of solution II is investigated for the same compact star Her X-I.

In this solution, we choose three values of parameter \(\chi =0,~0.3\) and 0.5 and corresponding to \(\sigma =0.1,~0.2\) and 0.3, respectively. The profiles of \({\widetilde{\rho }}^{~eff}\), \({\widetilde{p}}^{~eff}_{r}\), \({\widetilde{p}}^{~eff}_{t}\) and \({\widetilde{\Delta }}^{eff}\) are displayed in Fig. 6. It is observed that the energy density declines and the radial/tangential pressure increases with the increasing values of \(\chi \) and \(\sigma \). Moreover, matter variables are finite within the interior of celestial object. The anisotropic factor becomes zero at the center of object and increases for larger values of r and \(\chi \). Moreover, for \(\chi =0\), radial and tangential pressures become equal leading to zero anisotropy. As all energy conditions are satisfied therefore, the solution is physically viable as shown in Fig. 7. From Fig. 8, we can see that the system is in hydrostatic equilibrium for the chosen values of \(\chi \) and \(\sigma \), as all the three forces are balanced. Figures 9 and 10 demonstrate the potential stability of the second solution. The plots of radial and critical adiabatic index satisfy the inequality \(\Gamma \ge \Gamma _{critical}\) and lie above the defined limit.

6 Conclusions

The formulation of new solutions for the study of self-gravitating bodies has captured the interest of many astrophysicists. In this regard, the EGD approach has effectively extended spherical isotropic solutions by adding the anisotropic gravitational source. In the current work, we have applied gravitational decoupling via EGD to derive anisotropic solutions corresponding to the Starobinsky model of f(R) gravity. In order to check the consistency of the EGD approach with this model, we have added the effects of a new gravitational source in the isotropic Krori–Barua solution. The f(R) field equations for anisotropic fluid have been successfully decoupled into two sets of equations with each array corresponding to separate sources. The Bianchi identities for the matter sources have indicated the transfer of energy between the two sources. Furthermore, the constants in the considered solution have been determined by the matching of interior and exterior spacetimes on the boundary.

We have introduced a barotropic EoS for \(\Theta _\eta ^{\xi }\) as well as imposed constraints on \(\Theta _0^{0}\) and \(\Theta _1^{1}\) which has yielded solutions I and II, respectively. We have analyzed the physical characteristics of the obtained solutions by plotting the graphs of fluid parameters such as energy density, radial and tangential pressures for the star Her X-I. It has been found that the obtained solutions are physically well-behaved as they obey the necessary conditions of viability. The energy density decreases with a rise in values of \(\chi \) which has led to the construction of less dense spheres. On the other hand, the anisotropy attains larger values for higher values of \(\chi \) in both static solutions. Moreover, the system corresponding to each solution is in hydrostatic equilibrium. The proposed model corresponding to solution I is potentially unstable according to the speed of sound constraints while solution II is stable. We have also checked the stiffness parameter corresponding to both solutions and found that solution I violates the conditions \(\Gamma >\frac{4}{3}\) and \(\Gamma \ge \Gamma _{critical}\) whereas solution II is consistent with these criteria. Thus, the pressure of the developed spherical model corresponding to solution II increases greatly in response to a small change in density. Consequently, the compact body cannot be compressed easily.

Sharif and Ama-Tul-Mughani [29] extended charged Krori–Barua solution to the anisotropic domain via the EGD scheme in GR and deduced that the solutions corresponding to both constraints are physically viable and stable. The viability of the extended solutions is preserved in f(R) gravity while stability is preserved for pressure-like constraint only. From the graphical analysis, we have deduced that the second solution shows stable behavior when \(\chi \in [0,~0.5]\). Sharif and Waseem [50, 51] also utilized the metric potentials of Krori–Barua solution to generate anisotropic models by MGD approach in f(R) gravity for \(\chi \) ranging from 0 to 1. In comparison to this work, a smaller range of \(\chi \) generates stable anisotropic solutions corresponding to the second constraint. It is worthwhile to mention here that the f(R) analog of this solution is physically viable and stable for the particular values of the parameters \(\sigma \) and \(\chi \). We conclude that the f(R) theory yields stable decoupled stellar configuration through EGD technique.