1 Introduction

Compact stars have always attracted researchers due to their ability to offer distinct settings for studying dense nuclear matter. The Einstein field equations (EFEs) play a pivotal role in modeling compact stars. By solving EFEs, many studies aim to comprehend the intrinsic structure and matter distribution within these objects. However, obtaining suitable solutions to EFEs is a challenging task, and not all solutions are physically viable. Schwarzschild derived the inaugural exact solution to EFEs. Since then, the list of possible solutions has been steadily growing. Various authors have used different methods to find these solutions. Compact stars are unlikely to have a uniform matter distribution due to their high density. Anisotropy, also known as uneven matter distribution, is caused by the pressure splitting into several components within these stars [1]. Pressure changes within a star can be brought about by internal processes, even when the star’s initial distribution is uniform. This phenomenon was studied by Herrera [2] and other researchers (refer to [3,4,5,6,7,8,9]).

The embedding of the class one spacetime approach essentially connects two metric potentials. In a 2008 study by Herrera et al. [4], a method was proposed to derive static spherically symmetric anisotropic solutions from EFEs. This technique demonstrated that such solutions could be generated using just two generating functions. The primary advantage of utilizing this embedding is that it enables the entire system to be generated by selecting a single metric potential. Unlike the conventional approach, which usually assumes two generating functions, this method simplifies the process. Additionally, this approach offers a unique benefit of solving highly non-linear EFEs without relying on an equation of state (EoS).

On the other hand, a novel mathematical approach referred to as “vanishing complexity,” introduced by Herrera [10, 11], has attracted significant attention from researchers for its potential applications in analyzing compact stellar objects within both the standard framework of General Relativity (GR) and various modified gravity theories. The assessment of a system’s complexity has been approached through various parameters. Numerous attempts to characterize complexity have been made in various scientific fields (see [12,13,14,15,16,17,18,19,20,21,22,23]). Due to the inherent uniqueness of complex systems, there is currently no widely acknowledged methodology for measuring complexity. Many definitions of the multidimensional nature of complexity have been proposed, and these definitions have been linked to various scientific contexts, including information entropy, phase transitions, chaotic behavior, dimensionality, broken symmetry, and disequilibrium. However, the methods introduced by Lopez-Ruiz and other researchers [19,20,21] have offered a fresh perspective on complexity, which has also been applied to self-gravitating systems [24,25,26,27,28,29]. Herrera proposed a definition primarily designed for static, spherically symmetric systems [10, 11], which was later expanded to encompass scenarios in which spherically symmetric geometry dynamically develops [30].

Herrera’s definition of complexity [10, 11], primarily centers on the internal arrangement of a fluid distribution and is independent of information or disequilibrium. Herrera proposed this definition in the context of stellar systems, utilizing the orthogonal splitting of the Riemann tensor with the help of scalar structures. These scalar entities establish a relationship between local anisotropy in radial and transverse stresses, density non-uniformity, and the Tolman mass, which characterizes a static and confined stellar structure. The simplest system to study is a uniform fluid with equal pressure in all directions, which is assigned a complexity factor of zero. This complexity factor takes into account variations in pressure and energy density and is represented by a scalar function. Complexity disappears in two scenarios: isotropic, homogeneous fluid distributions, and when pressure anisotropy and energy non-uniformity counterbalance each other.

However, for time-dependent systems, complexity must account for dissipative effects and the system’s temporal evolution. It has been demonstrated that the complexity factor can still be expressed using the same scalar function by incorporating dissipative variables and adhering to homologous conditions [30, 31]. Recent studies have investigated how pressure anisotropy, density non-uniformities, and radial heat flux impact the evolution of complexity in radiating stars [32]. Additionally, the concept of complexity has been extended to encompass modified gravity theories within the framework of general relativity [33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48].

Several authors have obtained novel interior solutions for compact stars using two distinct approaches: The embedding class one approach [2, 50,51,52,53,54,55,56,57,58,59,60,61,62,63] (for a comprehensive survey of various metrics that have been used to study exact solutions of the EFEs one can see [64]) and the vanishing complexity approach under diverse settings [65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84].

This paper presents an exact solution obtained using the vanishing complexity approach and provides a comparative analysis with the well-established embedding class one approach. This investigation aims to provide the effectiveness and validity of these methods in generating solutions for EFEs. The physical analysis includes thermodynamical parameters, causality condition, stability analysis, mass function and mass radius profiles. Valuable insights into the behavior of compact objects are obtained through these investigations.

This paper is structured as follows: In Sect. 2, we provide a brief overview of the Einstein field equations system. Sections 2.1 and 2.2 serve as preliminaries to the vanishing complexity condition, as well as an embedding class one spacetime obeying the Karmarkar condition. In Sect. 3, we present a new interior solution based on the vanishing complexity factor and the corresponding solution through the embedding class one spacetime approach. Section 4 analyzes smooth matching between the interior and exterior spacetime using both the vanishing complexity and embedding class one approaches. Sections 58 provide a discussion of the physical properties of the well-behaved solution, including stability analysis, red-shift profiles, anisotropic parameter, energy conditions, and other standard physical parameters. Finally, in Sect. 9, we summarize our findings and concisely conclude the paper.

2 The system of Einstein field equations

The Einstein field equations can be deduced by minimizing the Einstein–Hilbert (EH) action with respect to the metric tensor. The EH action is given by the following expression:

$$\begin{aligned} S = \int \sqrt{-g}~ d^4x ~\left( {1 \over 16\pi }~\mathcal {R}+\mathcal {L}_m \right) . \end{aligned}$$
(1)

Here \(\mathcal {R}=g^{\mu \eta } \mathcal {R}_{\mu \eta }\), is the Ricci scalar invariant, \(\mathcal {L}_m\) represents the matter field Lagrangian and \(g=\text {det}[g_{\mu \eta }]\). The relationship between the matter stress–energy tensor and the Lagrangian \(\mathcal {L}_m\) is given by the equation:

$$\begin{aligned} T_{\mu \eta } = {-2 \over \sqrt{-g}} ~{\delta (\sqrt{-g}~\mathcal {L}_m) \over \delta g^{\mu \eta }}~. \end{aligned}$$
(2)

The interior of a relativistic star is characterized by a Schwarzschild-like line element given as:

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

where, \(e^{\nu (r)}\) and \(e^{\lambda (r)}\) denote arbitrary functions that serve as the metric potentials, defining the structure of the spacetime within the star.

In this model, we employ the following energy-momentum tensor to describe the interior of the anisotropic stellar fluid:

$$\begin{aligned} T_{\mu \eta }= & {} (p_t+\rho )v_{\mu }v_\eta -p_t g_{\mu \eta }+(p_r-p_t)\chi _\mu \chi _\eta . \end{aligned}$$
(4)

Here, the physical parameters \(\rho \), \(p_r\), and \(p_t\) correspond to the energy density, radial pressure measured in the direction of the spacelike vector, and transverse pressure orthogonal to \(p_r\), respectively.

The Einstein field equations for (3)–(4) are given as (for the units \(G=c=1\))

$$\begin{aligned} 8\pi \rho= & {} \frac{1 - e^{-\lambda }}{r^2} + \frac{\lambda 'e^{-\lambda }}{r}, \end{aligned}$$
(5)
$$\begin{aligned} 8\pi p_r= & {} \frac{\nu ' e^{-\lambda }}{r} - \frac{1 - e^{-\lambda }}{r^2}, \end{aligned}$$
(6)
$$\begin{aligned} 8\pi p_t= & {} \frac{e^{-\lambda }}{4}\left( 2\nu '' + {\nu '}^2 - \nu '\lambda ' + \frac{2\nu '}{r}-\frac{2\lambda '}{r}\right) , \end{aligned}$$
(7)

where \((')\) represents differentiation with respect to the radial coordinate r. By making use of (6) and (7), we derive the anisotropy measure as follows:

$$\begin{aligned} \Delta= & {} p_t-p_r. \end{aligned}$$
(8)

2.1 Complexity factor and vanishing complexity condition

The concept of the vanishing complexity factor criteria was introduced by Herrera within the context of general relativity, as outlined in [10].

Following Bel [85], Herrera [10] considered the following tensors (see also [86]):

$$\begin{aligned} Y_{\alpha \beta }= & {} R_{\alpha \gamma \beta \delta }\,u^{\gamma }\,u^{\delta },\\ Z_{\alpha \beta }= & {} ^\star R_{\alpha \gamma \beta \delta }\,u^{\gamma }\,u^{\delta } = \frac{1}{2} \,{\eta }_{{\alpha \gamma \epsilon \mu }} \, R^{\epsilon \mu }\,_{\beta \delta } \,u^{\gamma }u^{\delta },\\ X_{\alpha \beta }= & {} ^\star R^{\star }_{\alpha \gamma \beta \delta }\,u^{\gamma }\,u^{\delta }= \frac{1}{2} \, {\eta _{\alpha \gamma }\,^{\epsilon \mu }} {R^{\star }}_{\epsilon \mu \beta \delta }\,u^{\gamma }\,u^{\delta }, \end{aligned}$$

where \(^\star R_{\alpha \gamma \beta \delta }\) and \(^\star R^{\star }_{\alpha \gamma \beta \delta }\) are the left and double dual tensors. The orthogonal splitting of the Riemann tensor can be expressed in terms of above defined tensors [86]. The following explicit expressions for the three tensors \(Y_{\alpha \beta },\, Z_{\alpha \beta }\) and \(X_{\alpha \beta }\) in terms of the physical variables were calculated in [10]

$$\begin{aligned} Y_{\alpha \beta }= & {} \frac{4\pi }{3}[\rho + (p_r+ 2p_t)]h_{\alpha \beta } + 4\pi \Pi _{\alpha \beta } + E_{\alpha \beta },\\ Z_{\alpha \beta }= & {} 0,\\ X_{\alpha \beta }= & {} \frac{8\pi }{3}\rho \, h_{\alpha \beta } + 4\pi \Pi _{\alpha \beta } - E_{\alpha \beta }. \end{aligned}$$

In fact, utilizing the tensors \(X^{\alpha \beta }\) and \(Y^{\alpha \beta }\), Herrera defined four scalar functions denoted by \(X_T,\, X_{TF}, \,Y_T\), and \(Y_{TF}\), which allow to express these tensors.Additionally, a fifth scalar linked to the tensor \(Z^{\alpha \beta }\) vanishes in the static case (for details, kindly see [10]) and can be expressed as follows:

$$\begin{aligned} X_T= & {} 8\pi \rho ,\end{aligned}$$
(9)
$$\begin{aligned} X_{TF}= & {} \frac{4\pi }{r^3} \int _0^r y^3\frac{d\rho (y)}{dy} \,dy,\end{aligned}$$
(10)
$$\begin{aligned} Y_T= & {} 4\pi (\rho + 3p_r - 2\Pi ),\end{aligned}$$
(11)
$$\begin{aligned} Y_{TF}= & {} 8\pi \Pi - X_{TF}, \end{aligned}$$
(12)

where \(\Pi =p_r-p_t=-\Delta \), where \(\Delta \) is called “local anisotropy of pressure” and is determined by sum of \(X_{TF}\) and \(Y_{TF}\). The latter one determines the complexity factor in static and spherically symmetric self-gravitating systems.

The complexity factor \(Y_{TF}\) for the system (2)–(7) can be written as

$$\begin{aligned} Y_{TF}= & {} 8 \pi \Pi - \frac{4\pi }{r^3} \int _0^r y^3~\frac{d\rho (y)}{dy} \,dy. \end{aligned}$$
(13)

The condition \(Y_{TF}=0\) provides criteria of vanishing complexity. With the help of EFEs and the condition given in (13), the expression of anisotropy becomes:

$$\begin{aligned} \Delta =-\Pi =p_t-p_r= & {} \frac{1}{2r^3} \int _0^r y^3\frac{d\rho (y)}{dy} \,dy. \end{aligned}$$
(14)

The expression given in (14) may be treated as a non-local EOF that can be utilized as a valid criterion for the physical parameters while solving the EFEs.

Substituting the expressions of EFEs into (13) yields the vanishing factor \(Y_{TF}\) as

$$\begin{aligned} Y_{TF} = \frac{\nu '(r\lambda '-r \nu ')+2-2r\nu ''}{4re^\lambda }. \end{aligned}$$
(15)

Further, the vanishing complexity condition becomes

$$\begin{aligned} \nu '[r(\lambda '-\nu ')+2]-2r\nu ''=0. \end{aligned}$$
(16)

The above Eq. (16) can be represented as an exact differential equation

$$\begin{aligned} \frac{d}{dr}\left( {\nu \over 2} + \log \nu '-{\lambda \over 2}-\log r \right)= & {} 0. \end{aligned}$$

On integrating the above equation, we get the following relation

$$\begin{aligned} \frac{\nu }{2} + \log \nu '-\frac{\lambda }{2}-\log r= & {} C_1. \end{aligned}$$
(17)

It can also be rewritten as

$$\begin{aligned} \nu ' e^{\nu /2} = C_2\, r\, e^{\lambda /2}, \end{aligned}$$
(18)

where \(C_1\) and \(C_2\) are constants.

The relation (18) between the metric potentials can further be expressed as:

$$\begin{aligned} e^{\nu }=\left( B+A \int r \,\sqrt{e^{\lambda }}~dr\right) ^2, \end{aligned}$$
(19)

where A and B are integration constants. Using the line element given by (3) and (19), we can calculate the anisotropic factor of the fluid (\(\Delta \)) as follows:

$$\begin{aligned} \Delta =p_t-p_r= & {} \frac{2-e^{-\lambda (r)} \left( r \lambda '(r)+2\right) }{2 r^2}. \end{aligned}$$
(20)

For isotropic case, i.e., \(\Delta = 0\) and there are two possible scenarios. The first one is

$$\begin{aligned} \frac{2 e^{\lambda (r)}-\left( r \lambda '(r)+2\right) }{2 r^2 e^{\lambda (r)}}=0, \end{aligned}$$
(21)

and the second one is

$$\begin{aligned} {1\over e^{\lambda }}= & {} 0. \end{aligned}$$
(22)

The first condition Eq. (21), yields the isotropic solution

$$\begin{aligned} e^{\lambda (r)}= & {} -\left( 1+C_3 r^2\right) ,\end{aligned}$$
(23)
$$\begin{aligned} e^{\nu (r)}= & {} \left( \frac{A }{C_3 \sqrt{\frac{1}{1+C_3 r^2}}}+B\right) ^{2}, \end{aligned}$$
(24)

where \(C_3\) is a constant. The second condition leads to

$$\begin{aligned} e^{\lambda }= & {} \infty , \implies \lambda = \infty , \end{aligned}$$
(25)

which is not possible.

2.2 An embedding class one spacetime metric: the Karmarkar condition

If a spacetime can be mathematically described as a hypersurface embedded within a five-dimensional flat space, it is referred to as a spacetime of embedding class one. A necessary and sufficient condition for a spacetime to fall under class one is the existence of a symmetric tensor \(b_{ij}\) that satisfies the following criteria:

$$\begin{aligned} R_{\mu \nu \alpha \beta } = e \left( b_{\mu \alpha }b_{\nu \beta } - b_{\mu \beta }b_{\nu \alpha }\right) , \end{aligned}$$
(26)

along with the compatibility condition

$$\begin{aligned} \quad b_{\mu \nu ;\alpha } - b_{\mu \alpha ;\nu } = 0. \end{aligned}$$
(27)

In the above equations, the symbol ‘; ’ denotes covariant derivatives, and the value of e is either \(+1\) or \(-1\), depending on whether the normal to the spacetime is spacelike or timelike.

The space-time described by the metric (3) satisfies the Karmarkar condition, which is expressed as:

$$\begin{aligned} R_{1414}=\frac{R_{1212}R_{3434}+R_{1224}R_{1334}}{R_{2323}}. \end{aligned}$$
(28)

In this notation, (1, 2, 3, 4) correspond to the coordinates \((t, r, \theta , \phi )\) respectively. This condition holds for an embedding class I spacetime metric as long as \(R_{2323}\ne 0\) (as referred to in [87, 88]).

For the line element (3), the non-zero Riemann curvature tensor components are as follows:

$$\begin{aligned} R_{1414}= & {} -e^{\nu }\left( \frac{\nu ^{''}}{2}+\frac{\nu {'}^2}{4}-\frac{\lambda '\nu '}{4}\right) ,\end{aligned}$$
(29)
$$\begin{aligned} R_{2323}= & {} -e^{-\lambda }r^2\sin ^2{\theta }(e^{\lambda }-1),\end{aligned}$$
(30)
$$\begin{aligned} R_{1212}= & {} \frac{1}{2}r{\lambda }',\end{aligned}$$
(31)
$$\begin{aligned} R_{3434}= & {} -\frac{1}{2}r\sin ^2{\theta }\nu 'e^{\nu -\lambda }. \end{aligned}$$
(32)

The Karmarkar condition (28) leads to the differential equation:

$$\begin{aligned} \frac{2\nu ^{''}}{\nu '}+\nu '=\frac{\lambda 'e^{\lambda }}{e^{\lambda }-1}. \end{aligned}$$
(33)

Upon integrating (33), the relationship between \(\nu \) and \(\lambda \) is given by:

$$\begin{aligned} e^{\nu }=\left( c+d\int _{0}^{r}\sqrt{e^{\lambda }-1}~dr\right) ^2, \end{aligned}$$
(34)

where c and d are integration constants.

In view of (8), anisotropy of the fluid \(\Delta \) is expressed as [49]

$$\begin{aligned} \Delta =\frac{\nu {'}}{4e^{\lambda }}\left[ \frac{2}{r}-\frac{\lambda '}{e^{\lambda }-1}\right] \left[ \frac{\nu 'e^{\nu }}{2rB^2}-1\right] . \end{aligned}$$
(35)

For isotropic case, i.e., \(\Delta = 0\) and there are three possible solutions when

(a) \(\frac{\nu {'}}{4e^{\lambda }}=0\); (b) \([\frac{2}{r}-\frac{\lambda '}{e^{\lambda }-1}]=0\); (c) \([\frac{\nu 'e^{\nu }}{2rB^2}-1]=0\).

The solution (a) leads to \(e^{\nu } = C\) and \(e^{\lambda } = 1\). However, this solution results in a configuration with zero density, which is not physically meaningful. The solution of (b) yields the well-known Schwarzschild interior solution. While this solution is mathematically interesting and corresponds to a solution for a spherically symmetric distribution of matter (described by the Schwarzschild metric), it’s not physically realistic for most situations. The constant density obtained from this solution leads to non-physical properties like an infinite velocity of sound and an unrealistic adiabatic index. The solution resulting from (c) is the Kohler–Chao solution. It’s important to note that this solution is physically meaningful only in a cosmological context, where the pressure vanishes as the density approaches infinity (\(n \rightarrow \infty \)).

3 A new interior solution

To generate the model, we assume a new metric potential \(g_{rr}=e^{\lambda }\) specified by

$$\begin{aligned} e^{\lambda }= & {} \frac{a-b r^2}{a+b r^2}, \end{aligned}$$
(36)

where a and b are constants.

3.1 Interior solution through vanishing complexity factor approach

By substituting the value of \(e^{\lambda }\) in (19), we obtain the expression \(e^{\nu }\) as

$$\begin{aligned} e^{\nu }= & {} \left( \frac{A \sqrt{\frac{2 a}{a+b r^2}-1} \left( \sqrt{a-b r^2} \left( a+b r^2\right) +h_0(r)\right) }{2 b \sqrt{a-b r^2}}+B\right) {}^2,\nonumber \\ \end{aligned}$$
(37)

where A and B are integrating constants and

$$\begin{aligned} h_0(r)= & {} a \sqrt{a+b r^2} \tan ^{-1}\left( \frac{b r^2}{\sqrt{a-b r^2} \sqrt{a+b r^2}}\right) . \end{aligned}$$

Substituting the metric potentials given by (36) and (37) in EFEs given by (6) and (7), the expressions of \(\rho ,~ p_r,~ p_t\) and \(\Delta \) can be calculated as

$$\begin{aligned}{} & {} \rho = \frac{2 b \left( b r^2-3 a\right) }{\left( a-b r^2\right) ^2}, \end{aligned}$$
(38)
$$\begin{aligned}{} & {} p_r =\frac{2 b h_2(r) h_1(r)}{A h_1(r) h_0(r) \left( a-b r^2\right) ^{3/2}+h_3(r) \left( a-b r^2\right) ^2}, \end{aligned}$$
(39)
$$\begin{aligned}{} & {} p_t = \frac{b \left( A b h_0(r) r^2 \left( b r^2-3 a\right) \left( b r^2-a\right) +h_4(r)\right) }{h_5(r) \left( a-b r^2\right) ^2 \left( a+b r^2\right) },\end{aligned}$$
(40)
$$\begin{aligned}{} & {} \Delta = p_t-p_r = -\Pi , \end{aligned}$$
(41)

where

$$\begin{aligned} h_1(r)= & {} \sqrt{\frac{a-b r^2}{a+b r^2}},\\ h_2(r)= & {} \left( a+b r^2\right) \left( 3 a A-3 A b r^2+2 b B h_1(r)\right) \\{} & {} +A h_0(r) \sqrt{a-b r^2},\\ h_3(r)= & {} h_0 \left( a A+A b r^2\right) +2 b B,\\ h_4(r)= & {} 2 \sqrt{a-b r^2} \left( a+b r^2\right) ^2 \times \Big (a^2 A+2 A b^2 r^4 \\ {}{} & {} +a b (2 B h_1(r)-5 A r^2)\Big ),\\ h_5(r)= & {} A h_0(r) \left( a-b r^2\right) +\left( a+b r^2\right) \sqrt{a-b r^2} \times \\ {}{} & {} \times \left( a A+2 b B h_1(r)-A b r^2\right) . \end{aligned}$$

The expressions of other physical quantities are as follows:

$$\begin{aligned} m(r)= & {} \frac{r}{2} \left( 1-\frac{1}{e^{\lambda }}\right) = \frac{b r^3}{b r^2-a},\end{aligned}$$
(42)
$$\begin{aligned} u(r) ={m(r)\over r}= & {} \frac{a}{b r^2-a}+1, \end{aligned}$$
(43)

where m(r) and u(r) represent the mass and compactification, respectively. The graphical representation of the complexity factor is shown in Fig. 1.

3.2 Interior solution through embedding class one approach

In order to construct the model using the Karmarkar condition, we consider the same metric potential \(g_{rr}=e^{\lambda }\) as specified in (36). The Karmarkar condition for the line element (3) is expressed as

$$\begin{aligned} e^{\nu }=\Bigg (c+ d \int _0^r \sqrt{e^{\lambda }-1}~dr\Bigg )^2. \end{aligned}$$
(44)

Using the value of \(e^{\lambda }\) in (44), we get the expression \(e^{\nu }\) as

$$\begin{aligned} e^{\nu }= & {} \left( c-\frac{\sqrt{2} d r}{\sqrt{\frac{a}{a+b r^2}-1}}\right) ^2, \end{aligned}$$
(45)

where c and d are integrating constants. Substituting the metric potentials given by (36)–(45) in EFEs (6)–(7), the expressions of \(\rho ,~ p_r,~ p_t\) and \(\Delta \) are obtained as

$$\begin{aligned}{} & {} \rho =\frac{2 b \left( b r^2-3 a\right) }{\left( a-b r^2\right) ^2}, \end{aligned}$$
(46)
$$\begin{aligned}{} & {} p_r =\frac{2 b \left( 4 d^2 \left( a+b r^2\right) +b c^2-\sqrt{2} d h_6(r)\right) }{\left( a-b r^2\right) \left( 2 a d^2+b \left( c^2+2 d^2 r^2\right) \right) }, \end{aligned}$$
(47)
$$\begin{aligned}{} & {} p_t =\frac{b \left( 4 \sqrt{2} a^2 d+3 \sqrt{2} a b d r^2+2 a h_6(r)-\sqrt{2} b^2 d r^4\right) }{\left( a-b r^2\right) ^2 \left( \sqrt{2} a d+\sqrt{2} b d r^2+h_6(r)\right) },\nonumber \\ \end{aligned}$$
(48)
$$\begin{aligned}{} & {} \Delta = p_t-p_r = -\Pi , \end{aligned}$$
(49)

where

$$\begin{aligned} h_6(r)= & {} \sqrt{b} c \sqrt{-a-b r^2}. \end{aligned}$$
(50)

The expressions for other physical quantities, namely the mass and compactification, are as follows:

$$\begin{aligned}{} & {} m(r) = \frac{1}{2} \left( 1-\frac{1}{e^{\lambda }}\right) r = \frac{b r^3}{b r^2-a}, \end{aligned}$$
(51)
$$\begin{aligned}{} & {} u(r) ={m(r)\over r} = \frac{a}{b r^2-a}+1. \end{aligned}$$
(52)

The behaviours of density, pressures, anisotropy, mass, and compactification factor resulting from both approaches are displayed in Figs. 2, 3, 35, 5, and 6 respectively.

Fig. 1
figure 1

Variation of complexity factor with r

Fig. 2
figure 2

The variation of density with r for the models obtained through (i) the complexity vanishing factor approach (solid line), and (ii) the Karmarkar condition approach (dashed line)

Fig. 3
figure 3

The variation of \(p_r\) and \(p_t\) with r for the models obtained through (i) the complexity vanishing factor approach (solid line), and (ii) the Karmarkar condition approach (dashed line)

Fig. 4
figure 4

The variation of \(\Delta (r)\) with r for the models obtained through (i) the complexity vanishing factor approach (solid line), and (ii) the Karmarkar condition approach (dashed line)

Fig. 5
figure 5

The variation of m(r) with r for the models obtained through (i) the complexity vanishing factor approach (solid line), and (ii) the Karmarkar condition approach (dashed line)

Fig. 6
figure 6

The variation of \(u(r)={m(r)\over r}\) with r for the models obtained through (i) the complexity vanishing factor approach (solid line), and (ii) the Karmarkar condition approach (dashed line)

It’s important to note that not all expressions for various parameters calculated above may be in their simplest form.

4 Smooth matching of interior and exterior space-time

To determine the constant values A and B as stated in (19), along with the values of c and d used in (34), for a realistic stellar model featuring an anisotropic fluid distribution, a matching procedure is required between the interior metric solution and the Schwarzschild exterior solution at the star’s boundary. The interior metric is represented by:

$$\begin{aligned} ds^2= & {} \Big (1-{2M\over r}\Big ) dt^2-\Big (1-{2M\over r}\Big )^{-1}dr^2 \nonumber \\{} & {} -r^2(d\theta ^2+\sin ^2 \theta \, d\phi ^2). \end{aligned}$$
(53)

4.1 Evaluation of arbitrary constants of the solution obtained through the complexity vanishing condition

By matching the first and second fundamental forms of the interior solution (7) and exterior solution (53) at the boundary \(r=R\) (Darmois–Israel conditions), we get

$$\begin{aligned} e^{\nu _b}= & {} 1-{2M \over R} \nonumber \\= & {} \left( \frac{A \sqrt{\frac{2 a}{a+b R^2}-1} \left( C_1+h_1(R)\right) }{2 b \sqrt{a-b R^2}}+B\right) ^2, \end{aligned}$$
(54)
$$\begin{aligned} p_r(R)= & {} 0, \end{aligned}$$
(55)
$$\begin{aligned} e^{-{\lambda _b}}= & {} 1-{2M \over R} =\frac{a+b R^2}{a-b R^2} . \end{aligned}$$
(56)

Verification of these matches can be done by consulting Fig. 7. Using the boundary conditions (54)–(56), we get

$$\begin{aligned} M= & {} \frac{b R^3}{b R^2-a}, \end{aligned}$$
(57)
$$\begin{aligned} A= & {} \frac{\sqrt{b^2 (R-2 M)}}{\sqrt{R \left( a^2-b^2 R^4\right) }}, \end{aligned}$$
(58)
$$\begin{aligned} B= & {} -\frac{\sqrt{(R-2 M)} \left( a h_1(R) \sqrt{a+b R^2}+3 C_1 \right) }{2\sqrt{a+b R^2} \sqrt{R \left( a^2-b^2 R^4\right) }}, \end{aligned}$$
(59)

where

$$\begin{aligned}{} & {} C_1 = \sqrt{a-b R^2} \left( a+b R^2\right) . \end{aligned}$$
(60)

The selection of appropriate values for the free parameters a and b is crucial to ensure the consistent behavior of all physical properties within the stellar model. Additionally, the integrating constants A and B can be calculated using the expressions provided by (58) and (59).

4.2 Evaluating arbitrary constants of the solution obtained via the Karmarkar condition

Again, by matching the first and second fundamental forms of the interior solution (7) and exterior solution (53) at the boundary \(r=R\) (Darmois–Israel conditions), we get

$$\begin{aligned} e^{\nu _b}= & {} 1-{2M \over R} \nonumber \\= & {} \left( c-\frac{\sqrt{2} d R}{\sqrt{\frac{a}{a+b R^2}-1}}\right) ^2, \end{aligned}$$
(61)
$$\begin{aligned} p_r(R)= & {} 0, \end{aligned}$$
(62)
$$\begin{aligned} e^{-{\lambda _b}}= & {} 1-{2M \over R} =\frac{a+b R^2}{a-b R^2} , \end{aligned}$$
(63)

Using the boundary conditions (61)–(63), we get

$$\begin{aligned} M= & {} \frac{b R^3}{b R^2-a}, \end{aligned}$$
(64)
$$\begin{aligned} c= & {} \frac{2 \sqrt{R-2 M}}{\sqrt{R}}, \end{aligned}$$
(65)
$$\begin{aligned} d= & {} \frac{\sqrt{b} \sqrt{2 M-R}}{\sqrt{2} \sqrt{R} \sqrt{a+b R^2}}. \end{aligned}$$
(66)

Furthermore, the integrating constants c and d can be calculated using the expressions provided by (65) and (66). We consider the same parameter values a and b for both approaches in a manner that ensures a well-behaved nature for all physical properties within the stellar model.

5 Discussion on geometrical, physical variables and stability analysis

The stability of compact stellar structure can be assessed by examining several physical conditions using the parameter values \(a = -2.9\) and \(b = 0.008\). These values correspond to a compact star with a radius of \(R = 9.97\). In the upcoming subsections, we will present our analysis of these conditions.

5.1 Behaviour of Geometrical variables

The geometric variables \(e^{\lambda (r)}\) and \(e^{\nu (r)}\) must remain positive and non-singular within the interior of the celestial object. At the center, these variables satisfy specific conditions: \(e^{\nu (r)}|_{r=0}=\) finite and \(e^{-\lambda (r)}|_{r=0}=1\). This ensures that the metric potentials adhere to the initial fundamental boundary conditions, as depicted in Fig. 7.

Fig. 7
figure 7

The variation of metric potentials with r for the models obtained through (i) the complexity vanishing factor approach (solid line), and (ii) the Karmarkar condition approach (dashed line)

5.2 Zeldovich’s condition and finiteness of central parameters

At the center of the stellar object, the physical parameters \(\rho \), \(p_r\), and \(p_t\) are non-negative and satisfy the following condition (Zeldovich’s criteria) [90]

$$\begin{aligned} p_{r_c}/\rho _c \le 1. \end{aligned}$$
(67)

The profile in Fig. 8 demonstrates that both approaches of the presented models fulfill Zeldovich’s criteria.

Fig. 8
figure 8

The variation of \({p_r\over \rho }\) and \({p_t\over \rho }\) with r for the models obtained through (i) the complexity vanishing factor approach (solid line), and (ii) the Karmarkar condition approach (dashed line)

5.3 Adiabatic index

References [91] and [92] simplified the Chandrasekhar’s stability condition under radial perturbation theory which requires a positive and non-vanishing value of the characteristic frequency to a mass-central density relationship as \(M(\rho _c) \propto \rho _c^{3(\Gamma -4/3)/2}\).

The relativistic adiabatic index in given by [95]:

$$\begin{aligned} \Gamma = \frac{\rho + p_r}{p_r} \frac{dp_r}{d\rho }, \end{aligned}$$
(68)

whose values, according to Bondi [96] for a stable Newtonian sphere requires that \(\Gamma >4/3\). However, the presence of pressure anisotropy alters this condition into a more generalized form [97]

$$\begin{aligned} \Gamma > \frac{4}{3} + \left[ -\frac{4\Delta _c}{3 |p^{'}{r_c}|r} + \frac{\rho _c p_{r_c}}{2 |p^{'}_{r_c}|}r\right] , \end{aligned}$$
(69)

where \(\Delta _{c}\) and \(\rho _c\) represent anisotropy and energy density at the center in static equilibrium respectively. The enclosed terms in the square brackets correspond to the anisotropic and relativistic corrections, both of which have positive values, contributing to an increased unstable range of \(\Gamma \) [94]. Now, the adiabatic index values may be slightly below 4/3 and the system can still be stable. Hence, in general, if \(\Gamma >4/3\), the system is stable under gravitational collapse. The profile of adiabatic index is depicted in Fig. 9.

Fig. 9
figure 9

The variation of \(\Gamma (r)\) with r for the models obtained through (i) the complexity vanishing factor approach (solid line), and (ii) the Karmarkar condition approach (dashed line)

5.4 Static stability criteria for solutions obtained through the complexity vanishing and the Karmarkar approaches

The static stability criteria state that for non-rotating spherically symmetric equilibrium stellar models, the mass of compact stars must increase with their central density under small radial pulsations, expressed as:

$$\begin{aligned} \frac{\partial M}{\partial \rho _c}>0. \end{aligned}$$
(70)

The criteria ensure that the model remains both static and stable. They were independently proposed by [91] and [92] for stable stellar models. With the help of Eq. (57) and the total mass given by:

$$\begin{aligned} M=m(R) = \frac{1}{2} R \left( 1-\frac{a+b R^2}{a-b R^2}\right) , \end{aligned}$$
(71)

the expression of the mass in terms of the central density (\(a= -3 b/\rho _c\)) is as follows:

$$\begin{aligned} M(\rho _c)= & {} \frac{\rho R^3}{\rho R^2+6}. \end{aligned}$$
(72)

Furthermore,

$$\begin{aligned} \frac{\partial M}{\partial \rho _c}= & {} \frac{R^3}{\rho R^2+6}-\frac{\rho R^5}{\left( \rho R^2+6\right) ^2}>0, \end{aligned}$$
(73)

which satisfies the static stability criterion (70) for the solutions obtained through the complexity vanishing and the Karmarkar approaches (Fig. 10).

Fig. 10
figure 10

The variation of mass with central density for the models obtained through both approaches is represented by the dashed line

5.5 Stability equilibrium conditions

The modified Tolman–Oppenheimer–Volkoff (TOV) equation for anisotropic fluid distribution was expressed [89] as follows:

$$\begin{aligned} \underbrace{-{\nu ' \over 2}(\rho +p_r)}_{F_g}-\underbrace{{dp_r \over dr}}_{F_h}+\underbrace{{2\Delta \over r}}_{F_a}=0. \end{aligned}$$
(74)

In the above equation, the symbols \(F_g\), \(F_h\), and \(F_a\) correspond to the gravitational, hydrostatic, and anisotropic forces, respectively, that act on the stellar object. The profile presented in Fig. 11 illustrates that the gravitational force \(F_g\) surpasses both the anisotropic force \(F_a\) and the hydrostatic force \(F_h\). Consequently, the system remains in static equilibrium, with the gravitational force effectively counterbalancing the combined impact of the anisotropic and hydrostatic forces.

Fig. 11
figure 11

The variation of balancing forces with r for the models obtained through (i) the complexity vanishing factor approach (solid line), and (ii) the Karmarkar condition approach (dashed line)

6 Red-shift profiles

In the context of spherically symmetrical stellar structures, the functions describing gravitational red-shift (\(z_g(r)\)) and surface red-shift (\(z_s(r)\)) for the stellar system obtained through the complexity factor approach are as follows:

$$\begin{aligned} z_r(r)= & {} \frac{1}{\sqrt{e^{\nu }}}-1\nonumber \\= & {} \frac{1}{\frac{A \sqrt{\frac{2 a}{a+b r^2}-1} \left( \sqrt{a-b r^2} \left( a+b r^2\right) +h_0(r)\right) }{2 b \sqrt{a-b r^2}}+B}-1, \end{aligned}$$
(75)
$$\begin{aligned} z_s(r)= & {} \frac{1}{\sqrt{1-2u(r)}}-1 = \frac{\sqrt{a-b r^2}}{\sqrt{a+b r^2}}-1. \end{aligned}$$
(76)

The expressions for the gravitational red-shift function (\(z_{g}(r)\)) and the surface red-shift function (\(z_{s}(r)\)) for the stellar system obtained through the Karmarkar condition approach are provided as follows:

$$\begin{aligned} z_{g}(r)= & {} \frac{1}{\sqrt{e^{\nu }}}-1\nonumber \\= & {} \frac{1}{c-\frac{\sqrt{2} d \sqrt{-a-b r^2}}{\sqrt{b}}}-1 \end{aligned}$$
(77)
$$\begin{aligned} z_{s}(r)= & {} \frac{1}{\sqrt{1-2u(r)}}-1 = \frac{\sqrt{a-b r^2}}{\sqrt{a+b r^2}}-1. \end{aligned}$$
(78)

Interestingly, the gravitational red-shift \((z_g(r))\) and the surface red-shift \((z_s(r))\) for the compact object exhibit opposite behaviors with respect to the radial coordinate r. Specifically, \(z_g(r)\) decreases as r increases, while \(z_s(r)\) increases as r grows (see Fig. 12). Both the mass function m(r) and the parameter u(r) demonstrate an increasing trend with r.

Fig. 12
figure 12

The variation of the interior and surface red-shift with r for the models obtained through (i) the complexity vanishing factor approach (solid line), and (ii) the Karmarkar condition approach (dashed line)

7 Anisotropic parameter

In physically relativistic models, the radial pressure (\(p_r\)) is equal to the tangential pressure (\(p_t\)) at the center, and \(p_t>p_r\) as we move from the center to the surface of the fluid sphere. In other words, the pressure anisotropy (\(\Delta (r)\)) vanishes at the center (\(\Delta (0) = 0\)) and increases from the center to the surface of the fluid sphere [93]. The behavior of \(\Delta (r)\) across the stellar object is depicted in Fig. 4, illustrating that \(\Delta (r)\) vanishes at the center and assumes a positive value as we approach towards the boundary of the stellar object. This phenomenon is presented in Fig. 35, revealing that the anisotropic pressure exerts a repulsive force within compact star due to the positive anisotropy constant.

8 Energy conditions

For the assurance of a physically stable static model, the star’s interior must adhere to the following energy conditions: (i) the null energy condition \(\rho - p_r \ge 0\) (NEC), (ii) the weak energy conditions \(\rho - p_r \ge 0\), \(\rho \ge 0\) (WEC\(_r\)), and \(\rho - p_t \ge 0\), \(\rho \ge 0\) (WEC\(_t\)), and (iii) the strong energy condition \(\rho - p_r - 2p_t \ge 0\) (SEC). The illustration in Fig. 13 provides clear evidence that all these energy conditions are thoroughly satisfied within the confines of the compact star.

Fig. 13
figure 13

The variation of the energy conditions with r for the models obtained through (i) the complexity vanishing factor approach (solid line), and (ii) the Karmarkar condition approach (dashed line)

8.1 Causality and Hererra cracking conditions

The Hererra cracking method [98, 99] is employed to examine the stability of anisotropic stars under radial perturbations. The conditions for cracking and causality are expressed as follows:

$$\begin{aligned} -1< {(v_t^2)}-{(v_r^2)} \le 0, \end{aligned}$$
(79)

i.e.,

$$\begin{aligned} \frac{dp_t}{d\rho }= & {} \frac{dp_r}{d\rho }+\frac{d\Delta }{d\rho }=\frac{dp_r}{d\rho }+\frac{d \Delta }{dr}\frac{dr}{d\rho }, \end{aligned}$$
(80)
$$\begin{aligned} v_r^2-v_t^2= & {} -\frac{d\Delta }{dr}\frac{dr}{d\rho }. \end{aligned}$$
(81)

The profiles shown in Figs. 14 and 15 illustrate that the radial and tangential velocities satisfy the conditions \(0 < v_r^2, v_t^2 \le 1\) and \(-1 < v_t^2 - v_r^2 \le 0\) across the entire stellar object. These conditions adhere to the causality condition and suggest potential stability for the model under consideration.

Fig. 14
figure 14

The variation of \(v_r^2\), \(v_t^2\) with r for the models obtained through (i) the complexity vanishing factor approach (solid line), and (ii) the Karmarkar condition approach (dashed line)

Fig. 15
figure 15

The variation of the stability factor with r for the models obtained through (i) the complexity vanishing factor approach (solid line), and (ii) the Karmarkar condition approach (dashed line)

Table 1 Physical parameter values for compact Star PSR J1614-2230 with \(a=-2.9/\textrm{km}^2\) and \(b=0.008/\textrm{km}^2\)

9 Discussions and conclusions

In this paper, we present an exact solution to the EFEs utilizing the vanishing complexity approach and conduct a comparative analysis with the well-established embedding class one approach. Our work involves a comprehensive comparison of the geometrical and physical properties of a compact star model using both these approaches, accompanied by stability analyses. The thermodynamic analysis covers physical variables such as density (\(\rho \)), radial pressure (\(p_r\)), tangential pressure (\(p_t\)), the ratio of radial pressure to density (\(p_r/\rho \)), the ratio of tangential pressure to density (\(p_t/\rho \)), red-shift functions, and stability criteria such as the Bondi adiabatic condition, Zeldovich criteria, static stability criteria, energy conditions, causality, and Herrera cracking conditions. Based on our findings, it can be suggested that the vanishing complexity approach could serve as a viable alternative method to the embedding class one approach for the derivation of exact solutions of the EFEs. The physical and stability analyses of both models are conducted using the same parameter values: \(a = -2.9/\textrm{km}^2\), \(b = 0.008/\textrm{km}^2\), and \(R = 9.97~\textrm{km}\). Table 1 presents the values of the central adiabatic index (\(\Gamma _c\)), central pressure, central density, gravitational red-shift at the center and surface for the stellar object PSR J1614-2230. From the observations made in Table 1, it is evident that the adiabatic index, radial pressure at the center, and central red-shift are higher in the model obtained via the Karmarkar approach compared to the model obtained through the complex vanishing condition. These comparisons are made for the compact object with a radius of 9.97 km and a mass of \(2.14554 M_\odot \).

It’s worth noting that there are two additional methods that demonstrate a relationship between two metric potentials. The first method is based on conformally flat geometry and is described by the bridge equation [100]

$$\begin{aligned} e^{\nu }={L_1}^2r^2\cosh ^{2} \left( \int \frac{e^{\lambda /2}}{r}dr+L_2\right) , \end{aligned}$$
(82)

where \(L_1\) and \(L_2\) are constants of integration. This method encounters difficulties in determining the variation of red-shift at the interior, particularly at the point \(r=0\) [101]. The second approach involves the use of conformal killing vectors and is characterized by the bridge equation [102, 103]

$$\begin{aligned} e^{\nu } =L_3^2r^2 exp\left( -\frac{2k}{L_4}\int \frac{e^{\lambda /2}}{r}dr\right) , \end{aligned}$$
(83)

where \(L_3\), k and \(L_4\) are constants of integration. Similar to the first method, this approach also faces challenges in determining the central red-shift.