What happens when you drive a vibrating system with a square wave rather than a sine wave? Do you still see the same kinds of behavior, such as beats and resonance? When does the difference between a square wave and a sine wave matter most? Those are the questions this post will address.

Background Basic mechanical oscillations are modeled by the equation m u + γ u + k u = F sin(ωt + φ) You can think of m, γ, and k as mass, damping, and spring constant.

The same equation describes non-mechanical oscillations, such as electrical systems.

Sometimes the terms such as “mass” are still used when they are metaphorical rather than literal.

I wrote a four-part series of posts on mechanical vibrations a while back starting here.

The term on the right hand side is the forcing function.

F is the amplitude of the driving force and ω is its frequency.

The natural frequency of a system modeled by the equation above is ω02 = k/m.

When F = 0, the solutions to the differential equation will have this frequency.

When F is not zero, the solutions a component with the natural frequency and a component with the driving frequency.

When the two frequencies are different, you get beats.

When the two frequencies are the same, you get resonance.

More on beats and resonance here.

In this post we will look at solutions to the equation above where the forcing function is a square wave rather than a sine wave.

That is, we will replace sin(ωt + φ) with sign( sin(ωt + φ) ) where sign(x) is 1 when x is positive and -1 when x is negative.

Exploration To simplify things a little, we will set the damping term γ to zero, and set the phase φ in the driving function to zero.

Also, we will set m, k, and F all equal to 1.

We will focus on varying only the driving frequency ω.

We need initial conditions for our differential equations, so let’s pick u(0) = 1 and u‘(0) = 0.

When we drive the system at its natural frequency, i.

e.

with ω = 1, we get the same kind of resonance from a sine wave and a square wave.

Update: There are more resonant frequencies [1].

When we lower the driving frequency to ω = 0.

5 we see more of a difference.

In general we see more difference as ω gets smaller, and more difference when the period 1/ω is not an integer.

For example, here is ω = 0.

25, period T= 4: And here is ω = 0.

3, period T = 1.

66.

Here’s an example of driving a system with a square wave at a frequency higher than the natural frequency.

Here the difference between the solutions for the square wave and sine wave are closer together.

Apparently the higher frequency makes more difference than the non-integer period.

In the examples above, the solution with a square wave forcing function starts out flat.

That’s because of our initial conditions u(0) = 1 and u‘(0) = 0.

If we change the initial velocity condition to u‘(0) = 1, we get smoother solutions.

Here are the solutions with u‘(0) = 1 and ω = 0.

25 and ω = 0.

3.

Changing the initial velocity made more of a difference when the period was an integer.

See the next post for systems driven by a sawtooth wave rather than a square wave.

Related posts Mechanical vibrations Unexpected square wave Gibbs phenomenon [1] Sine-driven systems exhibit resonance if and only if the driving frequency matches the natural frequency.

While writing the next post on sawtooth forcing functions, I accidentally discovered resonance at lower frequencies.

The same can happen here with square wave-driven systems if ω = 1/(2n + 1).

For example, here’s a plot with ω = 1/5.

The reason resonance shows up for odd periods is that the square wave has Fourier components at every odd frequency.

.