I can't really make sense of those equations, but it looks something like the statement that for any $ a, b \in \mathbb{R} $, then for $ r = \sqrt{a^2 + b^2 }$ and $ \phi = \arctan(b/a) $ we have
$ a \sin(\theta) + b \cos(\theta) = r \sin(\theta + \phi).$
If you visualize x and y axes with $ cos(\theta) $ along the x-axis and $ sin(\theta) $ along the y-axis, then this says we can identify any sinusoidal, i.e. any function like $ r \sin(\theta + \phi) $, by its cartesian coordinates $(a,b)$ in this plane, or its polar coordinate $(r, \phi )$. $r$ is called the magnitude of the sinusodial, and $ \phi $ the phase.
This is directly related to Fourier Analysis. The main idea in Fourier Analysis is to decompose a function into its sinusodial components. For instance, if $f$ is a real-valued function on the interval $ [0, 2\pi] $ that is suitably regular, it turns out you can write $f$ uniquely as an infinite sum of sine and cosines, called the Fourier Series:
$ f(x) = a_0 + \sum_{n=1}^{\infty} (a_n \cos(nx) + b_n \sin(nx)). $
The numbers $ a_n $ and $ b_n $ are called the Fourier coefficients of your function.
I think this representation of Fourier series is sometimes difficult to grasp. But using the relationship above, we see we could have also wrote:
$ f(x) = a_0 + \sum_{n=1}^{\infty} r_n \sin(nx + \phi_n) $
In this form I think you can see more clearly what's going on: For each $n$, there is only one sinusoidal component of $f$ of frequency $n$; $r_n = \sqrt{a_n^2 +b_n^2}$ tells you its magnitude and $\phi_n$ tells you its phase.
The approach I propose as a reference is to take
$$t=(0:dt:1)*T\tag{1}$$
But your approach with
$$t = (-1+dt:dt:1)*T/2;\tag{2}$$
is perfectly valid under the condition that the "differential element" $dt$ (= $\Delta t$) is divided by 2 (see below the line with comments %%%%%%%%%).
Why that ? Because in case (2), one uses twice as many values of $f$ than in case (1), therefore it has to be compensated by taking a differential element divided by 2 !
Please note that factors $(2/T)$ are to be kept in front of formulas for $A(n)$ and $B(n)$.
function m;
clear all;close all;hold on;
dt = 1/1000;
T = 1; % signal period
% Approach (1):
% t = (0:dt:1)*T;
% f=2*sin(2*pi*t)+0.5*cos(2*pi*5*t)+3*cos(2*pi*3*t);
% plot(t,f,'c','linewidth',3);
% "Your" approach (2)... perfectly valid:
t=(-1+dt:dt:1)*T/2;
dt=dt/2; % <- %%%%%%%%%%%%... under this condition
% (that will be applied later on)
f =2*sin(2*pi*t)+0.5*cos(2*pi*5*t)+3*cos(2*pi*3*t);
plot(t,f,'c','linewidth',3)
plot(t,f,'c','linewidth',3)
N = 5;
get_fourier_trigo(f, T, t, dt, N, 1);
%
function get_fourier_trigo(f, T, t, dt, N, k_plot)
s='rgbcmyrgbcmy';
A0 = (2/T)*sum(f)*dt;
fFS = A0/2;
u=t*2*pi/T;
for n=1:N
A(n) = (2/T)*sum(f.*cos(n*u))*dt
B(n) = (2/T)*sum(f.*sin(n*u))*dt
fFS = fFS + A(n)*cos(n*u) + B(n)*sin(n*u);
c=s(n); % plotting color
plot(t, fFS, '-','color',c, 'LineWidth', 0.5, 'DisplayName', int2str(n));
end
title('Fourier Series')
legend show
Best Answer
My attempt to answer your question
Given that $\sqrt{-1} = j$, the exponential fourier series can describe periodic functions, with period $T_c$, that take on complex values. It can be denoted as follows
$$ f(t) = \sum_{n = - \infty}^{\infty}X_ne^{jn\omega_c t} $$
$$$$
$$ Xn = \frac{\left< f(t), e^{jn\omega_c t} \right>_{PP}}{{\| e^{jn\omega_c t} \|}^2} = \frac{1}{T}\int_{a -T/2}^{a + T/2} f(t)e^{-jn\omega_c t}dt $$
$$ X_n = |X_n|\angle \theta_n $$
Here, $f(t)$ can take on complex values because both $X_n$ and $e^{jn\omega_c t}$ take on complex values. If you want to describe a complex function with other functions, those other functions have to be complex too. (Notice how the inner product takes the complex conjugate of the second function in $X_n$)
$$$$
The trigonometric fourier series can only describe periodic functions, with period $T_c$, that take on real values (The major difference). It can be denoted as follows
$$ f(t) = a_0 + \sum_{n = 1}^{\infty}a_n \cos(n\omega_c t) + \sum_{n = 1}^{\infty}b_n \sin(n\omega_c t)$$
$$$$
$$ a_v = \frac{a_0}{2} = \frac{\left< f(t), 1 \right>_{PP}}{{\| 1 \|}^2} = \frac{1}{T}\int_{a-T/2}^{a+T/2} f(t)dt $$
$$ a_n = \frac{\left< f(t), \cos( n\omega_c t) \right>_{PP}}{{\| \cos( n\omega_c t) \|}^2} = \frac{2}{T}\int_{a-T/2}^{a+T/2} f(t)\cos( n\omega_c t)dt $$
$$ b_n = \frac{\left< f(t), \sin( n\omega_c t) \right>_{PP}}{{\| \sin( n\omega_c t) \|}^2} = \frac{2}{T}\int_{a-T/2}^{a+T/2} f(t)\sin( n\omega_c t)dt $$
Here the trigonometric functions, and the constant $1$, are restricted to take on only real values, and thus $f(t)$ can only take on real values.
$$$$
My attempt to show the connection between the two fourier series
For real values of $f(t)$ the exponential fourier series can be simplified to
$$ f(t) = X_0 + 2\sum_{n = 1}^{\infty}|X_n|\cos(n\omega_c t + \theta_n) $$
This should remind you of the compact trigonometric fourier series which can be denoted as follows
$$ f(t) = \frac{C_0 \cos(\theta_0)}{2} + \sum_{n = 1}^{\infty}C_n\cos(n\omega_c t + \theta_n) $$
$$$$
$$ C_n = \sqrt{(a_n)^2 + (b_n)^2} $$
$$ \theta_n = \begin{cases} -\arctan(\frac{b_n}{a_n}) &; \space a_n \geq 0 \\ \pi -\arctan(\frac{b_n}{a_n}) &; \space a_n \lt 0 \end{cases} $$
We can confirm the first term, knowing $b_0 = 0$, by looking at the following evaluation
$$ \theta_0 = \begin{cases} 0 &; \space a_n \geq 0 \\ \pi &; \space a_n \lt 0 \end{cases} $$
$$ \theta_0 = \text{sign}(a_n)$$
$$ C_0 = \sqrt{ (a_n)^2} = |a_n|$$
$$ C_0 cos(\theta_0) = |a_n| \text{sign}(a_0) = a_0 $$
$$$$
We can thus make the following observation regarding the different coefficients
$$ C_n = 2|X_n| \space , \space \space n \geq 0 $$
$$$$
Conclusion
From the above definitions, we can derive the following combining definition
$$ X_n = \frac{a_n - jb_n}{2} $$