clc; clear; close all;

n = 10;
A = hilb(n);

cond_A = cond(A);
fprintf('cond(A) = %e\n\n', cond_A);

x_exact = ones(n, 1);
b = A * x_exact;

x_inv = inv(A) * b;
x_backslash = A \ b;

err_inv = norm(x_inv - x_exact);
err_backslash = norm(x_backslash - x_exact);

fprintf('Error using inv(A)*b : %e\n', err_inv);
fprintf('Error using A\\b     : %e\n', err_backslash);

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: