Integration and differentiation of periodic functions

Integration and differentiation of periodic functions using FFT
35 Downloads
Updated 15 Apr 2017

View License

% Suppose that f(t) is a real 2pi-periodic function on the interval [0,2pi]
% and the 1*n vector x is the values of the function f(t) at the n
% equidistant points (n must be even)
% t_j=(j-1)*2*pi/n, j=1,2,...,n.
% The function
% y = derfft (x)
% uses fft to find the trigonometric interpolating polynomial that
% interpolates the function f(t) at the n points t_1,t_2,...,t_n. Then the
% function derfft computes the values the periodic derivative function
% f'(t) at the above points t_j.
%
% Example
% n = 2^7;
% t = [0:2*pi/n:2*pi-2*pi/n].';
% x = sin(t).*exp(-cos(t));
% xpe = cos(t).*exp(-cos(t))+sin(t).^2.*exp(-cos(t));
% xp = derfft (x);
% error = norm(xp-xpe,inf)
%
% If the function f(t) satisfies
% \int_(0)^(2pi)f(t)dt=0 and \int_(0)^(2pi)cos(nt)f(t)dt=0
% The function
% y = intfft (x)
% uses fft to find the trigonometric interpolating polynomial that
% interpolates the function f(t) at the n points t_1,t_2,...,t_n. Then the
% function intfft computes the values a periodic antiderivative function
% g(t) at the above points t_j, i.e.,
% g(t) = \int f(t)dt
% and g(2pi)=g(0).
% Note that g(t) is only one of the antiderivatives of the function f(t)
% and hence g(t) is not unique.
%
%
% Example
% n = 2^7;
% t = [0:2*pi/n:2*pi-2*pi/n].';
% x = sin(t).*exp(-cos(t));
% xie = exp(-cos(t));
% xi = intfft (x);
% error = xi-xie %must be a constant

Cite As

Mohamed Nasser (2024). Integration and differentiation of periodic functions (https://www.mathworks.com/matlabcentral/fileexchange/62577-integration-and-differentiation-of-periodic-functions), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2016a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Fourier Analysis and Filtering in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0