Frequency‐dependent two‐sex models: a new approach to sex ratio evolution with multiple maternal conditions

Abstract Mothers that experience different individual or environmental conditions may produce different proportions of male to female offspring. The Trivers‐Willard hypothesis, for instance, suggests that mothers with different qualities (size, health, etc.) will use different sex ratios if maternal quality differentially affects sex‐specific reproductive success. Condition‐dependent, or facultative, sex ratio strategies like these allow multiple sex ratios to coexist within a population. They also create complex population structure due to the presence of multiple maternal conditions. As a result, modeling facultative sex ratio evolution requires not only sex ratio strategies with multiple components, but also two‐sex population models with explicit stage structure. To this end, we combine nonlinear, frequency‐dependent matrix models and multidimensional adaptive dynamics to create a new framework for studying sex ratio evolution. We illustrate the applications of this framework with two case studies where the sex ratios depend one of two possible maternal conditions (age or quality). In these cases, we identify evolutionarily singular sex ratio strategies, find instances where one maternal condition produces exclusively male or female offspring, and show that sex ratio biases depend on the relative reproductive value ratios for each sex.


Introduction
The primary sex ratio can be defined as the proportion of male births in an individual's offspring production strategy (Trivers 1985). When the primary sex ratio is homogenous across the population, it evolves to equalize parental investment in both sexes (Fisher 1930). If males and females are equally costly, the sex ratio evolves to equality (Hamilton 1967). If males and females are differentially costly, the sex ratio skews in response to sex-specific offspring costs, such as differential offspring resource requirements, offspring mortality, or offspring-induced parental mortality (Shyu and Caswell 2016).
However, many species have facultative (conditiondependent) sex ratio strategies, where a parent adjusts the primary sex ratio of its offspring depending on some environmental or individual condition (Leimar 1996;West 2009). These facultative sex ratio strategies allow both multiple mating stages and multiple sex ratios to coexist within a population.
In order to better incorporate these factors into evolutionary projections, we have developed a two-sex modeling framework that has multiple maternal states with different sex ratios. Our general model is introduced in the section "A two-sex matrix model with multiple maternal conditions'' and further expanded upon in the "Model" sections of two case studies.
This framework combines three components that have never (to our knowledge) been simultaneously applied to the problem of facultative sex ratio evolution. We include arbitrary stage structures within male and female life cycles. We make the demographic model nonlinear, to include the dependence of reproductive success on the stage-sex composition of the population; this dependence provides a route through which sex ratio strategies will feed back on the fitness of the individuals adopting them, which is largely ignored in the current literature (e.g., Pen et al. 1999;Fawcett et al. 2011;Schindler et al. 2015). Finally, rather than relying on traditional criteria for sex ratio evolution that were derived for simpler cases (e.g., Schindler et al. 2016), we make use of the explicit evolutionary calculations obtained from adaptive dynamics. Thus, our modeling framework relaxes three of the primary simplifying assumptions that are common in the literature on sex ratio evolution.
To illustrate our framework, we will focus on a situation with two conditions of mothers, so that the facultative sex ratio strategy is described by the bivariate trait vector s: where s 1 is the sex ratio used by mothers in one condition (e.g., low quality) and s 2 is the sex ratio used by mothers in the other condition (e.g., high quality). Using multidimensional adaptive dynamics methods, as described in the section "Multidimensional adaptive dynamics", we determine how s evolves over time and find its evolutionarily singular strategies s Ã , which are potential long-term evolutionary outcomes. We then consider two specific cases where the sex ratio depends on maternal condition. In the first case ("Case 1: Maternal age"), young and old mothers can evolve different sex ratios. In the second case ("Case 2: Maternal quality"), high-and low-quality mothers can evolve different sex ratios, as in the Trivers-Willard hypothesis.

Background
Many species adjust the sex ratios of their offspring in response to spatial or temporal environmental variation. Parasitic wasps, which lay their eggs on a variety of hosts, vary their sex ratios based on host size (Charnov et al. 1981); because female larvae benefit more from larger food sources, wasp sex ratios are female-biased on large hosts and male-biased on small ones. Other species use different sex ratios in different seasons, in response to the timing of sex-specific life cycle events (Werren and Charnov 1978). Kestrels, for instance, produce offspring at different sex ratios at different points in the breeding season, to account for male and female maturation differences (Pen et al. 1999).
Sex ratios may also vary with some parental (usually maternal) condition, such as age. In many mammals, where males have higher infant mortality rates (Trivers 1985), sex ratios become increasingly female-biased with maternal age. This may be because older mothers are more prone to death or sterility and cannot replace lost sons as easily (Charlesworth 1977). Older fathers can also promote female-biased sex ratios; Drosophila melanogaster females with older mates tend to produce more female offspring, possibly because deleterious mutations in older fathers are more detrimental to sons (Long and Pischedda 2005). When older parents are more beneficial, sex ratio biases reverse. In Iberian red deer, for example, older females are larger, obtain more food, and expend more energy on reproduction. Sex ratios thus become increasingly male-biased with maternal age, because older mothers can afford the higher costs of sons (Lendete-Castillejos et al. 2004).
Other parental conditions, including health, size, or ranking, affect the conditions of the parent's offspring (Hewison and Gaillard 1999). These types of conditions, or qualities, are the focus of the Trivers-Willard hypothesis (Trivers and Willard 1973). The Trivers-Willard hypothesis predicts that a parent's quality will affect the sex ratios of their offspring if offspring quality is correlated with parental quality. Namely, low-quality parents should preferentially produce offspring of the sex with higher reproductive success (e.g., number of offspring) at low quality, and vice versa for high-quality parents.
Suppose that reproductive success of male offspring varies more steeply with quality than that of female offspring. Then, low-quality female offspring will have higher success than low-quality male offspring, but this ranking will be reversed for high-quality offspring (Fig. 1). Thus, low-quality parents, doomed to produce low-quality offspring, should favor females. High-quality parents, anticipating the production of high-quality offspring, should favor males. The influence of quality on reproductive success is usually described in terms of greater (males, in our example) or lesser (females) "variance in reproductive success," and the Trivers-Willard hypothesis is usually phrased as a prediction that highquality mothers will invest more in the sex with greater variance in reproductive output.
The example with males and females we used here is often applied to polygynous species, where high-quality males monopolize most breeding opportunities. As a result, a high-quality son outreproduces a high-quality daughter, but a low-quality daughter outreproduces a low-quality son. Because males are the sex with the greater variance in reproductive success, high-quality females adjust their sex ratios to invest in sons, while low-quality females invest in daughters.
Empirical support for the Trivers-Willard hypothesis has been found in many animals, most notably ungulates with strong sexual dimorphism and polygynous mating (e.g., Clutton-Brock et al. 1984Hewison and Gaillard 1999). However, results are sometimes mixed, possibly due to differences in data collection methods, quality measures, and difficulties in calculating lifetime reproductive success (e.g., Hewison and Gaillard 1999;Sheldon and West 2004;Schindler et al. 2016). The effects of maternal quality on sex ratio have also been studied in birds (e.g., Kilner 1998;Clout et al. 2002), humans (e.g., Gaulin and Robbins 1991;Cameron and Dalerum 2009), and many other taxa (West 2009, Ch. 6)

Model and Methods
Here, we present a framework for modeling facultative sex ratio evolution, one that includes multiple maternal conditions such as ages and the qualities described in the Trivers-Willard hypothesis. The basis of our framework is a two-sex population model that uses a series of matrices to describe various stages and life cycle processes (as in Shyu and Caswell 2016;Shyu and Caswell Submitted manuscript). Our model distinguishes between two individual conditions (e.g., age or quality) for both males and females. We accordingly incorporate four types of unions (male-female mated pairings) and different preferences for mating with partners in different conditions. Each maternal condition produces offspring with a different sex ratio. We analyze the transient dynamics of bivariate sex ratio evolution using the canonical equation of adaptive dynamics and the equilibrium dynamics by characterizing evolutionarily singular strategies (SSs) of the sex ratios.
A two-sex matrix model with multiple maternal conditions Consider, as an example, a two-sex population consisting of Condition 1 and Condition 2 individuals (e.g., young and old individuals, low-and high-quality individuals). Males and females mate to form unions (here, monogamous couples) that produce new offspring.
Unions where the male partner is in Condition i and the female partner is in Condition j will be written as u ij . As we shall see in the "Model" sections for the two case studies, the u ij may differ in available resources, fertilities, and other properties. We will specifically assume that any union with a Condition j female has sex ratio s j . This means that the primary sex ratio is a facultative trait that depends solely on maternal condition.
The population consists of conditions 1 and 2 males (m 1 ; m 2 ), conditions 1 and 2 females (f 1 ; f 2 ), and four types of unions (Fig. 2). The densities of each stage are given by the population vector:

Quality
Reproductive success

Low quality female
Low quality male

High quality female
High quality male Figure 1. Reproductive success as a function of quality in the Trivers-Willard hypothesis. In this example, low-quality females are more successful than low-quality males, but high-quality males and more successful than high-quality females. Additional male, female, or union types can be added as new entries in the population vector.
We divide mating, birth, and life cycle transition processes into three rate matrices: U, B, and T, respectively. As shown in Shyu and Caswell (Submitted manuscript), the average of these matrices is the continuous-time projection matrix: Specific examples of both the population vector and rate matrices are given in the "Model" sections for the two case studies. As we shall see, each of the three rate matrices in (3) may depend on the population vector (2) or the sex ratio vector (1) The essential property of two-sex models is that, in sexually reproducing species, reproduction depends on the relative abundance of males and females, or of males and females of particular life cycle stages. In the extreme case, as the relative abundance of either stage declines to zero, reproductive success also declines to zero. In less extreme imbalances of the sex structure, reproduction will still be affected by the availability of mates, in a way that depends on the life history and mating system of the species.
Thus, the matrices in (3) are functions of the stage frequency vector: where ‖n‖ is the 1-norm of n. As a result, (4) is a frequency-dependent model that converges to an equilibrium stage distributionp and a growth rate k that is the dominant eigenvalue of AðpÞ. This is a general property of frequency-dependent models (Ianelli et al. 2005).
To calculate k andp, it is sufficient to consider the dynamics of p (Shyu and Caswell Submitted manuscript): To findp, we integrate (6) with the MATLAB ODE45 differential equation solver until p converges top (e.g., until vector entries do not change significantly over consecutive integration intervals). The population's long-term growth rate k is then the dominant eigenvalue of AðpÞ, which has corresponding right and left eigenvectors w and v. Note that the right eigenvector is also the stable stage distribution; that is, w ¼p.

Mating preferences
The mating process, where adult males and females pair into reproducing unions, is described by the union formation matrix U. Mating functions in U give the rates of union formation as functions of the relative frequencies of males and females available to mate and are thus functions of the stage frequency vectorp (5).
Mating preferences in the mating functions describe the probabilities of favoring partners of certain conditions. The female preference distribution g j ðiÞ gives the proportion of Condition j females that mate with Condition i males. Similarly, the male preference distribution h i ðjÞ gives the proportion of Condition i males that mate with Condition j females. Summing these distributions over all male and female conditions, respectively, yields a total probability of 1: Examples of mating preference distributions include: 1. Fully assortative mating, where individuals only mate with partners in the same condition: 2. Random mating, where individuals pick partners based on their relative abundances in the population: 3. Biased mating, where individuals prefer partners of certain conditions. An attractiveness or competitiveness factor c i weighs the abundance of each partner condition, for example: Partners with larger c i are more preferable mates. If all c i are equal, (11) reduces to the random mating case (10). If c i ¼ 0, individuals of stage i do not mate. The total mating function M ij ðnÞ gives the total unions u ij (Condition i males mated with Condition j females) formed per time. The most general and flexible mating functions are based on generalized weighted means (H€ older means). These have the general form: where 0 ≤ b ≤ 1 and a < 0 (Hadeler 1989;Caswell 2001;Martcheva and Milner 2001). Note that M ij ðnÞ is calculated only over individuals that are available to mate (i.e., adult single male stages m i and adult single female stages f j ). As a result, the mating function does not depend on the males and females in nonmating stages, such as immature juveniles or adults already in unions.
The harmonic mean mating function in particular is one of the most widely used mating functions, because it satisfies the biological criteria for two-sex models and is typical of a wide range of Holder means Weeks 1986, Ianelli et al. 2005). Here, as in Shyu and Caswell (Submitted manuscript), we use a harmonic mean mating function where a = À1, b = 1/2, so that: The corresponding male and female per capita mating functions are: As we shall see, the union matrix U from (4) contains these per capita mating functions.

Multidimensional adaptive dynamics
Adaptive dynamics is a phenotype-based framework for modeling evolution. We have previously used univariate (one-dimensional) adaptive dynamics to determine evolutionarily singular strategies for a single, scalar sex ratio (Shyu and Caswell 2016). Here, we use multidimensional adaptive dynamics to analyze the evolution of the bivariate sex ratio s in (1).
Similar to the approach in Shyu and Caswell (2016), we consider a stable, monomorphic resident population with sex ratio phenotype s, projection matrix A as in (3), and a long-term exponential growth rate k that is the dominant eigenvalue of AðpÞ. This resident population is invaded by new, rare mutants, which differ from residents only in terms of their sex ratio phenotype. Such mutations are small, rare, and infrequent. As a result, mutants do not affect resident dynamics and will either die out or reach fixation before the next mutation arises (Gertiz et al. 1998;Metz 2006).
To successfully invade, the mutant strategy must be able to outperform the resident, under the conditions created by the resident. A given mutant has phenotype s 0 , projection matrix A 0 , and corresponding growth rate k 0 ; both A 0 and k 0 depend on the environmental conditions (e.g., mating rates) set by the resident. The mutant projection matrix A 0 is structurally identical to the resident matrix A; however, A 0 uses the mutant sex ratio s 0 and is evaluated at the resident equilibrium stage distributionp. An example of how to construct A 0 is shown in Shyu and Caswell (2016, section 3.2.1) The invasion fitness K s ðs 0 Þ is the relative growth rate of a mutant with sex ratio strategy s 0 , in an environment where the resident uses the strategy s: Only mutants with a positive invasion fitness have a positive probability of displacing the resident.
The selection gradient is the first derivative of the invasion fitness (15) with respect to the mutant phenotype s 0 , and indicates the direction of selection at a resident phenotype s. Note that the resident growth rate k does not depend on s 0 . Thus, the selection gradient is simply the sensitivity of mutant growth rate k 0 (Caswell 2010): where w 0 and v 0 are the dominant right and left eigenvectors of the mutant matrix A 0 ðpÞ, scaled so that v 0 | w 0 ¼ 1.
Although the invasion fitness (15) is a scalar, the selection gradient (16) is a row vector with two componentsthe partial derivatives of k 0 to each entry of s (1): As shown in the next two sections, the selection gradient (17) lends insight into both the transient and equilibrium evolutionary dynamics of s.

Evolutionary dynamics
The transient dynamics of s depend on the evolutionary trajectories generated by repeated mutant invasions. When mutations are small (do not differ drastically from the resident phenotype), these trajectories can be  As shown by Dieckmann and Law (1996), Durinx et al. (2005) and Durinx et al. (2008), the canonical equation is a differential equation that describes ds/dt, the change in the resident trait over time, using a first-order Taylor approximation. In both unstructured and structured populations, it can be written as the product of the selection gradient D(s) and a mutational variance-covariance matrix V(s) that encompasses mutation probabilities, frequencies, and effects (Doebeli 2011): The multivariate breeder's equation from quantitative genetics (Lande 1979) has a form similar to (18), but is based on standing genetic variation rather than the active mutational process (Doebeli 2011).
Although population size affects the mutation rate (Dieckmann and Law 1996), we will focus on the shape and direction of the evolutionary trajectories, rather than their speed, so that the population's (exponentially growing) size is irrelevant. We will also assume that effects of mutations on different components of s are uncorrelated (i.e., no pleiotropy), so that V(s) is a diagonal matrix.
The evolution of s is biologically constrained, in that neither s 1 nor s 2 can be <0 or >1 (or both 0 and 1 simultaneously) in a realistic, viable population. These constraints can be written as follows: 0 s 1 1 0 s 2 1 ðs 1 ; s 2 Þ 6 ¼ ð0; 0Þ Because we are interested in the direction and outcome of evolution, but not its speed, we can solve the boundary problems by adjusting the variance-covariance matrix to prevent evolution in unfeasible directions (Dieckmann et al. 2006). To this end, we use a mutational matrix of the form: This choice of V causes the mutational variances to decrease as s 1 and s 2 near 0 or 1. If either s 1 or s 2 goes to 0 or 1, their corresponding component of the canonical equation (18) will vanish, preventing that sex ratio from evolving out of the biologically constrained region (19).
With mutational matrix (20) and selection gradient (17), the canonical equation (18) becomes: We will use (21) to track the evolutionary trajectories of s through 2D trait space.

Equilibrium evolutionary dynamics
Potential evolutionary endpoints occur at stationary points of the canonical equation (21). The corresponding resident strategies s Ã are called singular strategies (SSs), where: As summarized in Figure  ds 1 = 0 ds 2 > 0 ds 1 = 0 ds 2 < 0 ds 1 > 0 ds 2 = 0 ds 1 < 0 ds 2 = 0 ds 1 = 0 ds 2 = 0 Boundary 1 0 < s 2 < 1 > 0 0 Figure 3. The five types of singular strategies s Ã ¼ ðs Ã 1 ; s Ã 2 Þ and their corresponding selection gradients (17). Although it is also possible for s Ã ¼ ð0; 1Þ or (1,0), these are marginal cases that we have not observed in our model. The remaining types of singular strategies (Types 2-5, boundary SSs) lie on each of the four boundaries of the constrained region, where s 1 or s 2 are either 0 or 1 (Leimar 1996; Schwanz et al. 2006). In these cases, both components of D(s) do not simultaneously equal 0. Instead, the selection gradient for the nonboundary sex ratio is 0, and the selection gradient for the boundary sex ratio points away from the boundary (Fig. 3). Note that (22) can still be satisfied depending on the value of V(s).
In most cases, as shown in Schwanz et al. (2006), there is a single SS s Ã , which falls into one of these five cases (but see the "Results" section for "Case 1b: Parental resource cost" for an example where this is not true). To find s Ã , we use the following steps: 1. Determine if there is any point in the constrained region (19) where both components of the selection gradient (17) are simultaneously 0. This can be done using MATLAB's fsolve or fmincon functions. If a solution is found, this is an interior (Type 1) SS. Else, we must check for a boundary SSs of Types 2-5. 2. To check for a Type 2 SS, set s 2 ¼ 0 and use MATLAB's fsolve function to find the corresponding value of s 1 where dk To check for a Type 3 SS, set s 2 ¼ 1 and find s 1 where dk

4.
To check for a Type 4 SS, set s 1 ¼ 0 and find s 2 where dk

5.
To check for a Type 5 SS, set s 1 ¼ 1 and find s 2 where dk These singular strategies s Ã are potential evolutionary endpoints for s. Characterizing their evolutionary and convergence stability can be challenging because s is a vector-valued trait (but see Appendix B). Generating the evolutionary trajectories of s using (21), however, may lend insight into general stability patterns.

Case Studies
We will use this framework to examine two cases where the primary sex ratio depends on maternal condition. Again, the evolving sex ratio phenotype is the vector s ¼ ðs 1 ; s 2 Þ, and the components of which are the sex ratios used by mothers in each condition.
Our maternal conditions of interest are as follows: • Case 1: Maternal age. Young mothers have sex ratio s 1 , and old mothers have sex ratio s 2 . • Case 2: Maternal quality. Low-quality mothers have sex ratio s 1 , and high-quality mothers have sex ratio s 2 .
In both cases, there are two possible conditions for an individual (young and old in Case 1; low-and high-quality in Case 2). Although individuals of different conditions may interbreed (e.g., a high-quality male may mate with a low-quality female), a couple's sex ratio is determined by the condition of the female partner (e.g., a couple with a low-quality female would have sex ratio s 1 regardless of the male partner's quality).
In each case, we examine the evolutionary trajectories generated by the variance-constrained, bivariate canonical equation (21), and the types of evolutionarily singular strategies s Ã (Fig. 3) that result.
Unless otherwise indicated, model parameters are as in Table 1. Our model also makes the following assumptions: • A union u ij (Condition i male mated with Condition j female) has divorce rate d ij , reproductive rate k j , and primary sex ratio s j . Note that the reproductive rate and primary sex ratio are maternally determined.
• Only unions can produce new offspring. Unmated males and females do not reproduce independently.
• Any offspring with a mutant parent also has the mutant phenotype; that is, the mutant genotype is genetically dominant.
Results for all cases are summarized in Table 2.

Case 1: Maternal Age
Previous studies suggest that sex ratios differ with parental age when male and female offspring are differentially costly. However, different types of offspring costs may result in different bivariate sex ratio patterns.
Differential offspring costs can occur when offspring of one sex induce more parental mortality (Shyu and Caswell 2016, Case 4). Human sons, for instance, reduce maternal longevity more than daughters do (Helle et al. 2002). Younger mothers should thus favor daughters (the less mortality-inducing sex), while older mothers favor sons (the more mortality-inducing sex). Charnov (1982) suggested this as an example of senescence through antagonistic pleiotropy (Williams 1957)that is, genes selected for their beneficial effects early in life (e.g., a lower mortality reproductive strategy) could have negative effects later in life (e.g., a higher mortality reproductive strategy).
Alternatively, differential offspring costs can occur when offspring of a particular sex are more likely to die before independence (Shyu and Caswell 2016, Case 2). In many mammals, also including humans, male offspring have higher in utero mortality rates (Trivers 1985;Vatten and Skjaerven 2004; though see also Orzack et al. 2015). Because older mothers are more likely to die or become sterile before they are able to replace lost sons, younger mothers should favor sons (the more mortality-prone sex), while older mothers favor daughters (the less mortality-prone sex) (Charlesworth 1977).
These two examples predict opposite trends for human sex ratios with maternal age. Empirical studies have alternatingly found sex ratios to increase (Takahashi 1954), decrease (Pollard 1969;James and Rostron 1985), or be uncorrelated with maternal age (Almagor et al. 1998;Jacobsen et al. 1999). These mixed results may suggest that the effects of various offspring costs vary or even counterbalance in different populations, or that there are additional factors at play.
We will examine how the sex ratios of younger and older mothers are affected by sex-biased offspring costs. We consider both parental mortality and offspring mortality costs, in turn, through the following two subcases: Per capita mating rate of a female in union u ij Given by (14) Case 1 (maternal age) only a m1 ; a f 1 Juvenile to young adult maturation rates 0.5 a m2 ; a f 2 Young adult to old adult maturation rates 0.5 l m0 ; l f 0 Juvenile mortality rates 0.1 b Parental mortality intensity factor in (32) 0.2 I Baseline investment rate in (27) 1 Case 2 (maternal quality) only a m1 ; a f 1 Low-quality juvenile to adult maturation rates 1 a m2 ; a f 2 High-quality juvenile to adult maturation rates 1 l m;01 ; l f ;01 Low-quality juvenile mortality rates 0.1 l m;02 ; l f ;02 High-quality juvenile mortality rates 0.1 c i Male competitiveness factor for Condition i (40) Probability that a Condition j female produces Condition i offspring, subject to (38) Table 2. Evolutionarily singular strategies s Ã for primary sex ratios that depend on maternal condition (age or quality).

Case Offspring cost Previous predictions Model results
Maternal age Case 1a Parental mortality (Case 4) † Young mothers favor sex inducing less mortality, old mothers favor sex inducing more mortality (Charnov 1982) Results depend on relative reproductive rates of young and old mothers ( Figure 6) Case 1b Offspring mortality during parental investment (Case 2) † Young mothers favor higher mortality sex, old mothers favor lower mortality sex (Charlesworth 1977) Infinitely many selectively neutral sex ratio combinations (Figure 7) Maternal quality Case 2 Offspring resource cost (Case 1) † High-quality mothers favor the sex with greater variance in reproductive success or value (Trivers and Willard 1973;Leimar 1996) High-quality mothers favor the sex with greater variance in reproductive value at boundary SS ( • Case 1a. Male and female offspring are differentially costly through their effects on parental mortality, similar to Charnov (1982). We previously described a similar single sex ratio model in Shyu and Caswell (2016, Case 4). • Case 1b. Male and female offspring have different mortality rates before independence (during the period of parental investment), similar to Charlesworth (1977). We previously described a similar single sex ratio model in Shyu and Caswell (2016, Case 2).

Model
We partition males and females into immature juveniles (m 0 , f 0 ), young adults (m 1 , f 1 ), and old adults (m 2 , f 2 ). Only young and old adults can mate to form reproducing unions, and the four possible union types are as follows: The population vector (2) has 10 stages total: We will write a model of the form (4), and the next three sections give the matrices B, U, and T in turn.

Births (B)
Unions with young adult and old adult females use the sex ratios s 1 and s 2 , respectively, and have characteristic reproductive rates k 1 and k 2 , respectively. The birth matrix B is thus: In Case 1a, where male and female offspring have different effects on parental mortality, the k j are fixed rates. In Case 1b, where male and female offspring have different mortality rates during the period of parental investment, k j becomes: where R j is the mother's rate of resource investment (total resources put into offspring per time), and C m and C f are the average male and female offspring resource costs (resources consumed per offspring born). In Shyu and Caswell (2016, Case 2), these costs are shown to be: where I is a constant baseline investment rate, a m1 and a f 1 are the male and female juvenile to adult maturation rates, and l m0 and l f 0 are the male and female juvenile mortality rates.

Union formation (U)
The union formation matrix U contains per capita mating rates of each union type. Using a harmonic mean mating function as in (13), the per capita mating functions (14) are: where m ¼ m 1 þ m 2 and f ¼ f 1 þ f 2 . The matrix U is then:

Transitions (T)
Each stage has a characteristic mortality rate: l xs where x 2 fm; f g and s 2 f0; 1; 2g If offspring impose parental mortality (Case 1a), the mortality rates of individuals in reproducing unions is greater than that of unmated individuals. Let l xs (30) be the mortality rate of an unmated individual, and l ij xs be the mortality rate of a mated individual in union u ij . Similar to Shyu and Caswell (2016, Case 4), l ij xs is increased from l xs by an amount c j : Let b be a nonnegative constant that modulates the intensity of offspring-induced mortality. In Case 1a, b is a positive constant. In Case 1b, offspring do not affect parental mortality, so b is 0. Then c j can be written as: Again, the average offspring costs C m and C f are given by (27).
Juveniles mature into young adults at a rate a m1 for males and a f 1 for females, young adults mature into old adults at a rate a m2 for males and a f 2 for females, and old adults cannot transition into any other prior stage. It is possible for a couple of one type to transition into another if a partner matures (e.g., a u 11 union will become a u 12 union if the young female partner matures into an old female). Unions may also divorce at a rate d ij or dissolve due to partner death, with mortality rates given by (31). The full transition matrix is T ¼ ½T 1 jT 2 where:

Results (Case 1a: Parental mortality cost)
Suppose that male and female offspring have different costs on parental mortality. As an example, let female offspring be somewhat more costly [C f ¼ 0:6; C m ¼ 0:4 in (32)]. As a baseline case, consider the scenario where young and old mothers have the same reproductive rate k 1 ¼ k 2 . In this case, all mothers have the same vital rates and reproductive abilities, regardless of their age. Figure 4A shows the direction and relative magnitudes of the selection gradients (blue), as functions of the age-specific sex ratios s 1 and s 2 . Note that the evolutionary trajectories of s (red) converge not to one singular strategy, but instead to a whole line of strategies. Changing the offspring costs C m and C f yields qualitatively similar behavior (results not shown). Along this line of strategies, both components of the selection gradient are 0, indicating the absence of selective pressure. Thus, if s is initialized at different values of s 1 and s 2 , its corresponding evolutionary endpoints may differ significantly. However, the same average primary sex ratio: is shared by all the trajectory endpoints, where s % 0:6 ( Fig. 4B). This is the same value expected from the equal investment principle in the single sex ratio case (Shyu and Caswell 2016), where the optimal single sex ratio s Ã evolves to: Ultimately, it appears that any combination of s 1 and s 2 that leads to s % 0:6 is a selectively neutral point on a line of singular strategies. Presumably because young and old females have similar reproductive rates, male and female offspring production can be partitioned between them in an infinite number of ways. Now consider the case where the reproductive rate k j changes with age. When younger and older mothers are sufficiently different, the line of selectively neutral strategies disappears, and s converges to a single endpoint s Ã regardless of its initial condition (Fig. 5). The methods in the section "Equilibrium evolutionary dynamics" identify these endpoints as boundary SSs. If the reproductive rate increases with age (k 1 \k 2 , Fig. 5A), s 1 evolves to 0 (Type 4 SS), meaning that younger mothers are producing only the more costly females. If the reproductive rate decreases with age (k 1 [ k 2 , Fig. 5B), s 1 evolves to 1 (Type 5 SS), so that younger mothers are producing only the less costly males. Figure 6 shows s Ã for a range of offspring costs on parental mortality. If the reproductive rate increases with age ( Fig. 6A), older females avoid the costly sex, while younger females compensate by producing only the costly  sex. When C m \ C f , for example, young mothers produce only the more costly females (s 1 ¼ 0); when C m [ C f , they switch to producing only the more costly males (s 1 ¼ 1). The older sex ratio s 2 favors the less mortalityinducing sex but, unlike s 1 , never evolves to exclusively producing a single sex. When costs become increasingly unequal (C m ) C f or C m ( C f ), s 2 diverges more from s 1 .
If the reproductive rate decreases with age (Fig. 6B), the directions of the sex ratio biases reverse. Younger females produce only the cheaper sex (s 1 ¼ 0 or s 1 ¼ 1), forcing older females to produce the costlier sex. When costs become increasingly unequal (C m ! 0 or C m ! 1), we see that s 2 diverges less from s 1 . Older mothers can produce more of the costlier sex when the sex-specific costs are similar (C m % C f ), but less when cost differences are high . Sex ratio singular strategies s Ã (s Ã 1 for younger females, s Ã 2 for older females) as a function of the male offspring cost C m , which affects parental mortality via (32). The female offspring cost C f ¼ 1 À C m (more costly males mean less costly females); other model parameters are as given in Table 1 (C m ) C f or C m ( C f ). This contrasts with how younger females produce only the costlier sex (Fig. 6A)

Results (Case 1b: Parental resource cost)
Suppose that male and female offspring do not affect parental mortality, but experience different mortality rates during the period of parental investment. As in Case 1a with identical mothers (Fig. 4), s ultimately converges to a selectively neutral line of singular strategies (Fig. 7).
Unlike Case 1a, this line persists even when young and old females differ in reproductive rates k j or baseline mortality rates l fj . Once again, all combinations of s 1 and s 2 on the line share a similar average primary sex ratio s ( Fig. 7B and 7D).
As a result, the population may converge to any one of an infinite number of sex ratio combinations, which are selectively neutral and have same average primary sex ratio. The sex ratios observed in the long-term may accordingly vary with the initial state of s.

Case 2: Maternal Quality
As described in the introduction, the Trivers-Willard hypothesis (Trivers and Willard 1973) predicts that the primary sex ratio produced by a mother should depend on maternal quality. Specifically, high-quality females will preferentially invest in the sex whose reproductive success varies most with quality. This hypothesis has three main assumptions: 1. An offspring's quality carries into adulthood. In comparison with their low-quality counterparts, highquality offspring will be larger, stronger, or have higher social ranks throughout their lifetimes. These advantages ultimately confer greater reproductive success or higher reproductive value (Leimar 1996). We will specifically consider two main advantages that high-quality adults have over low-quality adults. These advantages concern the male competitive factor c i and female resource investment rate R j described in the subsequent sections "Union formation (U)" and "Births (B)", respectively. We will assume that one or both of the following advantages is present.
• High-quality males obtain a greater proportion of total matings, and thus have a greater competiveness factor (c 2 [ c 1 ). • High-quality females invest more resources into offspring production, and thus have a greater resource investment rate (R 2 [ R 1 ).
2. The quality of an offspring is correlated with the quality of its parent (usually the mother). As shown in the subsequent section "Births (B)", we incorporate maternal quality transmission via a quality inheritance probability q ij . High-quality females will be more likely to produce high-quality offspring, while low-quality females will be more likely to produce low-quality offspring.
Maternal transmission of quality occurs in many species, especially those with small broods (Trivers and Willard 1973); high-ranking red deer mothers, for instance, produce larger and more dominant offspring (Clutton-Brock et al. 1986). Quality transmission also affects the value of female offspring; when offspring quality depends mostly on maternal quality, high-quality females are more productive in the long run (Leimar 1996). 3. One sex (usually males) has a greater variance in reproductive success with quality. Though the reproductive potential of both males and females may vary with quality, one sex varies more than the other, depending on the relative advantages of high-quality males and females. Although reproductive success is often framed in terms of number of offspring, Leimar (1996) showed that reproductive values are more relevant for sex ratio evolution. As described in the introduction, we express the notion of "variance in reproductive success" in terms of male and female reproductive value ratios. In polygynous ungulates, for example, males have the greater reproductive variance. Dominant high-quality males monopolize breeding opportunities and have many more offspring than low-quality males, while high-quality females have only moderately more offspring than low-quality females (Trivers and Willard 1973). In other species, females have the greater reproductive variance. Female baboons and macaques, for example, are more strongly affected by maternal quality due to their inheritance of maternal rank. As a result, the sex ratios of high-ranking mothers are biased toward female offspring (Silk 1983).

Model
Trivers and Willard based their analysis on a verbal argument that implicitly relies on the principle of equal investment. Here, we explore similar questions in a structured model that includes multiple stages, qualities, and pair formation.
The population in our model consists of male and female low-quality juveniles (m 01 , f 01 ), high-quality juveniles (m 02 , f 02 ), low-quality adults (m 1 , f 1 ), and high-quality adults (m 2 , f 2 ). Low and high-quality adults interbreed to form four types of unions, as in (23).
The population vector (2) has 12 stages total: nðtÞ ¼ m 01 m 02 m 1 m 2 f 01 f 02 f 1 f 2 u 11 u 21 u 12 u 22 ð Þ | Again, we will write a model of the form (4), and the next three sections give the matrices B, U, and T in turn.

Births (B)
Unlike Case 1, offspring do not have different mortality rates or impose parental mortality. However, the production of male and female offspring requires different amounts of resources, as in Shyu and Caswell (2016, Case 1). Producing a male offspring costs C m units of resources per time, while a female offspring costs C f units of resources per time. Each union's total rate of resource investment in offspring production is determined by maternal quality, where: R 1 ¼ rate of resource investment by low-quality females low-and high-quality female reproductive rates, k 1 ½R 1 and k 2 ½R 2 , are given by (26).
Let q ij be the probability that a female of quality j produces quality i offspring. We assume inheritance of quality, in that mothers are equally or more likely to produce offspring of the same quality. Thus, the q ij must satisfy the following conditions: The complete birth matrix B is:

Union formation (U)
Each union type u ij is formed at a mating rate U ij determined by the mating preference functions described in the earlier section "Mating preferences". Assume that males are not picky in their choice of females, so that the male preference distribution is given by the random mating preference (10). However, as per our first assumption, females may prefer to mate with high-quality males. Thus, the female preference distribution will be given by the biased mating preference (11).
Low and high-quality males have competitiveness factors c 1 and c 2 , respectively. Since high-quality males are more likely to obtain mates than their low-quality counterparts, c 2 [ c 1 . Because c 1 þ c 2 ¼ 1 in accordance with (8): Using the harmonic mean mating function (13), the per capita mating functions (14) become: The union matrix U is:

Transitions (T)
Mortality rates are the same for individuals of the same sex and quality, regardless of whether they are in unions. Again, unions dissolve due to divorce rates d ij or partner deaths (with mortality rates l m1 , l f 1 , l m2 , and l f 2 ).

Calculating variance in reproductive success
Recall that the Trivers-Willard hypothesis requires individuals of different qualities (here, high and low quality), a correlation between parent and offspring quality (q ≥ 0.5), and that one sex has a greater variance (larger differential) in reproductive success with quality. The hypothesis predicts that high-quality females preferentially invest in the sex with the greater variance in reproductive success (Trivers and Willard 1973). Testing this hypothesis requires two quantities: a measure of reproductive success for each sex, and a measure of the "variance" in reproductive success (i.e., how much reproductive success varies between high and low-quality individuals of a given sex).

Reproductive success
Though reproductive success is sometimes measured as number of offspring (Clutton-Brock et al. 1984, Leimar (1996) showed that reproductive value (the present value of all future offspring) was a more relevant index of reproductive success. This is especially true when the probability of maternal quality transmission is high; if females are more likely than males to pass their quality to offspring, a high-quality female may still have high reproductive success, in that her reproductive value is large even if her number of offspring is not (West 2009).
Here, we use the demographic definition of reproductive value, which depends on the matrix model. Specifically, the dominant left eigenvector v of the projection matrix AðpÞ is a vector of stage-specific reproductive values (shown in age-structured models by Goodman 1968; extended to stage-structured models by Caswell and Werner 1978 and others). Entry i of v corresponds to the reproductive value v i of stage i. Although different stages of a given sex will have different reproductive values, the juvenile (newborn) reproductive values should be the most relevant indices of reproductive success for each sex (Appendix A).

Variance in reproductive success
The "variance" in reproductive success can be written as the juvenile male and female reproductive value ratios (RVRs) at equilibrium (Leimar 1996). Note that reproductive values are defined only up to a multiplicative constant, so taking the ratios of reproductive values removes this constant factor.
Define the male reproductive value ratio MRVR as: where v m;02 and v m;01 are the reproductive values of high and low-quality juvenile males, respectively. Similarly, the female reproductive value ratio FRVR is: where v f ;02 and v f ;01 are the reproductive values of highand low-quality juvenile females, respectively. We will use MRVR and FRVR to represent the variance in reproductive success (between high-and low-quality individuals) for males and females, respectively.

Predictions of the Trivers-Willard hypothesis
When MRVR > FRVR (males have greater variance in reproductive success than females), high-quality mothers should be more likely than low-quality mothers to produce sons. As a result, we would expect that s 2 [ s 1 . Given the biological constraints (19), one of the following two cases should thus occur (Leimar 1996). s 1 ¼ 0 and 0\s 2 \1 0\s 1 \1 and s 2 ¼ 1 When FRVR > MRVR (females have greater variance in reproductive success than males), high-quality mothers should be more likely than low-quality mothers to produce daughters. As a result, we would expect that s 2 \ s 1 , and that one of the following two cases should occur (Leimar 1996). s 1 ¼ 1 and 0\s 2 \1 0\s 1 \1 and s 2 ¼ 0 (47)

Results
As described at the beginning of "Case 2: Maternal quality", we consider two advantages that high-quality individuals may have over low-quality individuals. Highquality males may be more attractive and competitive mates than low-quality males (c 2 [ c 1 ), which affects the male variance in reproductive success. Alternatively, highquality females may be more productive and have a greater resource investment rate than low-quality females (R 2 [ R 1 ), which affects the female variance in reproductive success. We will determine how s Ã evolves in both cases.

Male variance in reproductive success
Male variance in reproductive success depends on the difference between the low-quality male competitiveness factor c 1 from (40) and the high-quality male competitiveness factor c 2 ¼ 1 À c 1 . Because high-quality males obtain more matings, c 2 [ c 1 . As c 1 increases (c 2 decreases), the proportion of females mating with a low-quality male (not mating with a high-quality male) also increases. Figure 8A shows how MRVR, FRVR, and s Ã vary with c 1 . On the left side of the x-axis, males have high variance in competitive ability (c 1 ¼ 0:01; c 2 ¼ 0:99); on the right side of the x-axis, males have no variance in competitive ability (c 1 ¼ c 2 ¼ 0:5). As a result, the variance in male reproductive success, as given by MRVR, is highest on the left and converges to 1 on the right.
We have assumed that high and low-quality females are equally productive (R 2 ¼ R 1 ), so that there is almost no variance in female reproductive success (FRVR % 1). As a result, MRVR ≥ FRVR at all s Ã . However, note that, at low c 1 , FRVR is slightly >1, indicating that high-quality females are somewhat more successful than low-quality females (because they are more likely to produce highquality offspring).
As predicted by the Trivers-Willard hypothesis, lowquality mothers produce relatively more of the sex with lower variance in reproductive success, while high-quality mothers produce more of the higher variance sex. In this case, the sex ratio of high-quality mothers favors exclusively males (s Ã 2 ¼ 1), while the sex ratio of lowquality mothers is female-biased (s Ã 1 \ 0:5). When c 1 ¼ c 2 ¼ 0:5, MRVR = FRVR = 1 and equal sex ratios for both s Ã 1 and s Ã 2 can occur.

Female variance in reproductive success
Female variance in reproductive success is affected by the difference between the low-and high-quality female resource investment rates, R 1 and R 2 from (37). Again, high-quality females should have more resources for offspring production (R 2 [ R 1 ). Figure 8B shows how MRVR, FRVR, and s Ã vary with R 1 . We set R 2 ¼ 30 À R 1 , so that the left side of the x-axis corresponds to a high variance in female resource investment (R 1 ¼ 0:25; R 2 ¼ 29:75), and the right side corresponds to no variance in female resource investment (R 1 ¼ R 2 ¼ 15). Thus, FRVR is highest on the left and converges to 1 on the right. We assume that high-and low-quality males do not differ (c 2 ¼ c 1 ), so that MRVR = 1 always. In this case, FRVR ≥ MRVR at all s Ã ; that is, females always have the greater variance in reproductive success.
Again, consistent with the Trivers-Willard effect, highquality mothers favor the higher variance sex (females). While high-quality mothers produce relatively more high variance female offspring (s Ã 2 \ 0:5), low-quality mothers produce all low variance male offspring (s Ã 1 ¼ 1). Although low-quality females are relatively unproductive, all males are equally likely to mate with high-quality females and produce high-quality grandchildren. As a result, it appears that low-quality mothers evolve to maximize their sons.

The effect of quality inheritance
Lastly, we consider how s Ã is affected by the quality inheritance probability q ij in (38). We assume that quality depends only on mothers, which produce offspring of the same quality with a probability q ¼ q jj [ 0:5. An increase in q increases the value of high-quality mothers, because they are more likely to generate high-quality offspring. When q is high, high-quality females can become very valuable, leading high-quality mothers to prefer daughters over sons (Leimar 1996).
We also include both the male advantage and female advantages of high-quality individuals; that is, high-quality males are more competitive (c 2 [ c 1 ) and high-quality females are more fertile (R 2 [ R 1 ). Which sex has the larger reproductive variance now varies with q.
As shown in Figure 9, at low q, the variance in reproductive success of males exceeds that of females (MRVR > FRVR). High-quality mothers thus have malebiased sex ratios; low-quality mothers, in contrast, produce exclusively daughters. At intermediate q, there is an interval where MRVR = FRVR corresponding to interior SSs of s Ã . At higher q, females become the sex with higher variance in reproductive success (FRVR > MRVR). Highquality mothers ultimately converge to the equal sex ratio s 2 ¼ 0:5, while low-quality mothers produce only sons.
These results are consistent with the predictions of the Trivers-Willard hypothesis, in that high-quality mothers always produce more of the sex with greater variance in reproductive value than lower quality mothers do. At intermediate values of q, however, there is a region where MRVR = FRVR; this corresponds to interior (Type 1) SSs where both s 1 and s 2 are between 0 and 1 (see the subsequent section "Reproductive value ratios and the nature of s Ã "). Because males and females have the same reproductive value ratios at interior SSs, it is not obvious from the Trivers-Willard hypothesis which sex the high-quality parents will favor. . Singular strategies s Ã (s Ã 1 for low-quality females, s Ã 2 for high-quality females) and reproductive value ratios MRVR, FRVR as functions of (A) the low-quality male competitiveness factor c 1 , where the high-quality male competitiveness factor is c 2 ¼ 1 À c 1 (with R 1 ¼ R 2 ¼ 15), and (B) the low-quality female investment rate R 1 , where the high-quality female resource investment rate R2 ¼ 30 À R 1 (with c 1 ¼ c 2 ¼ 0:5). Other model parameters are as given in Table 1. Reproductive value ratios and the nature of s Ã In this section, we determine the reproductive value ratios at equilibrium for each type of SS s Ã , and their implications for the Trivers-Willard hypothesis. Recall that there are five types of s Ã in this model (an interior point and four boundary equilibria), each of which implies different conditions for the selection gradients (derivatives of invasion fitness) at equilibrium (summarized in Fig. 3). These selection gradients, in turn, depend on the reproductive values at equilibrium (the left eigenvector v 0 ) through (16). This permits us to invert the calculations presented thus far, which focus on finding s Ã in various scenarios. We now determine the relationship between male and female reproductive value ratios, given each possible type of s Ã .
In Appendix A, we find the relationship between the male and female reproductive value ratios MRVR (44) and FRVR (45) at each type of s Ã . These relationships are summarized in Table 3. Because the RVRs are measures of the variance in reproductive success for each sex (see the previous section "Variance in reproductive success"), each type of SS therefore also implies a certain relationship between male and female reproductive success. A Type 2 SS, for example, requires that MRVR < FVRVthat is, the variance in reproductive success of females must exceed that of males.
Each of the five types of s Ã also has a certain biological interpretation (Table 4). At Type 3 and 4 SSs, high-quality mothers will produce relatively more sons than lowquality mothers do; at Type 2 and 5 SSs, high-quality mothers will produce more daughters. This allows us to link variance in reproductive success, as given by MRVR and FRVR, to the sex favored by high-quality mothers, as invoked by the Trivers-Willard hypothesis.
As shown in Appendix A, we find that high-quality mothers consistently favor sons when MRVR > FRVR (Type 3 or 4 SS) and daughters when FRVR > MRVR (Type 2 or 5 SS). These results confirm a Trivers-Willard effect in our model and are similar to those of Leimar's simpler model (1996), which does not consider juvenile or union stages. We also find that when high-quality mothers produce exclusively one sex (Types 2 and 3 SSs), they always favor the sex with the greater reproductive value ratio. However, when low-quality mothers produce exclusively one sex (Type 4 and 5 SSs), they always favor the sex with the lower reproductive value ratio.
Our results demonstrate the presence of a "specialization principle"unless MRVR = FRVR at equilibrium, one maternal quality will produce all sons or all daughters (i.e., have a Type 2-5 boundary SS). The RVRs are only equal at Type 1 (interior) SSs, where high-quality mothers may favor either sex. Interior SSs are unique in that they do not experience selective pressure in any direction, because the selection gradients are zero for both sex ratios. This suggests that selective pressure only ceases completely when both male and female reproductive value ratios are equal (MRVR = FRVR). When MRVR = FRVR, infinite equilibria also appear in the model of Leimar Table 3. Relationships between the male and female reproductive value ratios MRVR and FRVR at each of the five possible singular strategies s Ã (in Figure 3).  . Singular strategies s Ã (s Ã 1 for low-quality females, s Ã 2 for high-quality females) and reproductive value ratios MRVR, FRVR as functions of the same quality inheritance probability q ¼ q jj . Both the male advantage (c 2 [ c 1 ) and female advantage (R 2 [ R 1 ) are present, with c 1 ¼ 0:1; c 2 ¼ 0:9, R 1 ¼ 10; R 2 ¼ 20. Other model parameters are as given in Table 1. (1996). Our model does not produce infinite equilibria; the reason for this difference is presently unknown.

Type of SS
Interior s Ã are also the only type of SS where the ratio of juvenile male to juvenile female reproductive values equals the ratio of the sex-specific resource costs. Specifically, by (A5): This result holds true for both low-quality juveniles (v m;01 =v f ;01 ) and high-quality juveniles (v m;02 =v f ;02 ). A similar result for the SS of a single sex ratio was found in Shyu and Caswell (2016, Case 1). As in the single sex ratio case, this suggests that the sex ratios evolve toward an "equal investment principle," where the ratio of male to female reproductive values equals to the ratio of the sex-specific resource costs. If, however, such a point does not exist within the biologically constrained region, s Ã becomes a boundary SS and equal investment no longer holds (Table 3, "Offspring costs" column).

Discussion
When a trait like the primary sex ratio varies with an individual's condition, the evolution of that trait may be difficult to anticipate. Because multiple conditions create population structure, and the reproductive advantages of both sexes depends on demographic factors like survival, fecundity, and life span (Leimar 1996;Schwanz et al. 2006), an explicitly demographic model is valuable for understanding facultative sex ratio evolution.
We have developed a new framework for modeling sex ratio evolution that combines three key components: explicit stage structure including multiple sexes and conditions, a nonlinear frequency-dependent mating process, and evolutionary calculations directly obtained from adaptive dynamics. Each of these three components relaxes one of the limiting assumptions found in the existing sex ratio evolution literature and allows our framework to be adapted to a variety of scenarios. Our models could, for example, be easily extended to include additional population structure in the form of more age classes, physiological conditions, or other kinds of parental differences.
Here, we have presented two specific applications of this framework, each of which includes two maternal conditions with different sex ratios. In these cases, the overall sex ratio strategy s is a vector trait with two simultaneously evolving components. Using multidimensional adaptive dynamics, we analyzed both the transient and the long-term evolution of s in cases where individuals differed in age or quality.
In these particular models, s displays a wide range of evolutionary behavior. The sex ratio strategy may evolve to an interior SS where both s 1 and s 2 are between 0 and 1, or a boundary SS where either s 1 or s 2 is 0 or 1 (i.e., mothers of a particular condition produce exclusively one sex). Previous models of facultative sex ratios have similarly found cases where at least one maternal condition only produces offspring of a single sex (e.g., Leimar 1996;Schwanz et al. 2006).
We have also found cases where s converges to a line of selectively neutral strategies. This line contains an infinite number of equally viable sex ratio combinations; this may be relevant to why empirical studies have observed so many different, and occasionally contradictory, relationships between sex ratios and maternal conditions (e.g., Jacobsen et al. 1999 in humans, Sheldon and West 2004 in ungulates). Ultimately, our model lends insight into the demographic factors that cause different types of evolutionary singular strategies and, in the case of multiple qualities, their relationships with the reproductive values that underlie the Trivers-Willard hypothesis.
Although we considered only two conditions at a time (i.e., young and old, high-and low-quality), in reality, individuals will vary across a spectrum of conditions. As alluded to above, our matrix model could be expanded to accommodate more stages for additional conditions, though continuously varying traits and conditions may require an alternative approach. Our model also assumes that mating preferences are proportional to the relative abundances (or weighted abundances) of adult stages, through functions like (10) and (11). Ranking systems where mating preferences depend on the overall composition of the population (e.g. females prefer the largest males currently available) are not explicitly covered by our formulation.
Several other aspects of our model could also be modified to explore different scenarios. We assumed, for example, that the effects of mutations on the sex ratios of younger and older (or low-and high-quality) individuals were uncorrelated. However, a mutation in one gene may affect multiple traits through pleiotropic effects. Antagonistic pleiotropy, whereby selection promotes genes that Table 4. How the sex preferred by high-quality mothers corresponds to different sex ratios, types of SS (Figure 3), and reproductive value ratio relationships. The first two cases correspond to the conditions (46) and the second two cases correspond to conditions (47). are beneficial earlier in life, but detrimental later in life, may be an important factor in the development of senescence (Williams 1957). Charnov (1982) hypothesized that this may influence how sex ratios shift with maternal age that is, factors reducing mortality from early reproduction might increase mortality from later reproduction. While we found changes in age-specific sex ratios, even without accounting for these kinds of pleiotropic effects, one could explicitly incorporate mutational correlations by modifying the mutational variance matrix V(s) (20). Although we have considered only the effects of maternal condition, paternal condition may also influence the primary sex ratio. Paternal attractiveness is of particular interest, in that females mated to attractive males may produce more sons to inherit their father's attractiveness. Resulting sex ratios depend on the nature of the female mating preference and costs and benefits of attractive male traits (Pen and Weissing 2000;Fawcett et al. 2007;West 2009). Paternal age may also affect offspring sex ratios. Several large-scale studies on human populations, for instance, have found more significant correlations between sex ratios and paternal ages than sex ratios and maternal ages (reviewed in Jacobsen et al. 1999). We previously assumed that any union u ij with a Condition j female has sex ratio s j ; that is, the primary sex ratio depends only on the maternal condition. However, our model could easily be modified to have sex ratios depend on the paternal condition as well.
Lastly, we do not consider any costs or mechanisms for switching between the facultative sex ratios s 1 and s 2 . Costly sex ratio manipulation, e.g., via selective abortion, may significantly affect sex ratio evolution (Pen and Weissing 2002), and cases where one parental condition uses a very different sex ratio from the other may be less feasible if there are high costs for switching sex ratios. There may also be biological limits to how much the sex ratio can be adjusted. Although actual mechanisms for sex ratio adjustment are still largely unknown, glucose levels in utero may be an important factor (Cameron 2004). small mutations. It depends on J, the Jacobian matrix of the selection gradient (Leimar 2009): J ¼ H þ @ 2 ðk 0 À kÞ @s 0 @s | Again, this expression can be calculated using the matrix calculus methods detailed in Shyu and Caswell (2016, section 3.3

.2)
A SS s Ã is convergence stable if VJ, the product of the mutational matrix from (18) and the Jacobian (B2), has eigenvalues with negative real parts at s Ã . The SS is strongly convergence stable (stable for any smooth, symmetric, positive definite V) if J is negative definite at s Ã (Leimar 2009). Again, many of the VJ and J matrices in our model are negative semidefinite or indefinite because of zero eigenvalues, leading to inconclusive stability results. Stability can be especially difficult to characterize for boundary SSs, which have limited directions for evolution.
Example eigenvalues of VJ are shown in Figure 11. Note that for boundary SSs, at least one diagonal entry of V, as given by (20), will be 0, resulting in zero eigenvalues of VJ. Zero eigenvalues appear to correspond to eigenvectors pointing toward the boundaries, while negative eigenvalues correspond to eigenvectors pointing along the boundaries.  Figure 11. Eigenvalues k 1 ; k 2 of the matrix VJ, which is used to characterize convergence stability (Table 5). Model is the same as in Figure 11.  (15) as a function of the mutant sex ratios s 0 1 (low-quality females) and s 0 2 (high-quality females). The resident population is at its SS sex ratio strategy s Ã . Red dots indicate the location of s Ã , while black lines indicate isoclines of zero invasion fitness (where the mutant and resident are equally fit). Plots are for the Case 2 (maternal quality) model with different values of q (same as Figure 9). C m ¼ C f ¼ 0:5; c 1 ¼ 0:1; c 2 ¼ 0:9; R 1 ¼ 10; R 2 ¼ 20; other parameters are as given in Table 1. (A) Example of an interior SS (Type 1) for q = 0.65. The eigenvalues of H are À1:6 Â 10 À6 and 2:9 Â 10 À7 . (B) Example of a boundary SS (Type 5) for q = 0.8. The eigenvalues of H are À8:5 Â 10 À4 and 2 Â 10 À7 .