---
title: Signals in continuous and discrete time
heading: Functions of time, and lists of numbers
eyebrow: C9 · Lesson 1 · Signals in continuous and discrete time
xp: 40
---

::: hook
A microphone puts out a voltage that changes smoothly with time: a function x(t), defined at every instant. Once a converter samples it, the same sound becomes a list of numbers, one every 1/48,000 of a second: a sequence x[n], defined only at whole numbers n. Most of electrical engineering moves signals back and forth between these two worlds, and the tools of this course work in both. They behave alike in most ways, but not in all. A sampled cosine, for one, may never repeat, and two different frequencies can give exactly the same samples.
:::

::: play
- The dots are the samples $x[n] = \cos(\omega_0 n)$, and the dashed curve is the cosine they were taken from. $\omega_0$ is in radians per sample.
- Start at $\omega_0 = 0.785$ (π/4): the pattern repeats every 8 samples. Now try 1.0: the samples never repeat exactly, because 2π/1 isn't a whole number or a ratio of whole numbers.
- Set $\omega_0$ to 5.498 (2π − π/4). The dashed curve wiggles fast, but the dots are the same as at 0.785. In discrete time, frequencies 2π apart are the same signal.
:::
:::

```sim plot
view: graph
x: n = 0..24
y: x = -1.3..1.3
slider: w = 0..6.3 = 0.785 step 0.001
plot: cos(w*n) | dashed | samples: 2000
plot: cos(w*n) | stems | label: x[n]
readout: samples per cycle of the cosine = 2*pi/w | digits: 4
```

::: predict
## Is $x[n] = \cos(n)$, a sampled cosine with $\omega_0$ = 1 radian per sample, periodic?

- [ ] Yes, with period 6
- [ ] Yes, with period 2π
- [x] No: it never repeats exactly
- [ ] Yes, with period 1

::: reveal
No. A period N must be a whole number of samples with $\omega_0 N$ a multiple of 2π, so N = 2πk for some whole k, and 2π is irrational. The values come close to repeating every 44 samples or so, but never exactly. A continuous cosine always repeats; its samples repeat only when $\omega_0/2\pi$ is a ratio of whole numbers.
:::
:::

::: nameit
## Two kinds of signal

A **continuous-time** signal x(t) is defined for every real t. A **discrete-time** signal x[n] is defined only for whole numbers n; it often comes from sampling, $x[n] = x(nT)$ with sampling period T. Sampling a cosine of f hertz at $f_s$ samples a second gives

$$x[n] = \cos(\omega_0 n), \quad \omega_0 = \frac{2\pi f}{f_s} \text{ radians per sample}$$

## Periodicity

x(t) is periodic with period T if $x(t + T) = x(t)$ for all t. A discrete signal needs a whole-number period N. For $\cos(\omega_0 n)$ that means $\omega_0 N = 2\pi m$ for whole numbers m and N: periodic only when $\omega_0/2\pi = m/N$ is rational, and in lowest terms N is the period. And because $\cos((\omega_0 + 2\pi)n) = \cos(\omega_0 n)$ for every whole n, discrete-time frequencies only matter over a range of 2π, usually taken as −π to π. The highest frequency a sequence can have is π radians per sample: alternating signs.

## Energy and power

$$E = \int_{-\infty}^{\infty} |x(t)|^2 dt \quad\text{or}\quad E = \sum_{n=-\infty}^{\infty} |x[n]|^2$$

and the power is the average of $|x|^2$ over all time. An **energy signal** has finite E (so zero average power), like a decaying pulse; a **power signal** has finite, nonzero power (so infinite energy), like a sinusoid, whose power is $A^2/2$. (These are "energies" as if x were a voltage across 1 Ω.)

| Signal | Energy | Power |
|---|---|---|
| $Ae^{-t/\tau}u(t)$ | $A^2\tau/2$ | 0 |
| $A\cos(\omega t + \phi)$ | infinite | $A^2/2$ |
| $a^n u[n]$, $\lvert a\rvert < 1$ | $1/(1 - a^2)$ | 0 |
:::

::: example
## Find the energy and power of $x(t) = 3e^{-2t}u(t)$.

::: solution
1. **Energy.**
   $$\begin{aligned} E &= \int_0^\infty 9e^{-4t} dt \\ &= 9/4 \\ &= 2.25 \end{aligned}$$
2. **Power.** Finite energy means the average power over all time is 0: it's an energy signal.
3. **Check with the table.** With $\tau = 1/2$, the table's $A^2\tau/2$ gives the same 2.25.

**Answer:** the energy is 2.25 and the average power is 0, so it's an energy signal.
:::
:::

::: example
## Is $x[n] = \cos(3\pi n/8)$ periodic, and with what period?

::: solution
1. **Frequency as a fraction of a cycle.**
   $$\begin{aligned} \frac{\omega_0}{2\pi} &= \frac{3\pi/8}{2\pi} \\ &= \frac{3}{16} \end{aligned}$$
2. **Period.** That's a ratio of whole numbers in lowest terms, so the period is 16 samples.
3. **Cycles per period.** In those 16 samples the underlying cosine goes through 3 cycles.

**Answer:** yes, it's periodic, with a period of 16 samples.
:::
:::

::: example
## Find the average power and the RMS value of $x(t) = 1 + 2\cos(100\pi t)$.

::: solution
1. **Drop the cross term.** Over a period the cross term $4\cos(100\pi t)$ averages to zero.
2. **Average power.** The DC part and the sinusoid contribute power separately because they're orthogonal:
   $$\begin{aligned} P &= 1^2 + 2^2/2 \\ &= 3 \end{aligned}$$
3. **RMS value.**
   $$\begin{aligned} \sqrt{P} &= \sqrt3 \\ &= 1.732 \end{aligned}$$
4. **Power signal.** The energy is infinite, so this is a power signal.

**Answer:** the average power is 3 and the RMS value is $\sqrt3 = 1.732$; it's a power signal.
:::
:::

::: check
given: A = 1 | 3 | 5; tau = 0.5 | 2 | 10
answer: A^2*tau/2
tolerance: 0.5%

## What is the energy of $x(t) = \given{A}e^{-t/\given{tau}}u(t)$?

::: right
Right. $A^2\tau/2$ = {answer}.
:::

::: misses
- [A^2*tau] The square decays twice as fast: $e^{-2t/\tau}$ integrates to τ/2.
- [A*tau] Square the signal before integrating.
- [any] Not yet. $\int_0^\infty A^2e^{-2t/\tau}dt$.
:::
:::

::: check
given: A = 2 | 3 | 10
answer: A^2/2
tolerance: 0.5%

## What is the average power of $\given{A}\cos(100t + 0.3)$?

::: right
Right. $A^2/2$, whatever the frequency and phase.
:::

::: misses
- [A^2] The average of $\cos^2$ is 1/2.
- [A/sqrt(2)] That's the RMS value. Power is its square.
- [any] Not yet. $A^2/2$.
:::
:::

::: check
given: m = 1 | 3 | 5 | 7; d = 4 | 8 | 16
answer: 2*d
tolerance: 0

## What is the period, in samples, of $\cos(\given{m}\pi n/\given{d})$?

::: right
Right. $\omega_0/2\pi = \given{m}/(2 \cdot \given{d})$ in lowest terms, so N = {answer}.
:::

::: misses
- [d] Write $\omega_0/2\pi$: it's {m}/{answer}, so the period is the denominator.
- [any] Not yet. Reduce $\omega_0/2\pi$ to lowest terms; N is the denominator.
:::
:::

::: check
given: a = 0.5 | 0.8 | 0.9 | -0.6
answer: 1/(1 - a^2)
tolerance: 0.5%

## What is the energy of $x[n] = (\given{a})^n u[n]$?

::: right
Right. A geometric series in $a^2$: {answer}.
:::

::: misses
- [1/(1 - a)] Square each term first: the ratio is $a^2$.
- [any] Not yet. $\sum a^{2n} = 1/(1 - a^2)$.
:::
:::

::: check
given: f = 50 | 440 | 1000; fs = 8000 | 44100
answer: 2*pi*f/fs
unit: rad
tolerance: 0.5%

## A {f} Hz cosine is sampled at {fs} samples a second. What is $\omega_0$, in radians per sample?

::: right
Right. $2\pi f/f_s$ = {answer} rad per sample.
:::

::: misses
- [f/fs] That's cycles per sample. Multiply by 2π.
- [2*pi*f] That's radians per second. Divide by the sample rate.
- [any] Not yet. $2\pi f/f_s$.
:::
:::

::: check
kind: choice

## Which of these is a power signal (finite, nonzero average power)?

- [ ] $e^{-t}u(t)$
- [x] $\cos(5t)$
- [ ] $(0.9)^n u[n]$
- [ ] a single rectangular pulse

::: misses
- [1] It dies away: finite energy, zero average power.
- [3] It decays: finite energy, $1/(1 - 0.81)$.
- [4] It lasts a finite time, so its energy is finite and its average power zero.
:::
:::

::: check
kind: parts
given: A = 2 | 3 | 5; a = 0.5 | 2 | 10

## Find the energy of $x(t) = Ae^{-at}u(t)$ with A = {A} and a = {a} (seconds).

::: part
answer: A^2/(2*a)
tolerance: 0.5%

### What is its total energy?

::: misses
- [A^2/a] The square decays at 2a.
- [any] $\int_0^\infty A^2e^{-2at}dt = A^2/2a$.
:::
:::

::: part
answer: ln(2)/(2*a)
unit: s
tolerance: 0.5%

### By what time has half the energy arrived?

::: misses
- [ln(2)/a] The energy builds as $1 - e^{-2at}$.
- [any] Solve $1 - e^{-2at} = 1/2$.
:::
:::
:::

::: check
kind: derivation
vars: A = 0.1..10, a = 0.1..100, T = 0.001..10

## $x(t) = Ae^{-at}u(t)$.

::: step
answer: A^2/(2*a)

### What is its total energy?
:::

::: step
answer: A^2*(1 - exp(-2*a*T))/(2*a)

### How much of it arrives between 0 and T?
:::

::: right
Right. The energy arrives as $1 - e^{-2aT}$ of the total.
:::
:::

::: explain
## Why do $\cos(\omega_0 n)$ and $\cos((\omega_0 + 2\pi)n)$ give exactly the same samples, while their continuous versions are different?

::: model
At a whole number n, adding 2π to the frequency adds $2\pi n$ to the angle, a whole number of full turns, which leaves the cosine unchanged. So every sample is the same. In continuous time, t takes values between the whole numbers too, and there the extra $2\pi t$ isn't a whole number of turns, so the two curves differ. Sampling only looks at the whole numbers and can't tell them apart. That's the root of aliasing, and it's why discrete-time frequency only needs a 2π range.
:::
:::

::: practice

::: check
given: m = 1 | 3; d = 5 | 10 | 16
answer: d
tolerance: 0

## What is the period of $\cos(2\pi \given{m} n/\given{d})$ in samples? ({m} and {d} share no factor.)

::: misses
- [any] $\omega_0/2\pi$ is {m}/{d}, already in lowest terms: the period is the denominator.
:::
:::

::: check
given: A = 1 | 4; tau = 1 | 3
answer: A^2*tau/2
tolerance: 0.5%

## What is the energy of $\given{A}e^{-t/\given{tau}}u(t)$?

::: misses
- [any] $A^2\tau/2$.
:::
:::

::: check
given: f = 100 | 1000; fs = 1000 | 48000
answer: 2*pi*f/fs
unit: rad
tolerance: 0.5%

## A {f} Hz cosine sampled at {fs} Hz: what is $\omega_0$ per sample?

::: misses
- [any] $2\pi f/f_s$.
:::
:::
:::
