Simplifying Cascading State Space Models I have the following 2 state space models

*

*\begin{array}{rcl}
\dot{x}_1&=&A_1x_1+B_{11}u_{11}+B_{12}u_{12}\\
y_1&=&C_1x_1+D_{11}u_{11}+D_{12}u_{12}
\end{array}


*\begin{array}{rcl}
\dot{x}_2&=&A_2x_2+B_{2}u_{2}\\
y_2&=&C_2x_2+D_{2}u_{2}\\
\end{array}
The first system is a controller which feeds the second system, The output of the second system then feeds back as one of the inputs to the first system:
\begin{array}\dot{y}_{1}&= u_{2}\end{array}
And:
\begin{array}\dot{u}_{12}&= y_{2}\end{array}
Algebraically, if I plug in y1 in u2 it works, but when I try plug y2 into u12, I get a loop as they are dependant on either other.
I am unsure how to combine these? It feels like I need to make the second system output a state not an input/output. I am just unsure how to do it.
 A: Ok... I was not satisfied by my comment, so here is the derivation :P
NOTE: I changed the output equation of the controller to $y_2=C_2x_2+D_{2}u_{2}$
\begin{align}
\dot{x}_1&=A_1x_1+B_{11}u_{11}+B_{12}u_{12}\\
\dot{x}_2&=A_2x_2+B_{2}u_{2}\\
y_1&=C_1x_1+D_{11}u_{11}+D_{12}u_{12} \\
y_2&=C_2x_2+D_{2}u_{2}\\
y_1&=u_2 \\
u_{12} & = y_2
\end{align}
substituting $y_1=u_2$:
\begin{align}
\dot{x}_1&=A_1x_1+B_{11}u_{11}+B_{12}u_{12}\\
\dot{x}_2&=A_2x_2+B_{2}(C_1x_1+D_{11}u_{11}+D_{12}u_{12})\\
y_2&=C_2x_2+D_{2}(C_1x_1+D_{11}u_{11}+D_{12}u_{12})\\
u_{12} & = y_2
\end{align}
now substituting $u_{12} = y_2$ in the last equation results in
\begin{align}
y_2 & =C_2x_2+D_{2}C_1x_1+D_{2}D_{11}u_{11}+D_{2}D_{12}y_2, \iff \\
(I-D_{2}D_{12}) y_2 & = C_2x_2+D_{2}C_1x_1+D_{2}D_{11}u_{11}, \iff \\
y_2 & = (I-D_{2}D_{12})^{-1}(C_2x_2+D_{2}C_1x_1+D_{2}D_{11}u_{11})
\end{align}
We can now substitute $u_{12} = y_2$ in the remaining
\begin{align}
\dot{x}_1&=A_1x_1+B_{11}u_{11}+B_{12}(I-D_{2}D_{12})^{-1}(C_2x_2+D_{2}C_1x_1+D_{2}D_{11}u_{11})\\
\dot{x}_2&=A_2x_2+B_{2}(C_1x_1+D_{11}u_{11}+D_{12}(I-D_{2}D_{12})^{-1}(C_2x_2+D_{2}C_1x_1+D_{2}D_{11}u_{11}))
\end{align}
which you may simplify yourself ;-)
Either way, this system is well-posed if the inverse of $I-D_{2}D_{12}$ exists, i.e., $\det(I-D_{2}D_{12})\neq0$
The interpretation here is that the matrix $D_{2}D_{12}$ cannot be full rank, which implies that we have some free variables that we can use to iteratively solve the associated system of equations (we do not have strict dependency, which causes an algebraic loop)
A: The answer from seaver is correct, but I think that it can also be shown a little more elegantly. Namely, when starting from the initially systems
\begin{align}
\dot{x}_1&=A_1x_1+B_{11}u_{11}+B_{12}u_{12}\\
\dot{x}_2&=A_2x_2+B_{2}u_{2}\\
y_1&=C_1x_1+D_{11}u_{11}+D_{12}u_{12} \\
y_2&=C_2x_2+D_{2}u_2\\
u_2&=y_1 \\
u_{12} & = y_2
\end{align}
the only relevant thing here is that $y_1$ and $y_2$ are well defined for a given state and other inputs. This can be put into equations using the output equations and the input-output relations, yielding
\begin{align}
y_1&=C_1x_1+D_{11}u_{11}+D_{12}y_2, \\
y_2&=C_2x_2+D_{2}y_1.
\end{align}
Combing this into one equation and bringing $y_1$ and $y_2$ to one side yields
$$
\begin{bmatrix}
I & -D_{12} \\
-D_2 & I
\end{bmatrix}
\begin{bmatrix}
y_1 \\ y_2
\end{bmatrix} =
\begin{bmatrix}
C_1x_1+D_{11}u_{11} \\
C_2x_2
\end{bmatrix}.
$$
This equation can always be solved for $y_1$ and $y_2$ if the matrix
$$
\begin{bmatrix}
I & -D_{12} \\
-D_2 & I
\end{bmatrix}
$$
is invertible (non-zero determinant), which I believe is indeed equivalent to  $\det(I-D_{2}D_{12})\neq0$.
