function ext=derzeros3(n) tau = cos( (0:n)*pi/n ); % nodes t = linspace( -1, 1, 20*n+1 ); rho = [ones(1,n+1); zeros(1,n+1); zeros(1,n+1)]; % data r = rho(:); r(4) = 1.5; % bump in curve [w,D] = genbarywts( tau, 3 ); % get barycentric weights % Now differentiate at nodes and set up companion pencil for p' [C0,C1] = gcmp( D*r/norm(D*r,inf), tau, 3, w/norm(w,inf) ); ext = eig( C0, C1 ); % locate extrema yext = hermiteval( r, ext, tau, 3, w, D ); % extremal heights [y,yp] = hermiteval( r, t, tau, 3, w, D ); % evaluate interpolant plot( tau,r(1:3:3*n+1),'bo', t,y, ext,yext,'r+' ); axis( [-1,1,0,2] );