Effects of interchanging sine terms with cosine terms

Suppose we have a real signal $x(t)$. Now, we know that $x(t)$ can be represented as a sum of sines and cosines. w be the angular frequency.

• If $a(\omega)$ be the coefficients of the cosine terms, and $b(\omega)$ be the coefficients of the sine terms, then if we perform a transformation on this signal such that now $b(\omega)$ are the coefficients of not sines but cosines and similarly, $a(\omega)$ the coefficients of the sines, then how will the waveform transform$[x(t)]$ look like?

• What will be the similarity between this transformed waveform and the original waveform?

• What is the name for this transformation (is it Hilbert transformation? )

Please attach graphs for an example $x(t)$ to clarify.

• Is this a homework problem? If yes, can you post what progress you have made and where you are stuck? – MBaz Mar 19 '17 at 16:03
• No. It is not a homework problem but a thought that sprung into my mind while reading single sideband modulation. The signal to be transmitted is passed through two branches: in one, it is frequency shifted upwards by a cosine wave and in the other, it is multiplied by a negative sine pulse (of same frequency as cosine) and later is Hilbert transformed. Signals from these two branches are added up at last. – Ayush Pandey Mar 19 '17 at 16:30
• This response may help give you insight: dsp.stackexchange.com/questions/31355/… – Dan Boschen Mar 19 '17 at 19:53
• Are talking about a periodic signal $x(t)$? You refer to coefficients $a$ and $b$, but you write them as functions of $\omega$. – Matt L. Mar 20 '17 at 8:22
• yes, books present the components as a integer variable k. I am choosing variable w = (k).(fundamental frequency), and so doesn't bring about any difference. You have still got the stuff what is being asked. – Ayush Pandey Mar 20 '17 at 11:38

If you have a $T$-periodic signal $x(t)$ with a Fourier series expansion

$$x(t)=a_0+\sum_{n=1}^{\infty}\left[a_n\cos(n\omega_0t)+b_n\sin(n\omega_0t)\right],\quad \omega_0=\frac{2\pi}{T}\tag{1}$$

then its Hilbert transform is given by

$$\mathcal{H}\{x(t)\}=\hat{x}(t)=\sum_{n=1}^{\infty}\left[a_n\sin(n\omega_0t)-b_n\cos(n\omega_0t)\right]\tag{2}$$

because $\mathcal{H}\{\cos(t)\}=\sin(t)$, $\mathcal{H}\{\sin(t)\}=-\cos(t)$, and $\mathcal{H}\{c\}=0$ for constant $c$.

This is not exactly the same as just swapping the coefficients $a_n$ and $b_n$. The signal with swapped coefficients (assuming $a_0=0$) is

$$y(t)=\sum_{n=1}^{\infty}\left[a_n\sin(n\omega_0t)+b_n\cos(n\omega_0t)\right]$$

which is related to $\hat{x}(t)$ by

$$y(t)=-\hat{x}(-t)\tag{3}$$

It is also equal to the Hilbert transform of $x(-t)$:

$$y(t)=\mathcal{H}\{x(-t)\}\tag{4}$$

So swapping the coefficients is equivalent to applying a linear time-varying system to the signal. It cannot be achieved by a Hilbert transform alone (which is a time-invariant operation).

Note that for even signals ($b_n=0$) and for odd signals ($a_n=0$) one does indeed obtain the Hilbert transform (for odd signals with a negative sign) by swapping coefficients. This is shown in the example in hops's answer.

I will base my answer on the following definitions until I hear otherwise from you. I will use $T$ as the fundamental period of the periodic signal $x(t)$. So, $\omega$ takes on discrete values at $\omega = \frac{2 \pi}{T} k$ where $k$ varies over all non-negative integers ($0, 1, 2, \cdots, \infty$). The underlying signal may then be decomposed into $$x(t) = a_0 + \sum_{k=1}^{\infty} a_k \cos\left(\frac{2\pi}{T} k t\right) + b_k \sin\left(\frac{2\pi}{T} k t\right).$$ I'm changing notations to something more natural for me, $a_k = a\left(\frac{2\pi}{T}k\right)$ and similarly $b_k = b\left(\frac{2\pi}{T}k\right)$.

Example 1: Let's consider a simple example. Perhaps the simplest non-trivial example (definitions of trivial may vary). Take $$x(t) = \left\{\begin{array}{cc}A&x \geq 0\\ -A & x < 0\end{array}\right.$$ The Fourier Series coefficients for this function (given as a sum of sines and cosines) with a fundamental period $T$ is given as $$a_k = \frac{1}{T} \int_{-T/2}^{T/2} x(t) \cos \left( \frac{2\pi}{T} k t\right)dt$$ and $$b_k = \frac{1}{T} \int_{-T/2}^{T/2} x(t) \sin \left( \frac{2\pi}{T} k t\right)dt.$$ All of the $a_k = 0$ since the integrand is odd (an even function times an odd function is odd). So, we only need to consider the $b_k$. Cranking through the calculus, we find that $$b_k = \left\{\begin{array}{cc}0 & \mbox{k is even}\\ \frac{4 A}{\pi k} & \mbox{k is odd}\end{array}\right.$$

The MATLAB code below can be used to construct an approximation of both signals (using $a_k$ and $b_k$ conventionally and using them swapped).

A = 1;
T = 1;
N = 1000;

t = (-0.5*T:0.0001*T:0.5*T).';
x = zeros(size(t));
y = zeros(size(t));

for k = 1:2:N
x = x + 4 * A / (pi*k) * cos(2*pi*k/T*t);
y = y + 4 * A / (pi*k) * sin(2*pi*k/T*t);
end

figure()
plot(t, x)
xlabel('time')
ylabel('signal')
title('Using a_k and b_k')

figure()
plot(t, y)
xlabel('time')
ylabel('signal')
title('Swapping a_k and b_k')

The images below show that indeed, for this particular example, swapping the $a_k$ and $b_k$ yields (if not exactly then a scalar multiple of) the Hilbert Transform. It doesn't seem like a very practical way to obtain it though, and I haven't proven that it works in general for all periodic signals.

• The result in your figure equals $-\hat{x}(-t)$, where $\hat{x}(t)$ is the Hilbert transform of $x(t)$. Since $x(t)$ is odd, its Hilbert transform is even, so you get $-\hat{x}(t)$, which is just the Hilbert transform with a negative sign. Note that this is just the case because you have an odd signal. For an even signal you would indeed simply get the Hilbert transform by swapping the coefficients. For general signals, you can't obtain the Hilbert transform by just swapping the coefficients. – Matt L. Mar 23 '17 at 12:49
• Thanks for the clarification @MattL. I suspected something like that was happening, but I didn't have much time to investigate. – hops Mar 23 '17 at 14:44

Let us just run a quick simulation and try ourselves. Assume we have a signal $s[n] = A \cos{(2 \pi \frac{f}{Fs} n )}$

A = 1000;
x = 0:1000;
f = 2;
Fs = 50;
s = A*cos(2*pi*f/Fs.*x);
F = fit(x(:),s(:),'fourier2');

I am using fourier series fitting upto 2 coefficients i.e., $(a_0, a_1, a_2)$ for the cosine term and $(b_1, b_2)$ for the sine term. $F$ will have a general model:

$$F(x) = a_0 + a_1 \cos{(\omega x)} + b_1 \sin{(\omega x)} + a_2 \cos{(2\omega x)} + b_2 \sin{(2 \omega x)}$$

Let us now flip the coefficients and see what happens to the phase of the new signal.

G = @(x) F.b1*cos(x.*F.w) + F.a1*sin(x.*F.w) + F.b2*cos(2.*x.*F.w) + F.a2*sin(2.*x.*F.w)
plot(x,s,x,G(x)); % To see the difference visually

h1 = hilbert(s);
h2 = hilbert(G(x));

phase_offset = mean(angle(h1./h2));

You will see the phase offset is about $1.57$ i.e. $\pi/2$. Basically switching the coefficients changes the phase of the signal.

You can also see this mathematically:

$$s(t) = a_0 + \sum\limits_{n=1}^{\infty} a_n \cos{(n\omega_0 t)} + b_n \sin{(n\omega_0 t)}$$

Now if you were to reverse the signal in time and change the phase of these sine and cosine terms by $\pi/2$, i.e.,

$$s^{'}(t) = a_0 + \sum\limits_{n=1}^{\infty} a_n \cos{(\pi/2 - n\omega_0 t)} + b_n \sin{(\pi/2 - n\omega_0 t)}$$

which is nothing but

$$s^{'}(t) = a_0 + \sum\limits_{n=1}^{\infty} b_n \cos{(n\omega_0 t)} + a_n \sin{(n\omega_0 t)}$$

• uhm $$\sin(n \omega_0 t - \pi/2)$$ is not $$+\cos(n \omega_0 t)$$. – robert bristow-johnson Mar 24 '17 at 4:33
• Yes! you are right. I'll edit my answer. Thanks for pointing it out. – Amal Mar 24 '17 at 14:24
• Your signal is a single sinusoid, so it can be represented by a single Fourier series coefficient. – Matt L. Mar 24 '17 at 16:22