1 Introduction

The idea that there exist some deep connections between thermodynamics and gravity has been accepted widely since the establishment of the black hole thermodynamic laws. Some important works further reveal the relation between gravity and thermodynamics. Jacobson considered that the Einstein equation can be derived from thermodynamical relation which hold on Rindler causal horizons [1], or the equilibrium of total entanglement entropy in “Causal Diamond” [2]. Verlinder suggested that the gravity is the entropy force [3]. In recent years, the proofs of the maximum entropy principle showed that the gravitational equation can be derived from the constraint equation and the maximum of total entropy [5,6,7,8,9,10]. All these researches are trying to establish a correspondence between the first variation of thermodynamic quantities and gravitational equation. However, assuming that the thermodynamic relation contains all information of gravity, it is naturally to investigate whether the second variation of thermodynamic quantities corresponds to the first variation of gravitational equations.

It is well-known that using the first variation of gravitational equation one can obtain the dynamical stability criterion. Chandrasekhar first discussed this problem and got the stability criterion for perfect fluid in general relativity [11]. Based on the works of Chandrasekhar, Friedman and Schutz [13,14,15], Friedman defined “canonical energy” and considered that it can provide the stability criterion [16]. Seifert and Wald developed a general method to obtain the dynamical stability criterion for spherically symmetric perturbation in diffeomoephism covariant theories [17]. Meanwhile, the second variation of thermodynamic quantities, such as total entropy, can provide the thermodynamical stability criterion. A system is thermodynamical stable means that the system is in the thermodynamical equilibrium and the second variation of the total entropy of the system is negative, \(\delta ^2S<0\). Using thermodynamical method to handle the stability problem is more directly than dynamical method.

An interesting question is whether the dynamical method can be replaced by thermodynamical method. In other words, one can ask whether the dynamical stability criterion is the same as the thermodynamical stability criterion. In fact, Cocke presented the maximum entropy principle, and suggested that the thermodynamical stability is the same as dynamical stability [19]. Recently, this issue was sparked by the work of Hollands and Wald [20]. Wald et al. [21] proved that in general relativity the thermodynamical stability is the same as the “canonical energy” presented by Friedman. With the definition of AMD mass, the proofs in Ref. [21] need a crucial assumption that the spacetime should be asymptotically flat. Roupas [22] also proved that the maximum of total entropy for perfect fluid gives the same criterion for dynamical stability obtained by Yabushita [23].

In Ref. [24], we presented a generalized thermodynamical criterion, which is the second variation of total entropy for perfect fluid star. And we showed that in general relativity it can provide the same stability criterion as the dynamical stability criterion obtained by Wald [17]. It should be mentioned that all the previous works are focused on the cases in general relativity. However, whether the dynamical method can replaced by thermodynamical method in modified theories is not clear. As an important generalization of general relativity, f(R) theories can explain the accelerated expansion of the universe because it contains higher order invariants in the action [25, 26]. In this manuscript, we show that the dynamical stability criterion is the same as the thermodynamical stability criterion in f(R) theories, which implies that there is an inherent connection between thermodynamics and gravity.

The rest of this paper is organized as follows. In Sect. 2, we briefly review wald’s general variation principle. Since the result in Ref. [18] can not directly degenerate to general relativity, we recast the process of how to obtain the stability criterion by dynamical method. And our result can directly degenerate to general relativity. In Sect. 3, we introduce the general thermodynamical stability criterion firstly and then show how to directly determine the stability criterion by thermodynamical method. At last, we summarized our manuscript with some discussions. It should be noted that only the basic idea and the main results are presented in Sects. 2 and 3. The complicated derivation processes are described in Appendix B and Appendix C.

Throughout our manuscript, we use the sign conventions of Ref. [27]. Units will be those in which \(c=G=1\), and the factor \(\kappa =8\pi \) in gravitational equations will be ignored. We denote \(f_R\equiv \frac{\partial f}{\partial R}\) and \(b=\delta (f_R)=f_{RR}\delta R\). In order to distinguish \(\mathcal {S}\) in Ref. [18] from the total entropy S in our manuscript, we introduced a new quantity written as \(\mathcal {F}=f_R'+\frac{2}{r}f_R\).

2 Dynamical method

2.1 Wald’s general variation principle

In this subsection we will briefly review the general variation principle presented by Seifert and Wald [17]. Referring to Refs. [28, 29] makes it available to obtain more details and discussions. Consider a diffeomorphism covariant Lagrangian four-form \(\varvec{\mathcal {L}}\), constructed from dynamical field \(\Psi \), which consist of the spacetime metric \(g_{ab}\) and other additional fields. The first variation of \(\varvec{\mathcal {L}}\) can be written as

(1)

where \(\varvec{\mathcal {E}}=0\) defines the Euler–Lagrange equation of motion, and \(\varvec{\theta }\) is the symplectic potential three-form \(\varvec{\theta }(\Psi , \delta \Psi )\). The antisymmetrized variation of the symplectic potential \(\varvec{\theta }\) yields the symplectic current three-form \(\varvec{\omega }\) as

$$\begin{aligned} {\varvec{\omega }}=\delta _{1}{\varvec{\theta }}(\Psi , \delta _{2}\Psi )-\delta _{2}{\varvec{\theta }}(\Psi , \delta _{1}\Psi ). \end{aligned}$$
(2)

When \(\delta _1\Psi \) and \(\delta _2\Psi \) satisfied the linearized equations of motions, then the symplectic current is conserved

$$\begin{aligned} d\varvec{\omega }=0 \,. \end{aligned}$$
(3)

For static background, the symplectic form \(\varvec{\Omega }\) for the theory can obtained by the integral of the pullback of symplectic current three-form

$$\begin{aligned} \varvec{\Omega }(\Psi ; \delta _1\Psi , \delta _2\Psi )=\int \limits _{\Sigma }\varvec{\bar{\omega }}[\Psi ; \delta _1\Psi , \delta _2\Psi ] \,, \end{aligned}$$
(4)

where \(\varvec{\bar{\omega }}\) is the pullback of \(\varvec{\omega }\) to the static hypersurfaces of the background solution.

If the perturbational fields are denoted as \(\psi ^{\alpha }\), then the symplectic form takes the form

$$\begin{aligned} \Omega (\Psi ; \psi _1^{\alpha }, \psi _2^{\alpha })=\int \limits _{\Sigma }\mathbf {W}_{\alpha \beta } \left( \frac{\partial \psi _1^{\alpha }}{\partial t}\psi _2^{\beta }-\frac{\partial \psi _2^{\alpha }}{\partial t}\psi _1^{\beta }\right) , \end{aligned}$$
(5)

where \(\mathbf {W}_{\alpha \beta }\) is the three-form and it was showed that \(\mathbf {W}_{\alpha \beta }=\mathbf {W}_{\beta \alpha }\) [17].

Using \(\mathbf {W}_{\alpha \beta }\) , we can define an inner product as

$$\begin{aligned} (\psi _1, \psi _2)\equiv \int \limits _{\Sigma }\mathbf {W}_{\alpha \beta }\psi _1^{\alpha }\psi _2^{\beta } \end{aligned}$$
(6)

Now suppose that the perturbational equations of motion take the form [17]

$$\begin{aligned} -\frac{\partial ^2}{\partial t^2}\psi ^{\alpha }=\mathcal {T}^{\alpha }\,_{\beta }\psi ^{\beta } \,, \end{aligned}$$
(7)

where \(\mathcal {T}\) is the time-evolution operator that contain spatial derivatives only. Seifert and Wald [17] showed that the operator \(\mathcal {T}\) is self-adjoint and symmetric. Based on Rayleigh-Ritz principle, we know that the greatest lower bound, \(\omega _0^2\), of the spectrum of \(\mathcal {T}\) is

$$\begin{aligned} \omega _0^2\le \frac{(\psi , \mathcal {T}\psi )}{(\psi , \psi )} \,. \end{aligned}$$
(8)

Wald [30] showed that the background solution is stable if \(\omega _0^2>0\). The denominator of Eq. (8) gives the inner product and always be positive. So the numerator \((\psi , \mathcal {T}\psi )>0\) implies that the system is stable, otherwise the perturbation exist a grow exponentially on a timescale \(\tau =1/|\omega _0|\).

By Eqs. (6) and (7), the numerator of Eq. (8) becomes

$$\begin{aligned} (\psi , \mathcal {T}\psi ) = \int \limits _{\Sigma }\mathbf {W}_{\alpha \beta }\psi _1^{\alpha }\mathcal {T}^{\beta }\,_{\gamma }\psi _2^{\gamma } = -\int \limits _{\Sigma }\mathbf {W}_{\alpha \beta }\psi _1^{\alpha }\frac{\partial ^2\psi _2^{\beta }}{\partial t^2} \,. \end{aligned}$$
(9)

In next subsection, we give the dynamical stability criterion for f(R) theories by Eq. (9).

2.2 Dynamical stability criterion for f(R) theories

f(R) theories In f(R) theories, the Ricci scalar R in Einstein-Hilbert action is replaced by a function of R. The Lagrangian four-form \(\varvec{\mathcal {L}}\) reads as

$$\begin{aligned} \varvec{\mathcal {L}}=\frac{1}{2}f(R)\varvec{\epsilon }+\varvec{\mathcal {L}}_{matter}[A, g^{ab}] \,, \end{aligned}$$
(10)

where A denotes the matter fields. Taking the variation of this Lagrangian we obtain the equation of motion

$$\begin{aligned} f_R R_{ab}-\frac{1}{2}f g_{ab}-(\nabla _a\nabla _b-g_{ab}\Box )f_R=8\pi T_{ab} \,. \end{aligned}$$
(11)

Similarly to [18], f(R) theories can be reduced to general relativity coupling to a scalar field \(\alpha \). And the Lagrangian is given by

$$\begin{aligned} \varvec{\mathcal {L}}=\frac{1}{2}(f_R(\alpha )R+f(\alpha )-\alpha f_R(\alpha ))\epsilon +\varvec{\mathcal {L}}_{matter}[A, g^{ab}] \,.\nonumber \\ \end{aligned}$$
(12)

Varying this Lagrangian yields

$$\begin{aligned} \theta ^a_{f(R)}= & {} f_R\theta ^a_{GR}+\theta ^a_{matter} \nonumber \\&+\frac{1}{2}\left[ (\nabla _b f_R)\delta g^{ab}-(\nabla ^af_R)g_{bc}\delta g^{bc}\right] \,, \end{aligned}$$
(13)

where \(\theta _{GR}\) is the symplectic potential current in general relativity,

$$\begin{aligned} \theta _{GR}=\frac{1}{2}\left( g_{bc}\nabla ^a\delta g^{bc}-\nabla _b\delta g^{ab}\right) . \end{aligned}$$
(14)

Spacetime metric For spherically symmetric perturbations of static background, spherically symmetric spacetimes, the metric take the form [31]

$$\begin{aligned} ds^2=-e^{2\Phi (t,r)}dt^2+e^{2\Lambda (t,r)}dr^2+r^2d\Omega ^2, \end{aligned}$$
(15)

for some function \(\Phi \) and \(\Lambda \), where \(d\Omega ^2=d\theta ^2+\sin ^2\theta d\varphi ^2\). In the rest of this manuscript, we denote the first order perturbation of \(\Phi \) and \(\Lambda \) by \(\phi \) and \(\lambda \), respectively, which means that \(\Phi (t,r)=\Phi (r)+\phi (t,r)\) and \(\Lambda (t,r)=\Lambda (r)+\lambda (t,r)\).

Lagrangian for perfect fluid Following Ref. [17], we can define the three-form \(N_{abc}\) on four-dimensional manifold M, which represents the density of fluid worldlines, by

$$\begin{aligned} N_{abc}=N_{ABC}(X)\nabla _a X^A\nabla _b X^B\nabla _c X^C \end{aligned}$$
(16)

where \(N_{ABC}\) is the three-form which was defined on the three-dimensional manifold of fluid worldlines, \(\mathcal {M}\). Then one can define the scalar particle number density \(\nu \) in terms of \(N_{abc}\) as

$$\begin{aligned} \nu ^2=\frac{1}{6}N_{abc}N^{abc} \,. \end{aligned}$$
(17)

If the Lagrangian for the matter part is given by

$$\begin{aligned} \varvec{\mathcal {L}}_{matter}=-\varrho (\nu )\varvec{\epsilon } \,, \end{aligned}$$
(18)

where \(\varrho \) is an arbitrary function of the particle density \(\nu \). Taking variation of Eq. (18), Seifert and Wald [17] constructed an identification

$$\begin{aligned} \varrho \rightarrow \rho , \quad \varrho '\nu -\varrho \rightarrow p, \end{aligned}$$
(19)

Here \(\varrho '\) denotes the derivative of \(\varrho \) with respect to \(\nu \). Except for this, \('\) means \(\frac{\partial }{\partial r}\) in other situations in our manuscript. Moreover, they obtained the equation of motion of matter, which was just the relativistic Euler equation, and the symplectic current \(\varvec{\omega }_{matter}\) of the perfect fluid.

From the conservation equation of energy momentum, \(\nabla _aT^{ab}=0\), we have

$$\begin{aligned} \frac{dp}{dr}=-(p+\rho )\frac{d\Phi }{dr} \,. \end{aligned}$$
(20)

Together with the identification Eq. (19), it is easy to find that

$$\begin{aligned} \frac{\partial \nu }{\partial r}=-\frac{\varrho '}{\varrho ''}\frac{\partial \Phi }{\partial r}\,. \end{aligned}$$
(21)

This formula would be used frequently in the subsequent calculations.

Lagrangian displacement Seifert and Wald [17] used the “Lagrangian coordinate” formalism to describe the fluid matter. In this formalism, the fluid is described by the manifold \(\mathcal {M}\) of all fluid worldlines in the spacetime. There is a three “fluid coordinate” \(X^A\) on \(\mathcal {M}\), \(X^A\equiv \{X^R, X^{\Theta }, X^{\Phi }\}\), and in the static background solution we have \(X^R=r\), \(X^{\Theta }=\theta \), \(X^{\Phi }=\varphi \). For spherically symmetric perturbation case, \(\delta X^{\Theta }=\delta X^{\phi }=0\). The radial perturbation \(\delta X^R\) can be describes by radial “Lagrangian displacement” as

$$\begin{aligned} \xi (r,t)\equiv -\delta X^R(t,r) \,. \end{aligned}$$
(22)

Note that we use the opposite signature of the definition of \(\xi \) as Ref. [17], to make the subsequent calculations appear self-consistent (See Appendix A).

Dynamical stability criterion To get the dynamical stability criterion, we solve the linearized perturbation of gravitational equations firstly. The perturbation equation of \(t-r\) and \(r-r\) components of Eq. (11) gives

$$\begin{aligned} \lambda =\mathcal {F}^{-1}\left( \frac{\partial b}{\partial r}-\frac{\partial \Phi }{\partial r}b-e^{2\Lambda }\varrho '\nu \xi \right) , \end{aligned}$$
(23)

and

$$\begin{aligned}&e^{2\Lambda -2\Phi }\frac{\partial ^2b}{\partial t^2} = \mathcal {F}\frac{\partial \phi }{\partial r} +\left( \frac{\partial \Phi }{\partial r}+\frac{2}{r}\right) \frac{\partial b}{\partial r} \nonumber \\&~\ +\left( \frac{2}{r}\frac{\partial \Lambda }{\partial r}+\frac{\partial \Lambda }{\partial r}\frac{\partial \Phi }{\partial r}-\left( \frac{\partial \Phi }{\partial r}\right) ^2 -\frac{\partial ^2\Phi }{\partial r^2}\right) b \nonumber \\&~\ -\left( 2\left( \frac{\partial \Phi }{\partial r}+\frac{2}{r}\right) \mathcal {F}-\frac{6}{r^2}f_R\right) \lambda -e^{2\Lambda }\varrho ''\nu \delta \nu \,. \end{aligned}$$
(24)

There is another conservation equation will be used. For spherical-symmetry metric Eq. (15), the first order variation of scalar curvature can be written as

$$\begin{aligned}&e^{2\Lambda }\left( R\lambda +\frac{b}{2f_{RR}}\right) = \frac{2e^{2\Lambda }}{r^2}\lambda -\frac{2}{r}\frac{\partial \phi }{\partial r} -2\frac{\partial \Phi }{\partial r}\frac{\partial \phi }{\partial r} \nonumber \\&\quad +\frac{2}{r}\frac{\partial \lambda }{\partial r}+\frac{\partial \Phi }{\partial r}\frac{\partial \lambda }{\partial r} +\frac{\partial \phi }{\partial r}\frac{\partial \Lambda }{\partial r}-\frac{\partial ^2\phi }{\partial r^2}+e^{2\Lambda -2\Phi }\frac{\partial ^2\lambda }{\partial t^2} \,.\nonumber \\ \end{aligned}$$
(25)

While we also have the matter equation of motion [17], which is just the time-evolution equation of variable \(\xi \)

$$\begin{aligned} e^{2\Lambda -2\Phi }\varrho '\frac{\partial ^2\xi }{\partial t^2}+\varrho '\frac{\partial \phi }{\partial r} +\left( \frac{\partial }{\partial r}+\frac{\partial \Phi }{\partial r}\right) (\varrho ''\delta \nu )=0 \,. \end{aligned}$$
(26)

Substituting Eq. (13) into Eq. (2), we find the specific form of the t-component of the symplectic current in f(R) theories takes the form [18]:

$$\begin{aligned} \omega ^t= & {} \varrho '\nu e^{2\Lambda -2\Phi }\left( \frac{\partial \xi _1}{\partial t}\xi _2-\frac{\partial \xi _2}{\partial t}\xi _1\right) \nonumber \\&+e^{-2\Phi }\left( b_1\frac{\partial \lambda _2}{\partial t}-\frac{\partial b_1}{\partial t}\lambda _2 -b_2\frac{\partial \lambda _1}{\partial t}+\frac{\partial b_2}{\partial t}\lambda _1\right) \,.\nonumber \\ \end{aligned}$$
(27)

From Eq. (27) we can read off \(\mathbf {W}_{\alpha \beta }\). Denote the numerator part of \(\omega _0\) in Eq. (8), \((\psi , \mathcal {T}\psi )\), by \(\mathcal {P}_{Dyn}\). More explicitly, together with Eqs. (25) and (26), it can be written as

$$\begin{aligned} \mathcal {P}_{Dyn}= & {} \int \limits _r -r^2e^{3\Lambda -\Phi }\varrho '\nu \xi \frac{\partial ^2\xi }{\partial t^2} \nonumber \\&+r^2 e^{\Lambda -\Phi }\lambda \frac{\partial ^2b}{\partial t^2}+r^2e^{\Lambda -\Phi }b\frac{\partial ^2\lambda }{\partial t^2} \,. \end{aligned}$$
(28)

It should be noted that the final result of [18] is dimensionally incorrect. Here we provide a corrected result. Using integration by partsFootnote 1 and after some complicated calculations, we finally obtain the dynamical stability criterion in the form

$$\begin{aligned} \mathcal {P}_{Dyn}= & {} \int \limits _r \mathcal {C}_{Dyn}^1\left( \frac{\partial b}{\partial r}\right) ^2+\mathcal {C}_{Dyn}^2\left( \frac{\partial \xi }{\partial r}\right) ^2 +\mathcal {C}_{Dyn}^3\xi \frac{\partial b}{\partial r} \nonumber \\&+\,\mathcal {C}_{Dyn}^4b\frac{\partial \xi }{\partial r}+\mathcal {C}_{Dyn}^5\frac{\partial b}{\partial r}\frac{\partial \xi }{\partial r}+\mathcal {C}_{Dyn}^6b^2 \nonumber \\&+\,\mathcal {C}_{Dyn}^7\xi ^2+\mathcal {C}_{Dyn}^8b\xi \,, \end{aligned}$$
(29)

where each \(\mathcal {C}_{Dyn}^i\) are the functions of the background fields. We put all detailed calculations and the expressions of each \(\mathcal {C}_{Dyn}^i\) in Appendix B.

3 Thermodynamical method

We first briefly introduce the generalized thermodynamical stability criterion obtained from the maximum entropy principle. Please refer to Refs. [6] and [24] to obtain further details and discussion.

Considering a perfect fluid star in static background spacetime with a static slice \(\Sigma \), we assume that quantities are measured by static observers. The Tolman’s law gives \(T\chi =const.\), where T and \(\chi \) are the temperature of the fluid and the redshift factor, respectively. Without loss of generality, we take \(T\chi =1\). Assuming that the fluid in region C on \(\Sigma \) satisfied ordinary thermodynamic relations and Tolman’s law. We have shown that if the constraint equation holds and the total entropy is an extremum, then the other components of gravitational equation are obtained [6, 8, 10]. The fact implies that the full set of gravitational equations may be replaced by the ordinary thermodynamic relations and the constraint equation.

An isolated system in thermodynamical equilibrium is said to be thermodynamical stable if \(\delta ^2S<0\). In Ref. [24] we have shown that if the star is deviated slightly from equilibrium state, the second variation of total entropy takes the form

$$\begin{aligned} \delta ^2S= & {} \int \limits _C\frac{1}{T}\bigg [2\delta \rho \delta \sqrt{h}+\sqrt{h}\delta ^2\rho \nonumber \\&+(p+\rho )\delta ^2\sqrt{h}-\frac{\delta p \cdot \delta \rho }{p+\rho }\sqrt{h}\bigg ] \,, \end{aligned}$$
(30)

where \(\rho \) and p are the energy density and pressure, respectively.

In the case of general relativity, we have proven that the thermodynamical stability criterion given by Eq. (30) is the same as the dynamical stability criterion given by Ref. [17]. In this section, we calculate the thermodynamical stability criterion in f(R) gravities. Recall that the gravitational field equation of f(R) theories can be written as

$$\begin{aligned} f_RR_{ab}-\frac{1}{2}f g_{ab}-[\nabla _a\nabla _b-g_{ab}\Box ]f_R=8\pi T_{ab}, \end{aligned}$$
(31)

and the general spherical symmetric spacetime is

$$\begin{aligned} ds^2=-e^{2\Phi (t,r)}dt^2+e^{2\Lambda (t,r)}dr^2+r^2d\Omega ^2 \,, \end{aligned}$$
(32)

we can easily obtain the energy density \(\rho =T_t\,^t\) and the pressure \(p=T_r\,^r\) of the perfect fluid star as

$$\begin{aligned} \rho= & {} \frac{f_R}{r^2}+\frac{e^{-2\Lambda }(2r\Lambda '-1)}{r^2}f_R+\frac{1}{2}f \nonumber \\&-\frac{R}{2}f_R-e^{-2\Lambda }f_R'' +e^{-2\Lambda }\left( \Lambda '-\frac{2}{r}\right) f_R' \,, \end{aligned}$$
(33)
$$\begin{aligned} p= & {} -\frac{f_R}{r^2}+\frac{e^{-2\Lambda }(1+2r\Phi ')}{r^2}f_R-\frac{1}{2}f \nonumber \\&+\frac{R}{2}f_R+e^{-2\Lambda }\left( \frac{2}{r}+\Phi '\right) f_R'. \end{aligned}$$
(34)

Since the redshift factor \(\chi =e^{\Phi }\), the temperature takes the form \(T=e^{-\Phi }\). Based on Chandrasekhar’s procedure [11], the \(t-r\) component of Eq. (31) gives

$$\begin{aligned} -(p+\rho )e^{2\Lambda }\frac{\partial \xi }{\partial x^0}= & {} f_R\frac{2}{r}\frac{\partial \Lambda }{\partial x^0}-\frac{\partial f_R'}{\partial x^0} \nonumber \\&+\frac{\partial \Phi }{\partial r}\frac{\partial f_R}{\partial x^0} +\frac{\partial \Lambda }{\partial x^0}\frac{\partial f_R}{\partial r}. \end{aligned}$$
(35)

By direct integration, we have

$$\begin{aligned} \lambda = \mathcal {F}^{-1}\left( \frac{\partial }{\partial r}b-\frac{\partial \Phi }{\partial r}b-(p+\rho )e^{2\Lambda }\xi \right) , \end{aligned}$$
(36)

this is just Eq. (23).

To calculate the explicitly form of Eq. (30) and compare with the dynamical stability criterion, we consider the same Lagrangian of matter as Eq. (18), which gives the identified relation Eq. (19) as

$$\begin{aligned} \varrho \rightarrow \rho , \qquad \varrho '\nu -\varrho \rightarrow p \,. \end{aligned}$$
(37)

These relations yield

$$\begin{aligned} \delta \rho =\varrho '\delta \nu , \qquad \delta p=\varrho ''\nu \cdot \delta \nu , \end{aligned}$$
(38)

so

$$\begin{aligned} \frac{\delta p \cdot \delta \rho }{p+\rho }=\frac{\varrho ''\nu \delta \nu \cdot \varrho '\delta \nu }{\varrho '\nu }=\varrho ''(\delta \nu )^2, \end{aligned}$$
(39)

where the explicitly form of \(\delta \nu \) is given by Eq. (A4). Meanwhile, the variation of the volume element \(\sqrt{h}\) gives

$$\begin{aligned} \delta \sqrt{h}=r^2e^{\Lambda }\lambda \,, \end{aligned}$$
(40)

and the variation of Eq. (33) gives

$$\begin{aligned} \delta \rho= & {} \frac{b}{r^2}-\frac{2e^{-2\Lambda }}{r^2}\left( 2r\frac{\partial \Lambda }{\partial r}-1\right) f_R\lambda +\frac{2e^{-2\Lambda }}{r}f_R \frac{\partial \lambda }{\partial r} \nonumber \\&+\frac{e^{-2\Lambda }}{r^2}\left( 2r\frac{\partial \Lambda }{\partial r}-1\right) b-\frac{R}{2}b+2e^{-2\Lambda }f_R''\lambda \nonumber \\&-e^{-2\Lambda }b''-2e^{-2\Lambda }\left( \frac{\partial \Lambda }{\partial r}-\frac{2}{r}\right) f_R'\lambda \nonumber \\&+e^{-2\Lambda }\frac{\partial \lambda }{\partial r}f_R'+e^{-2\Lambda }\left( \frac{\partial \Lambda }{\partial r}-\frac{2}{r}\right) b'. \end{aligned}$$
(41)

Then the second variation of \(\sqrt{h}\) and \(\rho \) can be obtained. Substituting these relations into Eq. (30), after tediously calculations we find that the thermodynamical stability criterion takes the form:Footnote 2

$$\begin{aligned} \delta ^2S= & {} \int \limits _r \mathcal {C}_{Thermo}^1\left( \frac{\partial b}{\partial r}\right) ^2+\mathcal {C}_{Thermo}^2\left( \frac{\partial \xi }{\partial r}\right) ^2 \nonumber \\&+\,\mathcal {C}_{Thermo}^3\xi \frac{\partial b}{\partial r}+\mathcal {C}_{Thermo}^4b\frac{\partial \xi }{\partial r} +\mathcal {C}_{Thermo}^5\frac{\partial b}{\partial r}\frac{\partial \xi }{\partial r} \nonumber \\&+\,\mathcal {C}_{Thermo}^6b^2+\mathcal {C}_{Thermo}^7\xi ^2+\mathcal {C}_{Thermo}^8b\xi \,, \end{aligned}$$
(42)

where each \(\mathcal {C}_{Thermo}^i\) are the functions of the background fields. We put all detailed calculations and the expressions of each \(\mathcal {C}_{Thermo}^i\) in Appendix C.

4 Conclusions and discussions

We have investigated the stability criterions for static spherical symmetric perfect fluid in f(R) theories by dynamical and thermodynamical methods, respectively. The dynamical stability criterion of the spherically symmetric perfect fluid in f(R) theories is given by Eq. (29). If the system is dynamical stable, then \((\psi , \mathcal {T}\psi )>0\), i.e., \(\mathcal {P}_{Dyn}>0\). And the thermodynamical stability criterion is given by Eq. (42). The negative of the second variation of the total entropy, \(\delta ^2S<0\), means the system is thermodynamical stable. Comparing Eqs. (B10), (B12), (B19), (B20), (B22), (B25), (B28), (B31) and Eqs. (C10), (C11), (C12), (C13), (C14), (C18), (C21) and (C22), we find that

$$\begin{aligned} \mathcal {C}_{Dyn}^i=-\mathcal {C}_{Thermo}^i. \end{aligned}$$
(43)

Therefore, Eqs. (29) and (42) are exactly the same except the opposite signs, which shows that the dynamical stability criterion is the same as the thermodynamical stability criterion in f(R) theories. Combining with the result obtained in Ref. [24], we find that the dynamical stability can be replaced by thermodynamical stability not only in general relativity, but also in modified theories, such as f(R) theories. It suggests that there is a universal inherent connection between thermodynamics and gravity.

Comparing the concrete calculations of the stability criterions, we found that thermodynamical method is more directly and simpler than the dynamical method. In dynamical method, one should determine the symplectic current \(\omega ^a\) and the three-form \(\mathbf {W}_{\alpha \beta }\) firstly, and then solve each evolution equation for variable by complicated calculations (it should be pointed out whether the evolution equation can be solved is uncertainly). After these preparations one can obtain the stability criterion. In thermodynamical method, we only need to substitute the expressions of the energy density \(\rho \) and the pressure p into Eq. (30), then the thermodynamical stability criterion can be obtained directly.