# Find state space model from transfer function

Let's suppose we have:

G(s) = (s+1)/(s^2-2s+1)

how can we find the state space representation of the transfer function:

x_dot = x2

x2_dot = 2*x2-x1+u

where u is an arbitrary input.

I am very new to this topic, so a detailed answere would be great ! :)

• Hint. The laplace operator roughly speaking performs derivatives. If you have $y/u=G(s)$, how can you substitute the "s" with derivatives? – LJSilver Jan 24 '17 at 9:23
• @LjSilver Hmmm... I am sorry, could you help me a bit... – james Jan 24 '17 at 10:38
• @LJSilver see my comment above. Help is needed. – james Jan 24 '17 at 15:35

So, assuming that the transfer function is between the output $Y(s)$ and the input $U(s)$, namely $$\dfrac{Y(s)}{U(s)} = G(s)\qquad\qquad(1)$$ multiplying (1) by $U(s)\cdot(s^2-2s+1))$ yields $$s^2 Y(s) -2s Y(s) + Y(s) = sU(s) + U(s)$$ Going back in the time domain we obtain $$\ddot y -2\dot y + y = \dot u + u\qquad (2)$$ Now, we look for a realization of the kind \begin{align*} \dot x &= Ax+Bu\qquad (3)\\ y &=Cx \end{align*} with $x=(x_1,x_2)$ and \begin{align*} A &= \begin{pmatrix}0 & 1\\a_1 & a_2\end{pmatrix} & B&=\begin{pmatrix}0\\1\end{pmatrix}, & C&=\begin{pmatrix}c_1&c_2\end{pmatrix}\end{align*} The next step is to find the values of $(a_1,a_2,c_1,c_2)$ for which (3) has the same input-output behaviour of (2). From (3) we have \begin{align*} y&=c_1x_1+c_2x_2\\ \dot y&= c_1\dot x_1 + c_2\dot x_2 = c_1x_2 + c_2a_1x_1 + c_2a_2 x_2 + c_2u\\ \ddot y&= c_1\ddot x_1 + c_2\ddot x_2 = c_1a_1x_1+c_1a_2x_2 +c_1u+ c_2a_1x_2+ c_2a_2a_1x_1+c_2a_2^2 x_2 + c_2a_2u + c_2\dot u \end{align*} substituting into (2) yields \begin{align*} 0&=(c_1+c_1a_1+c_2a_2a_1-2c_2a_1)x_1 + (c_2+c_1a_2+c_2a_1+c_2a_2^2-2c_1-2c_2a_2)x_2\\ &+(c_1+a_2c_2-2c_2-1)u + (c_2-1)\dot u \end{align*} since that equality must hold for all $(x_1,x_2,u,\dot u)$ that' equivalent to ask \begin{align*} c_1+c_1a_1+c_2a_2a_1-2c_2a_1&=0\\c_2+c_1a_2+c_2a_1+c_2a_2^2-2c_1-2c_2a_2&=0\\ c_1+a_2c_2-2c_2-1&=0\\c_2-1&=0 \end{align*} and a solution is $$(a_1,a_2,c_1,c_2)=(-1,2,1,1)$$ Therefore \begin{align*} \begin{pmatrix}\dot x_1\\\dot x_2\end{pmatrix} &=\begin{pmatrix}0&1\\-1&2\end{pmatrix}\begin{pmatrix}x_1\\x_2\end{pmatrix} + \begin{pmatrix}0\\1\end{pmatrix}\\y&=\begin{pmatrix}1&1\end{pmatrix}\begin{pmatrix}x_1\\x_2\end{pmatrix} \end{align*}