y=sgn(sinx)y = \operatorname{sgn}(\sin x)

Graph of the Square Wave y=sgn(sinx)y = \operatorname{sgn}(\sin x)

y=sgn(sinx)y = \operatorname{sgn}(\sin x) takes only the sign of the sine sinx\sin x, giving a square wave whose value alternates between +1+1 and 1-11.

Definition

The sign function is defined as follows.

sgn(t)={+1(t>0)0(t=0)1(t<0)\operatorname{sgn}(t) = \begin{cases} +1 & (t > 0) \\ 0 & (t = 0) \\ -1 & (t < 0) \end{cases}

Applying it to t=sinxt = \sin x gives the function considered here.

Domain and range

The domain is all real numbers, and the range consists of just three values: 1-1, 00 and +1+1.

Intervalsinx\sin xyy
0<x<π0 < x < \pipositive+1+1
x=nπx = n\pi0000
π<x<2π\pi < x < 2\pinegative1-1

Periodicity and symmetry

The period is 2π2\pi, the same as that of sinx\sin x. Since sgn(sin(x))=sgn(sinx)\operatorname{sgn}(\sin(-x)) = -\operatorname{sgn}(\sin x), the function is odd, with point symmetry about the origin.

Points of discontinuity

At each x=nπx = n\pi the value jumps discontinuously between +1+1 and 1-1. The jump has size 22, and the value at that instant is 00. Against the smooth wave of sinx\sin x, this graph is made only of horizontal segments and vertical jumps.

There are two jumps in each period, and everywhere else the derivative is 00. The value switches without ever having a slope, a structure typical of the step functions.

Fourier series

A square wave can be written as a sum of odd-numbered sines.

sgn(sinx)=4πk=0sin((2k+1)x)2k+1\operatorname{sgn}(\sin x) = \frac{4}{\pi}\sum_{k=0}^{\infty}\frac{\sin\bigl((2k+1)x\bigr)}{2k+1}

The coefficients fall off only as 12k+1\dfrac{1}{2k+1}, so the convergence is slow and a good approximation needs many terms. Truncating the series leaves an overshoot near each jump, known as the Gibbs phenomenon2. Adding terms does not reduce the height of that overshoot, which stays at about 9%9\%; only its width narrows.

WaveformHarmonics presentDecay of the coefficients
Square waveodd1n\dfrac{1}{n}
Triangle waveodd1n2\dfrac{1}{n^{2}}

The general rule shows through: a waveform with jumps has slowly decaying coefficients, while one with mere corners has fast decaying ones.

Applications

  • The clock signal of a digital circuit
  • On-off control
  • Pulse-width modulation
  • The synthesis of electronic sound
  1. Square wave, Wikipedia
  2. Gibbs phenomenon, Wikipedia