Physics Stack Exchange is a question and answer site for active researchers, academics and students of physics. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am not physics in training so if anything is unclear please request clarification.

I have a set of objects to be placed on a line, linked with springs of known lengths (L) and stiffnesses (K). I want to solve the equilibrium positions of each object (x).

x0        x1             x2

I am following this Wikipedia entry - I believe the idea is to set the forces on each object zero and then solve linear equations.

However, my problem is a bit more complicated. My objects have known lengths, so the problem becomes:

x0         x1             x2
    |~~L1~~| |~~~~~~L2~~~~|

I would also forbid the objects occupy the same place. Can someone please help me derive a solution here? Thanks so much.

share|cite|improve this question
The bold sentence brings in huge complications. Simple harmonic approximation won't work anymore: as you bring two objects very close together you need to use more and more force to bring them even closer (in other words, the potential should diverge in the limit where the spring is totally compressed, i.e. its length is zero). This problem is not easy and you might want to make additional assumptions. On the other hand, if you can assume that oscillations won't be too big then you can essentially proceed the same way as in the article. – Marek Jul 25 '11 at 15:56
This reminds me of how ${\TeX}$ distributes boxes on a page. If you want to do something like that and are not so much interested in simulating the physical system, you could look at chapter 12 "Glue" in – whoplisp Jul 25 '11 at 18:17
up vote 2 down vote accepted

Springs in series

The masses' finite lengths and the rest lengths of the springs are not really relevant because they don't change and hence don't contribute to the energy.

If the total length from the beginning of the first mass to the end of the last one is 10 meters, for example, and all the rest lengths of springs and sizes of masses add up to 3 meters, just subtract that and work with 7 meters of length. The springs now have zero rest length. You can add the masses back in at the end.

We now have springs in a line. Their tension must all be the same at equilibrium, so if $k_i$ represents the spring constant of spring $i$ and $x_i$ represents its stretched length, then

$$k_ix_i = T$$

for all springs, with $T$ the tension.


$$\sum_i x_i = L$$

with $L$ the adjusted length (original length minus masses and rest lengths).

This is easy to solve. Plugging the first relation into the second,

$$\sum_i\frac{T}{k_i} = L$$


$$ T = \frac{L}{\sum_i 1/k_i}$$

Now we know the tension, we can find the individual $x_i$ by

$$x_i = \frac{T}{k_i}$$

Springs in parallel

The finite size of the masses means that some masses may touch. I suggest you fix this by solving the system with the masses having zero size. Then check to see if any masses are too close to each other, so that they overlap, or have passed through each other. For any such pairs of masses, modify the problem to combine these into a single mass, thus modifying the initial conditions. Then solve the problem over again.

To solve the problem with zero-size masses, let spring $j$ have spring constant $k_j$, length $l_j$, and rest length $l_{0j}$. We need to minimize the potential energy

$$U = \frac{1}{2}\sum_j(l_j - l_{0j})^2 k_j$$

subject to some constraints such as

$$l_a + l_b = l_c$$

Write these constraints as

$$f_i(l_a,l_b,l_c) = 0$$

for constraint $i$.

Then we can introduce a Lagrange multiplier $\lambda_i$ for each constraint and write

$$\nabla U = \sum_i \lambda_i \nabla f_i$$

If we look at just the $j^{th}$ component of these gradients we get

$$k_j(l_j - l_{0j}) = \pm \lambda_{j1} + \pm \lambda_{j2} + \ldots$$

where the $\pm$ depends on how $l_j$ enters that particular constraints, and the sum is over all the constraints involving spring $j$.

This is just a system of linear equation which you can solve via the usual methods.

share|cite|improve this answer
Oh, this is an equilibrium problem. Well, then it's quite trivial... – Marek Jul 25 '11 at 19:51
Thanks. See my picture above, the springs are not just in tandem. There are also springs connecting non-adjacent objects. How do I resolve the positions of the OBJECTS using the stretched length xi in your equation? – Haibao Tang Jul 25 '11 at 20:42
@Haibao Presumably the ends are fixed. In that case, the extra spring in your picture is immobile and doesn't change anything and can be ignored. I'll add some detail in the answer, though. – Mark Eichenlaub Jul 25 '11 at 22:15
@Mark, I should add that the ends are NOT fixed in this particular problem. All the positions are unknown, except that we can arbitrarily set one position, e.g. x0=0 to be the point of reference. – Haibao Tang Jul 25 '11 at 22:52

I'm assuming you want to solve such problems automatically on a computer. If you want to solve them individually by hand, the best method will obviously be different.

Without the constraint that the objects can't pass through each other, the problem is an unconstrained quadratic optimization problem, which is solved simply by taking the gradient of that quadratic function and setting it to zero (which is a linear equation).

With the constraint, the problem becomes a quadratic programming problem. The potential energy matrix Q will indeed be positive definite (because if you make add a sufficiently large multiple of any perturbation to the coordinates, the potential energy will eventually go up), so it's also an example of convex programming.

There are many libraries available to solve convex quadratic programming problems for you with well-known algorithms. That Wikipedia article gives the examples of OpenOpt, qp-numpy, CVXOPT...

So to solve your problem you just convert the given spring and object lengths and spring stiffnesses into the format of a quadratic programming problem, call an appropriate library function to solve it, and then interpret the solution as the desired equilibrium positions.

share|cite|improve this answer
Thanks. Can you write a sample quadratic programming formulation using CPLEX format, for the toy example above? This will really help me. – Haibao Tang Jul 25 '11 at 20:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.