1> A = [1 1+0.5e-15 3; 2 2 20; 3 6 4] A = 1.0000 1.0000 3.0000 2.0000 2.0000 20.0000 3.0000 6.0000 4.0000 2> 2> [l, u, p] = lu(A) l = 1.00000 0.00000 0.00000 0.66667 1.00000 0.00000 0.33333 0.50000 1.00000 u = 3.00000 6.00000 4.00000 0.00000 -2.00000 17.33333 0.00000 0.00000 -7.00000 p = Permutation Matrix 0 0 1 0 1 0 1 0 0 3> p * A - l * u ans = 0 0 0 0 0 0 0 0 0 4> hilb(4) ans = 1.00000 0.50000 0.33333 0.25000 0.50000 0.33333 0.25000 0.20000 0.33333 0.25000 0.20000 0.16667 0.25000 0.20000 0.16667 0.14286 5> help sol `sol' is a function from the file C:\Documents and Settings\rudiger.achilles\desktop\sol.m SOL(A,b) Trova la soluzione di un sistema lineare A*x = b utilizzando la fattorizzazione di Gauss con pivoting per righe. Additional help for built-in functions and operators is available in the on-line version of the manual. Use the command `doc ' to search the manual index. Help and information about Octave is also available on the WWW at http://www.octave.org and via the help@octave.org mailing list. 6> clear A 7> A = hilb(13); 8> x = ones(13,1); 9> b = A * x b = 3.18013 2.25156 1.81823 1.54740 1.35622 1.21177 1.09774 1.00488 0.92750 0.86184 0.80532 0.75608 0.71275 10> x_calc = sol(A,b) x_calc = 1.00000 0.99999 1.00037 0.99400 1.05308 0.71559 1.98219 -1.25796 4.49045 -2.58490 3.34539 0.11545 1.14635 11> err_rel = norm(x - x_calc)/norm(x) err_rel = 1.6981 12> % errore percentuale 12> err_rel * 100 ans = 169.81 13> sqrt(13) ans = 3.6056 14> norm(x) ans = 3.6056 15> clear x 16> x = linspace(-1,10); 17> y = 2 * exp(3*x); 18> plot(x,y) 19> semilogy(x,y) 20> for n = 1 : 100 > A = hilb(n); x = ones(n,1); b = A * x; > x_calc = sol(A,b); > err_rel(n) = norm(x - x_calc)/norm(x); > [l, u, p] = lu(A); > r(n) = max(max(abs(l*u - p*A))); > end; 21> size(err_rel) ans = 1 100 22> semilogy(1:100,err_rel,1:100,r,'r') 23> grid on 24> cond(5) ans = 1 25> cond(hilb(5)) ans = 4.7661e+005 26> cond(hilb(1)) ans = 1 27> cond(hilb(2)) ans = 19.281 28> cond(hilb(100)) ans = 1.4641e+019 29> quit