HW 4.15

Nasser Abbasi

 

OUTPUT

 

This shows that N=17, the abs value of maximum element in D is close to 1. The plot of condition number vs matrix size follows the same pattern as how the maximum element size grows vs matrix size as well. We see that the condition number becomes very large when the limit of double accuracy in matlab is reached. (around 16 decimal points).

 

» nma_HW_4_15

 

 

 Program to solve problem 4.15

 by Nasser Abbasi

 

Enter the maximum number of points (N) to try for:16

Warning: Matrix is close to singular or badly scaled.

         Results may be inaccurate. RCOND = 1.158588e-016.

> In d:\nabbasi\data\nabbasi_web_page\academic\my_courses\phys_240\HW10\nma_HW_4_15.m at line 17

Warning: Matrix is close to singular or badly scaled.

         Results may be inaccurate. RCOND = 1.764763e-018.

> In d:\nabbasi\data\nabbasi_web_page\academic\my_courses\phys_240\HW10\nma_HW_4_15.m at line 17

Warning: Matrix is close to singular or badly scaled.

         Results may be inaccurate. RCOND = 2.483244e-020.

> In d:\nabbasi\data\nabbasi_web_page\academic\my_courses\phys_240\HW10\nma_HW_4_15.m at line 17

Warning: Matrix is close to singular or badly scaled.

         Results may be inaccurate. RCOND = 3.246740e-022.

> In d:\nabbasi\data\nabbasi_web_page\academic\my_courses\phys_240\HW10\nma_HW_4_15.m at line 17

Warning: Matrix is close to singular or badly scaled.

         Results may be inaccurate. RCOND = 3.964100e-024.

> In d:\nabbasi\data\nabbasi_web_page\academic\my_courses\phys_240\HW10\nma_HW_4_15.m at line 17

»

 

 

» nma_HW_4_15

 

 

 Program to solve problem 4.15

 by Nasser Abbasi

 

Enter the maximum number of points (N) to try for:20

Warning: Matrix is close to singular or badly scaled.

         Results may be inaccurate. RCOND = 1.158588e-016.

> In d:\nabbasi\data\nabbasi_web_page\academic\my_courses\phys_240\HW10\nma_HW_4_15.m at line 17

Warning: Matrix is close to singular or badly scaled.

         Results may be inaccurate. RCOND = 1.764763e-018.

> In d:\nabbasi\data\nabbasi_web_page\academic\my_courses\phys_240\HW10\nma_HW_4_15.m at line 17

Warning: Matrix is close to singular or badly scaled.

         Results may be inaccurate. RCOND = 2.483244e-020.

> In d:\nabbasi\data\nabbasi_web_page\academic\my_courses\phys_240\HW10\nma_HW_4_15.m at line 17

Warning: Matrix is close to singular or badly scaled.

         Results may be inaccurate. RCOND = 3.246740e-022.

> In d:\nabbasi\data\nabbasi_web_page\academic\my_courses\phys_240\HW10\nma_HW_4_15.m at line 17

Warning: Matrix is close to singular or badly scaled.

         Results may be inaccurate. RCOND = 3.964100e-024.

> In d:\nabbasi\data\nabbasi_web_page\academic\my_courses\phys_240\HW10\nma_HW_4_15.m at line 17

Warning: Matrix is close to singular or badly scaled.

         Results may be inaccurate. RCOND = 4.539855e-026.

> In d:\nabbasi\data\nabbasi_web_page\academic\my_courses\phys_240\HW10\nma_HW_4_15.m at line 17

Warning: Matrix is close to singular or badly scaled.

         Results may be inaccurate. RCOND = 4.892271e-028.

> In d:\nabbasi\data\nabbasi_web_page\academic\my_courses\phys_240\HW10\nma_HW_4_15.m at line 17

Warning: Matrix is close to singular or badly scaled.

         Results may be inaccurate. RCOND = 5.228577e-030.

> In d:\nabbasi\data\nabbasi_web_page\academic\my_courses\phys_240\HW10\nma_HW_4_15.m at line 17

Warning: Matrix is close to singular or badly scaled.

         Results may be inaccurate. RCOND = 5.996228e-032.

> In d:\nabbasi\data\nabbasi_web_page\academic\my_courses\phys_240\HW10\nma_HW_4_15.m at line 17

»


 

 

CODE

function nma_HW_4_15()

%

%Program to solve problem 4.15

%by Nasser Abbasi

 

clear all; help nma_HW_4_15;

 

data = struct('matrixSize',0,...

              'DmaxElement',0,...

              'VconditionNumber',0);

 

N= input('Enter the maximum number of points (N) to try for:');

 

for(i=2:N)

 

   V = generate_V(i);

   D = ( V*inv(V) ) - eye(i);

 

   data.matrixSize(i)       =  i;

   data.DmaxElement(i)      =  abs(max(max(D)));

   data.VconditionNumber(i) =  cond(V);

 

end

 

 

figure;

plot(data.matrixSize, data.DmaxElement,'-');

title('Vandermonde matrix size vs maximum element size in D');

xlabel('Matrix size N');

ylabel('abs value of maximum element in V*inv(V) - I');

set(gca,'Xtick',[1:N]);

grid on;

 

figure;

semilogy(data.matrixSize, data.DmaxElement,'-');

set(gca,'Xtick',[1:N]);

title('Vandermonde matrix size vs maximum element size in D');

xlabel('Matrix size N');

ylabel('Log of abs value of maximum element in V*inv(V) - I');

grid on;

 

figure;

plot(data.matrixSize, data.VconditionNumber,'-');

title('condition number of Vandermonde matrix vs matrix size');

xlabel('matrix size');

ylabel('condition number');

set(gca,'Xtick',[1:N]);

grid on;


 

figure;

semilogy(data.matrixSize, data.VconditionNumber,'-');

title('condition number of Vandermonde matrix vs matrix size');

xlabel('matrix size');

ylabel('Log of condition number');

set(gca,'Xtick',[1:N]);

grid on;

 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% function to generate Vendermond matrix gievn N.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function V=generate_V(N)

 

  for(i=1:N)

     for(j=1:N)

         V(i,j) = i^(j-1);

     end

  end