Conversion from state space back to transfer function in octave. I'm having problem converting a transfer function to state space and then going back to the same transfer function. 
I did a little experiment:
[A, B, C, D] = tf2ss(tf([50, 10, 1], [1, 0]));
[b, a] = ss2tf(A, B, C, D);

results in b: [-9, -1], a: [1, -1, ~0]
Why is this? Shouldn't I get back the exact same transfer function that I put into tf2ss(), ie b = [50, 10, 1] and a = [1, 0]? 
I have also tried c2d(pid(10, 1, 50), 1) but got this:

error: ss: dss2ss: this descriptor system cannot be converted to
  regular state-space form

Why?
 A: State space models of that form can only represent transfer function which are proper, so the order of the denominator polynomial has to be greater of equal to that of the numerator. This is not the case for your test case.
In order to see why one can use the formula that converts a state space model of the form
$$
\dot{x} = A\,x + B\,u \\
y = C\,x + D\,u
$$
into a equivalent transfer function
$$
G(s) = C\,(s\,I - A)^{-1} B + D.
$$
The inverse of $s\,I - A$, with $A,I\in\mathbb{R}^{n\times n}$, will be in $\mathbb{R}^{n\times n}$ as well with each element having the determinant of $s\,I - A$ in the denominator and the numerator in the $i$th row and $j$th column having the determinant of the submatrix of $s\,I - A$ by removing $i$th row and $j$th column (this is also known as a minor). It can be shown that the order of each denominator (ignoring pole-zero cancellation for now) will always be equal to $n$, while the order of each minor can at most be $n-1$. If pole-zero cancellation would occur then both would decrease in order, so the order of the numerator will always be less then that of the denominator. Pre and post multiplying this by $C$ and $B$ does not change this fact and when adding $D$ one could multiply it by $\det(s\,I - A)/\det(s\,I - A)$ such that the factions can be combined. This last step would at most make the order of the numerator equal to that of the denominator, but not greater.
It is possible to represent improper transfer functions with state space models, however for this the time derivative has to be redefined as
$$
E\,\dot{x} = A\,x + B\,u.
$$
In order to use this I think you have to use the command dss (both in MATLAB and Octave). If the matrix $E$ is not full rank then the resulting transfer function will be improper. For as far as I known MATLAB (and maybe therefore Octave as well) does not support this for the conversion functions between transfer functions and state space models.
