1 Introduction

The processes that affect the size and composition of natural populations occur on a wide range of spatial and temporal scales. For example, speciation can occur due to spatial segregation of subpopulations, which genetically diverge due to adaptions to the local environment (Smith 1966). Spatial variation of the environment on smaller scales typically leads to trade-offs such as the growth-mortality trade-off among tropical trees which is caused by variation in light availability (Wright et al. 2010).

In terms of temporal effects, it was previously held that measurable evolutionary change required vast amounts of time, on the order of thousands or millions of generations, to occur, and that therefore there was a clear separation between evolutionary and ecological dynamics. The latter occurs on the order of ten generations or less, but recent field studies and theoretical work has contradicted this clear cut separation and instead shown that evolution can occur over tens of generations, blurring the difference between evolutionary and ecological dynamics (Carroll et al. 2007). This rapid change can be driven by a changing environment, e.g. as in the industrial melanism in the peppered moth (Kettlewell 1956), or as in the case of Darwin’s finches by migration into a novel environment with many adaptive peaks (Grant and Grant 2006).

The entanglement of eco-evo time scales raises the question of when it is valid to speak of evolutionary and ecological dynamics as two separate processes. One way to answer this question is to make use of perturbation analysis, which formalises the idea of processes acting on different time scales (Wasow 2018; Vasileva 1963), and makes it possible to quantify the error which the assumption of an absolute separation of time scales introduces. Perturbation analysis is applicable when a model contains a very small (or very large) parameter and aims at expressing the solution as a power series in this small parameter. The first term in this infinite series corresponds to an absolute separation of time scales, and higher order terms provide a correction to the zeroth-order approximation. In ecology, this method has been used in order to show that the logistic equation can be derived by assuming a separation of time scales between trophic levels, where the resource dynamics occurs on a much faster time scale compared to the population dynamics (Lakin and Van Den Driessche 1977; Naidu and Rajagopalan 1979). The technique has also been used in evolutionary game theory (Wu et al. 2010), and more generally in stochastic models of evolution (McAvoy and Allen 2021), in order to obtain analytical results for, e.g. fixation probabilities.

Here, we apply perturbation analysis to a general population dynamical model where the small parameter corresponds to the difference in frequency-dependent selection between different genotypes. We show that if selection is weak the model can be split up into distinct parts describing the evolutionary and ecological dynamics. We also apply the method to one model of public goods dynamics and one model of predator competition, and investigate how the error scales with the order of the approximation. Lastly, we discuss the relation between our framework and other methods for deriving approximate models in population dynamics.

2 General model

We consider N interacting subpopulations that represent distinct genotypes (or phenotypes). The population dynamics are assumed to be deterministic and driven exclusively by birth and death, and we currently disregard the effects of migration and mutation, although these processes could be added to the model. The dynamics are then governed by the following system of coupled ordinary differential equations:

$$\begin{aligned} \frac{dx_i}{dt}&= F_i( {\mathbf {x}} ) x_i - D_i( {\mathbf {x}} ) x_i, i=1,\ldots ,N \end{aligned}$$
(1)

where \(F_i( {\mathbf {x}} )\) is the per capita birth rate and \(D_i( {\mathbf {x}} )\) is the per capita death rate of genotype i, which in this general setting depend on size of all subpopulations population \( {\mathbf {x}} = (x_1,x_2,\ldots ,x_N)\) We now assume that both the birth rate and death rate can be decomposed into the product of a frequency-dependent and a density-dependent factor, i.e.

$$\begin{aligned} F_i( {\mathbf {x}} ) = f_i({\mathbf {u}})g(s) \nonumber \\ D_i( {\mathbf {x}} ) = d_i({\mathbf {u}})h(s) \end{aligned}$$
(2)

where the frequency-dependent factors \(f_i\) and \(d_i\) depend on the frequency of all types \({\mathbf {u}}= (u_1,\ldots ,u_N)\), where \(u_i = x_i/\sum _{j=1}^N x_j\) and the density-dependent factor depends on the total population size \(s=\sum _{i=1}^N x_i\), and are equal for all genotypes. We thus obtain the following system

$$\begin{aligned} \frac{dx_i}{dt}&= f_i( {\mathbf {u}})g(s) x_i - d_i({\mathbf {u}})h(s) x_i, i=1,\ldots ,N. \end{aligned}$$
(3)

2.1 Change of variables

In order to get a better understanding of the dynamics of this system, we make a change of variables to obtain a system of ODEs for the variables \(({\mathbf {u}},s)\). This is related to the standard translation between the Lotka–Volterra equations and replicator dynamics (see Theorem 7.5.1 in Hofbauer and Sigmund 1998). Denoting time derivative with a dot, the rate of change of \(u_i\) can be written

$$\begin{aligned} \frac{du_i}{dt}&= \frac{d}{dt} \left( \frac{x_i}{\sum _{j=1}^N x_j} \right) = \frac{\dot{x_i} \sum _{j=1}^N x_j-x_i\left( \sum _{j=1}^N \dot{x_j} \right) }{\left( \sum _{j=1}^N x_j\right) ^2} = \\&= \frac{(f_i({\mathbf {u}})g(s)x_i - d_i({\mathbf {u}})h(s)x_i)s - x_i \left( \sum _{j=1}^N f_j({\mathbf {u}})g(s)x_j - d_j({\mathbf {u}}) h(s)x_j\right) }{s^2} = \\&= u_i\left( f_i({\mathbf {u}})g(s)- d_i({\mathbf {u}})h(s) \right) - u_i \left( \sum _{j=1}^N f_j({\mathbf {u}})g(s)u_j - d_j({\mathbf {u}}) h(s)u_j\right) = \\&= u_i\left[ \left( f_i({\mathbf {u}}) - \sum _{j=1}^N u_j f_j({\mathbf {u}}) \right) g(s) - \left( d_i({\mathbf {u}}) - \sum _{j=1}^N u_j d_j({\mathbf {u}}) \right) h(s) \right] . \end{aligned}$$

In order to simplify this expression, we note that the sums in the last expression are equal to the average frequency-dependent birth and death rates, which we denote:

$$\begin{aligned} {\bar{f}}({\mathbf {u}})&= \sum _{j=1}^N u_jf_j({\mathbf {u}}) \end{aligned}$$
(4)
$$\begin{aligned} {\bar{d}}({\mathbf {u}})&= \sum _{j=1}^N u_jd_j({\mathbf {u}}). \end{aligned}$$
(5)

With these definitions, we obtain:

$$\begin{aligned} \frac{du_i}{dt}&= u_i\left[ \left( f_i({\mathbf {u}}) - {\bar{f}}({\mathbf {u}}) \right) g(s) - \left( d_i({\mathbf {u}}) - {\bar{d}}({\mathbf {u}}) \right) h(s) \right] . \end{aligned}$$

We now assume that the frequency-dependent birth and death rate for genotype i can be expressed as a baseline birth/death rate (common to all genotypes) plus a genotype-specific term of order \(\varepsilon \):

$$\begin{aligned} f_i({\mathbf {u}})&= f_0({\mathbf {u}}) + \varepsilon \phi _i({\mathbf {u}}) \nonumber \\ d_i({\mathbf {u}})&= d_0({\mathbf {u}}) + \varepsilon \eta _i({\mathbf {u}}), \end{aligned}$$
(6)

where \(\varepsilon \ll 1\) and \(\phi _i({\mathbf {u}})\), \(\eta _i({\mathbf {u}})\) are some functions that depend on the frequency of all genotypes. The difference between the birth rate of genotype i and the mean birth rate can now be written: \(f_i({\mathbf {u}}) - {\bar{f}}({\mathbf {u}}) = \varepsilon (\phi _i- {\bar{\phi }})\), where \({\bar{\phi }} = \sum _i \phi _i u_i\). The assumption that \(\varepsilon \ll 1\) now implies that the difference in frequency-dependent birth rates between different genotypes is small, and since the same holds for the death rates selection is weak.

This results in the following equation for each \(u_i\):

$$\begin{aligned} \frac{du_i}{dt}&= \varepsilon u_i\left[ \left( \phi _i({\mathbf {u}}) -{\bar{\phi }}({\mathbf {u}}) \right) g(s) - \left( \eta _i({\mathbf {u}}) -{\bar{\eta }}({\mathbf {u}}) \right) h(s) \right] . \end{aligned}$$

We now proceed to derive an equation for the total population size.

$$\begin{aligned} \frac{ds}{dt}&= \frac{d}{dt} \left( \sum _{i=1}^N x_i \right) = \sum _{i=1}^N \dot{x_i} = \sum _{i=1}^N f_i( {\mathbf {u}})g(s) x_i - d_i({\mathbf {u}})h(s) x_i\nonumber \\&= g(s) \sum _{i=1}^N f_i ({\mathbf {u}})x_i - h(s)\sum _{i=0}^Nd_i({\mathbf {u}})x_i = g(s) s {\bar{f}}({\mathbf {u}}) - h(s)s{\bar{d}}({\mathbf {u}}) \nonumber \\&= g(s) s (f_0({\mathbf {u}}) + \varepsilon {\bar{\phi }}({\mathbf {u}})) - h(s)s (d_0({\mathbf {u}}) + \varepsilon {\bar{\eta }}({\mathbf {u}})) \end{aligned}$$
(7)

where in the second to last step we used the fact that \(x_i = su_i\). In summary, we get the following coupled system of \(N+1\) equations:

$$\begin{aligned} \frac{du_i}{dt}&= \varepsilon u_i\left[ \left( \phi _i({\mathbf {u}}) -{\bar{\phi }}({\mathbf {u}}) \right) g(s) - \left( \eta _i({\mathbf {u}}) -{\bar{\eta }}({\mathbf {u}}) \right) h(s) \right] \end{aligned}$$
(8)
$$\begin{aligned} \frac{ds}{dt}&= \varepsilon s \left[ g(s) {\bar{\phi }}({\mathbf {u}}) - h(s) {\bar{\eta }} ({\mathbf {u}}) \right] + s\left( g(s) {f_0}({\mathbf {u}}) - h(s){d_0} ({\mathbf {u}}) \right) . \end{aligned}$$
(9)

We thus have \(N+1\) equations that describe the dynamics in the \(({\mathbf {u}},s)\)-space. However, note that one equation can be omitted since \(u_N = 1-\sum _{i=1}^{N-1} u_i\).

2.2 Perturbation solution

We would now like to express the solutions \(u_i(t)\) and s(t) as a power series in our small parameter \(\varepsilon \) (i.e. a perturbation solution):

$$\begin{aligned} u_i(t)&= u_{i0}(t) + \varepsilon u_{i1}(t) + {\mathcal {O}}(\varepsilon ^2) \\ s(t)&= s_0(t) + \varepsilon s_1(t) + {\mathcal {O}}(\varepsilon ^2). \end{aligned}$$

The next step is to insert this ansatz into (8), but here care has to be taken with expressions of the form \(\phi _i({\mathbf {u}})\) and g(s), since we need to evaluate expressions of the form \(\phi _i \left( {\mathbf {u}}_0(t) + \varepsilon {\mathbf {u}}_1(t) + {\mathcal {O}}(\varepsilon ^2)\right) \). Now, if the functions are multivariate polynomials, it is readily seen that

$$\begin{aligned} \phi _i\left( {\mathbf {u}}_0 + \varepsilon {\mathbf {u}}_1 + {\mathcal {O}}(\varepsilon ^2)\right) = \phi _i({\mathbf {u}}_0) + {\mathcal {O}}(\varepsilon ), \end{aligned}$$
(10)

and similarly

$$\begin{aligned} g\left( s_0 + \varepsilon s_1 + {\mathcal {O}}(\varepsilon ^2)\right) = g(s_0) + {\mathcal {O}}(\varepsilon ). \end{aligned}$$
(11)

If our functions are not polynomials, we can invoke the Stone–Weierstrass approximation theorem, which states that any continuous function defined on a compact subset \(X \subset {\mathbb {R}}^N\) can be uniformly approximated by polynomials to any degree of accuracy (De Branges 1959). If this should be the case, we simply replace our original functions with the approximating polynomials and then make use of the property (10) and (11).

We now insert the perturbation ansatz into (8) and comparing terms of order \(\varepsilon ^0\) we get

$$\begin{aligned} \frac{du_{i0}}{dt}&= 0 \nonumber \\ \frac{ds_0}{dt}&= s_0\left( g(s_0) {f_0}({\mathbf {u}}_0) - h(s_0){d_0} ({\mathbf {u}}_0) \right) . \end{aligned}$$
(12)

This implies that the frequency is unchanged and \(u_{i0}(t)=u_{i0}(t=0)\) for all \(t \ge 0\), whereas the population size changes according to the difference between the density-dependent per capita growth rate \(g(s_0)\) and death rate \(h(s_0)\), each with a constant prefactor which depends on the baseline frequency-dependent birth/death rate of the initial frequency of genotypes \({\mathbf {u}}_0\).

This dynamics occurs on the \({\mathcal {O}}(1)\) time scale and exclusively captures changes in population density. Therefore, it is natural to define it as the ecological time scale. From the perspective of perturbation analysis, this is usually referred to as the inner solution.

Higher-order corrections are obtained by comparing terms of order \(\varepsilon \) and higher; however, this is not possible in this general setting where we have not specified the functions that describe frequency- and density-dependent birth and death rates. In the next sections, where we treat two specific models, higher-order terms are obtained.

In order to describe the dynamics for large times on the order of \(1/\varepsilon \) (the outer solution), we define a new time scale \(\tau = \varepsilon t\) and express the solution as:

$$\begin{aligned} u_i(t)&= U_{i0}(\tau ) + \varepsilon U_{i1}(\tau ) + {\mathcal {O}}(\varepsilon ^2) \\ s(t)&= S_0(\tau ) + \varepsilon S_1(\tau ) + {\mathcal {O}}(\varepsilon ^2). \end{aligned}$$

The time derivatives on this time scale are given by

$$\begin{aligned} \frac{dU_{i0}}{d\tau }&= \frac{1}{\varepsilon } \frac{dU_{i0}}{dt} \\ \frac{dS}{d\tau }&= \frac{1}{\varepsilon } \frac{dS}{dt}. \end{aligned}$$

Using the power series ansatz yields, to order \(\varepsilon ^0\)

$$\begin{aligned} \frac{dU_{i0}}{d\tau }&= U_{i0}\left[ \left( \phi _i({\mathbf {U}}_0) - {\bar{\phi }} ({\mathbf {U}}_0) \right) g(S_0) - \left( \eta _i({\mathbf {U}}_0) -{\bar{\eta }}({\mathbf {U}}_0) \right) h(S_0) \right] \\ 0&= S_0\left( g(S_0) {f_0}({\mathbf {U}}_0) - h(S_0){d_0} ({\mathbf {U}}_0) \right) . \end{aligned}$$

In order to eliminate \(S_0\) from the first equation, we need to make two assumptions: firstly, assume that \(S_0 \ne 0\) (i.e. the total population size is nonzero) and secondly, assume that there exists an equilibrium density \(S_0^\star \ne 0\) that solves the second equation \(g(S_0) {f_0}({\mathbf {U}}_0) = h(S_0)d_0 ({\mathbf {U}}_0)\). We also need to make sure that the equilibrium density is stable which can be determined by analysing the zeroth-order equation for the density (12). The equilibrium is stable if the derivative of the right hand size evaluated at \(S_0^\star \) is negative:

where the last inequality is obtained since we assumed that \(g(S_0^\star ) {f_0}({\mathbf {U}}_0) = h(S_0^\star )d_0 ({\mathbf {U}}_0)\). In summary, the equilibrium density \(S_0^\star \ne 0\) has to satisfy:

$$\begin{aligned}&i) \ g(S_0^\star ) {f_0}({\mathbf {U}}_0) = h(S_0^\star )d_0 ({\mathbf {U}}_0)\ \mathrm { and}\\&ii)\ g'(S_0^\star ) {f_0}({\mathbf {U}}_0) < h'(S_0^\star ){d_0} ({\mathbf {U}}_0). \end{aligned}$$

If multiple points exist that satisfy these conditions, then the initial condition determines which equilibrium point is attained by the ecological dynamics.

If at least one such point exists, we can write

$$\begin{aligned} \frac{dU_{i0}}{d\tau }&= U_{i0}\left[ \left( \phi _i({\mathbf {U}}_0) - {\bar{\phi }} ({\mathbf {U}}_0) \right) g(S_0^\star ) - \left( \eta _i({\mathbf {U}}_0) -{\bar{\eta }}({\mathbf {U}}_0) \right) h(S_0^\star ) \right] , \end{aligned}$$
(13)

which describes the dynamics on the \(1/\varepsilon \) time scale. On this time scale, the population size equilibrates instantaneously and we only capture the changes in frequency. It is therefore natural to think of this as the evolutionary time scale.

In summary, the perturbation analysis shows that the dynamics of the system (8) has two distinct regimes. For short times \(t={\mathcal {O}}(1)\), the population size s changes and the frequencies \({\mathbf {u}}\) are unchanged. This is typically referred to as the ecological time scale. For larger times \(t={\mathcal {O}}(1/\varepsilon )\), the density is constant, whereas the frequency is altered. This is typically referred to as the evolutionary time scale.

3 Application to public goods game under logistic growth

We now apply the above results to a specific model, one that describes the dynamics of public goods production in a population consisting of producers and free-riders (Gerlee and Altrock 2017). The model assumes that the public good is shared among all individuals and that it has a linear effect on the growth rate. This gives rise to the following frequency-dependent growth rates, where type 1 are the producers and type 2 are the free-riders (see Gerlee and Altrock 2017 for details):

$$\begin{aligned} f_1(u)&= \alpha (1+ \beta u) - \kappa \\ f_2 (u)&= \alpha (1+ \beta u) \end{aligned}$$

where u is the frequency of producers, \(\alpha \) is growth rate in the absence of the public good, \(\beta \) describes impact of the public good and \(\kappa \) is the cost of production. In terms of assumption (6), we note that \(f_0(u) = \alpha (1+ \beta u)\), whereas \(\phi _1 = -1\) and \(\phi _2 = 0\), and as long as the cost of production is small (\(\kappa \ll 1\)) selection is weak.

The two types are assumed to be identical except for the public good production, and therefore, the density-dependence is identical for both types. It is assumed to follow logistic growth with carrying capacity K, i.e. \(g(s)=1-s/K\), and the per capita death rate is assumed to be constant and equal to \(\mu \). This implies that the dynamics of the population are given by:

$$\begin{aligned} \frac{dx_1}{dt}&= f_1(u)x_1 \left( 1- \frac{x_1+x_2}{K} \right) - \mu x_1\\ \frac{dx_1}{dt}&= f_2(u)x_2 \left( 1- \frac{x_1+x_2}{K} \right) - \mu x_2.\\ \end{aligned}$$

As before, we change variables to \(s=x_1+x_2\) and \(u=\frac{x_1}{x_1+x_2}\) and obtain the following system

$$\begin{aligned} \frac{du}{dt}&= -\kappa u(1-u) \left( 1-\frac{s}{K}\right) \nonumber \\ \frac{ds}{dt}&= -\kappa su \left( 1-\frac{s}{K}\right) + \alpha (1+ \beta u) s\left( 1-\frac{s}{K}\right) - \mu s. \end{aligned}$$
(14)

We now express the solutions u(t) and s(t) as a power series in \(\kappa \):

$$\begin{aligned} u(t)&= u_0(t) + \kappa u_1(t) + {\mathcal {O}}(\kappa ^2) \\ s(t)&= s_0(t) + \kappa s_1(t) + {\mathcal {O}}(\kappa ^2). \end{aligned}$$

We insert the power series ansatz into (14) and gather terms with the same power of \(\kappa \). To zeroth order in \(\kappa \), this yields

$$\begin{aligned} \frac{du_0}{dt}&= 0 \end{aligned}$$
(15)
$$\begin{aligned} \frac{ds_0}{dt}&= \alpha (1+\beta u_0) s_0\left( 1-\frac{s_0}{K}\right) - \mu s_0, \end{aligned}$$
(16)

i.e. on the ecological time scale we obtain logistic growth with a growth rate that depends on the initial frequency of producers \(u_0\). With some additional algebra, we obtain the following equations to first order in \(\kappa \):

$$\begin{aligned} \frac{du_1}{dt}&= -u_0(1-u_0)\left( 1-\frac{s_0}{K}\right) \end{aligned}$$
(17)
$$\begin{aligned} \frac{ds_1}{dt}&= -s_0u_0\left( 1-\frac{s_0}{K}\right) + \alpha (1+\beta u_0) s_1\left( 1-\frac{2s_0}{K}\right) + \alpha \beta u_1 s_0\left( 1-\frac{s_0}{K}\right) - \mu s_1. \end{aligned}$$
(18)

Here, things get more complicated. Both the population size and frequency of producers change and the time derivative of u depends s and vice versa. Thus, we no longer have the separation of ecological and evolutionary time scales observed at zeroth order.

By carrying out the change of variables \(\tau = \kappa t\), we obtain the system:

$$\begin{aligned} \kappa \frac{du}{d \tau }&= -\kappa u(1-u) \left( 1-\frac{s}{K}\right) \nonumber \\ \kappa \frac{ds}{d \tau }&= -\kappa su \left( 1-\frac{s}{K}\right) + \alpha (1+ \beta u) s\left( 1-\frac{s}{K}\right) - \mu s. \end{aligned}$$
(19)

We now employ the outer power series ansatz

$$\begin{aligned} u(t)&= U_0(\tau ) + \kappa U_1(\tau ) + {\mathcal {O}}(\kappa ^2) \\ s(t)&= S_0(\tau ) + \kappa S_1(\tau ) + {\mathcal {O}}(\kappa ^2). \end{aligned}$$

and obtain to zeroth order in \(\kappa \):

$$\begin{aligned} \frac{dU_0}{d \tau }&= - U_0(1-U_0) \left( 1-\frac{S_0}{K}\right) \\ 0&= \alpha (1+\beta U_0) S_0 \left( 1-\frac{S_0}{K}\right) - \mu S_0. \end{aligned}$$

The second equation can be solved for \(S_0\) and ignoring the trivial solution \(S_0=0\) yields

$$\begin{aligned} S_0 = K(1-\frac{\mu }{\alpha (1+ \beta U_0)}). \end{aligned}$$
(20)

Inserting this into the first equation now gives

$$\begin{aligned} \frac{dU_0}{d \tau }&= - \frac{ \mu }{\alpha (1+ \beta U_0)}U_0(1-U_0), \end{aligned}$$
(21)

which provides us with the zeroth-order dynamics on the evolutionary (\(1/\kappa \)) time scale. Comparing terms of order \(\kappa \), we obtain after some calculations:

$$\begin{aligned} \frac{dU_1}{d\tau }&= U_0(1-U_0)\frac{S_1}{K} +2U_0U_1 \left( 1-\frac{S_0}{K}\right) + U_1 \left( 1-\frac{S_0}{K}\right) \nonumber \\ \frac{dS_0}{d\tau }&= -S_0U_0\left( 1-\frac{S_0}{K}\right) + \alpha (1+\beta U_0) S_1\left( 1-\frac{2S_0}{K}\right) + \alpha \beta U_1 S_0\left( 1-\frac{S_0}{K}\right) - \mu S_1. \end{aligned}$$
(22)

Since we know \(S_0\) from (20), we can solve the second equation for \(S_1\) and obtain

$$\begin{aligned} S_1(\tau )&= \frac{\frac{S_0}{d \tau }+S_0\left( 1-\frac{S_0}{K}\right) (U_0-\alpha \beta U_1)}{\alpha (1+\beta U_0)\left( 1-\frac{2S_0}{K}\right) -\mu }, \end{aligned}$$

where

$$\begin{aligned} \frac{dS_0}{d\tau }&= -\frac{K \beta \mu ^2}{\alpha ^2(1+\beta U_0)^3}U_0(1-U_0). \end{aligned}$$

This expression for \(S_1\) can then be substituted into (22) to yield a closed ODE for \(U_1\).

3.1 Numerical comparison

In order to compare the accuracy of the zero-order approximation of the original system (14), we calculate a composite solution using the method of matched asymptotic expansions (Lagerstrom 2013). The composite solution is obtained by adding the inner and outer solutions and subtracting the overlap, which is given by the the outer limit of the inner solution, and the inner limit of the outer solution. If we assume that the initial conditions are given by \((u(t=0),s(t=0))=(a,b)\), and since u remains unchanged for the inner solution, this implies that

$$\begin{aligned}&\lim _{t \rightarrow \infty } u(t) = \lim _{\tau \rightarrow 0} U(\tau ) = a \\&\lim _{t \rightarrow \infty } s(t) = \lim _{\tau \rightarrow 0} S(\tau ) = K(1-\frac{\mu }{\alpha (1+ \beta a)}) \end{aligned}$$

where the equality for s comes from the fact that s is completely determined in terms of u in the inner solution. The composite solution can now be written

$$\begin{aligned} u_c(t)&= u_0(t) + U_0(\kappa t) - a \nonumber \\ s_c(t)&= s_0(t) + S_0(\kappa t) - K(1-\frac{\mu }{\alpha (1+ \beta a)}). \end{aligned}$$
(23)

A numerical solution to (14) is shown in Figure 1A for different values of the small parameter \(\kappa \) together with the zero-order composite solution (23). As expected, a small value of \(\kappa \) leads to solution which shows clearer separation in ecological and evolutionary dynamics where the population first grows to carrying capacity without changes in frequency and then a subsequent change in frequency.

Fig. 1
figure 1

A Solution of (14) for different values of \(\kappa \) with the initial condition \((u,s) = (0.5,0.01)\). The other parameters are set to \(\alpha =\beta =1\) and \(K=1\). The magenta curve shows the zeroth-order composite solution (23). The underlying vector field corresponds to \(\kappa = 0.1\). B The total error between the numerical solution of the original system (14) and the composite solution (23) as defined by (24) with \(T_{max} = 2000\). The initial condition was set to \((u,s) = (0.5,0.01)\) and the parameters are set to \(\alpha =\beta =1\) and \(K=1\). The dashed line corresponds to \(E(\kappa ) \sim \kappa \) (Color figure online)

In order to quantify the error introduced by the zero-order approximation, we calculate the total error

$$\begin{aligned} E(\kappa ) = \left( \int _0^{T_{max}} \left( u(t)-u_c(t) \right) ^2 + \left( s(t)-s_c(t) \right) ^2dt\right) ^{1/2} \end{aligned}$$
(24)

where all solutions are calculated numerically using the lsoda-solver as implemented in SciPy’s odeint. Figure 1B shows that as expected the error \(E(\kappa )\) of the zero-order composite solution scales as \(\kappa \) as long as \(\kappa \ll 1\).

We also compare the accuracy of the zeroth- and first-order approximation of the population size on the ecological time scale by solving (16) and (18) numerically and calculating the error compared to the numerical solution of the full system. The initial conditions for the first-order ODEs are chosen such that the approximation is valid for all values of \(\kappa \), which corresponds to setting \(u_1(t=0)=s_1(t=0)=0\). The solutions are shown in Figure 2A and the total error in Figure 2B. This shows that the error scales according to \(\kappa \) for the zeroth-order solution and \(\kappa ^{2}\) for the first-order solution.

Fig. 2
figure 2

A Solutions of the ecological dynamics (16) and (18) for \(\kappa = 0.2\) with initial condition \((u,s) = (u_0,s_0)=(0.5,0.01)\) and \((u_1,s_1)=(0,0)\). The other parameters are set to \(\alpha =\beta =1\) and \(K=1\). B The total error for the zeroth- and first-order approximation. The dashed lines have slope 1 and 2, respectively (Color figure online)

4 Application to predator competition in a Lotka–Volterra system

We now turn to a more complicated system of a prey and two competing predators:

$$\begin{aligned} \frac{dx}{dt}&= \alpha x - \beta x \left( y_1+ (1+\varepsilon )y_2\right) \end{aligned}$$
(25)
$$\begin{aligned} \frac{dy_1}{dt}&= \delta xy_1 - \gamma y_1 \end{aligned}$$
(26)
$$\begin{aligned} \frac{dy_2}{dt}&= \delta (1+\varepsilon ) xy_2 - \gamma y_2, \end{aligned}$$
(27)

where x denotes the population size of the prey, \(y_1\) the population size of the wild-type predator and \(y_2\) the invading predator, which is a factor \((1+\varepsilon )\) better at feeding on the prey. The global stability of the steady states of this system has previously been investigated (Llibre and Xiao 2014), and here, we are concerned with the dynamics of the special case when \(\varepsilon \ll 1\).

Although the entire system does not conform to the general form of (3), it will be useful to carry out the outlined perturbation solution since it allows us to analyse a case where the ecological dynamics does not converge to a stable equilibrium point, but rather to a limit cycle.

We focus on the predator populations and therefore consider the dynamics of the total population of predators \(s=y_1+y_2\) and the fraction of the wild-type predator \(u=y_1/(y_1+y_2)\). In order to carry out the perturbation solution, we make a change of variables and consider the system in terms of x, s and u. After some algebra, we obtain:

$$\begin{aligned} \frac{dx}{dt}&= \alpha x - \beta x \left( s+ (1+\varepsilon )s(1-u)\right) \nonumber \\ \frac{du}{dt}&= -\varepsilon \delta x u(1-u) \nonumber \\ \frac{ds}{dt}&= \varepsilon \delta sx(1-u)+\delta sx -\gamma s. \end{aligned}$$
(28)

We begin with the perturbation solutions on the ecological time scale and make the ansatz:

$$\begin{aligned} x(t)&= x_0(t) + \varepsilon x_1(t) + {\mathcal {O}}(\varepsilon ^2) \nonumber \\ u(t)&= u_0(t) + \varepsilon u_1(t) + {\mathcal {O}}(\varepsilon ^2) \nonumber \\ s(t)&= s_0(t) + \varepsilon s_1(t) + {\mathcal {O}}(\varepsilon ^2). \end{aligned}$$

By inserting this into (28) and equating powers of \(\varepsilon \), we obtain to zeroth order

$$\begin{aligned} \frac{dx_0}{dt}&= \alpha x_0 - \beta x_0 s_0 \nonumber \\ \frac{du_0}{dt}&= 0 \nonumber \\ \frac{ds_0}{dt}&= \delta s_0x_0 -\gamma s_0, \end{aligned}$$
(29)

which we recognise as a standard Lotka–Volterra system in the variables \((x_0,s_0)\), and where the fraction of wild-type predator \(u_0\) remains constant.

To first order in \(\varepsilon \), we obtain

$$\begin{aligned} \frac{dx_1}{dt}&= \alpha x_1 - \beta \left( x_0\left( s_1+s_0(1-u_0) \right) + x_1s_0 \right) \nonumber \\ \frac{du_1}{dt}&= -\delta x_0 u_0 (1-u_0) \nonumber \\ \frac{ds_1}{dt}&= \delta s_0x_0(1-u_0)+\delta (x_0s_1+x_1s_0) -\gamma s_0, \end{aligned}$$
(30)

where we see a decrease in the fraction of the wild-type (since \(x_0 u_0 (1-u_0) > 0\)).

In order to analyse the evolutionary dynamics, we carry out the change of variables \(\tau = \varepsilon t\) and obtain

$$\begin{aligned} \varepsilon \frac{dx}{d\tau }&= \alpha x - \beta x \left( s+ (1+\varepsilon )s(1-u)\right) \nonumber \\ \varepsilon \frac{du}{d\tau }&= - \varepsilon \delta x u(1-u) \nonumber \\ \varepsilon \frac{ds}{d\tau }&= \varepsilon \delta sx(1-u)+\delta sx -\gamma s. \end{aligned}$$
(31)

We then make the ansatz:

$$\begin{aligned} x(t)&= X_0(\tau ) + \varepsilon X_1(\tau ) + {\mathcal {O}}(\varepsilon ^2) \nonumber \\ u(t)&= U_0(\tau ) + \varepsilon U_1(\tau ) + {\mathcal {O}}(\varepsilon ^2) \nonumber \\ s(t)&= S_0(\tau ) + \varepsilon S_1(\tau ) + {\mathcal {O}}(\varepsilon ^2), \end{aligned}$$

and obtain to zeroth order in \(\varepsilon \)

$$\begin{aligned} 0&= \alpha X_0 - \beta X_0 S_0 \nonumber \\ \frac{dU_0}{dt}&= -\delta X_0 U_0 (1-U_0) \nonumber \\ 0&= \delta S_0X_0 -\gamma S_0. \end{aligned}$$
(32)

The first and third equation together yield \(X_0=\gamma /\delta \) and \(S_0 = \alpha / \beta \), which we recognise as the steady state of the zeroth-order ecological dynamics (29). Thus, on an evolutionary time scale (to zeroth order) the prey population and the total predator population take on their ecological steady state values. The fraction of wild-type predators, on the other hand, follows a replicator-like equation, with a constant selection coefficient given by \(-\delta X_0 = -\gamma \), which is the death rate of the predators.

Comparing terms of order \(\varepsilon \), we obtain

$$\begin{aligned} \frac{dX_0}{dt}&= \alpha X_1 - \beta \left( X_0\left( S_1+S_0(1-U_0) \right) + X_1S_0 \right) \nonumber \\ \frac{dU_1}{dt}&= -\delta X_0 U_1 (1-2U_0) - \delta X_1 U_0 (1-U_0) \nonumber \\ \frac{dS_0}{dt}&= \delta \left( S_0X_0(1-U_0) +X_0S_1 + X_1S_0 \right) -\gamma S_1. \end{aligned}$$
(33)

Since both \(X_0\) and \(S_0\) are constant, the first and third equation have a left hand side equal to zero and can both be solved for \(X_1\) and \(S_1\), respectively. After some calculations, we obtain \(X_1 = -\frac{\gamma }{\delta } (1-U_0)\) and \(S_1 = -\frac{\alpha }{\beta } (1-U_0)\). To first order on the evolutionary time scale, we thus see a change in the prey and total predator population size according to

$$\begin{aligned} x(t)&= \frac{\gamma }{\delta } - \varepsilon \frac{\gamma }{\delta } (1-U_0(\tau )) + {\mathcal {O}}(\varepsilon ^2) \end{aligned}$$
(34)
$$\begin{aligned} s(t)&= \frac{\alpha }{\beta } - \varepsilon \frac{\alpha }{\beta }(1-U_0(\tau )) + {\mathcal {O}}(\varepsilon ^2), \end{aligned}$$
(35)

where the fraction of wild-type predators \(U_0(t)\) changes according to (32) and the first-order correction according to (33).

4.1 Numerical comparison

In this example, where the ecological dynamics do not converge to a stable state (as it did for the public goods game), but instead enter into a limit cycle, we are not able to form a composite solution valid for all times. Instead, we consider the dynamics on the ecological and evolutionary time scales separately. We focus on the fraction of wild-type predators and investigate how the zeroth- and first-order approximations on the ecological ((29) and (30)) and evolutionary ((32) and (33)) time scales compare to the solution of the full Lotka–Volterra system (28). All solutions were calculated numerically using the lsoda-solver as implemented in SciPy’s odeint. The result is shown in figure 3A where the inset shows the ecological dynamics (up to \(t\approx 20\)) and the evolutionary dynamics is shown on the large axes. The full solution exhibits oscillatory dynamics and at the same decreases in a sigmoid fashion. The amplitude of these oscillations is diminished as \(\varepsilon \) decreases (data not shown). To zeroth order on the ecological time scale, we obtain a constant fraction of wild-type predators, whereas the first-order approximation tracks the oscillation fairly well approximately halfway through one cycle. On the evolutionary time scale the zeroth- and first-order approximations both capture the sigmoid decrease in the wild-type predator.

When comparing the error between the full Lotka–Volterra system and the approximations on the ecological time scale, we see as expected that the error of the zeroth-order solution scales as \(\varepsilon \), whereas the error of the first-order solution scales as \(\varepsilon ^2\).

Fig. 3
figure 3

A The fraction of wild-type predators as a function of time for the full Lotka–Volterra system (red), on the ecological time scale (blue) and evolutionary time scale (green). Zeroth-order approximations are dashed, whereas first-order approximations are shown as solid lines. The parameters are \(\varepsilon = 0.05\), \(\alpha =0.2\), \(\beta =1\), \(\delta = 0.5\) and \(\gamma = 1\). The initial conditions are \((x,y_1,y_2)=(1,1,0.01)\). B The total error between the numerical solution of the original system (28) and the zeroth- and first-order approximations on the ecological time scale (see inset in panel A). The total time was set to \(T_{max} = 20\), and the parameters and initial conditions were set as in panel A. The dashed lines correspond to \(E(\kappa ) \sim \varepsilon \) and \(\varepsilon ^2\) (Color figure online)

5 Discussion

We have shown how perturbation analysis together with the assumption of weak selection provides a formal way of expressing the dynamics of a population on ecological and evolutionary time scales. The approximate solution is expressed as a power series in a parameter that quantifies the deviation between the frequency-dependent birth and death rates of each genotype and the average. We have applied the method to a specific model of a two strategy public goods game and the competition between two predators in a Lotka–Volterra model and showed numerically that the error introduced scales with the selection coefficient to the power \(k+1\), where k is the order of the approximation.

An important result is the derivation of the zeroth-order equation for the outer/evolutionary dynamics (13), which can be viewed as a generalisation of the replicator equation

$$\begin{aligned} \frac{du_i}{dt}&= u_i\left( f_i({\mathbf {u}}) -{\bar{f}}({\mathbf {u}}) \right) , \end{aligned}$$

with the addition of density-dependent rates that modulate the intensity of selection. Our equation also captures the effects of frequency-dependence on both birth and death rates. The replicator equation has been derived for constant (Traulsen et al. 2006) and exponentially growing (Taylor and Jonker 1978) populations, whereas (13) holds (to zeroth order in \(\varepsilon \)) for any type of density- and frequency-dependent growth.

The model of the public goods game has been analysed previously in order to obtain an approximate equation of the change in producer frequency (Gerlee and Altrock 2017). In that case, an equation for the invariant manifold was derived and solved in terms of a power series in the death rate \(\mu \). The resulting differential equation for the change in producer frequency was given by

$$\begin{aligned} \frac{du}{d t}&= - \frac{ \mu \kappa }{\alpha (1+ \beta u) - u\kappa }u(1-u), \end{aligned}$$

which at a first glance differs from (21). However, a Taylor expansion of the prefactor to first order in \(\kappa \) is given by \(\frac{-\mu \kappa }{\alpha (1+\beta u)}\) and if time is rescaled according to \(\tau = \kappa t\) (as was done to obtain (21)) we see that an equation identical to (21) is obtained. The two approaches thus yield identical equations for the evolution of the producer frequency.

We have also shown that our framework can be applied to models where the ecological dynamics follow oscillatory dynamics such as in the Lotka–Volterra system (28). Also, here we obtain to zeroth order a replicator equation for the fraction of the wild-type prey (32), where the selection coefficient is constant and given by the death rate of the predators. We showed that higher order corrections to this simple relationship can be obtained, but also that they add little to the zeroth-order solution, at least for small selection strengths. The Lotka–Volterra system is overly simplistic and does not account for mechanisms such as bounded growth of prey and predator handling-time. However, our framework is general and can also be applied to predator-prey models that are more realistic and thus more complex.

The concept of weak selection and the separation of ecological and evolutionary time scales which follows from it has been used extensively in mathematical modelling of population biology (Lion 2018). It is a central concept in adaptive dynamics, which is a framework that describes the long-term evolutionary dynamics of an evolving population (Geritz 2005). There it is assumed that evolution follows a ’trait substitution sequence’ in which monomorphic populations are invaded by fitter mutants that displace the wild-type. This process is captured by the so-called canonical equation (Dieckmann and Law 1996), which describes how the value of the traits under selection evolves over time and is obtained as deterministic approximation of a directed random walk in the trait space. Notably this framework has been extended to situations where the ecological dynamics are oscillatory and chaotic (Ferriere and Gatto 1995).

Weak selection also features heavily in evolutionary game theory (EGT) since it simplifies the analysis and allows for explicit calculations of, e.g. fixation probabilities (Nowak et al. 2004). The impact of higher order terms in EGT has been investigated by Wu et al. (2010) , who showed that the universality of weak selection breaks down when higher order terms are considered and that the microscopic model of evolution influences the dynamics. In addition, it has also been shown that the ranking of strategies depends on the strength of selection and therefore, that zeroth-order approximations are a poor proxy under strong selection, in particular in multi-player games (Wu et al. 2013).

Related to the work on EGT is Allen and McAvoy’s analysis of fixation probabilities in populations of arbitrary size and spatial structure (McAvoy and Allen 2021), where weak selection allows for computation of fixation probabilities in polynomial rather than exponential time. They have also considered a wide array of genetic structures (e.g. haploid, diploid, etc.), and also there perturbation analysis as applied to selection strength plays a central role in obtaining analytical results (Allen and McAvoy 2019).

The above-mentioned EGT-models as well as those of Allen and McAvoy describe populations of a fixed size. This condition is relaxed in (Argasinski and Broom 2013) who consider populations of varying size where birth and death rates are affected by both density- and frequency-dependence. They consider a system of coupled ODEs, which is a similar setting to ours, but are restricted to logistic density-dependence. Their treatment of time-scale separation is also far from rigorous, and they only consider the zeroth-order equilibrium solution to the ecological dynamics when expressing the evolutionary dynamics. Variable population sizes are also considered in Cressman and Garay (2003), which investigate stability in \(N-\)species coevolutionary systems. They claim that time scale separation is not required in their analysis, and instead their focus is on ’stationary density surfaces’ which correspond to equilibria of the ecological dynamics. However, such equilibria are not reached (for general initial conditions) unless the ecological time scale is completely separate from the evolutionary. Another model that considers a variable population size is analysed by Parsons and Quince (2007), which is formulated in terms of a two-dimensional Markov chain, where the transition rates contain a logistic density-dependence. They also make use of perturbation analysis in order to calculate fixations probabilities, but in their analysis it is the reciprocal of the carrying capacity which plays the role of the small parameter.

Lastly, it should be mentioned that weak selection has also been used in inclusive fitness theory, where it simplifies the calculations of fixation probabilities and selection gradients (Van Cleve 2015), and in the theory of branching processes (Lambert 2006).

In contrast to the above-mentioned contributions to our understanding of weak selection and its implications for eco-evo dynamics, we would like to highlight that the work presented here is the first to jointly consider: (i) general density-dependent growth (as opposed to, e.g. Argasinski and Broom 2013), (ii) a rigorous treatment of ecological and evolutionary time scales in terms of inner and outer solutions including composite solutions obtained using matched asymptotic expansions, and (iii) a quantification and numerical verification of the error introduced by using zeroth- and first-order approximations.

One limitation of our framework is that it only applies to deterministic models. For small populations, stochastic models are more relevant since they account for demographic noise, and extending our methodology to such models would therefore be desirable. One way of achieving this could be to formulate the dynamics as an \(N-\)dimensional Markov chain that describes the population size of the considered genotypes and writing down the corresponding Fokker–Planck equation as in Parsons and Quince (2007). By assuming weak frequency-dependence and expanding the solution of the Fokker–Planck equation in a power-series of the selection strength, it might be possible to obtain approximate solutions. Another, possibly simpler approach would be to take the continuum limit of the Markov chain to obtain a system of N coupled stochastic differential equations (Czuppon and Traulsen 2021). In this setting, questions about fixation probabilities and fixation times can be pursued using perturbation analysis coupled with the toolbox of stochastic analysis.

The framework we have introduced is applicable to a large class of population dynamical models with density- and frequency-dependence and makes it possible to derive approximate solutions in the case of weak selection. The use of composite solutions in addition makes it possible to obtain solutions valid for all times. If selection is not weak, it is possible to include higher-order terms in the power series expansion and still obtain distinct models for the ecological and evolutionary time scales. As was seen for the public goods and Lotka–Volterra model, these higher order corrections typically involve changes in both density and frequency.

The method presented here also makes it possible to test if, for a given model, separation of time scales is a sensible approximation. This could for example be used to investigate if evolutionary game theory, which only describes changes in frequency, is a reasonable description of a certain system, or if changes in density have to be accounted for.