% Compute the relative condition numbers of
% the roots x_1, x_2, ..., x_{20} of the Wilkinson polynomial w(x) = (x-1)(x-2)\ldots(x-20)
% with respect to perturbation of the coefficient of the term x^{19}, a_{19} = -210,
% from -210 to, for instance, -210+2^{-23}.
% (condition number for the j-th root is kappa(x_j) = |a_{19} x_j^{18}|/|w'(x_j)|.)
clc; clear all; close all;
x = [1:20]'; % 20 roots of w
W = poly(x); % coefficients of w
derW = polyder(W); % coefficients of derivative of w
kappa = zeros(20,1);
derWval = zeros(20,1);
for j = 1:20 % for the j-th root compute condition number
derWval(j) = polyval(derW,j);
kappa(j) = abs(W(2)*j^18/derWval(j));
% note W(2) corresponds to a_19:
% coefficients are numbered in descending powers of the polynomial
end
format long e;
kappa