\chapter{The Response of Multiple Traits to Selection.}
The fitness of an organism depends on the outcome of many different
organismal processes and phenotypes. Thus natural selection is often acting on many
phenotypes in concert. In some cases the various directions that selection
tries to pull the population phenotypes may not all be possible to
satisfy all at once. Such fitness tradeoffs occur when selection acts on genetic correlated phenotypes in
contradictory ways.

To understand the short-term consequence of selection on multiple
phenotypes we can generalize the Breeder's equation  to multiple traits\cite{lande:79}. Considering two traits we can write our responses in both traits as
\begin{eqnarray}
R_1 & = V_{A,1} \beta_1 + V_{A,1,2} \beta_2 \nonumber \\
R_2 & = V_{A,2} \beta_2 + V_{A,1,2} \beta_1  \nonumber \\
\end{eqnarray}
where the $1$ and $2$ index our two different traits. Here $V_{A,1} $
and $ V_{A,2}$ are the additive genetic variance for trait $1$ and $2$
respectively, while $V_{A,1,2}$ is our additive covariance between our
traits. Our selection gradient for trait 1, $\beta_1$, represents the
change in fitness as you change trait 1 alone holding other traits
constant constant. These $\beta$ can be estimated by multivariate
regression, see brelow.
The multivariate breeders equation is a statement that our response in
any one phenotype is modified by selection on other traits that
genetically covary with that trait.

We can also write this equivalently in matrix form, for an arbitrary
number of traits. Writing our change in the mean of our multiple phenotypes within a generation as the vector $\bf{S}$ and our response across multiple generations as
the vector $\bf{R}$. These two quantities are related by
\begin{equation}
\bf{R} = \bf{G} \bf{V}^{-1} \bf{S} = \bf{G} \boldsymbol{ \beta}
\end{equation}
 where $\bf{V}$ and $\bf{G}$ are our matrices of the
 variance-covariance of phenotypes and additive genetic values
 (eqn. \eqref{G_matrix} \eqref{P_matrix}) and
 $\boldsymbol{\beta}$ is a vector of selection gradients (i.e. the
 change within a generation as a fraction of the total phenotypic
 variance). Note that $\boldsymbol{\beta} = \bf{V}^{-1} \bf{S} $, such
 that each $\beta$ represents the selection gradient on a trait
 accounting for it's phenotypic covariances with other traits.

%\gc{Need to add example of using this.}

% Finches https://www.jstor.org/stable/pdf/2410334.pdf?refreqid=excelsior%3A17ac61589f5347fdae6d84ea6bff7288

 An example of the outcome of selection on multiple phenotypes
 consider the bout of selection measured by
 \citet{grant1995predicting}  in medium ground Darwin's
 finch ({\it Geospiza fortis}).  They measured 634 birds in '76, of
 which only $15\%$ survived to 1977. The birds who survived were
 heavier and had longer, deeper bills than average.\\
 \begin{table}
 \begin{tabular}{lcccc}\\
 {\small Trait} & {\small Mean before Selection (1976)} & S & $\beta$
   & {\small Mean next gen. (1978)}\\
   \hline
 Weight & 16.06 & 0.74 & 0.477 & 17.13 \\
Bill Length & 10.63 &  0.54  & -0.144  & 10.95 \\
  Bill Depth & 9.21 & 0.36 & 0.528  &  9.70
 \end{tabular}
 \caption[][2cm]{Trait means and selection differentials and gradients from an
   episode of selection in {\it Geospiza fortis}. Numbers from table
   2 \& 3 of \citet{grant1995predicting}.}
 \end{table}
 Accounting for the phenotypic covariances among the traits ($\bf{V}^{-1}$), they found that both
 weight and bill depth showed direct directional selection towards larger
 values (positive $\beta$s). However, bill length showed weak
 selection towards shorter beaks (negative $\beta$), reflecting the fact that bill length shows positive phenotypic correlation with
 bill depth and weight, and most of the direct selection was on weight
 and bill depth dragging bill length along. Looking at the next
 generation all three traits have all significantly increased. Thus
 despite selection posssibly favouring shorter bill lengths, and
 certainly not favouring long bills, bill length increased in the next
 generation due to its positive genetic covariance with two traits
 that selection was acting to increase.

 %% quotes about tradeoffs

\begin{question}
You collect observations of red deer within a generation, recording an
individual's number of offspring and phenotypes for a number of traits which are known to
have additive genetic variation. Using your data, you construct the plots shown in
Figure \ref{fig:red_deer_Q} (standardizing the phenotypes). Answer the following
questions by choosing one of the bold options. Briefly justify each of your answers with reference to the breeder's
equation and multi-trait breeder's equation. \\
{\bf A)}	Looking just at figure \ref{fig:red_deer_Q} A, in what direction do you expect male antler size to evolve? \\
{\bf Insufficient information, increase, decrease.}\\

{\bf B)}	Looking just at figures \ref{fig:red_deer_Q} B and C, in what direction do you expect male antler size to evolve? \\
{\bf Insufficient information, increase, decrease.}\\

{\bf C)}	Looking at figures \ref{fig:red_deer_Q} A, B, and C, in what direction do you expect male antler size to evolve? \\
{\bf Insufficient information, increase, decrease.}\\
\end{question}

\begin{figure}
\begin{center}
\includegraphics[width=\textwidth]{figures/Red_deer_selection.pdf}
\end{center}
\caption{ Observations of red deer within a generation; recording an
individual's number of offspring and phenotypes (simulated data), which are known to
have additive genetic variation. The figures left to right are
A-C. (Data are simulated. \gitcode{https://github.com/cooplab/popgen-notes/blob/master/Rcode/Red_deer_MV_selection.R}) } \label{fig:red_deer_Q}
\end{figure}

As an example of correlated responses to selection, consider the  \citet{wilkinson:93} selection experiment on Stalk-eyed
 flies ({\it Cyrtodiopsis  dalmanni}). Stalk-eyed flies have evolved amazingly long eye-stalks. In the lab, \citeauthor{wilkinson:93} established six populations of
 wild-caught flies and selected up and down on males eye-stalk to body
 size ratio for 10 generations (left plot in Figure
 \ref{fig:Stalk_eyed_response}). Despite the fact that he did not
 select on females, he saw a correlated response in the females from
 each of the lines (right plot), because of the genetic correlation
 between male and female body proportions.

\begin{figure}
\begin{center}
\includegraphics[width= \textwidth]{Journal_figs/Quant_gen/stalk_eyed_flies/stalk_eyed_flies_response.pdf}
\end{center}
\caption[][-2cm]{ \citeauthor{wilkinson:93} selected two populations of flies for
 increased eye-stalk to body length ratio in males (mean shown as
 up triangles), and two for a
 decreased ratio (down triangles), by taking the top 10 males with the highest (lowest)
 ratio out of 50 measures. He also established two control populations
 (circles). He constructed each generation of females by sampling 10
 at random from each population.  Data from \citet{wilkinson:93}. \gitcode{https://github.com/cooplab/popgen-notes/blob/master/Journal_figs/Quant_gen/stalk_eyed_flies/Wilkinson_93_response_to_sel.R} } \label{fig:Stalk_eyed_response}   %\cite{potti:11}
\end{figure}

\begin{marginfigure}[1cm]
\begin{center}
\includegraphics[width=0.9 \textwidth]{illustration_images/Quant_gen/Stalk_eyed_flies/WulpPlateVIIIjpg.jpg}
\end{center}
\caption{Stalk-eyed Flies ({\it Diopsidae}).  \BHLNC{Diptera. van der Wulp. 1898.}{https://www.biodiversitylibrary.org/item/39414\#page/631/mode/1up}{Smithsonian Libraries}} \label{fig:Stalk_eyed_flies}
\end{marginfigure}
\begin{question}

At the end of ten generations in \citeauthor{wilkinson:93}'s experiment (Figure
\ref{fig:Stalk_eyed_response}), the males from the up- and down-selected
lines had mean eye-stalk to body ratios of $1.29$ and $1.14$
respectively, while the females from the up- and down-selected lines
had means of $0.9$ and $0.82$. \\
{\bf A)} \citeauthor{wilkinson:93} estimated that by selecting the top/bottom 10 males, he had on average shifted the mean body ratio by 0.024 within
each generation. What is the male heritability of eye-stalk to body-length ratio?

{\bf B)} Assume that the additive genetic variance of male and female phenotypes are
equal and that there is no direct
selection on female body-proportion in this experiment, i.e. that all of
the response in females is due to correlated selection. Can you
estimate the male-female genetic correlation of the eye-stalk ratio?
\end{question}

\begin{figure*}
\begin{center}
\includegraphics[width= \textwidth]{Journal_figs/Quant_gen/Garter_snakes_Brodie/Garter_snakes_Brodie.pdf}
\end{center}
\caption{ {\bf Left)} The garter snake fitness surface estimated by \citet{brodie1992correlational}
 lighter colours indicate higher
 relative fitness. {\bf Middle)} The phenotypes of all of the snakes released
   by Brodie, each dot is an individual. {\bf Right)} The phenotypes
   of surviving snakes. Note how snakes in the top left and bottom
   right corner are over represented in the survivors. Data from  \citet{brodie1992correlational}
  \gitcode{https://github.com/cooplab/popgen-notes/blob/master/Journal_figs/Quant_gen/Garter_snakes_Brodie/Garter_snakes_Brodie.R}. } \label{fig:Garter_snakes_Brodie}
\end{figure*}

%s, where the snakes with thehighest probability of survival perform uninterrupted flight if striped but flee evasivelyif spotted or unstriped.

% Eutaenia ordinoides
% northwestern garter snake (Thamnophis ordinoides)
%https://commons.wikimedia.org/wiki/File:The_natural_history_of_Washington_territory,_with_much_relating_to_Minnesota,_Nebraska,_Kansas,_Oregon,_and_California,_between_the_thirty-sixth_and_forty-ninth_parallels_of_latitude,_being_those_(14574590600).jpg

\paragraph{Estimating multivariate selection gradients}
We can estimate multivariate directional ($\beta$) and quadratic selection
gradients ($\gamma$) just as we did for a single traits ($x_1$ and $x_2$), using linear
and quadratic models (in eqn \eqref{fitness_regression} and \eqref{fitness_regression_stab}). For example, for two traits we can write
\begin{equation}
w_i \sim \beta_1 x_{1,i} + \nicefrac{1}{2} \gamma_1 x_{1,i}^2 + \beta_2 x_{2,i} + \nicefrac{1}{2}
\gamma_2 x_{2,i}^2  + \gamma_{1,2} x_{1,i} x_{2,i}  + \wbar \label{fitness_regression_MV}
 \end{equation}
where $\beta_1$ and $\gamma_1$ are the directional and quadratic
selection gradients for trait one, and similarly for trait two \citep{lande1983measurement}. The
covariance selection gradient between traits is given by
$\gamma_{1,2}$ . This technique for measuring multivariate selection is
sometimes called `Lande-Arnold regression'.

\citet{brodie1992correlational}'s work provides a nice example of
selection on multiple predation-avoidance traits in northwestern garter snakes
({\it Thamnophis ordinoides}). \citeauthor{brodie1992correlational} released hundreds of snakes born in
the lab into the wild, and then performed mark-recapture observations
to monitor their fate.
\begin{marginfigure}
\begin{center}
\includegraphics[width= 0.75\textwidth]{illustration_images/Quant_gen/Garter_snake/Eutaenia_cooperi.jpg}
\end{center}
\caption{Northwestern garter snake ({\it Eutaenia cooperi}, now {\it
    Thamnophis ordinoides})
\BHLNC{The natural history of Washington territory, with much relating to
  Minnesota, Nebraska, Kansas, Oregon, and California (1859). Cooper
  J.G. and Suckley,
  G. }{https://commons.wikimedia.org/wiki/File:The_natural_history_of_Washington_territory,_with_much_relating_to_Minnesota,_Nebraska,_Kansas,_Oregon,_and_California,_between_the_thirty-sixth_and_forty-ninth_parallels_of_latitude,_being_those_(14574590600).jpg}{Smithsonian
  Libraries} } \label{fig:Garter_snake}
%, between the thirty-sixth and forty-ninth parallels of latitude, being those parts of the final reports on the survey of the Northern Pacific railroad route, containing the climate and physical geography, with full catalogues and descriptions of the plants and animals collected from 185 to 1857
\end{marginfigure}  Before releasing them he measured how stripy
they were, and their behavioural tendency to reversals of direction
during simulated flight from a predator. His quadratic fitness surface is shown in Figure
\ref{fig:Garter_snakes_Brodie}, based on fitting the
regression given by eqn \eqref{fitness_regression_MV} to juvenile
survival. He found that neither single trait directional or quadratic
gradients were significant, i.e. there was no apparent selection on one
trait ignoring the other. However, there was a significant negative
covariance ($\gamma_{1,2}<0$). The individuals with the highest chance of survival are
{\it either} highly striped and perform few reversals (top left
corner), {\it or} have little striping but reverse course frequently
(bottom right corner).

%\gc{Add section of multivariate fitness landscapes}

%Drosophila life history chapter
%https://www.genetics.org/content/214/1/3

\section{Some applications of the multivariate trait breeder's equation}

The multivariate breeders equation has a lot of different uses in
understanding the response of multiple traits to selection. It also
offers strong insights into the mechanistic underpinnings of kin selection and sexual selection. We'll discuss these next.

\subsection{Hamilton's Rule and the evolution of altruistic and
  selfish behaviours}
\begin{quotation}
``~`The only reason for making a buzzing-noise that I know of is
because you're a bee.' Then [Pooh] thought another long time, and
said: `The only reason for being a bee that I know of is to make
honey...And the only reason for making honey is so as I can eat it.'~''
--Winnie-the-Pooh, \citet{milne}.
\end{quotation}

%https://www.flickr.com/photos/bibliodyssey/albums/72157610318114895

%“If it could be proved that any part of the structure of any one species had been formed for the exclusive good of another species, it would annihilate my theory, for such could not have been produced through natural selection.”

%% https://commons.wikimedia.org/wiki/File:1911_Britannica_-_Bee_-_Apis_mellifica.png
%%bear with bee hive https://www.flickr.com/photos/internetarchivebookimages/20323812950/

One of the seismic shifts caused by Darwin's work was the realisation that organisms don't exist for the benefit of other
individuals or other species.
Bees didn't evolve to pollinate flowers, any more than they
evolved to make honey for bears. If we can say that there
is a `reason' why an organism exist it is only to leave offspring to the
next generation.  Pooh can be forgiven for straying from Darwinian thought, as he exists
for the benefit of Christopher Robin and other childrens' bedtime
stories.

However, there's a wrinkle to this Darwinian view. Worker bees don't make honey
to benefit their offspring, they are sterile and are working
for the benefit of the Queen bee and her offspring.
\marginnote{\citet{smith1964kin} coined the name kin selection to describe Hamilton's approach to this problem. It's also sometimes called the inclusive fitness approach, as we need to include not just one individual's fitness but the weighted sum of all the fitness of all their relatives. }
Individuals frequently behave in ways that sacrifice their own fitness for the
benefit of others. That selection favours such apparent acts of altruism is puzzling at first sight. \citet{hamilton1964genetical,hamilton1964genetical2} supplied the first general evolutionary explanation of such altruism.
His intuition was that while an individual is losing out of some reproductive output, the alleles underlying an altruistic behaviour can still spread in the population if this cost is outweighed by benefits gained
through the transmission of these alleles through a related individual. Note that this means that the
allele is not acting in an self-sacrificing manner, even though individuals may as a result.

Altruism reflects social interactions. So as a simple model let's imagine that individuals interact in pairs, with our focal
individual $i$ being paired with an individual $j$.
Imagine that individuals have two possible phenotypes $X=1$ or $0$,
corresponding to providing or withholding some small act of `altruism'
(we could just as easily flip these labels and call them an unselfish
act and a selfish act respectively).
Our pairs of individuals interacting could, for example, be siblings sharing a
nest. The altruistic trait could be as simple as growing at a slightly slower rate so as to reducing sibling-competition for food from
parents, or more complicated acts of altruism such as children foregoing their own reproduction so as to help their parents raise their siblings.

Providing the altruistic act has a cost $C$ to the fitness of our individual and failing to provide this act has no cost. Receiving this altruistic act confers a fitness benefit $B$ over individuals who did not receive this act. \citeauthor{hamilton1964genetical}'s rule states that such a trait will spread through the population if
\begin{equation}
 2F B > C
\end{equation}
where $F$ is the average kinship coefficient between the interacting
individuals ($i$ and $j$). In the usual formulation of Hamilton's Rule our $2F$ is replaced by the `Coefficient of relationship', which is the
  proportion of alleles shared between the individuals. Here we use
  two times the kinship coefficient to keep things inline with our
  notation for these chapters. Note that if our individuals are themselves inbred we need
to do a little more careful to reconcile these two measures.
So the altruistic behaviour will spread even if it is costly to the individual if its cost is paid off by the benefit to sufficiently related individuals.

As one example of kin-selection consider \citet{krakauer2005kin}'s work on
co-operative courtship in wild turkeys ({\it Meleagris
  gallopavo}). Male turkeys often form display
partnerships, with a subordinate male helping a dominant male with
displaying to females and defending the females from other groups of males. \begin{marginfigure}
\begin{center}
\includegraphics[width= \textwidth]{illustration_images/Quant_gen/Turkey/turkey.jpg}
\end{center}
\caption{Turkey  ({\it Meleagris
  gallopavo}). \BHLNC{Bilder-atlas zur Wissenschaftlich-populären
Naturgeschichte der Vögel in ihren sämmtlichen Hauptformen (1864). Wien,K.K. Hof}{https://www.biodiversitylibrary.org/page/33050564\#page/199/mode/1up}{Smithsonian Libraries} } \label{fig:turkey}
\end{marginfigure}  These pairs are often full brothers ($F=0.25$),
with the subordinate male often being the younger of the two. The
subordinate male often loses out on mating opportunities over their
entire lifetime by acting as a wingman for their older
brothers. \citet{krakauer2005kin} estimated that dominant males gained
an extra $6.1$ offspring when they display with a partner than males
who display alone. While the subordinate males lose out on fathering $0.9$
offspring compared to solitary males. Thus the costs of helping by
subordinate males is more than compensated by the fitness gains of
their brothers ( $ (2 \times 0.25)  \times 6.1 > 0.9$), and so the
evolution of this  altruistic  helping in co-operative courtship is potentially well explained by kin-selection \citep[see ][for more analysis]{akccay2016}.
\begin{question}
How would this answer be changed if the male Turkey partnerships were only
$\nicefrac{1}{2}$ sibs, or first cousins?
\end{question}

\begin{marginfigure}
\begin{center}
\includegraphics[width= \textwidth]{figures/Response_to_sel/Hamiltons_rule_B_C.pdf}
\end{center}
\caption{{\bf Top)} The fitness of individual $i$ as a function of
  their behavioural phenotype, where altruistic/non-altruistic
  behavioural phenotypes are encoded as $1$ and $0$ respectively. The
  direct fitness cost of behaving altruistically is $C$. {\bf Bottom)}
  The fitness of our focal individual $i$ as a function of the
  behavioural phenotype of their interacting partner ($j$). Our focal
  individual gets an increase $B$ in fitness if their partner behaves
  altruistically. \gitcode{https://github.com/cooplab/popgen-notes/blob/master/Rcode/Quant_gen/Hamilton_rule_B_C.R}} \label{fig:Hamilton_B_C}
\end{marginfigure}

Where does this result come from? Well, we can use our quantitative genetics framework to gain some
intuition by deriving a simple version of Hamilton's Rule by thinking
about the phenotypes of an individual's kin as genetically correlated
phenotypes. To sketch a proof of this result, let's assume that our focal $i$ individual's fitness can be written as
\begin{equation}
W(i,j)= W_0 + W_i +W_j
\end{equation}
where $W_i$ is the contribution of the fitness of the individual $i$ due
to their own phenotype, and $W_j$ is the contribution to our
individual $i$'s fitness due to the interacting individual $j$'s behaviour (i.e. $j$'s phenotype).
With the benefit $B$ and cost $C$, our $W(i,j)$ are depicted in Figure \ref{fig:Hamilton_B_C}.

Following our multivariate breeder's equation, we can write the expected change of our behavioural phenotype as
\begin{equation}
R = \beta_i V_A + \beta_j V_{A,i,j},
\end{equation}
Our altruistic phenotype is increasing in the population if $R>0$, i.e. if
\begin{equation}
  \beta_i V_A + \beta_j V_{A,i,j}  > 0 \end{equation}
\marginnote{ Here we've following a simplified version of
  \citet{queller1992quantitative}'s treatment, to re-derive Hamilton's rule in a quantitative genetics framework (Hamilton's original papers did this in a population genetics framework).} The slope $\beta_i$ of the regression of our focal individual's
behavioural phenotype on fitness is proportional to $-C$. The slope
$\beta_j$ of the regression of our interacting partner's phenotype on
our focal individual's fitness is proportional to $B$ (with the same
constant of proportionality). Therefore, our altruistic phenotype is increasing in the population if
\begin{eqnarray}
  \beta_i V_A + \beta_j V_{A,i,j} & > 0  \nonumber  \\
 B \frac{V_{A,i,j}}{V_A} & >  C  \label{eqn:Covar_Hamilton}
\end{eqnarray}
So what's the average genetic covariance between
individual $i$ and $j$'s altruistic phenotype? Well it's the same
behavioural phenotype in both individuals, so the phenotypes are
genetically correlated if our individuals are related to each
other. The covariance of the same phenotype between two individuals is
just $2 F_{i,j} V_A$ (see \eqref{additive_covar_general_rellys}). So
our altruistic phenotype is increasing in the population if

\begin{eqnarray}
   & B\frac{2 F_{i,j} V_A}{V_A} &> C \nonumber  \\
  2 F_{i,j} B & > C
\end{eqnarray}
Seen from this perspective, \citeauthor{hamilton1964genetical}'s rule
is simply a statement that altruistic behaviours can spread via
kin-selection, if the average cost to an individual of displaying an
altruistic phenotype, i.e. carrying altruistic alleles, is paid back through the average benefit of interacting with altruistic relatives (kin).

%  1791 book on Hymenoptera https://twitter.com/BioDivLibrary/status/1174773646113562624
\begin{figure}
\begin{center}
\includegraphics[width= 0.75 \textwidth]{illustration_images/Quant_gen/Hymenoptera/Hymenoptera.jpg}
\end{center}
\caption{A selection of the huge diversity of  Hymenoptera. \BHLNC{Naturgeschichte, Klassification und Nomenclatur der
    Insekten vom Bienen, Wespen und Ameisen. Christ, JL}{https://www.biodiversitylibrary.org/item/165219?\#page/6/mode/1up}{University of Illinois Urbana Champaign} } \label{Hymenoptera}
\end{figure}

 \begin{marginfigure}
\begin{center}
\includegraphics[width= 0.7 \textwidth]{illustration_images/Quant_gen/honey_ant/honey_ant.png}
\end{center}
\caption{Australian Honey-pot Ant ({\it Camponotus inflatus}). Honey ants are gorged with
  honeydew collected by their nest mates, till they swell to the size
  of grapes, and are used as a food storage
  device.  \BHLNC{Ants,
  bees, and wasps; a record of observations on the habits of the
  social Hymenoptera (1897) Lubbock, J.}{https://www.biodiversitylibrary.org/page/9657360\#page/485/mode/1up}{Smithsonian Libraries}  } \label{fig:honey_ant}
\end{marginfigure}
Under the kin-selection, relatedness and the breeding structure of the populations are
hypothesized to be a key factor in determining the evolution of altruistic behaviours.
One most impressive example of the evolution of altruism is the
repeated evolution of eusociality, where sterile castes have evolved
to help to rear their siblings rather than their own offspring. Eusociality has evolved at least eight independent times in
 Hymenoptera ( bees, wasps, and ants). There's huge variation in
 mating systems in Hymenoptera from high levels of multiple mating to monandry. \citet{hughes2008ancestral} conducted a
comparative phylogenetic analysis of mating system across hundreds of Hymenoptera species. They found that each of the eight of
eusocial clades had monandry, females mating with a single male, as an ancestral
state. Thus, eusociality initially evolved in populations where
relatedness was maximized among siblings.

%Once eusociality evolved,
%the females in some eusocial species have evolved to mate multiple
%times but this only occurs in species where non-reproductive females
%can not regain fertility, i.e.

%\erin{this phrasing is a little misleading because it's 'paid back' to the allele, but not to the individual. I'd suggest something like 'if the fitness cost of altruism to an allele is paid back on average through the benefits of interacting with altruistic relatives (kin).

% Special eg on kinship, good for other egs https://www.cell.com/current-biology/issue?pii=S0960-9822(18)X0012-8

%% reciprocal altuisim Quller
%% https://www.pnas.org/content/pnas/108/Supplement_2/10792.full.pdf
% http://pdxscholar.library.pdx.edu/cgi/viewcontent.cgi?article=1000&context=sysc_fac

% https://sci-hub.se/https://www.nature.com/articles/318366a0
%% https://archive.org/stream/allaboutanimalsf00newy/allaboutanimalsf00newy#page/53/mode/1up

% http://darwin-online.org.uk/content/frameset?pageseq=23&itemID=F8.2&viewtype=side

%%

\input{Chapters/Notes_on_new_sections/alt_alturism}

\subsection{Sexual selection and the evolution of mate preference by indirect benefits. }

Organisms often put an enormous effort into finding and attracting mates, sometimes at
a considerable cost to their chances of survival. Why are individuals so choosy about who they mate with, particularly when their choice seems to be based on elaborate characters and arbitrary displays
that surely lower the viability of their mates?
\begin{marginfigure}
\begin{center}
\includegraphics[width= \textwidth]{illustration_images/Quant_gen/glow_worm/18011950889_b2a1a1323e_z.jpg}
\end{center}
\caption{Male (left) and female (right) common glow worm  ({\it Lampyris
    noctiluca}). \BHLNC{The animal kingdom : arranged after its organization;
  forming a natural history of animals, and an introduction to
  comparative anatomy. (1863) Cuvier, G.}{https://www.flickr.com/photos/internetarchivebookimages/18011950889/in/photolist-Uqr16w-UqqZZu-4VxYcU-ZiyCTu-8DEFyz-6pxZpd-ZiyCXC-yFyBF-GEoD6s-u3DKnd-6pxZrd-4q7euj-5KsWen-yqphkW-xvGrfw-ytA3rP-ybfeBA-yqi7oo-tFL3h3-xvJnrz-BPm4Jd-wLVg9F-trDXtp-wVbxw2-y6MpEq-BWCQVA-vb793E-tHGekh-u4av2t-oewQcC-ow671H-t6ZJg7-u4Ap1m-xntXw9-ovPEMu-u3DFws-vbeMw2-tHMJiY-u1FJpo-tLqTCw-fFFAEG-y1Pfmz-u1FHaE}{University of Toronto - Gerstein Science Information Centre} } \label{fig:glow_worms}
\end{marginfigure}
% Slug mating https://commons.wikimedia.org/wiki/File:Limax_maximus_mating.jpg
% https://www.flickr.com/photos/internetarchivebookimages/20406571412/
% https://www.lastwordonnothing.com/2012/08/10/tgipf-slug-sex-redux/

One major reason why individuals evolve to be choosy about who they mate with is that it can directly impact their fitness. By choosing a mate with
particular characteristics, individuals can gain more parental care for
their offspring, avoid parasites, or be choosing a mate with higher fertility. For example,  female glow-worms flash at night to attract males flying by. Females with larger, brighter lanterns have higher fecundity, so
males with a preference for brighter flashes will gain a direct benefit to their own fitness. (Note that males will benefit even if these differences in female fecundity are entirely driven by differences in environment, and thus non-heritable.) Indeed male glow worms have evolved to be attracted to brighter
flashing lures.
\begin{marginfigure}[-0.5cm]
\begin{center}
\includegraphics[width= \textwidth]{Journal_figs/Quant_gen/glow_worm_flashes/glow_worm_flashes.pdf}
\end{center}
\caption{Female Glow worms who have the largest, and therefore
  brightest, lanterns have the highest fecundity. Data from
  \citet{hopkins2015m}. \gitcode{https://github.com/cooplab/popgen-notes/blob/master/Journal_figs/Quant_gen/glow_worm_flashes/glow_worm_flashes.R} } \label{fig:glow_worms_lantern}
\end{marginfigure}
However, even in the absence of direct benefits of choice, selection can still indirectly favour the evolution of choosiness. These
indirect benefits occur because individuals can have higher fitness
offspring by choosing a mate whose phenotype indicates high viability
(the so-called `good genes' hypothesis), or by choosing a mate whose
phenotype is simply attractive, and likely to produce similarly
attractive offspring (the `runaway' or `sexy sons' hypothesis).

\begin{figure}
\begin{center}
\includegraphics[width=\textwidth]{figures/Response_to_sel/Genetic_corr_assort_mating.pdf}
\end{center} \label{fig:assort_mating_2_trait}
\caption{{\bf Left)} Assortative mating between males and
  females. Males vary in a display trait (e.g. tail length), females
  vary in their preference for this trait. We see evidence of
  assortative mating as females with a preference for a particular
  value of the male trait tend to mate with those males. {\bf Right}) As both
  male trait and female preference are genetic this establishes a
  genetic correlation in the next generation. This is simulated data. \gitcode{https://github.com/cooplab/popgen-notes/blob/master/Rcode/Quant_gen/QT_cross_assortative_mating_2_kids.R}} \label{fig:assort_mating_2_trait}
\end{figure}

We'll denote a display trait, e.g. tail length, in males by $\mars$ and a preference
trait in females by $\venus$. Our display trait is under direct selection in males, such that its response to selection can be written as
\begin{equation}
R_{\mars} = \beta_{\mars} V_{A, \mars}
\end{equation}
Let's assume that the female preference trait, the degree to which
females are attracted to long tails, is not under direct
selection $\beta_{\venus}=0$. Then the response to selection of the
preference trait can be written as
\begin{eqnarray}
R_{\venus} &=\beta_{\venus}V_{A,\venus}  + \beta_{\mars} V_{A, \venus
  \mars}
& = \beta_{\mars} V_{A, \venus  \mars}
\end{eqnarray}
So the female preference will respond to selection if it is
genetically correlated with the male trait, i.e. if $V_{A, \venus
  \mars}$ is not zero. There's a number of different ways this genetic correlation could arise; the
simplest is that the loci underlying the male trait may have a
pleiotropic effect on female preference. However, female preference
may often have quite a distinct genetic basis from male display traits.

A more general way in which trait-preference genetic correlations may arise is through assortative mating. As females vary in their
tail-length preference, the ones with a preference for longer
tails will mate with long-tailed males and the opposite for females
with a preference for shorter-tails. Therefore, a
genetic correlation between display and preference traits will
become established (see Figure \ref{fig:assort_mating_2_trait}).

The males with the longer tails will also carry the alleles
associated with the preference for longer tails, as their long-tailed
dads tended to mate with females with a genetic preference for long
tails. Similarly, the males with shorter tails will carry alleles associated with the preference for
shorter tails. Thus if there is direct selection for males with longer tails, then
the female preference for longer tails will increase too, as it is
genetically correlated via assortative mating.

\begin{figure}
\begin{center}
\includegraphics[width=\textwidth]{Journal_figs/Quant_gen/guppies_female_choice/guppies_female_choice.pdf}
\end{center}
\caption{Mean phenotypes for the two up- and two down-selected
  populations of Guppies. Left panel: A response to selection was seen
  due to the direct selection on male colouration. Right panel: An
  indirect, correlated response was also seen in female
  preference. Data from
  \citet{houde:94}. \gitcode{https://github.com/cooplab/popgen-notes/blob/master/Journal_figs/Quant_gen/guppies_female_choice/guppies_female_choice.R}} \label{fig:assort_mating_guppies}
\end{figure}

As an example of how direct selection on display traits can drive the
evolution of preference traits, let's consider some data from
guppies. Guppies ({\it Poecilia reticulata}) are a classic system for
studying the interplay of natural and sexual selection. In some populations of
guppies, females show a preference for males with more orange colouration.\begin{marginfigure}
\begin{center}
\includegraphics[width=\textwidth]{illustration_images/Quant_gen/Guppies/1439_fish_40.png}  %https://commons.wikimedia.org/wiki/File:1439_fish_40.png
\end{center} \label{fig:guppies}
\caption{Guppy ({\it Poecilia reticulata}). \newline \noindent \tiny{From a set of 1962 stamps
  of Hungary. Contributed to \href{https://commons.wikimedia.org/wiki/File:1439_fish_40.png}{wikimedia} by Darjac, not covered by copyright}}
\end{marginfigure}
 \citet{houde:94} established four replicate
population pairs of guppies and selected one of each pair for an increased or decreased orange coloration in males, selecting the top/bottom $20$ out of $50$
males. She randomly chose females from each population to form the next generation, and so did not
exert direct selection on females. She measured the response to
selection on male colouration and on female preference for orange (left
and right panels of Figure \ref{fig:assort_mating_guppies}
respectively). In the lines that were selected for more orange males,
females showed an increased preference for orange. While in those
lines selected for less orange in male displays, females
showed a decreased preference for orange. This is consistent with indirect selection on female orange preference as a response to
selection on male colouration, due to a genetic correlation between
female preference and male trait. It is {\it a priori} unlikely
that pleiotropy is the source of the genetic correlation between these
traits, rather it is likely caused by females assortatively mating with
males that match their colour preference.

Returning to our bird tail example, what could drive the direct
selection on male tail length? The selection for longer tails in males could come about because
longer tails are genetic correlated with higher male viability, for
example perhaps only males who gather an excess of food have the
resources to invest in growing long tail, i.e. a long tail is an
honest signal of fitness. This would correspond to a `good genes' explanation of female mate
choice evolution.

\marginnote{
\begin{quote}
``The case of the male Argus Pheasant is eminently interesting,
because it affords good evidence that the most refined beauty may
serve as a sexual charm, and for no other purpose.'' -- \citet{darwin1888descent}
\end{quote} }
There's another subtler way that selection could favour our male
trait. Imagine that the variation in female preference trait is
because some females have no strong preference for male tail
length, but some females have a strong preference for males with
longer tails.
\begin{marginfigure}
\begin{center}
\includegraphics[width= \textwidth]{illustration_images/Quant_gen/Argus_pheasant/Argus_pheasant_small.jpg}
\end{center}
\caption{Argus Pheasant.  \BHLCC{A monograph of the pheasants. (1918). Beebe, W}{https://www.flickr.com/photos/biodivlibrary/10053909294/}{Smithsonian Institution Libraries}{2.0}} \label{fig:argus}
\end{marginfigure}
Males with longer tails would then have higher fecundity than
the short-tailed males as there's a subset of females who are strongly
attracted to long tails, and these males also get to mate with the
other females. Thus selection favours long-tailed males, and so indirectly favours
female preference for longer tails; females with a preference
for longer-tails have sons who in turn are more attractive. This
model is sometimes called the sexy-son model. It is also called
the Fisherian runaway model \citep{fisher1915evolution}, as female
preference and male trait can coevolve in an escalating fashion
driving more and more extreme preferences for arbitrary traits. Thus
many extravagant display traits in males and females may exist purely
because individuals find them beautiful and are attracted to them.

%\erin{I don't take away from this description that you can get runaway sexual selection without external directional selection for longer tails ... can you make that more clear? I think the problem is making the female trait a preference for short vs. long tails when maybe it should be presented as a preference for long tails vs. no preference so the males with longer tails get a boost from positive sexual selection. Also, why do you plot mean daughter's trait against mean son's trait and not, say, mean father's trait against mean daughter's trait or increase in population prevalence or correlation between male-female traits over time?}

% potential guppy image https://www.google.com/imgres?imgurl=https%3A%2F%2Fc1.staticflickr.com%2F1%2F457%2F20360503816_a88cdcd96d_b.jpg&imgrefurl=https%3A%2F%2Fwww.flickr.com%2Fphotos%2Finternetarchivebookimages%2F20360503816&docid=jtYRcc7UmAvIeM&tbnid=DBAauK0xAgK4mM%3A&vet=10ahUKEwirkrKWy8rcAhWTAHwKHfVdCmUQMwg2KAEwAQ..i&w=1024&h=840&itg=1&client=firefox-b-1-ab&bih=681&biw=1280&q=Lebistes%20reticulatus&ved=0ahUKEwirkrKWy8rcAhWTAHwKHfVdCmUQMwg2KAEwAQ&iact=mrc&uact=8


\section{Error Calculation}
\label{sec:Error_Calculation}
This section contains the error calculation of the measured values. The systematic and the total error is calculated in this chapter. The error calculation is done for the fitted values longtidudinal sound velocity $c_L$, transversal sound velocity $c_T$ and the attenuation coefficient $\mu$ (see sections \ref{subsec:wave_length_calculation} to \ref{subsec:Longitudinal_Ultrasound_Velocities_in_Liquids}).

% ----------------------------------------------------------------------------------
\subsection{Uncertainties}
\label{subsec:Uncertainties}
All conducted measurements in this experiment have uncertainties. Although it was possible to use the oscilloscope to measure the values very precisely, there is still an uncertainty. This is due to the difficulty to move the cursors exactly to a peak. The systematic uncertainties are shown in table \ref{tab:equipment}.

% ----------------------------------------------------------------------------------
\subsection{Uncertainty of the sound velocity $c_L$ and $c_T$}
\label{subsec:Uncertainty_Sound_Velocity}
The total uncertainty $s_{c,\ \text{tot}}$ of the sound velocity for a specific medium $c_m$ is calculated with the following equation \ref{eq:total_uncertainty_sound_velocity}:

\begin{equation}
s_{c,\ \text{tot}}=\sqrt{s_{c,\ \text{syst}}^2+s_{c,\ \text{stat}}^2}
\label{eq:total_uncertainty_sound_velocity}
\end{equation}

with:

\begin{equation}
s_{c,\ \text{syst}}=\sqrt{\left(\frac{\partial c}{\partial x}\Biggr|_{c}\cdot s_{x}\right)^2 + \left(\frac{\partial c}{\partial \Delta t}\Biggr|_{c}\cdot s_{\Delta t}\right)^2}
\label{eq:syst_uncertainty_sound_velocity}
\end{equation}

and:

\[
\frac{\partial c}{\partial x}\Biggr|_{c}=\dfrac{2}{\Delta t} \qquad , \qquad \frac{\partial c}{\partial \Delta t}\Biggr|_{c}=-\dfrac{2x}{\Delta t^2}
\]

where:
\begin{multicols}{2}
\begin{conditions}
	s_{c,\ \text{tot}} & total uncertainty of $c_m$ \\
	s_{c,\ \text{stat}} & statistical uncertainty of $c_m$ \\
	s_{\Delta t} & uncertainty of $\Delta t$ \\
	\Delta t & time of flight (see figure \ref{fig:measuring_procedure})
\end{conditions}
\begin{conditions}
	s_{c,\ \text{syst}} & systematic uncertainty of $c_m$ \\
	s_x & uncertainty of x \\
	x & sound path distance \\
	c & sound velocity $c_m$
\end{conditions}
\end{multicols}

\hspace{0.5cm}

Table \ref{tab:Uncertainty_Sound_Velocity} shows the statistical, the systematic and the total uncertainty. The systematic uncertainty was calculated by using equation \ref{eq:syst_uncertainty_sound_velocity}. The statistical uncertainty was obtained from QtiPlot. The total uncertainty was calculated by using equation \ref{eq:total_uncertainty_sound_velocity}. All calculations were done in MATLAB (see appendix \ref{sec:MATLAB_Error_Calculation}).

\begin{table}[H]
	\centering
	\renewcommand{\arraystretch}{1.1}
	\begin{tabular}{|l|c|c|c||c|c|c|}
		\cline{2-7}
		\multicolumn{1}{c|}{} & \multicolumn{3}{c||}{\textbf{1 MHz}} & \multicolumn{3}{c|}{\textbf{5 MHz}} \\
		\cline{2-7}
		\multicolumn{1}{c|}{} & \textbf{Statistic} & \textbf{Systematic} & \textbf{Total} & \textbf{Statistic} & \textbf{Systematic} & \textbf{Total} \\
		\multicolumn{1}{c|}{} & in m/s & in m/s & in m/s & in m/s & in m/s & in m/s \\
		\hline
		\textbf{PMMA} & 4.8 & 18.5 & 19.1 & 9.8 & 18.4 & 20.9 \\
		\hline
		\textbf{Aluminium} & - & - & - & 30.2 & 50.6 & 58.9 \\
		\hline
		\textbf{Copper} & - & - & - & 16.9 & 50.6 & 53.4 \\
		\hline
		\textbf{Brass} & - & - & - & 45.7 & 24.6 & 51.9 \\
		\hline
		\textbf{Water 21 \textdegree C} & - & - & - & 2.8 & 6.3 & 7.0 \\
		\hline
		\textbf{Water 49 \textdegree C} & - & - & - & 4.7 & 6.9 & 8.4 \\
		\hline
		\textbf{Saltwater 40 \textdegree C} & - & - & - & 5.9 & 7.8 & 9.8 \\
		\hline
		\textbf{PMMA trans.} & 14.3 & 5.1 & 15.1 & - & - & - \\
		\hline
	\end{tabular}
	\caption{The statistical uncertainty is from QtiPlot. Error propagation is used to calculate the systematic and the total uncertainty.}
	\label{tab:Uncertainty_Sound_Velocity}
\end{table}

\newpage
% ----------------------------------------------------------------------------------
\subsection{Uncertainty of the attenuation coefficient $\mu$}
\label{subsec:Uncertainty_Attenuation_Coefficient}
The total uncertainty $s_{\mu,\ \text{tot}}$ of the attenuation coefficient for a specific medium $\mu$ is calculated with the following equation \ref{eq:total_uncertainty_attenuation_coefficient}:

\begin{equation}
s_{\mu,\ \text{tot}}=\sqrt{s_{\mu,\ \text{syst}}^2+s_{\mu,\ \text{stat}}^2}
\label{eq:total_uncertainty_attenuation_coefficient}
\end{equation}

with:

\begin{equation}
s_{\mu,\ \text{syst}}=\sqrt{\left(\frac{\partial \mu}{\partial x}\Biggr|_{\mu}\cdot s_{x}\right)^2 + \left(\frac{\partial \mu}{\partial \hat{p}}\Biggr|_{\mu}\cdot s_{\hat{p}}\right)^2 + \left(\frac{\partial \mu}{\partial \hat{p}_0}\Biggr|_{\mu}\cdot s_{\hat{p}_0}\right)^2}
\label{eq:syst_uncertainty_attenuation_coefficient}
\end{equation}

and:

\[
\frac{\partial \mu}{\partial x}\Biggr|_{\mu}=\dfrac{\ln{\Bigr(\frac{\hat{p}}{\hat{p}_0}\Bigr)}}{x^2} \qquad , \qquad \frac{\partial \mu}{\partial \hat{p}}\Biggr|_{\mu}=- \dfrac{1}{x\hat{p}} \qquad , \qquad \frac{\partial \mu}{\partial \hat{p}_0}\Biggr|_{\mu}=\dfrac{1}{x\hat{p}_0}
\]

where:
\begin{multicols}{2}
	\begin{conditions}
		s_{\mu,\ \text{tot}} & total uncertainty of $\mu$ \\
		s_{\mu,\ \text{stat}} & statistical uncertainty of $\mu$ \\
		s_{\hat{p}} & uncertainty of $\hat{p}$ \\
		x & sound path distance \\
		\hat{p}_0 & amplitude (see figure \ref{fig:measuring_procedure})
	\end{conditions}
	\begin{conditions}
		s_{\mu,\ \text{syst}} & systematic uncertainty of $\mu$ \\
		s_x & uncertainty of x \\
		s_{\hat{p}_0} & uncertainty of $\hat{p}_0$ \\
		\hat{p} & amplitude (see figure \ref{fig:measuring_procedure}) \\
		\mu & attenuation coefficient
	\end{conditions}
\end{multicols}

\hspace{0.5cm}

Table \ref{tab:Uncertainty_Attenuation_Coefficient} shows the statistical, the systematic and the total uncertainty. The systematic uncertainty was calculated by using equation \ref{eq:syst_uncertainty_attenuation_coefficient}. The statistical uncertainty was obtained from QtiPlot. The total uncertainty was calculated by using equation \ref{eq:total_uncertainty_attenuation_coefficient}. All calculations were done in MATLAB (see appendix \ref{sec:MATLAB_Error_Calculation}).

\hspace{0.5cm}

\begin{table}[H]
	\centering
	\renewcommand{\arraystretch}{1.1}
	\begin{tabular}{|l|c|c|c||c|c|c|}
		\cline{2-7}
		\multicolumn{1}{c|}{} & \multicolumn{3}{c||}{\textbf{1 MHz}} & \multicolumn{3}{c|}{\textbf{5 MHz}} \\
		\cline{2-7}
		\multicolumn{1}{c|}{} & \textbf{Statistic} & \textbf{Systematic} & \textbf{Total} & \textbf{Statistic} & \textbf{Systematic} & \textbf{Total} \\
		\multicolumn{1}{c|}{} & in m/s & in m/s & in m/s & in m/s & in m/s & in m/s \\
		\hline
		\textbf{PMMA} & 0.7 & 2.6 & 2.6 & 2.5 & 5.8 & 6.3 \\
		\hline
	\end{tabular}
	\caption{The statistical uncertainty is from QtiPlot. Error propagation is used to calculate the systematic and the total uncertainty.}
	\label{tab:Uncertainty_Attenuation_Coefficient}
\end{table}


\documentclass[a4paper]{scrartcl}
\usepackage[margin=1.5cm]{geometry}

\usepackage{amsmath}
\usepackage{cleveref}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{booktabs}
\usepackage{csquotes}
\usepackage{algpseudocode}
\usepackage{pdflscape}

\renewcommand{\vec}{\mathbf}
\renewcommand{\Re}{\operatorname{Re}}
\renewcommand{\Im}{\operatorname{Im}}
\newcommand{\dd}[1]{\,\mathrm{d}#1}
\newcommand{\ca}[1]{\accentset{\circ}{#1}}
\newcommand{\vp}[2]{\left<#1,#2\right>}
\newcommand{\abs}[1]{\left\lvert#1\right\rvert}
\newcommand{\diag}[1]{\mathrm{diag}\left(#1\right)}
\newcommand{\R}{\mathbb{R}}

\renewcommand{\epsilon}{\varepsilon}
\renewcommand{\theta}{\vartheta}

\begin{document}
\textbf{\Huge Warning: These are my notes. Don't expect this document to be self-contained and correct.}

\section{ADER-DG for linear acoustics}
The linearized acoustic equations are given as (see Finite Volume book by LeVeque)
\begin{equation}\label{eq:pde}
 \frac{\partial Q_p}{\partial t} + A_{pq}\frac{\partial Q_q}{\partial x} + B_{pq}\frac{\partial Q_q}{\partial y} = 0,
\end{equation}
where
\begin{equation}
 q = \begin{pmatrix}p \\ u \\ v\end{pmatrix}, \quad
 A = \begin{pmatrix}0 & K_0 & 0 \\ 1/\rho_0 & 0 & 0 \\ 0 & 0 & 0 \end{pmatrix}, \quad
 B = \begin{pmatrix}0 & 0 & K_0 \\ 0 & 0 & 0 \\ 1/\rho_0 & 0 & 0 \end{pmatrix}.
\end{equation}

The corresponding weak form is
\begin{equation}
 \int_{\Omega}\phi_k\frac{\partial Q_p}{\partial t}\dd{V} +
 \int_{\partial\Omega}\phi_k \left(n_xA_{pq} + n_yB_{pq}\right)Q_q\dd{S} -
 \int_{\Omega}\left(\frac{\partial \phi_k}{\partial x}A_{pq}Q_q + \frac{\partial \phi_k}{\partial y}B_{pq}Q_q\right)\dd{V} = 0,
\end{equation}
where $n=(n_x,n_y)$ is the outward unit surface normal.

We discretise the weak form with finite elements, which are triangles $\mathcal R^{(m)}$, and obtain
\begin{equation}
 \int_{\mathcal R^{(m)}}\phi_k\frac{\partial Q_p}{\partial t}\dd{V} +
 \int_{\partial\mathcal R^{(m)}}\phi_k \left(\left(n_xA_{pq} + n_yB_{pq}\right)Q_q\right)^*\dd{S} -
 \int_{\mathcal R^{(m)}}\left(\frac{\partial \phi_k}{\partial x}A_{pq} + \frac{\partial \phi_k}{\partial y}B_{pq}\right)Q_q\dd{V} = 0,
\end{equation}
where we a numerical flux (indicated with *).

Suppose we are given an unstructured triangular grid where each cell is given by the 3 points
$P_0,\dots,P_2$ in counter-clockwise order. The coordinates of each point is $P_i = (x_i,y_i)$.

We approximate $Q$ with a modal basis, i.e.
\begin{equation}
 Q_p^h(x,y,t) = \hat{Q}_{lp}\left(t\right)\phi_l\left(\xi^{(m)}(x,y), \eta^{(m)}(x,y)\right),
\end{equation}
where
\begin{align}
 x(\xi,\eta) = x_0 + (x_1-x_0)\xi + (x_2-x_0)\eta, \\
 y(\xi,\eta) = y_0 + (y_1-y_0)\xi + (y_2-y_0)\eta.
\end{align}

Then we obtain, using the substitution rule,
\begin{multline}
 |J|\frac{\partial \hat{Q}_{lp}}{\partial t}(t)\int_{0}^{1}\int_{0}^{1}\phi_k(\xi,\eta)\phi_l(\xi,\eta)\dd{\eta}\dd{\xi}
 + \sum_{i=1}^3 |S_i|\int_0^1\phi_k(r_i(\chi))(n_xA_{pq}+n_yB_{pq}Q_q)^*\dd{\chi} \\
 - |J|\hat{Q}_{lp}(t)\int_{0}^{1}\int_{0}^{1}\left(\frac{\partial \phi_k}{\partial x}(\xi,\eta)A_{pq}
 + \frac{\partial \phi_k}{\partial y}(\xi,\eta)B_{pq}\right)\phi_l(\xi,\eta)\dd{\eta}\dd{\xi} = 0,
\end{multline}
where $J=(x_1-x_0)(y_2-y_0)-(x_2-x_0)(y_1-y_0)$, and $r_i$ and $|S_i|$ are given by
\begin{align}
 r_1(\chi) &= \begin{pmatrix}\chi \\ 0\end{pmatrix}, & |S_1| = \sqrt{(x_1-x_0)^2 + (y_1-y_0)^2}, \\
 r_2(\chi) &= \begin{pmatrix}1-\chi \\ \chi\end{pmatrix}, & |S_2| = \sqrt{(x_2-x_1)^2 + (y_2-y_1)^2}, \\
 r_3(\chi) &= \begin{pmatrix}0 \\ 1-\chi\end{pmatrix}, & |S_3| = \sqrt{(x_2-x_0)^2 + (y_2-y_0)^2}.
\end{align}
We also need to transform the gradients, that is,
\begin{equation}
 \begin{pmatrix}
  \dfrac{\partial\phi_k}{\partial x} & \dfrac{\partial\phi_k}{\partial y}
 \end{pmatrix} =
 \begin{pmatrix}
  \dfrac{\partial\phi_k}{\partial\xi} & \dfrac{\partial\phi_k}{\partial\eta}
 \end{pmatrix}
 \underbrace{
 \begin{pmatrix}
  \dfrac{\partial\xi}{\partial x} & \dfrac{\partial\xi}{\partial y} \\
  \dfrac{\partial\eta}{\partial x} & \dfrac{\partial\eta}{\partial y}
 \end{pmatrix}}_{=:D\boldsymbol{\xi}(x,y)}
\end{equation}
Using the inverse function theorem we have
\begin{equation}
 D\boldsymbol{\xi}(x,y) = [D\boldsymbol{x}(\xi,\eta)]^{-1} =
 \begin{pmatrix}
  x_1-x_0 & x_2-x_0 \\
  y_1-y_0 & y_2-y_0
 \end{pmatrix}^{-1} =
 \dfrac{1}{J}
 \begin{pmatrix}
  y_2-y_0 & x_0-x_2 \\
  y_0-y_1 & x_1-x_0
 \end{pmatrix}.
\end{equation}
For later use we note
\begin{align}
 A^* = A\dfrac{\partial\xi}{\partial x} + B\dfrac{\partial\xi}{\partial y} =
 \dfrac{y_2-y_0}{J}A + \dfrac{x_0-x_2}{J}B, \\
 B^* = A\dfrac{\partial\eta}{\partial x} + B\dfrac{\partial\eta}{\partial y} =
 \dfrac{y_0-y_1}{J}A + \dfrac{x_1-x_0}{J}B.
\end{align}

We turn now to the flux term, which shall have the following form:
\begin{equation}
 (n_xA_{pq}+n_yB_{pq}Q_q)^* = A^+Q_q^{(m)} + A^-Q_q^{(m_i)},
\end{equation}
where $m_i$ denotes the neighbour of element $m$.
First, note that we may use rotational invariance:
\begin{equation}
 n_xA + n_yB = TAT^{-1},
\end{equation}
where
\begin{equation}
T(n_x,n_y)=\begin{pmatrix}
 1 & 0 & 0 \\
 0 & n_x & -n_y \\
 0 & n_y & n_x
\end{pmatrix}, \quad
T^{-1}(n_x,n_y)=\begin{pmatrix}
 1 & 0 & 0 \\
 0 & n_x & n_y \\
 0 & -n_y & n_x
\end{pmatrix},
\end{equation}
i.e. we only need to solve the Riemann problem in x-direction. In the homogeneous case we have
\begin{equation}
 A^{+} = \frac{1}{2}\begin{pmatrix}
 c & K_0 & 0 \\
 1/\rho_0 & c & 0 \\
 0 & 0 & 0
\end{pmatrix}, \quad
 A^{-} = \frac{1}{2}\begin{pmatrix}
 -c & K_0 & 0 \\
 1/\rho_0 & -c & 0 \\
 0 & 0 & 0
\end{pmatrix},
\end{equation}
where $c=\sqrt{K_0/\rho_0}$.

In the inhomogeneous case we have
\begin{equation}
 A^{+} = \begin{pmatrix}
 \frac{K_0^+c^-c^+}{K_0^-c^++K_0^+c^-} & \frac{K_0^-K_0^+c^+}{K_0^-c^++K_0^+c^-} & 0 \\
 \frac{K_0^+c^-}{\rho_0^+\left(K_0^-c^++K_0^+c^-\right)} & \frac{K_0^-K_0^+}{\rho_0^+\left(K_0^-c^++K_0^+c^-\right)} & 0 \\
 0 & 0 & 0
\end{pmatrix}, \quad
 A^{-} = \begin{pmatrix}
 -\frac{K_0^-c^-c^+}{K_0^-c^++K_0^+c^-} & \frac{K_0^-K_0^+c^-}{K_0^-c^++K_0^+c^-} & 0 \\
 \frac{K_0^-c^+}{\rho_0^-\left(K_0^-c^++K_0^+c^-\right)} & -\frac{K_0^-K_0^+}{\rho_0^-\left(K_0^-c^++K_0^+c^-\right)} & 0 \\
 0 & 0 & 0
\end{pmatrix}.
\end{equation}
Hence, the flux is given as
\begin{equation}
 TA^-T^{-1}Q^- + TA^+T^{-1}Q^+.
\end{equation}
For ease of notation, we define
\begin{equation}
 \mathcal{A}^{x,y,\pm} = T(x,y)A^\pm T(x,y)^{-1}.
\end{equation}

Note, that we need the transposed version as we multiply the matrix from the right. Hence,
with abuse of notation we define

\begin{equation}
 \mathcal{A}^{x,y,\pm} = T^{-T}\left(A^\pm\right)^T T^{T} = T\left(A^\pm\right)^T T^{-1},
\end{equation}
where we used that $T^{-1}=T^T$.

Finally, in order to correctly integrate over the neighbours we need the following integrals:
$$
\int_0^1\phi_k(r_i(\chi))\phi_l(r_j(1-\chi))\dd{\chi}
$$
Here $j$ is the number of the edge of the neighbour of the local edge $i$.

We are now able to obtain the complete semi-discrete scheme:
\begin{multline}
|J|\frac{\partial \hat{Q}_{lp}}{\partial t}(t)\int_{0}^{1}\int_{0}^{1}\phi_k(\xi,\eta)\phi_l(\xi,\eta)\dd{\eta}\dd{\xi} \\
 + \sum_{i=1}^3 |S_i|\mathcal{A}_{pq}^{n_{x,i},n_{y,i},+}\hat{Q}_{lp}(t)\int_0^1\phi_k(r_i(\chi))\phi_k(r_i(\chi))\dd{\chi} \\
 + \sum_{i=1}^3 |S_i|\mathcal{A}_{pq}^{n_{x,i},n_{y,i},-}\hat{Q}_{lp}^{(m_j)}(t)\int_0^1\phi_k(r_i(\chi))\phi_k(r_j(1-\chi))\dd{\chi}\\
 - |J|\hat{Q}_{lp}(t)A^*_{pq}\int_{0}^{1}\int_{0}^{1}\frac{\partial \phi_k}{\partial \xi}(\xi,\eta)\dd{\eta}\dd{\xi}
 - |J|\hat{Q}_{lp}(t)B^*_{pq}\int_{0}^{1}\int_{0}^{1}\frac{\partial \phi_k}{\partial \eta}(\xi,\eta)\dd{\eta}\dd{\xi} = 0,
\end{multline}

To be precomputed:
\begin{align*}
 M_{kl} &= \int_{0}^{1}\int_{0}^{1}\phi_k(\xi,\eta)\phi_l(\xi,\eta)\dd{\eta}\dd{\xi} \\
 F_{kl}^{i,0} &= \int_0^1\phi_k(r_i(\chi))\phi_k(r_i(\chi))\dd{\chi} \\
 F_{kl}^{i,j} &= \int_0^1\phi_k(r_i(\chi))\phi_k(r_j(1-\chi))\dd{\chi} \\
 K_{kl}^\xi &= \int_{0}^{1}\int_{0}^{1}\frac{\partial\phi_k}{\partial\xi}(\xi,\eta)\phi_l(\xi,\eta)\dd{\eta}\dd{\xi} \\
 K_{kl}^\eta &= \int_{0}^{1}\int_{0}^{1}\frac{\partial\phi_k}{\partial\eta}(\xi,\eta)\phi_l(\xi,\eta)\dd{\eta}\dd{\xi}
\end{align*}

\subsection{Boundary conditions}
Periodic boundary conditions are difficult in the unstructured case.
We introduce two alternatives:
\subsubsection{Absorbing boundary conditions}
Set $\hat{Q}^+=0$.
\subsubsection{Wall boundary conditions}
Set $\hat{Q}^+=T\Gamma T^{-1}\hat{Q}^-$, where $\Gamma=\diag{1,-1,1}$.

\subsection{Source terms}
Assume we have a source term of the form
\begin{equation}
 S_p(t)\delta(x_s,y_s)
\end{equation}
then we need to add
\begin{equation}
 \frac{1}{|J|}M_{kq}^{-1}\phi_q\left(\xi(x_s,y_s),\eta(x_s,y_s) \right)\int_{t_n}^{t_n+\Delta t} S_p(t)\dd{t}
\end{equation}
to the cell that contains the source term.

\end{document}


%% LyX 2.2.3 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{babel}
\begin{document}

\section{Quantification of code accuracy}

The accuracy of numerical predictions is quantified with a Least Squares
norm regularized for the extent of data coverage. Here is an example
for lift polars, where $C_{l}^{exp}$ denotes the measured lift coefficient
and $C_{l}^{sim}$ denotes the simulated value:
\[
\epsilon_{i}^{C_{l}}=\left(\alpha_{max}-\alpha_{min}\right)^{-1}\left(\int_{\alpha_{min}}^{\alpha_{max}}\left(C_{l}^{sim}-C_{l}^{exp}\right)^{2}d\alpha\right)^{\frac{1}{2}}
\]
The same approach is adopted for drag and moment coefficient polars,
when available. A similar norm is adopted for boundary layer runs,
but the integration proceeds along the streamwise coordinate until
the end of the dataset at $x=L$:
\[
\epsilon_{i}^{\theta}=\frac{1}{L}\left(\int_{0}^{L}\left(\theta_{\left(x\right)}^{sim}-\theta_{\left(x\right)}^{exp}\right)^{2}dx\right)^{\frac{1}{2}}
\]
Error measures for each quantity are then defined

\section{Parametrization of the Skin Friction Relation}

The skin friction closure relation is a function of the form:
\[
C_{f}=f_{\left(H,Re_{\theta}\right)}^{C_{f}^{0}}
\]
This function has three key features:
\begin{enumerate}
\item It tends to infinity as H approaches one:
\[
\lim_{H\rightarrow1}C_{f}=+\infty
\]
\item It is positive for share factors below separation $H<H_{sep}$ and
negative afterwards:
\[
\exists H_{sep}=f_{\left(Re_{\theta}\right)}\::\:\begin{cases}
C_{f}>0 & H<H_{sep}\\
C_{f}<0 & H>H_{sep}
\end{cases}
\]
\item And it tends to a nearly constant value in deep separation:
\[
\exists C_{f}^{dsep}=f_{\left(Re_{\theta}\right)}\::\:\lim_{H\rightarrow\infty}C_{f\left(H,Re_{\theta}\right)}=C_{f}^{dsep}
\]
\end{enumerate}
Values of the shape factor at which separation occurs $\left(H_{sep}\right)$
and the skin friction in deeply separated $C_{f}^{dsep}$ flows are
not precisely known. A good parametrization must let them be varied
by the minimization algorithm, and that is indirectly achieved by
the following  expression:
\[
C_{f\left(H,Re_{\theta},A_{i}\right)}^{mod}=S_{\left(H,Re_{\theta},A_{i}\right)}^{dim}\left(f_{\left(H,Re_{\theta}\right)}^{C_{f}^{0}}+\delta^{C_{f}}\right)-\delta^{C_{f}}\text{\qquad,\quad\ensuremath{\delta^{C_{f}}\in\mathbb{R}}}
\]
Where $\delta^{C_{f}}$ is a constant property of the parametrization
that enables variations in the shape factor at which the onset of
separation occurs, whereas the general shape of the closure relation
is taylored by the $S_{\left(\right)}^{dim}$. The dimensional shape
function maps the region for which the closure relation is being taylored
into a unit square, over which shape of the curve is taylored with
a classic Bernstein polynomial approach.
\[
S_{\left(H,Re_{\theta},A_{i}\right)}^{dim}=B_{\left(\eta_{\left(H\right)}^{H},\eta_{\left(Re_{\theta}\right)}^{RT},A_{i}\right)}^{dxx}
\]
\[
\qquad with\quad\eta^{H}=\begin{cases}
0 & H<u_{ub}\\
\frac{H-H_{lb}}{H_{ub}-H_{lb}} & otherwise\\
1 & H>u_{ub}
\end{cases}\qquad and\quad\eta^{Re_{\theta}}=\begin{cases}
0 & Re<u_{ub}\\
\ln\left(\frac{Re}{Re_{min}}\right)/\ln\left(\frac{Re_{max}}{Re_{min}}\right) & otherwise\\
1 & H>u_{ub}
\end{cases}
\]

\section{Bernstein polynomials}

In the future, we will use Bernstein polynomials of arbitrary order.
However, for this early phase of the work we will restrict our study
to Bernstein polynomials of order 6 and degree 5. The basis of Bernstein
polynomials of order 6 and degree 5 is written as:
\[
\begin{array}{rl}
B_{\left(x\right)}^{d5r0} & =x^{5}\\
B_{\left(x\right)}^{d5r1} & =5x^{4}\left(1-x\right)\\
B_{\left(x\right)}^{d5r2} & =10x^{3}\left(1-x\right)^{2}\\
B_{\left(x\right)}^{d5r3} & =10x^{2}\left(1-x\right)^{3}\\
B_{\left(x\right)}^{d5r4} & =5x\left(1-x\right)^{4}\\
B_{\left(x\right)}^{d5r5} & =\left(1-x\right)^{5}
\end{array}\qquad\qquad\begin{array}{rl}
\frac{\partial}{\partial x}\left(B^{d5r0}\right) & =5x^{4}\\
\frac{\partial}{\partial x}\left(B^{d5r1}\right) & =5\left(4x^{3}\left(1-x\right)-x^{4}\right)\\
\frac{\partial}{\partial x}\left(B^{d5r2}\right) & =10\left(3x^{2}\left(1-x\right)^{2}-2x^{3}\left(1-x\right)\right)\\
\frac{\partial}{\partial x}\left(B^{d5r3}\right) & =10\left(2x\left(1-x\right)^{3}-3x^{2}\left(1-x\right)^{2}\right)\\
\frac{\partial}{\partial x}\left(B^{d5r4}\right) & =5\left(\left(1-x\right)^{4}-4x\left(1-x\right)^{3}\right)\\
\frac{\partial}{\partial x}\left(B^{d5r5}\right) & =-5\left(1-x\right)^{4}
\end{array}
\]
Let us now define the 6 bernstein polynomial (shape) coefficients:
\[
A_{1},A_{2},A_{3},A_{4},A_{5},A_{6}
\]
Used to construct arbitrary polynomials by linear combination of the
Bernstein basis:
\[
B_{\left(x,A_{i}\right)}^{d5}=A_{1}B_{\left(x\right)}^{d5r0}+A_{2}B_{\left(x\right)}^{d5r1}+A_{3}B_{\left(x\right)}^{d5r2}+A_{4}B_{\left(x\right)}^{d5r3}+A_{5}B_{\left(x\right)}^{d5r4}+A_{6}B_{\left(x\right)}^{d5r5}
\]
The derivative of $B^{d5}$ to the $x$-coordinate is written as:
\[
\frac{\partial}{\partial x}\left(B_{\left(x,A_{i}\right)}^{d5}\right)=A_{1}\frac{\partial}{\partial x}\left(B_{\left(x\right)}^{d5r0}\right)+A_{2}\frac{\partial}{\partial x}\left(B_{\left(x\right)}^{d5r1}\right)+A_{3}\frac{\partial}{\partial x}\left(B_{\left(x\right)}^{d5r2}\right)+A_{4}\frac{\partial}{\partial x}\left(B_{\left(x\right)}^{d5r3}\right)+A_{5}\frac{\partial}{\partial x}\left(B_{\left(x\right)}^{d5r4}\right)+A_{6}\frac{\partial}{\partial x}\left(B_{\left(x\right)}^{d5r5}\right)
\]

\section{Shape Function}

For now, we will only apply changes as a function of the shape factor
$H$. Let us then write:
\[
S_{\left(H,Re_{\theta},A_{i}\right)}^{dim}=B_{\left(\eta_{\left(H\right)}^{H},A_{i}\right)}^{d5}\qquad with\qquad\qquad with\quad\eta^{H}=\begin{cases}
0 & H<u_{ub}\\
\frac{H-H_{lb}}{H_{ub}-H_{lb}} & otherwise\\
1 & H>u_{ub}
\end{cases}
\]
So that we can write:
\[
\frac{\partial S}{\partial H}=\frac{\partial}{\partial H}\left(B_{\left(\eta_{\left(H\right)}^{H},A_{i}\right)}^{d5}\right)=\frac{\partial}{\partial\eta}\left(B_{\left(\eta_{\left(H\right)}^{H},A_{i}\right)}^{d5}\right)\frac{\partial\eta}{\partial H}\qquad with\qquad x=\eta^{H}
\]
So:
\[
\frac{\partial}{\partial\eta}\left(B_{\left(\eta_{\left(H\right)}^{H},A_{i}\right)}^{d5}\right)=\frac{\partial}{\partial x}\left(B_{\left(x,A_{i}\right)}^{d5}\right)
\]
And:
\[
\frac{\partial\eta}{\partial H}=\begin{cases}
\frac{\partial}{\partial H}\left(0\right) & H<u_{ub}\\
\frac{\partial}{\partial H}\left(\frac{H-H_{lb}}{H_{ub}-H_{lb}}\right) & otherwise\\
\frac{\partial}{\partial H}\left(1\right) & H>u_{ub}
\end{cases}=\begin{cases}
0 & H<u_{ub}\\
\frac{1}{H_{ub}-H_{lb}} & otherwise\\
0 & H>u_{ub}
\end{cases}
\]
Whereby:
\[
\frac{\partial S}{\partial H}=\frac{\partial}{\partial x}\left(B_{\left(x,A_{i}\right)}^{d5}\right)\frac{\partial\eta}{\partial H}
\]

\section{Cf Parametrization Summary}

The bernstein polynomials are given as:
\[
B_{\left(x,A_{i}\right)}^{d5}=A_{1}B_{\left(x\right)}^{d5r0}+A_{2}B_{\left(x\right)}^{d5r1}+A_{3}B_{\left(x\right)}^{d5r2}+A_{4}B_{\left(x\right)}^{d5r3}+A_{5}B_{\left(x\right)}^{d5r4}+A_{6}B_{\left(x\right)}^{d5r5}
\]
Their derivatives come as:
\[
\frac{\partial}{\partial x}\left(B_{\left(x,A_{i}\right)}^{d5}\right)=A_{1}\frac{\partial}{\partial x}\left(B_{\left(x\right)}^{d5r0}\right)+A_{2}\frac{\partial}{\partial x}\left(B_{\left(x\right)}^{d5r1}\right)+A_{3}\frac{\partial}{\partial x}\left(B_{\left(x\right)}^{d5r2}\right)+A_{4}\frac{\partial}{\partial x}\left(B_{\left(x\right)}^{d5r3}\right)+A_{5}\frac{\partial}{\partial x}\left(B_{\left(x\right)}^{d5r4}\right)+A_{6}\frac{\partial}{\partial x}\left(B_{\left(x\right)}^{d5r5}\right)
\]
The map from x to H is given as:
\[
x=\begin{cases}
0 & H<u_{ub}\\
\frac{H-H_{lb}}{H_{ub}-H_{lb}} & otherwise\\
1 & H>u_{ub}
\end{cases}
\]
The jacobian of the transformation is given as:
\[
\frac{\partial x}{\partial H}=\begin{cases}
0 & H<u_{ub}\\
\frac{1}{H_{ub}-H_{lb}} & otherwise\\
0 & H>u_{ub}
\end{cases}
\]
The dimensional shape function is given as:
\[
S_{\left(H,A_{i}\right)}^{d5}=B_{\left(\eta_{\left(H\right)}^{H},A_{i}\right)}^{d5}
\]
And it derivative is given as:
\[
\frac{\partial S^{d5}}{\partial H}=\frac{\partial}{\partial x}\left(B_{\left(x,A_{i}\right)}^{d5}\right)\frac{\partial x}{\partial H}
\]
The new skin friction correlation is given as:
\[
C_{f\left(H,Re_{\theta},A_{i}\right)}^{mod}=S_{\left(H,A_{i}\right)}^{d5}\left(f_{\left(H,Re_{\theta}\right)}^{C_{f}^{0}}+\delta^{C_{f}}\right)-\delta^{C_{f}}\text{\qquad,\quad\ensuremath{\delta^{C_{f}}\in\mathbb{R}}}
\]
Its derivative to H is given as:
\[
\frac{\partial}{\partial H}\left(C_{f\left(H,Re_{\theta},A_{i}\right)}^{mod}\right)=\frac{\partial S^{d5}}{\partial H}\left(f_{\left(H,Re_{\theta}\right)}^{C_{f}^{0}}+\delta^{C_{f}}\right)+S_{\left(H,A_{i}\right)}^{d5}\frac{\partial}{\partial H}\left(f_{\left(H,Re_{\theta}\right)}^{C_{f}^{0}}\right)
\]
Derivatives to other variables are simpler. Here, the example for
$Re_{\theta}$:
\[
\frac{\partial}{\partial Re_{\theta}}\left(C_{f\left(H,Re_{\theta},A_{i}\right)}^{mod}\right)=S_{\left(H,A_{i}\right)}^{d5}\frac{\partial}{\partial Re_{\theta}}\left(f_{\left(H,Re_{\theta}\right)}^{C_{f}^{0}}\right)
\]
Done!

\subsection{For paper}

The skin friction correlation is parametrized by combining the original
correlation $\left(C_{f\left(H,Re_{\theta}\right)}^{0}\right)$ with
a shape function $\left(S_{\left(H,A_{i}\right)}^{dM}\right)$ whose
shape depends on a set of coefficients $\left(A_{i}\right)$ that
are varied by the optimization algorithm:
\[
C_{f\left(H,Re_{\theta},A_{i}\right)}^{mod}=S_{\left(H,A_{i}\right)}^{dM}\left(f_{\left(H,Re_{\theta}\right)}^{C_{f}^{0}}+\delta^{C_{f}}\right)-\delta^{C_{f}}\text{\qquad,\quad\ensuremath{\delta^{C_{f}}\in\mathbb{R}}}
\]
The shape function consists of a linear combination of 5th degree
Bernstein polynomials and $\left(\delta^{C_{f}},\,H_{lb},\,H_{ub}\right)$
are constants that affect the parametrization scope:
\[
B_{\left(x,A_{i}\right)}^{dM}=\sum_{i=0}^{i=M}A_{i+1}B_{\left(x\right)}^{5i}\qquad with\qquad\left\{ \begin{array}{l}
B_{\left(x\right)}^{Mi}=\left(\begin{array}{c}
M\\
i
\end{array}\right)x^{i}\left(1-x\right)^{M-i}\\
x=\frac{H-H_{lb}}{H_{ub}-H_{lb}}
\end{array}\right.
\]
Setting all shape coefficients to unity yields the original closure
relation and the $H_{\left(H,Re_{\theta}\right)}^{*}$ correlation
was parametrized with a similar procedure.

\section{Hstar Parametrization}

The key feature here is to preserve the limit value for a collapsing
boundary layer:
\[
\lim_{H\rightarrow1}H^{*}=2
\]
This is easily by setting the lower limit of the $H$ intervention
region at $H_{min}=1$ (which we would do anyway), fixing the first
Bernstein coefficient of to $A_{1}^{H}=1$ (it is simply not provided
as a free parameter to the optimizer) and making a classic CST approach
(no offset needed here). So we write:
\[
H_{\left(H,Re_{\theta},A_{i}\right)}^{*mod}=S_{\left(H,A_{i}\right)}^{d5}\left(f_{\left(H,Re_{\theta}\right)}^{H^{*0}}\right)
\]
Whereby the derivative to $H$ comes from the chain rule:
\[
\frac{\partial}{\partial H}\left(H_{\left(H,Re_{\theta},A_{i}\right)}^{*mod}\right)=\frac{\partial}{\partial H}\left(S_{\left(H,A_{i}\right)}^{d5}\left(f_{\left(H,Re_{\theta}\right)}^{H^{*0}}\right)\right)
\]
\[
=\frac{\partial}{\partial H}\left(S_{\left(H,A_{i}\right)}^{d5}\right)\left(f_{\left(H,Re_{\theta}\right)}^{H^{*0}}\right)+S_{\left(H,A_{i}\right)}^{d5}\frac{\partial}{\partial H}\left(f_{\left(H,Re_{\theta}\right)}^{H^{*0}}\right)
\]
And the other derivatives come more simply, here the example for $Re_{\theta}$:
\[
\frac{\partial}{\partial Re_{\theta}}\left(H_{\left(H,Re_{\theta},A_{i}\right)}^{*mod}\right)=\frac{\partial}{\partial Re_{\theta}}\left(S_{\left(H,A_{i}\right)}^{d5}\left(f_{\left(H,Re_{\theta}\right)}^{H^{*0}}\right)\right)=S_{\left(H,A_{i}\right)}^{d5}\frac{\partial}{\partial Re_{\theta}}\left(f_{\left(H,Re_{\theta}\right)}^{H^{*0}}\right)
\]

\subsection{For paper}
\end{document}


\documentclass[11pt,a4paper]{report}
\usepackage{amsmath,amsfonts,amssymb,amsthm,epsfig,epstopdf,titling,url,array}
\usepackage{changepage}
\usepackage{graphicx}
\theoremstyle{plain}
\newtheorem{thm}{Theorem}[section]
\newtheorem{lem}[thm]{Lemma}
\newtheorem{prop}[thm]{Proposition}
\newtheorem*{cor}{Corollary}
\theoremstyle{definition}
\newtheorem{defn}{Definition}[section]
\newtheorem{conj}{Conjecture}[section]
\newtheorem{exmp}{Example}[section]
\newtheorem{exercise}{Exercise}[section]
\theoremstyle{remark}
\newtheorem*{rem}{Remark}
\newtheorem*{note}{Note}
\begin{document}

\section*{Problem}
Two quarters are placed next to each other on a table (side-by-side, just touching each other).  One is held fixed and the other is revolved (rolled) around it.  How many rotations does the revolving quarter make?
\\
\\
\textit{Source:} A learned of this problem from a coworker. I do not know its original source.

\section*{Bonus Problem}
 Suppose the that the two coins have different sizes, say the fixed one has radius $r_1$ and the moving coin has radius $r_2$.  Find a function of $r_1$ and $r_2$ that determines the number of rotations that the revolving coin makes.

\section*{Solution}
It makes two full rotations.

\section*{Bonus Solution}
 We will start by giving an intuitively appealing, but incorrect solution and then correct it. The circumference of the stationary coin is $2{\pi}r_1$. That is how far the rotating coin has to travel.  Suppose that the rotating coin were just rolling along a flat surface.  How many revolutions would it take for it to move that far?  In each revolution, it goes $2{\pi}r_2$ units of distance.  Therefore, it should take $2{\pi}r_1 / 2{\pi}r_2 = r_1/r_2$ revolutions to do it. Unfortunately, this answer does not agree with what you can see when you do the $r_1 = r_2$ case with your hands and eyes with two quarters. There you get 2. To understand where the problem is, imagine now that $r_2$ is very small in relation to $r_1$.  A great example to think about is that the stationary circle is the earth and the moving one is a tire on a car driving around the equator, with the simplifying assumption that the earth is perfectly round and the road it is driving on is a perfect circle around the earth.  The number of turns of the tire that it takes to cover any distance along the great circle route is correctly given by $d/2{\pi}r_2$ where $r_2$ is the radius of the tire measured in whatever units of distance we are using and $d$ is the distance.  Now suppose that the tire starts with the little ``Goodyear'' logo facing up toward the top of the car.  Suppose further that when the car has gone exactly 1/2 way around the world, it has done exactly 3.5 million full rotations.  The logo will be facing ``up'' again, but relative to its initial position, it will have made an additional 1/2 rotation.  What is going on here is that the ``linear'' displacement model that measures progress along the great circle is not accounting for the fact that the path is a circle.  Each rotation of the wheel results in a small (tiny in this case) additional change in the orientation of the top of the wheel relative to the center of the earth. The small additional changes associated with each rotation add up to one full rotation.  The correct answer is therefore $1 + r_1/r_2$.

\newpage
Another way to get to the same result is to consider Figure \ref{fig:quarters} below.

\begin{figure}[h!]
  \includegraphics[width=2in]{quarters.png}
  \caption{}
  \label{fig:quarters}
\end{figure}

The center of the moving circle travels along the dotted circle. That circle has circumference $2\pi(r_1+r_2)$. Computing linear displacement along this longer path effectively cancels the ``rotational advantage'' in the model above, so you can compute the number of rotations directly: $2\pi(r_1+r_2) / 2{\pi}r_1 = (r_1 + r_2) / r_1 = 1 + r_2/r_1$.

The degenerate cases are interesting and good to check.  If $r_2$ is zero, you get $1$ which makes sense, since you are just spinning the top circle around a point.  If $r_1$ is zero, things are hopeless - you get nowhere spinning a zero-radius wheel. If, as in the round-the-world example, $r1$ is much smaller than $r_2$, the ``$+1$'' is negligible.

\end{document}


\chapter{Assigning and Testing Algebraic Properties}

Sometimes algebraic expressions can be further simplified if
there is additional information about the value ranges
of its components. The following section describes
how to inform {\REDUCE} of such assumptions.

\section{REALVALUED Declaration and Check}

The declaration {\tt REALVALUED} \ttindex{REALVALUED} may be used
to restrict variables to the real numbers. The syntax is:
\begin{verbatim}
        realvalued v1,...vn;
\end{verbatim}
For such variables the operator {\tt IMPART} \ttindex{IMPART} gives
the result zero. Thus, with
\begin{verbatim}
        realvalued x,y;
\end{verbatim}
the expression \verb;impart(x+sin(y)); is evaluated as zero.
You may also declare an operator as real valued
with the meaning, that this operator maps real arguments always to
real values. Example:
\begin{verbatim}
        operator h; realvalued h,x;
        impart h(x);

           0

        impart h(w);

           impart(h(w))
\end{verbatim}
Such declarations are not needed for the standard elementary functions.

To remove the propery from a variable or an operator use the declaration
{\tt NOREALVALUED} \ttindex{NOREALVALUED} with the syntax:
\begin{verbatim}
        norealvalued v1,...vn;
\end{verbatim}

The boolean operator {\tt REALVALUEDP} \ttindex{REALVALUEDP}
allows you to check if a variable, an operator, or
an operator expression is known as real valued.
Thus,
\begin{verbatim}
        realvalued x;
        write if realvaluedp(sin x) then "yes" else "no";
        write if realvaluedp(sin z) then "yes" else "no";
\end{verbatim}
would print first \verb+yes+ and then \verb+no+. For general
expressions test the impart for checking the value range:
\begin{verbatim}
        realvalued x,y; w:=(x+i*y); w1:=conj w;
        impart(w*w1);

           0

        impart(w*w);

           2*x*y
\end{verbatim}

\section{Declaring Expressions Positive or Negative}

Detailed knowlege about the sign of expressions allows {\REDUCE}
to simplify expressions involving exponentials or {\tt ABS}\ttindex{ABS}.
You can express assumptions about the
{\tt positivity}\ttindex{positivity} or {\tt netativity}\ttindex{negativity}
of expressions by rules for the operator {\tt SIGN}\ttindex{SIGN}.
Examples:
\begin{verbatim}
         abs(a*b*c);

            abs(a*b*c);

         let sign(a)=>1,sign(b)=>1; abs(a*b*c);

            abs(c)*a*b

         on precise; sqrt(x^2-2x+1);

            abs(x - 1)

         ws where sign(x-1)=>1;

            x - 1
\end{verbatim}
Here factors with known sign are factored out of an {\tt ABS} expression.
\begin{verbatim}
         on precise; on factor;

         (q*x-2q)^w;

                      w
           ((x - 2)*q)

         ws where sign(x-2)=>1;

            w        w
           q *(x - 2)

\end{verbatim}

In this case the factor $(x-2)^w$ may be extracted from the base
of the exponential because it is known to be positive.

Note that {\REDUCE} knows a lot about sign propagation.
For example, with $x$ and $y$ also $x+y$, $x+y+\pi$ and $(x+e)/y^2$
are known as positive.
Nevertheless, it is often necessary to declare additionally the sign of a
combined expression. E.g.\ at present a positivity declaration of $x-2$ does not
automatically lead to sign evaluation for $x-1$ or for $x$.