Periodic Functions

This is a general program for the evaluation of the coefficients of the Fourier series expansions of periodic functions:

f(X) = A0/2+ A1* COS(W1*X) + A2*cos(W2*X) + ...+ An*cos(WnX) +..

+B1*sin( W1*X)+B2*sin(W2*X)+...+ B3*cos(Wn*X)

where Wn = (2*pi+N)/T, pi=3.14..., and T being the period of the function.

Program Notes

f (X) can be defined using a Function F(X) statement as shown in the program or piecewise (in which case the
coordinates of the vertices must be input)

The maximum number of Fourier coefficients that can be computed using this program is limited to

10. To modify this change:
DIM Q(N), DIM R(N)
where N is the maximum number of coefficients

The number of intervals for the numerical integration is set in this line:

M=N8*J
in which J is the order of the coefficients + 1,
and N 8 is set equal to 20. 

In order to reduce the computation time (when computing more than five coefficients) either of these statements can be modified as needed.

Downloads:

basic program (liberty basic) lbfsapf.bas

Test Case:

Compute the first five coefficients of the Fourier expansion of the sawtooth function shown below: