In: Computer Science
. Let xj , j = 1, . . . n be n distinct values. Let yj be any n values. Let p(x) = c1 + c2x + c3x 2 + · · · + cn x ^n−1 be the unique polynomial that interpolates the data (xj , yj ), j = 1, . . . , n (Vandermonde approach).
(a) Remember that (xj , yj ), j = 1, . . . , n are given. Derive the n × n system Ac = b that determines the coefficients ck (as we did in class for n = 4).
(b) Write a MATLAB script that sets up the Vandermonde matrix V for any given vector x.
(c) Find the condition number (infinity norm) of the matrix V where x consists of n = 10, 20, 30, 40 equally spaced points spanning the interval [0, 1]. Report your results in a table of each n
=== (a) ===
The given "n" points must satisfy the equation of the polynomial as:
This can be re-arranged in the matrix form as:
This can be rearranged in "" form as:
Here:
=== (b) ===
To write the MATLAB script, we require two inputs of "n" and "x". Assuming this, the required script is written as the following:
%=================================================================
format long
clear all;clc;
x = [1 4 -6 7]'; % sample x vector
n = length(x);
V=[];
for i=1:n
V = [V x.^(i-1)];
end
display(V)
% Alternatively, vander command can be used
V_inbuilt = fliplr(vander(x));
display(V_inbuilt)
%=================================================================
Output image:
===== (c) =====
format long
clear all;clc;
fprintf('Condition number\t n\n');
for n=[10,20,30,40];
x = linspace(0,1,n); % Equally spaced points
V = fliplr(vander(x)); % Vandermonde matrix
Cond_no = max(sum(V,2)); % Condition number (infinity norm)
fprintf('\t%d\t\t\t%f\n',n,Cond_no)
end
Output image