f = @(x) x.^5;
n = 5;
for i=0:n
tarray(i+1) = i/n;
end
for j=1:(n+1)
for i=1:(n+1)
matrix(j,i) = tarray(i).^(j-1);
end
end
matrix
for i=1:(n+1)
matrixanswer(i) = f(tarray(i));
end
matrixanswer
matrixanswer = matrixanswer'
c = cond(matrix)
solution = matrix\matrixanswer
residualvector = (matrix*solution) - matrixanswer;
fprintf('The Condition of the Row-Based N=5 matrix is %2.5f and the solution is\n', c);
solution
fprintf('And the Residual Vector is \n');
residualvector
for i=1:(n+1)
for j=1:(n+1)
matrix2(i,j) = tarray(i).^(j-1);
end
end
for i=1:(n+1)
matrixanswer2(i) = f(tarray(i));
end
matrixanswer2 = matrixanswer2';
c = cond(matrix2);
solution = matrix2\matrixanswer2;
residualvector = (matrix2*solution) - matrixanswer2;
fprintf('The Condition of the Column-Based N=5 matrix is %2.5f and the solution is\n', c);
solution
fprintf('And the Residual Vector is \n');
residualvector
% f = @(x) x.^5;
% n = 30;
%
%
%
% for i=0:n
% tarray(i+1) = i/n;
% end
% for j=1:(n+1)
% for i=1:(n+1)
%
% matrix(j,i) = tarray(i).^(j-1);
% end
% end
% matrix
% for i=1:(n+1)
% matrixanswer(i) = f(tarray(i));
% end
% matrixanswer
% matrixanswer = matrixanswer'
% c = cond(matrix)
% solution = matrix\matrixanswer
% residualvector = (matrix*solution) - matrixanswer;
%
% fprintf('The Condition of the Row-Based N=30 matrix is %2.5f and the solution is\n', c);
% solution
% fprintf('And the Residual Vector is \n');
% residualvector
%
% for i=1:(n+1)
%
% for j=1:(n+1)
%
% matrix2(i,j) = tarray(i).^(j-1);
%
% end
%
% end
% for i=1:(n+1)
%
% matrixanswer2(i) = f(tarray(i));
%
% end
% matrixanswer2 = matrixanswer2';
% c = cond(matrix2);
% solution = matrix2\matrixanswer2;
% residualvector = (matrix2*solution) - matrixanswer2;
% fprintf('The Condition of the Column-Based N = 30 matrix is %2.5f and the solution is\n', c);
% solution
% fprintf('And the Residual Vector is \n');
% residualvector