# How long will it take for a dampened spring to reach a certain point?

I've written a spring simulation for a UI in JavaScript, and everything is going great, users are able to throw UI elements all over the place and have them slide right where they need to go with a little wiggle.

However I'm trying to chain spring simulations together, and I'd like to know what time a spring will cross its equilibrium point so that I can ready the next animation in the chain to start at the right time and velocity.

How can I solve this formula for $$t$$ so I can know when the spring will cross a certain point? I'd like to know for all types of springs, but practically I'm only working with slightly underdamped ones. My current formula for finding an underdamped spring's displacement from its equilibrium is $$f(t) = e^{-ct/2m} * (d_0 * cos(\frac{\sqrt{4mk - c^2}*t}{2m}) + \frac{2mv_0+cd_0}{\sqrt{4mk-c^2}} * sin(\frac{\sqrt{4mk - c^2}*t}{2m}))$$ where:

$$m$$: the mass of the springing object,

$$k$$: the stiffness of the spring, the spring constant,

$$c$$: the damping force,

$$d_0$$: the springing object's initial distance from its equilibrium at $$time = 0$$ ,

$$v_0$$: the springing object's velocity once the user lets go of it at $$time = 0$$,

and $$t$$ for time.

Can I solve this mess for $$t$$ rather than $$f(t)$$?

• You will need to solve it numerically, I don't think it has an analytic solution
– user65081
Aug 18, 2021 at 23:49
• You are missing a parenthesis around the sine and cosine terms to multiply with the exponential. The general solution should be of the form $$x= \exp(-\beta t) \left( A \sin (\omega t) + B \cos( \omega t) \right)$$ Aug 19, 2021 at 1:09
• @JohnAlexiou It was right there in the code too... thanks, I missed that, edited to reflect Aug 19, 2021 at 2:51

There is an analytical solution, if you bring the equation to the form $$x = R \exp(-\zeta \theta) \cos \left(\theta \sqrt{1-\zeta^2}+\psi \right)$$
The solution for $$x=0$$ is
$$\theta = \frac{ \frac{\pi}{2} ( 2 i -1) - \psi }{\sqrt{1-\zeta^2}}$$
where $$i=1,2,3 \ldots \infty$$. The time and angle are related as $$\theta = \omega_n t$$, with $$\omega_n^2 = \frac{k}{m}$$ and damping ratio $$\zeta = \frac{c}{2 m \omega_n}$$.
The amplitude is $$R = \sqrt{A^2+B^2}$$ and phase $$\psi =-\arctan(A/B)$$ where $$A$$ is the coefficient of $$\sin()$$ and $$B$$ the coefficient of $$\cos()$$.