# State space equation for spring pendulum

Let's say we have a spring pendulum, where the spring itself is massless, and there is no damping at the hinge. That is, the only things we are concerned about are the forces applied by the spring and gravity.

Let's let $l+r$ be the length of the spring where $l$ is the length of the spring when it isn't stretched or compressed, and $r$ is the distance it has stretched. The spring has spring constant $k$. In addition, we let $\theta$ be the angle from the vertical of the spring pendulum. Let's say at the end of the pendulum there is a mass $m$.

My goal here is to derive a state space representation of this system. This is what I've done thus far:

I'm use Lagrangian mechanics to describe the model

Using $r$ and $\theta$ as my generalized coordinates... \begin{align} L&=T-V\\ T&=\frac{1}{2}m\dot{r}^2+\frac{1}{2}m\left(l+r\right)^2\dot{\theta}^2\\ V&=\frac{1}{2}kr^2-mg\left(l+r\right)\cos\theta\\ L&=\frac{1}{2}m\dot{r}^2+\frac{1}{2}m\left(l+r\right)^2\dot{\theta}^2-\frac{1}{2}kr^2+mg\left(l+r\right)\cos\theta \end{align} Okay, so then I use $\frac{d}{dt}\frac{\delta L}{\delta q_i}=\frac{\delta L}{\delta q_i}$ and get the following:

For $r$ \begin{align} \frac{\delta L}{\delta r}&=m\left(l+r\right)\dot{\theta}-kr+mg\cos\theta\\ \frac{\delta L}{\delta \dot{r}}&=m\dot{r}\\ \frac{d}{dt}\frac{\delta L}{\delta \dot{r}}&=\frac{\delta L}{\delta r}\\ m\ddot{r}&=m\left(l+r\right)\dot{\theta}-kr+mg\cos\theta\\ \end{align}

For $\theta$ \begin{align} \frac{\delta L}{\delta \theta}&=-mg\left(l+r\right)\sin\theta\\ \frac{\delta L}{\delta \dot{\theta}}&=m\left(l+r\right)^2\dot{\theta}\\ \frac{d}{dt}\frac{\delta L}{\delta \dot{\theta}}&=\frac{\delta L}{\delta\theta}\\ \frac{d}{dt}\left(m\left(l+r\right)^2\dot{\theta}\right)&=-mg\left(l+r\right)\sin\theta\\ 2m\dot{r}\dot{\theta}\left(l+r\right)+m\left(l+r\right)^2\ddot{\theta}&=-mg\left(l+r\right)\sin\theta\\ 2m\dot{r}\dot{\theta}+m\left(l+r\right)\ddot{\theta}&=-mg\sin\theta \end{align}

Now I have my equations of motion, so I can define my states: $$x= \begin{bmatrix} x_1\\x_2\\x_3\\x_4 \end{bmatrix} = \begin{bmatrix} r\\ \dot{r}\\ \theta\\ \dot{\theta} \end{bmatrix}$$

Then, $$\dot{x}= \begin{bmatrix} x_2\\ \left(l+x_1\right)x_4-kx_1+mg\cos x_3\\ x_4\\ -\frac{2x_2x_4}{l+x_1}-\frac{g\sin x_3}{l+x_1}\\ \end{bmatrix}$$

Now I assume I linearize and approximate $l+x_1\approx l$, $\cos x_3\approx 1$, and $\sin x_3\approx 0$.

But how do I proceed after this?

## migrated from electronics.stackexchange.comDec 4 '14 at 17:26

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

• Do you want a numerical or an analytical solution? Why did you truncate the expansion of sin to the 0th degree (the linear term is usually included)? For an analytical solution, I think you still need to get rid of $x_2x_4$, so one might go ahead and assume that to be zero (~the square of a velocity). After that, you can use your favourite method of solving differential equations, perhaps Laplace transform given that you apparently first posted this to electronics.SE. – alarge Dec 4 '14 at 19:10
• @alarge I'm looking for an analytical solution. The \$x_2x_4/(l+x_1)\$ and the \$x_1x_4\$ are the main issues that I'm running into. I suppose you are saying I can set both of those to zero? And yeah, you got me, being an EE, Laplace transform is the way I like to handle things :) – Mr. Snowflake Dec 11 '14 at 15:47