# MATH310S26 Day 21 - Convolution Theory and Filtering **Date:** March 6, 2026 **Topics:** Convolution integral theory, RC circuit analysis, 2D Fourier transforms, image filtering ## Administrative Notes - Work day Monday (March 9) - no low-stakes feedback - Narrative project outlines due Monday (flexible - complete by Tuesday/Wednesday) - Individual and group project discussions ongoing ## From RC Circuits to Convolution ### The Circuit Equation Starting with the [RC circuit](https://en.wikipedia.org/wiki/RC_circuit) differential equation: $RQ' + \frac{1}{C}Q = V(t)$ Rewritten in standard form: $Q' + \frac{1}{RC}Q = \frac{V(t)}{R} = f(t)$ ### Fourier Domain Solution Applying the Fourier transform and using the derivative rule from [[MATH310S26-Day20-Notes]]: $\hat{Q}(\omega) = \hat{f}(\omega) \cdot \frac{RC}{1 + i\omega RC}$ Key insight: $\hat{Q} = \hat{f} \cdot \hat{g}$ where $\hat{g}(\omega) = \frac{RC}{1 + i\omega RC}$ ### The Convolution Theorem From [[MATH310S26-Day20-Notes]], the inverse Fourier transform of a product: $\mathcal{F}^{-1}\{\hat{f} \cdot \hat{g}\} = \frac{1}{\sqrt{2\pi}}(f * g)(t)$ where the [convolution integral](https://en.wikipedia.org/wiki/Convolution) is: $(f * g)(t) = \int_{-\infty}^{\infty} f(p) \cdot g(t-p) \, dp$ ## Physical Interpretation of Convolution ### The Filter Function Recall from previous work: $\mathcal{F}\left\{u(t) e^{-t/\tau}\right\} = \frac{1}{\sqrt{2\pi}} \cdot \frac{\tau}{1 + i\omega\tau}$ Setting $\tau = RC$: $g(t) = \frac{1}{RC} u(t) e^{-t/RC}$ ### Convolution as Filtering The solution becomes: $Q(t) = \int_{-\infty}^{\infty} f(p) \cdot u(t-p) e^{-(t-p)/RC} \, dp$ **Key operations on the filter g:** 1. **Flip**: $g(-p)$ - horizontal reflection 2. **Shift**: $g(t-p)$ - slide through all values 3. **Multiply and integrate**: weighted average with input signal ## Example: Sinusoidal Input ### Setup To understand how the RC circuit filters signals, consider: $f(t) = e^{i\omega t} \quad \text{(take real part for } \cos(\omega t)\text{)}$ ### Convolution Calculation $Q(t) = e^{-t/RC} \int_{-\infty}^{\infty} e^{i\omega p} u(t-p) e^{p/RC} \, dp$ The step function $u(t-p) = 1$ when $t > p$, limiting integration: $Q(t) = e^{-t/RC} \int_{-\infty}^{t} e^{(i\omega + 1/RC)p} \, dp$ Evaluating: $Q(t) = e^{-t/RC} \cdot \frac{1}{i\omega + 1/RC} \cdot e^{(i\omega + 1/RC)t} = \frac{RC \cdot e^{i\omega t}}{1 + i\omega RC}$ ### Extracting the Real Part Rationalizing the denominator: $Q(t) = \frac{RC \cdot e^{i\omega t} (1 - i\omega RC)}{(\omega RC)^2 + 1}$ Taking the real part: $\text{Re}\{Q(t)\} = \frac{RC}{(\omega RC)^2 + 1} \left[\cos(\omega t) + RC\omega \sin(\omega t)\right]$ ### Physical Meaning - **Input**: $\cos(\omega t)$ - **Output**: Amplitude scaled by $\frac{RC}{(\omega RC)^2 + 1}$ plus phase shift - **Key behavior**: As $\omega$ increases, amplitude decreases → **low-pass filter** This matches the Day 19 implementation exactly! The transfer function $g(\omega) = \frac{1}{1 + i\omega RC}$ suppresses high frequencies. ## Visual Understanding Making the real abstract and difficult math tangible is always tricky but with the rise of [3Blue1Brown](https://en.wikipedia.org/wiki/3Blue1Brown) and Grant Sanderson's visualization package [Manim](https://www.manim.community/) things have been made easier. In the following video Sanderson has discussed [convolution](https://en.wikipedia.org/wiki/Convolution) with the goal of applying it to [digital image processing](https://en.wikipedia.org/wiki/Digital_image_processing). However, as he does, there are some nice visualizations in simpler settings. ![](https://youtu.be/KuXjwB4LzSA?si=-nNPYLu6HB2tpa6f) ### Discrete Convolution Analogy From Grant Sanderson's visualization: 1. **Dice probability**: Flip one array, slide, multiply pairs, sum → [probability distribution](https://en.wikipedia.org/wiki/Probability_distribution) of each sum ![](https://youtu.be/KiBDhz5UtTk) ![](https://youtu.be/A6fpX5l20Ic) 2. **[Moving average](https://en.wikipedia.org/wiki/Moving_average)**: Small window of weights (sum to 1) slides over data → smoothing ![](https://youtu.be/V4ykIKnlnbk) ![](https://youtu.be/HOO8TAdxtEw) ### Connection to Our Problem - **Input signal** $f(p)$: the data to be filtered - Cosine function, i.e., a single mode out of a [Fourier representation](https://en.wikipedia.org/wiki/Fourier_series) of the data - **Filter** $g(t-p)$: the window (flipped and shifted) - Originating from the [RC circuit](https://en.wikipedia.org/wiki/RC_circuit) - **Output** $Q(t)$: filtered/smoothed result - [Sinusoids](https://en.wikipedia.org/wiki/Sine_wave) of the same frequency come back but with altered amplitudes so that waves of higher frequency have their amplitudes artificially lowered by the filter ## 2D Fourier Transforms and Image Filtering ### Fourier Analysis of Images Images as 2D data → [2D Fourier transform](https://en.wikipedia.org/wiki/Fourier_transform#Fourier_transform_on_Euclidean_space) reveals: **Spatial patterns → Frequency domain:** - Vertical stripes → horizontal dots in frequency space - Horizontal stripes → vertical dots in frequency space - Higher frequency → dots farther from origin - Diagonal patterns → rotated frequency response ![[Teaching/MATH310/MATH310S26/Lecture Notes/Media/Day 21/Slide36.png]] ### Key Observations from Examples 1. **Rectangle/pulse in space** → [sinc pattern](https://en.wikipedia.org/wiki/Sinc_function) (cross-shaped "squiddies") 2. **[Gaussian](https://en.wikipedia.org/wiki/Gaussian_function) in space** → Gaussian in frequency (preserves shape) 3. **Sharp edges** → high-frequency content spreads widely 4. **Smooth regions** → concentrated low-frequency content ![[Teaching/MATH310/MATH310S26/Lecture Notes/Media/Day 21/Slide43.png]] ![[Tripod.gif]] ### Filtering in Practice ![[Teaching/MATH310/MATH310S26/Lecture Notes/Media/Day 21/Slide50.png]] **[Low-pass filtering](https://en.wikipedia.org/wiki/Low-pass_filter)** (blur): - Multiply by [Gaussian kernel](https://en.wikipedia.org/wiki/Gaussian_blur) in frequency domain ![[Teaching/MATH310/MATH310S26/Lecture Notes/Media/Day 21/Slide51.png]] - Result: blurred image ![[Teaching/MATH310/MATH310S26/Lecture Notes/Media/Day 21/Slide57.png]] ![[Teaching/MATH310/MATH310S26/Lecture Notes/Media/Day 21/Slide60.png]] **[High-pass filtering](https://en.wikipedia.org/wiki/High-pass_filter)** ([edge detection](https://en.wikipedia.org/wiki/Edge_detection)): ![[Teaching/MATH310/MATH310S26/Lecture Notes/Media/Day 21/Slide64.png]] ## Check Your Understanding 1. **Convolution mechanics**: If $g(t) = u(t)e^{-t}$ (unit step × exponential), what happens to $g(t-p)$ as $p$ varies from $-\infty$ to $\infty$? 2. **Frequency response**: Why does $\frac{1}{1 + i\omega RC}$ represent a low-pass filter? What happens as $\omega \to 0$? As $\omega \to \infty$? 3. **2D patterns**: If an image has a checkerboard pattern, what would you expect in its 2D Fourier transform? ## Key Takeaways 1. **Convolution = Flip + Shift + Integrate**: The fundamental operation for filtering 2. **Frequency domain multiplication = Time domain convolution**: Computational advantage 3. **RC circuits naturally implement low-pass filters**: Physical systems do math! 4. **2D transforms extend to image processing**: Same principles, higher dimensions ## Mathematical Connections - [[MATH310S26-Day7-Notes]]: Fourier series foundations - [[MATH310S26-Day15-Notes]]: Delta functions and sinc - [[MATH310S26-Day19-WorkdayMaterials (Convolution theorem and RC filtering)]]: Practical implementation - [[MATH310S26-Day20-Notes]]: Convolution theorem, RC circuit analysis, spectrograms The theoretical framework developed today provides the mathematical foundation for the FFT-based filtering implemented in Day 19's work materials. Students can now understand WHY multiplying in frequency space achieves the same result as the convolution integral - it's not just computational convenience, but mathematical equivalence!