# Why am I getting non-sinusoidal output for sinusoidal input in a mass-spring system?

A mass-spring system is represented by the following transfer function

$$H(s) = \frac{s^{2} + 0.1s + 10}{s^{4} + 0.2s^{3} + 20s^{2}}$$

For a sinusoidal input I am getting a non-sinusoidal output, as shown below (input in gray, output in blue):

I am using the following MATLAB code to generate the plot:

t = 0:0.1:20;
u = sin(1*t);
lsim(sys_x1, u,t)

• This should probably be in the Physics SE, but since electrical circuits can have the same transfer functions, I will attempt an answer anyway. In the time-domain, it is difficult or impossible to really input an infinite sine-wave, your input signal is zero for time < 0. Did you run your simulation long enough for the output to stabilize? The output appears to be curving downward. Commented Jun 1, 2019 at 20:54
• @DKNguyen gray is input signal(u) and blue is output Commented Jun 1, 2019 at 20:55
• You haven't waited long enough for it to settle. It is a combination of a sinewave and an integral term by the looks of it. Commented Jun 1, 2019 at 21:06
• the frequency looks the same to me. its just a bit harder to see because the amplitude is building up. draw a straight line through the output wave and its more obvious Commented Jun 1, 2019 at 21:14
• I'm voting to close this question as off-topic because it's about springs and masses, not electronics. Commented Jun 2, 2019 at 1:52

There's a double integrator in the TF that inverse transforms to a ramp, which is what you're seeing added to the sinusoidal response to the sinusoidal input.

• Thanks. Removing integrator gives sinusoidal output of the same frequency. But doesnt integrator add 90 degree phase without changing frequency and amplitude? Commented Jun 1, 2019 at 21:38
• @Siddhesh Nope. An integrator adds 90 degrees phase shift with a frequency-dependent amplitude change. If you want to torture yourself by thinking in frequency-domain terms, it turns out that the double integrator, when excited by a sinusoid at anything but the exactly correct starting phase, will respond with a ramp. This is much easier to see in the time domain. Commented Jun 1, 2019 at 21:49
• @TimWescott Indeed, thats the response I am getting . The book I am referring says "for an LTI system, a sinusoidal input gives rise to a sinusoidal output again, and at the same frequency as the input". Which seems to contradict this observation. Commented Jun 1, 2019 at 21:57
• Another way to look at those 2 S terms in the denominaor is as a sort of "double resonance" at 0Hz. So the transient response will have an undamped 0 Hz component of some sort (a ramp in this case). Commented Jun 1, 2019 at 22:10

To complement Chu's answer, using SymPy:

>>> from sympy import *
>>> s = Symbol('s', complex=True)
>>> H = (s**2 + 0.1*s + 10) / (s**4 + 0.2*s**3 + 20*s**2)


Since the Laplace transform of the input

$$x (t) := \begin{cases} \sin(t) & \text{if } t \geq 0\\ 0 & \text{otherwise}\end{cases}$$

is given by

$$X(s) = \frac{1}{s^2+1}$$

the Laplace transform of the response is

>>> X =  1 / (s**2 + 1)
>>> Y =  H * X
>>> apart(Y,s)
0.473687126080213*(0.000584726932522512*s + 1.0)   0.00131287391978728*(0.0105485232067511*s - 1.0)   0.5
- ------------------------------------------------ + ------------------------------------------------ + ---
2                                               2                                 2
s  + 1                                     0.05*s  + 0.01*s + 1.0                 s


In $$\\LaTeX\$$,

$$Y(s) = - \frac{0.473687126080213 \left(0.000584726932522512 s + 1.0\right)}{s^{2} + 1} + \frac{0.00131287391978728 \left(0.0105485232067511 s - 1.0\right)}{0.05 s^{2} + 0.01 s + 1.0} + \frac{0.5}{s^{2}}$$

Note the $$\\frac{1}{s^2}\$$ term, which corresponds to a ramp in the time domain. This is unsurprising, as the double pole at the origin ensures that the LTI system being studied is not BIBO-stable.

Note also that the roots of $$\0.05 s^{2} + 0.01 s + 1.0\$$ have negative real parts:

>>> solve(0.05*s**2 + 0.01*s + 1.0)
[-0.1 - 4.47101778122163*I, -0.1 + 4.47101778122163*I]


Thus, the response contains:

• forced response: scaled and time-shifted version of the input sinusoid $$\\sin (t)\$$ (for $$\t \geq 0\$$).

• natural response: exponentially decaying sinusoid plus ramp.