% M13p5-remez.diary
% Matlab script to visualize the progress of the Remez exchange algorithm
% to iteratively find a polynomial that meets the alternation theorum conditions.
% 2011-11-22 Dan Ellis dpwe@ee.columbia.edu
% The animation takes you through several iterations to find a polynomial with 11
% equiripple extrema between -1 and 1. It returns the actual polynomial. At each stage,
% you see the "candidate" extrema as red circles, the lagrange polynomial fit to those
% points as a blue curve (which goes through the red circles but usually doesn't have
% actual extrema there), blue circles intersected by vertical green lines as the true
% extremal values, then shifting the red points to those frequencies followed by
% stretching the entire x axis so the ripples again cover -1 to 1.
p = remezviz2;
% In the end, the polynomial we got is of course the single 10th order equiripple
% polynomial - the same one that is described by the Chebyshev function T_5^2
xx = [-1.1:0.01:1.1];
plot(xx,polyval(p,xx),xx,chebpolyval(5,xx).^2,'.r')
axis([-1.1 1.1 -1 4]);