Fourier series
One type of spectral analysis is called Fourier or harmonic decomposition. Its based on the theory, that any periodic function can be expressed as the sum, or series of sinusoidal functions. If a periodic function is expressed this way, each component in the series must be periodic over the same interval as the original function. The components are integer multiples or harmonics of the original functions fundamental (base) frequency. This decomposition is described by the following formulas:
,
or in complex form
,
where
,
and
are the Fourier coefficients.
Let us see this decomposition in case of some practical waveforms:
Triangle wave
![]()
Square wave
![]()
Let us demonstrate the above theorem with Tina in case of a square
wave of f=1kHz frequency and 1V amplitude up to three sine waves. The
easiest way is to put together a simple circuit (fourex1.sch). The
circuit consists of three sine wave generators connected in series
and the reference square wave generator. The frequencies of the sine
wave generators are
,
and
,
however the amplitudes are
and
according to the above formula.

The result of the transient analysis can be seen on the following figure.

Note that the above figure was entirely made by Tina using its
Equation Editor in the Diagram Window. For example the
is
described in the following way in the Equation Editors text
mode: \i(f,1)=\f(4,\s(p))sin(\s(w)t) as it can be seen on the next figure.

If you press the View button
you can preview the formula in the Equation Editor. Press the Edit
button
to return into the text mode if you want to make further changes.
Finally press the Copy button
to place the formula in the Diagram Window.

Obviously if you connected more than 3 generators in series, you would have achieved a better match. There is an easy way to demonstrate this statement. Using Tinas Interpreter you can easily write a function that calculates the sum of any number of sine waves (fourex1.ipr).
Function Square(t, n);
{Sum of n sine waves, n: number of
sine waves, t: time}
Begin
f := 1k;
w := 2 * pi * f;
x := 0;
For i := 0 To n - 1 Do
x := x + 1 / (2 * i + 1) *
sin((2 * i + 1) * w * t);
Square := 4 / pi * x;
End;
{Sum of 20 sine waves}
Draw(Square(Time, 20), Square);
To run the above example invoke the Interpreter from the Tools menu,
type in the above text or read in fourex1.ipr by selecting the Open
command from the File menu. If you press the Run
button after a short calculation the following function appears:

The more sine waves you would sum up the better match you would get. Note however the small peaks at the edges of the square wave. This is called Gibbs phenomenon. According to the mathematical theory the Fourier series can not approximate properly non-continuous functions in the point of discontinuity. In case of a square wave there will always be 18% overrun at the edges at any number of approximating sine waves. Let us demonstrate this with 100 harmonics; simple change 20 to 100 in the Draw command of the above example (fourex1.ipr)

However there are methods which improve the convergence of the Fourier series near the discontinuity. The essence of these techniques is to modify the Fourier coefficients by multiplying each coefficient by a weight factor. This method is also called window function technique. Two Hungarian mathematicians - Fejér, and Lánczos - invented such window functions that are commonly used in practice.
In practice however there are no discontinuous waveforms though to
the rise/fall time could be very short in comparison to the period
time. This means, that the Fourier series will always converge. Let
us demonstrate this with the approximation of the triangular waveform
with just 3 harmonics using the above circuit. Change the amplitude
of the sinusoidal generators to
,
and
.
Change the waveform of the reference generator to triangle wave (fourex12.sch).

In practice of course you use the Fourier series option of TINA in opposite direction. You have a periodic function and you want to know the Fourier components. To get them in Tina first you have to run a transient analysis and then in the appearing Diagram window select a curve. Then in the diagram window you have to select Fourier series from the Process menu. After selecting this menu item Tina performs a harmonic decomposition, calculating the Fourier coefficients for the sinusoidal components of any voltage or current. After you select Fourier series a dialog box appears, where you have to set the sampling start time, the base frequency, the number of samples, the number of harmonics, and the format.
Example: Let us determine the Fourier decomposition of the previous square wave (f=1kHz, A=1V). We will compare the theoretical decomposition with the result calculated by TINA.
The Fourier series of a square wave function is
.
Because square wave function is an odd function
,
all the coefficients
,
and
,
too. Comparing the above function with the definition of the Fourier
series its quite clear that:
,
,
,
,
.
In Tina we get approximately the same result. However due to
numerical inaccuracy we dont get exactly 0 for the
theoretically 0 coefficients. If you examine these values more
carefully youll see, that they are not significant because they
are
times less than the fundamental value.
Load this example (fourex2.sch). Run transient analysis then select
the appearing square wave and choose Fourier series from the Process
menu. In the dialog box change the default format from complex
representation /
/
to real representation /
/.

If you have set all the parameters, press Calculate. At the bottom of the dialog box the Fourier coefficients appear. Tina allows you to use these values in other programs. Every time you press Calculate the coefficients are placed not only at the bottom of the dialog box but on the clipboard, as well. You can import this table of Fourier components in other programs, for example Word or Excel to process.
|
Harmonics |
Amplitude (A) |
Amplitude (B) |
|
0. |
0 |
0 |
|
1. |
976.56u |
1.27 |
|
2. |
-1.15n |
-749.01n |
|
3. |
976.56u |
424.41m |
|
4. |
-4.6n |
-1.5u |
|
5. |
976.56u |
254.64m |
Its also possible to evaluate the above result graphically. You only need to press Draw, then Tina generates you a diagram with the Fourier coefficients.

You can also get complex Fourier components with Tina. To do this select the complex representation in the Fourier series dialog box and press Calculate again. On the following three figures youll see the harmonic decomposition of the same sine wave (f=1kHz, A=1V) but this time using the complex representation. On the first figure the dialog box can be seen, on the next the Fourier coefficients as they are placed on the clipboard, and on the last the graphical representation of the result.

|
Harmonics |
Amplitude (A) |
Phase (ø) |
|
0. |
0 |
0 |
|
1. |
636.62m |
-89.96 |
|
2. |
374.51n |
90.09 |
|
3. |
212.21m |
-89.87 |
|
4. |
749.01n |
90.18 |
|
5. |
127.32m |
-89.78 |

To compare this result with the previous one we have to perform a
simple mathematical transformation. Using the Euler-formula:
or vice versa
.
From this we get, that
,
,
,
,
.
Again it is important to mention, that due to numerical inaccuracy
we dont get exactly 0 for the theoretically 0 coefficients.
Its especially true in case of the phase values. As harmonic
magnitudes become small it becomes difficult to determine phase.
Again, this is a numerical problem only.