1> help lugauss `lugauss' is a function from the file C:\Documents and Settings\rudiger.achilles\desktop\lugauss.m LUGAUSS Fattorizzazione LU senza pivoting A = LUGAUSS(A) calcola la fattorizzazione LU di Gauss della matrice A, memorizzando nella parte triangolare inferiore stretta di A la matrice L (gli elementi diagonali di L sono tutti uguali a 1) ed in quella superiore il fattore U 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. 2> % Quarteroni-Saleri, p. 146, Esempio 5.8 2> 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 3> B = lugauss(A) B = 1.0000e+000 1.0000e+000 3.0000e+000 2.0000e+000 -8.8818e-016 1.4000e+001 3.0000e+000 -3.3777e+015 4.7288e+016 4> L = tril(B,-1) + eye(3) L = 1.0000e+000 0.0000e+000 0.0000e+000 2.0000e+000 1.0000e+000 0.0000e+000 3.0000e+000 -3.3777e+015 1.0000e+000 5> U = triu(B) U = 1.0000e+000 1.0000e+000 3.0000e+000 0.0000e+000 -8.8818e-016 1.4000e+001 0.0000e+000 0.0000e+000 4.7288e+016 6> A - L * U ans = 0 0 0 0 0 0 0 0 6 7> help lu `lu' is a function from the file C:\Programmi\3.2.4_gcc-4.4.0\libexec\octave\3.2.4\oct\i686-pc-mingw32\lu.oct -- Loadable Function: [L, U, P] = lu (A) -- Loadable Function: [L, U, P, Q] = lu (S) -- Loadable Function: [L, U, P, Q, R] = lu (S) -- Loadable Function: [...] = lu (S, THRES) -- Loadable Function: Y = lu (...) -- Loadable Function: [...] = lu (..., 'vector') Compute the LU decomposition of A. If A is full subroutines from LAPACK are used and if A is sparse then UMFPACK is used. The result is returned in a permuted form, according to the optional return value P. For example, given the matrix `a = [1, 2; 3, 4]', [l, u, p] = lu (a) returns l = 1.00000 0.00000 0.33333 1.00000 u = 3.00000 4.00000 0.00000 0.66667 p = 0 1 1 0 The matrix is not required to be square. Called with two or three output arguments and a spare input matrix, then "lu" does not attempt to perform sparsity preserving column permutations. Called with a fourth output argument, the sparsity preserving column transformation Q is returned, such that `P * A * Q = L * U'. Called with a fifth output argument and a sparse input matrix, then "lu" attempts to use a scaling factor R on the input matrix such that `P * (R \ A) * Q = L * U'. This typically leads to a sparser and more stable factorization. An additional input argument THRES, that defines the pivoting threshold can be given. THRES can be a scalar, in which case it defines UMFPACK pivoting tolerance for both symmetric and unsymmetric cases. If THRES is a two element vector, then the first element defines the pivoting tolerance for the unsymmetric UMFPACK pivoting strategy and the second the symmetric strategy. By default, the values defined by `spparms' are used and are by default `[0.1, 0.001]'. Given the string argument 'vector', "lu" returns the values of P Q as vector values, such that for full matrix, `A (P,:) = L * U', and `R(P,:) * A (:, Q) = L * U'. With two output arguments, returns the permuted forms of the upper and lower triangular matrices, such that `A = L * U'. With one output argument Y, then the matrix returned by the LAPACK routines is returned. If the input matrix is sparse then the matrix L is embedded into U to give a return value similar to the full case. For both full and sparse matrices, "lu" looses the permutation information. 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. 8> % qui c'e' un errore: ho voluto calcolare lu(A) 8> [l, u, p] = lu(B) l = 1.00000 0.00000 0.00000 0.66667 1.00000 0.00000 0.33333 0.50000 1.00000 u = 3.0000e+000 -3.3777e+015 4.7288e+016 0.0000e+000 2.2518e+015 -3.1525e+016 0.0000e+000 0.0000e+000 1.0000e+001 p = Permutation Matrix 0 0 1 0 1 0 1 0 0 9> p * A - l * u ans = 0.0000e+000 3.3777e+015 -4.7288e+016 0.0000e+000 1.8750e+000 7.0840e+000 0.0000e+000 -6.2500e-002 5.4199e-001 10> A A = 1.0000 1.0000 3.0000 2.0000 2.0000 20.0000 3.0000 6.0000 4.0000 11> p * A ans = 3.0000 6.0000 4.0000 2.0000 2.0000 20.0000 1.0000 1.0000 3.0000 12> l l = 1.00000 0.00000 0.00000 0.66667 1.00000 0.00000 0.33333 0.50000 1.00000 13> u u = 3.0000e+000 -3.3777e+015 4.7288e+016 0.0000e+000 2.2518e+015 -3.1525e+016 0.0000e+000 0.0000e+000 1.0000e+001 14> l*u ans = 3.0000e+000 -3.3777e+015 4.7288e+016 2.0000e+000 1.2500e-001 1.2916e+001 1.0000e+000 1.0625e+000 2.4580e+000 15> U U = 1.0000e+000 1.0000e+000 3.0000e+000 0.0000e+000 -8.8818e-016 1.4000e+001 0.0000e+000 0.0000e+000 4.7288e+016 16> p * A ans = 3.0000 6.0000 4.0000 2.0000 2.0000 20.0000 1.0000 1.0000 3.0000 17> % Quarteroni-Saleri, p. 147, Esempio 5.9 17> % sistema lineare mal condizionato 17> a = hilb(13); 18> cond(a) ans = 1.9487e+018 19> x = ones(13,1); 20> 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 21> % da completare la prossima volta, cioe' il 25/11/2011 21> quit