-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathfourier.Rmd
157 lines (118 loc) · 7.26 KB
/
fourier.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# Fourier Transforms {#fourier}
## Continuous-Time Fourier Transforms {-}
The Fourier transform is an alternative representation of a signal. It describes the frequency content
of the signal. It is defined as
\begin{equation}
G(f) \overset{\text{def}}{=} \int_{-\infty}^\infty g(t)e^{-j2\pi f t}\,dt.
(\#eq:fourier)
\end{equation}
Notice that it is a function of frequency $f$, rather than time $t$. Notice also that it is complex-valued,
since its definition involves the imaginary number $j \overset{\text{def}}{=} \sqrt{-1}$.
The following video explains the visual intuition behind the Fourier transform. Note that this video
uses $i$ to denote the imaginary number $\sqrt{-1}$, whereas we use $j$ (which is common in electrical engineering,
to avoid confusion with current).
<iframe width="560" height="315" src="https://www.youtube.com/embed/spUNpyF58BY" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
To calculate the Fourier transform of a signal, we will rarely use \@ref(eq:fourier). Instead, we will
look up the Fourier transform of the signal in a table like Appendix \@ref(ctft) and use properties of the
Fourier transform (as shown in Appendix \@ref(fourier-properties)).
```{example}
Calculate the Fourier transform of $g(t) = 80e^{-20t} u(t)$.
```
```{solution}
This signal is most similar to $e^{-t} u(t)$ in Appendix \@ref(ctft), whose Fourier transform is
$\frac{1}{1 + j2\pi f}$. The only differences are:
- Our signal has an extra factor of 80 in front. This factor comes along for the ride by linearity of the Fourier transform.
- Our signal is time-scaled by a factor of 20, so we have to apply the scaling property.
Since we _multiplied_ by 20 in the time domain, we have to _divide_ by 20 in the
frequency domain, on both the _inside_ and the _outside_.
Putting everything together, we see that the Fourier transform is:
\[ G(f) = 80 \frac{1}{20} \frac{1}{1 + j 2\pi \frac{f}{20}}. \]
This is a complex-valued function. That is, at each frequency $f$, $G(f)$ is a complex number, with a
real and an imaginary component. To make it easier to visualize, we calculate its magnitude
using Theorem \@ref(thm:calculating-magnitude).
\begin{align*}
|G(f)| = \sqrt{|G(f)|^2} &= \sqrt{G(f) \cdot G^*(f)} \\
&= \sqrt{\frac{4}{1 + j2\pi \frac{f}{20}} \cdot \frac{4}{1 - j2\pi \frac{f}{20}}} \\
&= \sqrt{\frac{4}{1 + (2\pi \frac{f}{20})^2}}
\end{align*}
Now, the _magnitude_ of the Fourier transform is a function we can easily visualize.
From the graph, we see that the signal has more low-frequency content than high-frequency content.
```
```{r, echo=FALSE, fig.show = "hold", fig.align = "default"}
fs <- seq(-50, 50, by=.1)
plot(fs, sqrt(4 / (1 + (2*pi*fs/20)^2)), col="orange", type="l", lwd=2,
xaxt="n", yaxt="n", bty="n",
xlab="Frequency (f)", ylab="Fourier Transform Magnitude |G(f)|")
axis(1, pos=0)
axis(2, pos=0, at=(0:4) / 2)
```
## Discrete-Time Fourier Transforms {-}
Discrete-time signals are obtained by sampling a continuous-time signal
at regular time intervals. The sampling rate $f_s$ (in Hz) specifies the
number of samples per second. The signal below is sampled at a rate of
$f_s = 16$ Hz.
```{r, echo=FALSE, fig.show = "hold", fig.align = "default"}
ts <- seq(0, 1, .001)
plot(ts, sin(2 * pi * 4 * ts) + sin(2 * pi * 6 * ts), type="l",
xlab="Time (seconds)", ylab="Amplitude")
ts <- seq(0, 1, length.out=17)
points(ts, sin(2 * pi * 4 * ts) + sin(2 * pi * 6 * ts), pch=19)
```
We write $x[n] = x(t_n)$ for the $n$th time sample, where $t_n = \frac{n}{f_s}$.
It's possible to choose a sampling rate $f_s$ that is too low. In the graph below,
the underlying continuous-time signal (in black) is a sinusoid with a frequency of 14 Hz.
However, because the discrete-time signal (in red) was sampled at a rate of 16 Hz, the
sinusoid appears to have a frequency of 2 Hz.
```{r, echo=FALSE, fig.show = "hold", fig.align = "default"}
ts <- seq(0, 1, .001)
plot(ts, sin(2 * pi * 14 * ts), type="l", col="black",
xlab="Time (seconds)", ylab="Amplitude")
lines(ts, -sin(2 * pi * 2 * ts), col="red")
ts <- seq(0, 1, length.out=17)
points(ts, sin(2 * pi * 14 * ts), pch=19, col="red")
```
We say that the higher frequency is **aliased** by the lower one.
At a sampling rate of $f_s$, any frequencies outside the range
\[ (-f_s / 2, f_s / 2) \]
will be aliased by a frequency inside this range. This "maximum frequency"
of $f_s / 2$ is known as the **Nyquist limit**.
Therefore, the Fourier transform of a discrete-time signal is effectively only
defined for frequencies from $-f_s/2$ to $f_s/2$. Contrast this with the Fourier transform of a
continuous-time signal, which is defined on all frequencies from $-\infty$ to $\infty$.
Aliasing is not just a theoretical problem. For example, if helicopter blades are spinning
too fast for the frame rate of a video, then they can look like they are not spinning at all!
<iframe width="560" height="315" src="https://www.youtube.com/embed/AYQAKwCxScc" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
When calculating the Fourier transform of a discrete-time signal, we typically work with
_normalized_ frequencies. That is, the frequencies are in units of "cycles per _sample_" instead of
"cycles per _second_". (Another way to think about this is that we assume all discrete-time signals are
sampled at 1 Hz.) As a result, the Nyquist limit is $1/2$, so the **Discrete-Time Fourier Transform**
is defined only for $|f| < 0.5$.
\begin{align}
G(f) &\overset{\text{def}}{=} \sum_{n=-\infty}^\infty g[n] e^{-j2\pi f t}\,dt & -0.5 < f < 0.5
(\#eq:discrete-fourier)
\end{align}
To calculate the Fourier transform of a signal, we will rarely use \@ref(eq:discrete-fourier). Instead, we will
look up the Fourier transform of the signal in a table like Appendix \@ref(dtft) and use properties of the
Fourier transform (as shown in Appendix \@ref(fourier-properties)).
## Essential Practice {-}
1. Calculate the Fourier transform $G(f)$ of the continuous-time signal
\[ g(t) = \begin{cases} 1/3 & 0 < t < 3 \\ 0 & \text{otherwise} \end{cases}. \]
Graph its magnitude $|G(f)|$ as a function of frequency.
2. Calculate the Fourier transform $G(f)$ of the discrete-time signal
\[ g[n] = \delta[n] + 0.4 \delta[n-1] + 0.4 \delta[n+1]. \]
Graph $G(f)$. (The Fourier transform should be a real-valued function, so you do not need to take its magnitude.)
3. Which of the following terms fill in the blank? The Fourier transform $G(f)$ of a real-valued time signal $g(t)$
is necessarily ....
a. real-valued: $G(f) \in \mathbb{R}$
b. positive-valued: $G(f) > 0$
c. symmetric: $G(-f) = G(f)$
d. conjugate symmetric: $G(-f) = G^*(f)$
(_Hint:_ Write out $G(f)$ and $G(-f)$ according to the definition \@ref(eq:fourier), and
use Euler's identity (Theorem \@ref(thm:euler)). Simplify as much as possible, using the facts that
$\cos(-\theta) = \cos(\theta)$ and $\sin(-\theta) = -\sin(\theta)$.)
4. Which of the following terms fill in the blank? The Fourier transform $G(f)$ of a real-valued and _symmetric_
time signal $g(t)$ is necessarily ....
a. real-valued: $G(f) \in \mathbb{R}$
b. positive-valued: $G(f) > 0$
c. symmetric: $G(-f) = G(f)$
d. conjugate symmetric: $G(-f) = G^*(f)$