← All virtual labs
Signals & Systems · Virtual lab

Generation, transforms, convolution & spectra

Seven self-contained experiments, each a genuinely computing simulation written in plain JavaScript — no libraries, every pixel drawn from the real equation. Generate the standard signals, split a waveform into even and odd parts, shift and scale time, watch convolution flip-and-slide an overlap area into the output, rebuild a square wave harmonic by harmonic and see Gibbs ringing, sample a sinusoid below Nyquist and watch it alias, and push an input through an LTI system. Pick an experiment, then move through Aim, Theory, Procedure, the live Simulation, a graded Self-assessment, and References.

1 · Signal generator & complex exponential

Sine, square, triangle, sawtooth, impulse, unit step, exponential and e^(jωt)
To synthesise the standard continuous-time test signals from their defining formulae and to study the complex exponential e^(jωt), observing how its real and imaginary parts are a cosine and a sine of the same frequency, while amplitude, frequency and phase controls reshape the waveform.

Every signal here is computed point-by-point from an explicit formula of time t. A sinusoid is x(t) = A·sin(ωt + φ) where ω = 2πf is angular frequency and φ the phase. The square, triangle and sawtooth are periodic non-sinusoids built from the fractional part of ft. The unit impulse δ(t) is the idealised spike with unit area; here it is drawn as a single tall sample at t = 0. The unit step u(t) is 0 for t below 0 and 1 thereafter. The exponential is x(t) = A·e^(σt).

The complex exponential ties them together. By Euler's identity:

e^(jωt) = cos(ωt) + j·sin(ωt)
Re = A·cos(ωt + φ)    Im = A·sin(ωt + φ)
magnitude = A (constant)    phase advances at rate ω

The trajectory in the complex plane is a circle of radius A traced at angular rate ω — the rotating phasor whose horizontal shadow is a cosine and vertical shadow a sine. This is the atom from which Fourier analysis builds every signal.

  1. Open the Simulation tab and pick a waveform from the dropdown.
  2. Drag amplitude, frequency and phase and watch the live plot recompute.
  3. Select Complex exp e^(jωt) to see the real (cyan) and imaginary (purple) parts plotted together, plus the rotating phasor on the right.
  4. For the exponential, set frequency to the decay rate σ and observe growth versus decay as the sign flips.
  5. Read the measured peak, RMS and period in the stats panel and confirm RMS = A/√2 for a pure sine.

Signal x(t)

x(t) / Re
Tip: the impulse is shown as one unit-area sample at t=0; the step jumps from 0 to 1 there.

Controls

1.00
1.00 Hz
1.5x
Peak
--
RMS
--
Period
--
ω rad/s
--
  • Oppenheim, Willsky & Nawab — Signals and Systems, 2nd ed., Ch. 1. Prentice Hall.
  • Haykin & Van Veen — Signals and Systems, 2nd ed., Ch. 1. Wiley.
  • Virtual Labs (IIT) — Signals and Systems: Basic Signals, vlab.co.in.

2 · Even / odd decomposition

x(t) = xe(t) + xo(t), with xe = (x(t)+x(-t))/2 and xo = (x(t)-x(-t))/2
To split an arbitrary signal into its even and odd components using the reflection x(-t), to verify that the two parts add back to the original, and to confirm that the even part is symmetric about t=0 while the odd part is antisymmetric.

Any real signal can be uniquely written as the sum of an even part (mirror-symmetric, like a cosine) and an odd part (point-symmetric through the origin, like a sine). The construction uses only the signal and its time reversal x(-t):

xe(t) = (x(t) + x(-t)) / 2    (even: xe(-t) = xe(t))
xo(t) = (x(t) - x(-t)) / 2    (odd: xo(-t) = -xo(t))
x(t) = xe(t) + xo(t)

The proof is direct: add the two definitions and the x(-t) terms cancel, leaving x(t). Replacing t by -t in xe leaves it unchanged because x(t) and x(-t) swap roles; the same swap flips the sign of xo. A signal that is already even has zero odd part, and vice versa. The decomposition is useful because the Fourier transform of an even real signal is purely real and even, while an odd real signal transforms to a purely imaginary odd spectrum.

  1. Open the Simulation and choose a base signal. A pure asymmetric shape such as the shifted Gaussian shows the effect best.
  2. Adjust the shift and asymmetry sliders to make the signal lopsided about t=0.
  3. Read the top plot x(t), the middle plot xe(t) and the bottom plot xo(t).
  4. Confirm xe is mirror-symmetric and xo is point-symmetric, then check the reconstruction error stat is essentially zero — xe + xo reproduces x.
  5. Try the cosine (pure even, xo vanishes) and sine (pure odd, xe vanishes) to verify the limiting cases.

Three plots

x(t) xe(t) even xo(t) odd xe+xo

Base signal

1.2
1.0
0.50
Even energy
--
Odd energy
--
Recon error
--
Symmetry
--
Energy splits cleanly: total energy = even energy + odd energy (the cross term integrates to zero).
  • Oppenheim, Willsky & Nawab — Signals and Systems, 2nd ed., Sec. 1.2.3. Prentice Hall.
  • Lathi — Linear Systems and Signals, 2nd ed., Ch. 1. Oxford.
  • Virtual Labs (IIT) — Signals and Systems: Even and Odd Components, vlab.co.in.

3 · Time transformations

Shifting x(t - t0), scaling x(at) and reversal x(-t)
To apply the three independent operations on the time axis — shifting, scaling and reversal — in a controlled order, and to see how each reshapes the signal by comparing the original against the transformed waveform on the same axes.

Operations on the time variable move and stretch a signal without touching its amplitude. For a general transform y(t) = x(a·t - t0) the rules are:

Shift: y(t) = x(t - t0) — t0 > 0 delays (moves right)
Scale: y(t) = x(a·t) — |a| > 1 compresses, |a| < 1 stretches
Reversal: y(t) = x(-t) — mirror about t = 0

Order matters. The combined form y(t) = x(a(t - b)) first scales then shifts by b, whereas x(at - t0) shifts by t0/a after scaling. Here the engine evaluates the composite argument g(t) = a·t - t0 (with the reversal toggle negating a), so you read off the transformed value as x(g(t)). A negative a both reverses and scales. The transformations are the geometric backbone of convolution, where one signal is reversed and shifted across another.

  1. Open the Simulation and choose a base pulse with a clear shape so changes are visible.
  2. Drag shift t0 — positive values delay the signal to the right.
  3. Drag scale a — values above 1 compress in time, below 1 stretch it.
  4. Toggle reversal to mirror about the origin; combine it with a scale to see x(-a t).
  5. The faint grey curve is the original; the cyan curve is the transformed result. The argument readout shows the live mapping a·t - t0.

Original vs transformed

x(t) original y(t) transformed
Mapping: y(t) = x(t)

Transform

0.0
1.00
Effective a
1.00
Delay
0.0
Action
none
Peak at t
--
  • Oppenheim, Willsky & Nawab — Signals and Systems, 2nd ed., Sec. 1.2.1. Prentice Hall.
  • Proakis & Manolakis — Digital Signal Processing, 4th ed., Ch. 2. Pearson.
  • Virtual Labs (IIT) — Signals and Systems: Time Scaling and Shifting, vlab.co.in.

4 · Convolution — flip and slide

y(τ) = ∫ x(s) h(τ - s) ds, animated as overlap area at each shift
To evaluate the convolution of two signals by the flip-and-slide method, watching one signal reflected and dragged across the other while the shaded overlap area at each shift is accumulated point-by-point into the output y(τ).

Convolution combines two signals into a third that measures how much they overlap as one slides past the other. For continuous time:

y(τ) = (x * h)(τ) = ∫ x(s) · h(τ - s) ds
steps: flip h to h(-s), shift to h(τ-s), multiply, integrate
output length spans the sum of the two supports

The recipe is fixed: take the second signal, flip it left-to-right, shift it to position τ, multiply it sample-by-sample against the first, and integrate (sum the overlap area). That single number is y at shift τ. Sliding τ from far left to far right traces the whole output. Here the integral is approximated by a Riemann sum over a fine grid, which is exactly the discrete convolution sum y[n] = Σ x[k] h[n - k]. Convolution is commutative, associative and distributive, and convolving any signal with an impulse returns the signal unchanged.

  1. Open the Simulation and pick shapes for x(s) (cyan) and h(s) (purple).
  2. Press Play. The flipped-and-shifted copy of h slides across x; the green shaded region is their instantaneous product overlap.
  3. The bottom plot grows: each shift contributes one output sample equal to the shaded area, so the curve y(τ) is drawn as the slide proceeds.
  4. Drag the shift τ slider by hand to freeze any position and read the overlap area.
  5. Convolve a pulse with itself to get a triangle; convolve anything with the impulse to recover it unchanged.

Flip-and-slide

Output y(τ) accumulated

x(s) h(τ-s) overlap area y(τ)

Signals

-5.0
1.4x
Shift τ
--
Overlap area
--
y(τ) now
--
Peak y
--
The green area equals one output sample. Sum over all shifts and you have the full convolution.
  • Oppenheim, Willsky & Nawab — Signals and Systems, 2nd ed., Ch. 2. Prentice Hall.
  • Lathi — Linear Systems and Signals, 2nd ed., Sec. 2.4. Oxford.
  • Virtual Labs (IIT) — Signals and Systems: Convolution, vlab.co.in.

5 · Fourier series & Gibbs

Partial sum of N harmonics approaching square / sawtooth / triangle
To reconstruct a periodic waveform as a finite sum of harmonically related sinusoids, to watch the partial sum approach the target as the number of harmonics N grows, and to observe the Gibbs overshoot that persists near discontinuities however large N becomes.

A periodic signal of fundamental ω0 is an infinite weighted sum of sinusoids at integer multiples of ω0. For the odd waveforms here only sine terms appear:

x(t) = Σ b_n sin(n ω0 t)
Square: b_n = 4/(nπ) for odd n, else 0
Sawtooth: b_n = 2(-1)^(n+1)/(nπ)
Triangle: b_n = 8/(nπ)^2 with alternating sign, odd n

The N-term partial sum is the best least-squares fit of N harmonics to the target. As N grows the sum converges to the waveform everywhere it is continuous. At a jump it converges to the midpoint, but the overshoot just before the jump does not shrink — it settles at about 9 percent of the jump height no matter how many terms you add. This is the Gibbs phenomenon; the ringing simply narrows toward the discontinuity. The amplitude spectrum b_n falls off as 1/n for the square and sawtooth (slow, because of the jump) but as 1/n² for the continuous triangle (fast).

  1. Open the Simulation and choose a target waveform.
  2. Drag harmonics N from 1 upward. The orange partial sum sharpens toward the grey target.
  3. For the square and sawtooth, watch the ears near the jumps — the overshoot stat stays near 9 percent however large N is.
  4. Switch to the triangle: convergence is far faster and the overshoot vanishes, because there is no discontinuity.
  5. Read the spectrum bars; lit bars are included in the sum, dim bars are the harmonics still left out.

Partial sum vs target

Harmonic amplitude spectrum

target partial sum included harmonic

Controls

5
Terms used
--
Overshoot
--
RMS error
--
Roll-off
--
Gibbs overshoot near a jump converges to roughly 8.95 percent of the jump — it never disappears.
  • Oppenheim, Willsky & Nawab — Signals and Systems, 2nd ed., Ch. 3. Prentice Hall.
  • Stein & Shakarchi — Fourier Analysis, Ch. 2 (Gibbs phenomenon). Princeton.
  • Virtual Labs (IIT) — Signals and Systems: Fourier Series, vlab.co.in.

6 · Sampling & aliasing

Sample x(t) at fs and watch the reconstruction alias when fs < 2 f
To sample a sinusoid at a chosen rate fs, to reconstruct a band-limited signal from those samples, and to observe how a too-low rate folds the true frequency down to a lower alias frequency that the samples cannot distinguish from the original.

Sampling reads a continuous signal at evenly spaced instants spaced T = 1/fs apart. The Nyquist-Shannon theorem fixes when the samples keep all the information:

fs >= 2 f_max (Nyquist criterion)
Nyquist frequency = fs / 2
alias: f_alias = | f - fs · round(f / fs) |

If the signal frequency f exceeds the Nyquist frequency fs/2, the samples are identical to those of a lower-frequency sinusoid: the high frequency is aliased down by folding around multiples of fs. A reconstructor that assumes the lowest possible frequency consistent with the samples then draws the wrong, lower-frequency wave — the apparent frequency is f_alias above. Here the reconstruction is the ideal band-limited sinc interpolation of the samples, so when fs is high enough it overlays the original exactly, and when fs is too low it collapses onto the alias. The familiar wagon-wheel effect on film is exactly this.

  1. Open the Simulation. The grey curve is the true continuous sinusoid; the cyan dots are the samples.
  2. Set the signal frequency f and the sampling rate fs.
  3. Lower fs below 2f and watch the orange sinc reconstruction peel away from the grey original and lock onto a slower alias.
  4. Read the alias frequency stat and the Nyquist verdict (OK or aliasing) updating live.
  5. Set fs to exactly 2f to sit on the Nyquist edge, then nudge it either way to cross the boundary.

Original, samples & reconstruction

true x(t) samples sinc reconstruction
Verdict: --

Controls

2.0 Hz
10.0 Hz
Nyquist fs/2
--
Samples / s
--
Alias freq
--
Ratio fs/2f
--
  • Oppenheim, Willsky & Nawab — Signals and Systems, 2nd ed., Ch. 7. Prentice Hall.
  • Proakis & Manolakis — Digital Signal Processing, 4th ed., Sec. 1.4. Pearson.
  • Virtual Labs (IIT) — Signals and Systems: Sampling and Aliasing, vlab.co.in.

7 · LTI system response

y(t) = x(t) * h(t) — output as the convolution of input with impulse response
To compute the output of a linear time-invariant system by convolving the input with the system impulse response h(t), and to relate the shape of h(t) — its decay, its width, its oscillation — to the filtering effect seen at the output.

A linear time-invariant system is completely characterised by its impulse response h(t), the output produced by a unit impulse at the input. Because such a system is linear and time-invariant, any input is a superposition of shifted impulses and the output is the same superposition of shifted, scaled copies of h:

y(t) = x(t) * h(t) = ∫ x(s) h(t - s) ds
impulse in → h(t) out
stable if ∫ |h(t)| dt is finite; causal if h(t)=0 for t<0

The impulse response acts as a filter. A slowly decaying exponential h(t) = e^(-at)u(t) is a leaky integrator that smooths and lags the input (a low-pass effect). A short narrow h barely alters the input. A damped sinusoid h rings, emphasising frequencies near its oscillation rate (a resonator). Here both x and h are sampled finely and the output is the discrete convolution sum, scaled by the time step to approximate the integral. Read the energy gain and the peak shift to quantify how the system reshapes its input.

  1. Open the Simulation. The cyan curve is the input x(t), the purple curve is the impulse response h(t), and the amber curve is the output y(t).
  2. Choose an input — a pulse, a step or a sinusoid.
  3. Choose an impulse response — a decaying exponential (integrator), a narrow pulse (near pass-through) or a damped sine (resonator).
  4. Adjust the decay rate and width of h and watch the output smooth, lag, or ring accordingly.
  5. Read the energy gain, the peak delay and whether the response is stable.

Input, impulse response, output

x(t) input h(t) response y(t) output

System

1.5
1.2
Energy gain
--
Peak delay
--
Sum h(t)dt
--
Stable?
--
  • Oppenheim, Willsky & Nawab — Signals and Systems, 2nd ed., Sec. 2.1-2.3. Prentice Hall.
  • Lathi — Linear Systems and Signals, 2nd ed., Ch. 2. Oxford.
  • Virtual Labs (IIT) — Signals and Systems: LTI Systems, vlab.co.in.