11-Dec-2013 1> % i due esempi di sistemi lineari della lezione 1> A = [2 1 -1 -3; 4 2 1 -3; 2 -1 3 5; 3 -1 -1 1] A = 2 1 -1 -3 4 2 1 -3 2 -1 3 5 3 -1 -1 1 2> b = [-5 -7 11 8]' b = -5 -7 11 8 3> b2 = [-5 -7 11 9]' b2 = -5 -7 11 9 4> % risolvere il sistema lineare Ax = b 4> x = A\b x = 1.00000 -1.66667 -1.16667 2.16667 5> % la nostra soluzione a mano 5> sol = [1 -6 1 0]' + 13/6 * [0 2 -1 1]' sol = 1.0000 -1.6667 -1.1667 2.1667 6> rank(A) ans = 3 7> [A, b] ans = 2 1 -1 -3 -5 4 2 1 -3 -7 2 -1 3 5 11 3 -1 -1 1 8 8> rank([A, b]) ans = 3 9> % soluzione di A * x = 0 9> null(A) ans = 0.00000 0.81650 -0.40825 0.40825 10> v = [0 2 -1 1]'; 11> norm(v), sqrt(6) ans = 2.4495 ans = 2.4495 12> v/norm(v) ans = 0.00000 0.81650 -0.40825 0.40825 13> det(A) ans = 8.6597e-015 14> cond(A) ans = 2.3082e+016 15> % fattorizzazione P * A = L * U 15> [L U P] = lu(A) L = 1.00000 0.00000 0.00000 0.00000 0.75000 1.00000 0.00000 0.00000 0.50000 0.80000 1.00000 0.00000 0.50000 -0.00000 -0.38462 1.00000 U = 4.00000 2.00000 1.00000 -3.00000 0.00000 -2.50000 -1.75000 3.25000 0.00000 0.00000 3.90000 3.90000 0.00000 0.00000 0.00000 -0.00000 P = Permutation Matrix 0 1 0 0 0 0 0 1 0 0 1 0 1 0 0 0 16> sol(A,b) error: subscript indices must be either positive integers or logicals 16> help sol 'sol' is a function from the file C:\cygwin\home\achilles\programmi_matlab\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 online 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. 17> x2 = A\b2 x2 = 1.1599 -1.8184 -1.4051 2.2317 18> rank([A, b2]) ans = 4 19> quit