# Linear algebra of state space representation won't be linear (superposition theorem)...

After answering a question about calculating the state space representation of a circuit with 3 sources in it (the circuit is there), I had a doubt - while checking, it became clear there is something wrong somewhere.

## What has been done

So I solved the circuit for each one of the sources powered ON at a time. I ended up with 3 differential equations (numbered with $i=1...3$): $$\alpha_{i}\ddot{V_o}+\beta_{i}\dot{V_o}+\gamma_i{V_o}=\delta_iU_i$$ Where $U_i$ is the powered source value.

The superposition theorem should enable me to sum these differential equations together, such that: $$\ddot{V_o}+a_{1}\dot{V_o}+a_2{V_o}=b_{1}I_i+b_2V_1+b_3V_2$$ With $$a_2=\frac{\gamma_1}{\alpha_1}+\frac{\gamma_2}{\alpha_2}+\frac{\gamma_3}{\alpha_3}$$ $$a_1=\frac{\beta_1}{\alpha_1}+\frac{\beta_2}{\alpha_2}+\frac{\beta_3}{\alpha_3}$$ $$b_i=\frac{\delta_i}{\alpha_i}$$ Which is represented in state space $$\dot{X}=AX+BU$$ $$V_o=CX+DU$$ By $$A=\begin{bmatrix} 0 & 1\\ -a_2 & -a_1 \end{bmatrix}$$ $$B=\begin{bmatrix} 0 & 0 & 0\\ b_{1} & b_{2} & b_{3} \end{bmatrix}$$ $$C=[1, 0]$$ $$D=[0,0,0]$$ For a state vector $$X=\begin{bmatrix} V_o\\ \dot{V_o} \end{bmatrix}$$ And input vector $$U=\begin{bmatrix} I_i\\ V_1\\ V_2 \end{bmatrix}$$

I've made a sanity-check of each of my elementary differential equations in steady state ($V_o=\delta_i/\gamma_i*U_i$) and they're all right. Then tested each one of them in their own state space Simulink block, which looked good.

## Question

The total state space block though, filled in the same way as the elementary differential equations but based on the sum of the differential equations instead, is totally wrong: e.g. if I'm supposed to get 100 out for 100 in in steady state, I end up with 32.

There must be an error somewher, and from those clues I would lean towards transforming to state space. But where?

This should be enough to tell me if it's something fundamental - if all seems good though, I can upload pictures of my notes.

Here is to illustrate: the upper state space model contains the total differential equation, and the 3 others are the differential equations of the cricuit for each power source. • What is inside those state space models? Jan 25, 2015 at 16:41
• I updated my post with what's inside, basically the 3 elementary differential equations on the one hand and the sum of all of those on the other. Jan 25, 2015 at 18:06

By your logic the total differential equation should start with $3 \ddot{V}_0$. But I think you misinterpreted the Superposition Theorem. It states that if you have $y_i$ output for $u_i$ input, then you will have $\sum_i y_i$ output for $\sum_i u_i$ input, for a given system, i.e. for a single differential equation. What you have is 3 independent differential equations and you can't just "sum" them. You need to see that these are different equations and each of them has 2 states like following:

$$\begin{bmatrix}\dot{V}_{01} \\ \ddot{V}_{01} \\ \dot{V}_{02} \\ \ddot{V}_{02} \\ \dot{V}_{03} \\ \ddot{V}_{03} \end{bmatrix} = \begin{bmatrix} 0 & 1 & 0 & 0 & 0 & 0 \\ -\gamma_1/\alpha_1 & -\beta_1/\alpha_1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & -\gamma_2/\alpha_2 & -\beta_2/\alpha_2 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & -\gamma_3/\alpha_3 & -\beta_3/\alpha_3 \end{bmatrix} \begin{bmatrix}{V}_{01} \\ \dot{V}_{01} \\ {V}_{02} \\ \dot{V}_{02} \\ {V}_{03} \\ \dot{V}_{03} \end{bmatrix} + \begin{bmatrix} 0 & 0 & 0 \\ \delta_1/\alpha_1 & 0 & 0 \\ 0 & 0 & 0 \\ 0 & \delta_2/\alpha_2 & 0 \\ 0 & 0 & 0 \\ 0 & 0 & \delta_3/\alpha_3 \end{bmatrix} \begin{bmatrix}I_1 \\ V_1 \\ V_2 \end{bmatrix}$$

$$y = \begin{bmatrix}1 & 0 & 1 & 0 & 1 & 0\end{bmatrix}\begin{bmatrix}{V}_{01} \\ \dot{V}_{01} \\ {V}_{02} \\ \dot{V}_{02} \\ {V}_{03} \\ \dot{V}_{03} \end{bmatrix}$$

To see why summing up the differential equations won't work, consider these equations:

$$\dot{x}(t) + 2x(t) = u(t) \\ \dot{x}(t) + 3x(t) = u(t)$$

where $u(t)$ is the step function and $x(0)=0$. These equations have the solutions $(1-e^{-2t})/2$ and $(1-e^{-3t})/3$ respectively. Summing these equations yields the following equation

$$2\dot{x}(t) + 5x(t) = 2u(t)$$

which has the solution $2(1-e^{-5t/2})/5$, which is not the sum of the solutions of the above equations.

• Thank you for this very clear answer. So in that case, the matrix C is [1 0 1 0 1 0] for y_total=y1+y2+y3, right? Also, shouldn't the 1's in the B matrix be replaced with delta_i/alpha_i (i from 1 to 3)? Jan 27, 2015 at 1:02
• And spot on about the factor 3, that one was a stupid mistake. Jan 27, 2015 at 1:35
• @MisterMystère You are right. I fixed the answer. Jan 27, 2015 at 10:51
• I modified my answer quoted above if you want to take a quick look - of course, you are mentioned. Jan 27, 2015 at 11:19
• By the way, I'm wondering what to do to set initial conditions. I assume I can't set one V_0 to, say, 230 volts; and the others at 0 because the derivatives depend on V_0 so that will make the 3 equations incoherent right? But I can't set all of them to the same value as the sum will be 3 times that. And if I subtract 2 times that, all the other values will be corrupted. So what to do then? Jan 27, 2015 at 18:30