tracking error state space, linear control example I am trying to understand a detail from an example, from the control textbook Slotine and Li (1991) "Applied Nonlinear Control", Prentice-Hall, Example 6.4, pag. 220 (hopefully there is not any typing error in the book). A linear system is given: 
$$\eqalign{
   \left[ {\matrix{
   {{{\dot x}_1}}  \cr 
   {{{\dot x}_2}}  \cr 
 } } \right] =& \left[ {\matrix{
   {{x_2} + u}  \cr 
   u  \cr 
 } } \right]  \cr\\ 
   y =& {x_1} \cr} 
$$
where the output $y$ is desired to track $y_d$. Differentiating the output, an explicit relation between $y$ -output- and $u$ -control input- is obtained:
$$\dot y = {x_2} + u$$
Until here it is clear. Now, the authors choose a control law:
$$u =  - {x_2} + {{\dot y}_d} - (y - {y_d})$$ 
and say that this yield the tracking error equation:
$$\dot e + e = 0$$
with the $e$ being the tracking error, defined as $ e=y-y_{d} $ and the internal dynamics:
$${{\dot x}_2} + x_2=\dot {y_d} - e$$
... and the problem continues.
My question is: how does one define the control law $u =  - {x_2} + {{\dot y}_d} - (y - {y_d})$ ?? And how does this relate to the two following equations ($\dot e + e = 0$ and ${{\dot x}_2} + x_2 = \dot{y_d} - e$)?
Any simple clarifying answer is much appreciated.
Thanks
 A: Let's assume you want $y$ to follow a desired $y_\text{d}$ and if you want dynamics of the error to be of first order then you define
$$e = y-y_\text{d}.$$
Assume you want the following first order error dynamics (note that the relative degree of the system is also one)
$$\dot{e}+a_0e =0,$$
which is asymptotically stable for $a_0>0$. Now, simply plug in the definition of $e$ to obtain
$$\dot{y}-\dot{y}_\text{d}+a_0(y-y_\text{d})=0.$$
As we know $y = x_1$, we know that $\dot{y}=x_2+u$, hence
$$x_2+u-\dot{y}_\text{d}+a_0(x_1-y_\text{d})=0.$$
Now solve for $u$ to obtain
$$u= -x_2+\dot{y}_d-a_0(x_1-y_d).$$
Note that $x_1=y$ and this method requires that $y_\text{d}$ is at least continuously differentiable.
A: Actually, @MrYouMath gave already a detailed and correct expalanation. Here some more words on the tracking error dynamics:
The dynamic of the tracking error $e = y-y_d$ is what you specify, i.e., the desired dynamics of the plant output $y$ along the desired trajectory $y_d$. This specified error dynamics should be asymptotically stable, since it might desired that $e \to 0$, as $t\to \infty$ or $y\to y_d$, as $t\to \infty$. 
Here it is chosen as the error differential equation:
\begin{align}
0 &=  \dot e  + e \\
& = \dot y-\dot y_d + y-y_d
\end{align}
which is asymptotically stable since it is Hurwitz (the corresponding characterisitic polynomial has an eigenvalue equals $-1$). 
Consequently, initial errors $e(t_0)$ tend to zero as time increases.
Now to obtain $0 =  \dot e  + e $ you simply choose $u$ in the equation
\begin{align}
\dot y = x_2 + u.
\end{align}
In the example, $x_2$ is compensated exactly, so you need just to add the remaining terms $(\dot y_d,y,y_d)$ to obtain the desired error dynamics, i.e., 
\begin{align}
u = -x_2 + \dot y_d -(y-  y_d)
\end{align}
It follows 
\begin{align}
\dot y = x_2 - x_2 + \dot y_d -( y-  y_d) \Rightarrow e +\dot e = 0
\end{align}
In the design, the dynamics in $x_2$ is not considered, it remains the internal dynamics
\begin{align}
\dot x_2 &= u =  -x_2 + \dot y_d -(y-  y_d)\\
& \Rightarrow \dot x_2 +x_2 = \dot y_d - e
\end{align}
final remark:
Note that this dynamics must be stable for $e\equiv0$. This yields the zero dynamics $\dot x_2 = -x_2$ which is indeed asympt. stable. 
