% choose a value for b.
b = 5;
% range over which we'll plot.
x = linspace(-3,3,1001);
% initialize the vector f.
f = zeros(size(x));
% A(alpha) and B(alpha) are independent of x, so we precompute them.
% Notes:
% * for many examples we might have alpha or alpha^2 in the
% denominator, so we linspace from 1e-6 instead of from 0
% * larger values of b may require more alpha-points for sufficient
% accuracy, so try increasing the "1001" if necessary
% * alpha is a vector here, so we put dots in front of *, ^ and /
alpha = linspace(1e-6,b,1001);
A = 0*alpha;
B = 2*alpha./(1 + alpha.^2);
% for every x we numerically integrate over alpha to approximate f(x).
for i = 1:length(x)
xx = alpha;
yy = A.*cos(alpha*x(i)) + B.*sin(alpha*x(i));
f(i) = (1/pi)*trapz(xx,yy);
end
% plot the result.
figure
plot(x,f,'linewidth',2)
grid on