I have a discrete square wave $f(t)$ where $t \in \mathbb{N}$, of amplitude $A$, period $T$ and duty cycle $1/T$
$$ f(t) = \left\{\begin{matrix} A, & \mathrm{if}\;t=Tn\\ 0, & \mathrm{if}\;t\neq Tn \end{matrix}\right. \;,\; n \in \mathbb{N} $$
size = 23
T = 5
A = 10
t = np.arange(size)
f = np.zeros(size)
f[t%T==0] = A
fig, ax = plt.subplots(figsize=(12, 5))
ax.step(t, f)
ax.set(
xticks=t,
xlabel='time $t$',
ylabel='amplitude $A$',
title=f"Square wave of amplitude {A}, period {T} and duty cycle 1/{T}"
)
plt.show()
Given the Fourier series
$$ \mathcal{F}[g(t)] = a_0 + \sum_{h=1}^{\infty} a_h \cos(2 \pi h \nu \cdot t) - \sum_{h=1}^{\infty} b_h \sin(2 \pi h \nu \cdot t) $$
for this square wave
$$ a_0 = \frac{A}{T} $$
$$ a_h = \frac{2A}{\pi h} \sin \left( \frac{\pi h}{T} \right) $$
$$ b_h = 0 $$
so
$$ \mathcal{F}[f(t)] = \frac{A}{T} + \sum_{h=1}^{\infty} \frac{2A}{\pi h} \sin\left(\frac{\pi h}{T}\right) \cos\left(\frac{2 \pi h}{T} \cdot t\right) $$
where the Fourier coefficients of harmonic $h$ is $\frac{2A}{\pi h} \sin\left(\frac{\pi h}{T}\right)$.
The discrete difference of $f(t)$
$$ f'(t) = f(t) - f(t-1) $$
is the sum of two square waves $f(t)$ and $-f(t-1)$ with opposite amplitude and shifted by a sample unit
$$ f'(t) = \left\{\begin{matrix} +A, & \mathrm{if}\;t=Tn\\ -A, & \mathrm{if}\;t=Tn+1\\ 0, & \mathrm{otherwise} \end{matrix}\right. \;,\; n \in \mathbb{N} $$
t1 = t[1:]
f1 = np.diff(f)
fig, ax = plt.subplots(figsize=(12, 5))
ax.step(t1, f1)
ax.set(
xticks=t,
xlabel='time $t$',
ylabel='amplitude $A$',
title=f"Discrete difference of a square wave of amplitude {A}, period {T} and duty cycle 1/{T}"
)
plt.show()
We can thus say (is it correct?) that the Fourier series of $f'(t)$ is the sum of the Fourier series $\mathcal{F}[f(t)]$ and $\mathcal{F}[-f(t-1)]$
$$ \mathcal{F}[f'(t)] = \left[ \frac{A}{T} + \sum_{h=1}^{\infty} \frac{2A}{\pi h} \sin\left(\frac{\pi h}{T}\right) \cos\left(\frac{2 \pi h}{T} \cdot t\right) \right] - \left[ \frac{A}{T} + \sum_{h=1}^{\infty} \frac{2A}{\pi h} \sin\left(\frac{\pi h}{T}\right) \cos\left(\frac{2 \pi h}{T} \cdot (t-1)\right) \right] $$
$$ \mathcal{F}[f'(t)] = \sum_{h=1}^{\infty} \frac{2A}{\pi h} \sin\left( \frac{\pi h}{T}\right) \left[ \cos\left( \frac{2 \pi h}{T} \cdot t\right) - \cos\left( \frac{2 \pi h}{T} \cdot (t-1)\right) \right] $$
How can I get the Fourier coefficient of harmonic $h$ from $\mathcal{F}[f'(t)]$?
Is there a better way to express the Fourier series of $f'(t)$?
EDIT #1
As @MattL. noticed (see comments) what I'm dealing with is actually a discrete-time signal, so a better representation of the signal would be
and for the discrete difference will look like