Making sense of phase portrait of simple mass-spring oscillator

I'm new to physics, and I'm having trouble making sense of phase portrait of the following system,

$$m \ddot{x} + k x = 0$$

whose phase portrait is in here.

Since

$$x(t) = \sqrt{\frac{2E}{k}} \cos\left(\omega t + \phi \right)$$

where $$\omega := \sqrt{\frac{k}{m}}$$, once we are given $$k$$ and $$m$$, we are completely sure about $$x(t)$$ as a function of $$t$$, except for $$E$$. I think this $$E$$ should be related to how strong we pull or push the spring in the first time.

Can we visualize a movement of $$(x(t), v(t))$$ on the $$x-v$$ plane as a function of time $$t$$, given initial $$E$$?

Can somebody tell how can I visualize the movement? (e.g. website, MATLAB code, etc)

• $E$ is fixed by the initial conditions $x(0)$ and $\dot{x}(0)$. Every different initial condition will give you a different red curve in the figure you linked – pp.ch.te Mar 29 '19 at 8:10
• via Wolfram. For matlab you should probably try the parametric plot function. – denklo Mar 29 '19 at 9:09

The total energy of the system $$E = \frac12mv^2 + \frac 12m\omega^2x^2$$

So the graph of $$v$$ against $$x$$ will be an ellipse with $$-A\le x\le +A$$ and $$-\omega A\le v \le +\omega A$$ with $$E=\frac 12 m\omega^2 A^2$$ where $$A$$ is the amplitude of the motion.

So the graphs in your diagram are a series of ellipses with different total energies of the system and amplitudes.

You can think of a point on the graph moving along the graph with the passage of time.
For the system to move from $$(+A,0)$$ to $$(0,+\omega A)$$ with take a quarter of a period.

Here is a still from an animation using Geogebra

The total energy is fixed by your initial conditions, so each combination of $$x(0)$$ and $$\dot{x}(0)$$ will produce a specific ellipse in the phase diagram. In my opinion, phase diagrams are easier to grok in the Hamiltonian context. The Hamoltonian for simple harmonic motion is given by $$H = \frac{p^2}{2m} + \frac{1}{2}m\omega^2q^2$$

where $$p$$ is the generalized momentum conjugate to $$q$$. For our purposes, it suffices to say $$q=x$$ and $$p$$ is what we normally think of as momentum. Hamilton's euqations then give us a pair of couple differential equations that we can solve for the position and momentum at a given time, which we may then plot to get an ellipse like above. To be explicit, we get $$\dot{p} = -m\omega^2x \text{ and } \dot{q}=p/m$$

To get the phase diagram shown in your link, we may solve these two equations over many small timesteps and plot the result.

The trajectory in the top plot is parameterized by $$t$$, and the yellow dot shows the motion of the simple harmonic motion through phase space. The bottom plot is a quick schematic showing the corresponding location in real space.

The code used to generate this animation can be found here.