13-Nov-2013 1> edit horner.m 2> zeros(3,1) ans = 0 0 0 3> b = [1;2;3;4] b = 1 2 3 4 4> b(2) ans = 2 5> b(end) ans = 4 6> b(:) ans = 1 2 3 4 7> b(1:2) ans = 1 2 8> A = [1 2 3; 4 5 6] A = 1 2 3 4 5 6 9> A(:,2) ans = 2 5 10> A(1:2,2) ans = 2 5 11> A(2,:) ans = 4 5 6 12> A A = 1 2 3 4 5 6 13> A(2,1) ans = 4 14> help horner 'horner' is a function from the file C:\cygwin\home\achilles\programmi_matlab/Programmi_CS4a\horner.m HORNER Metodo di Horner Y=HORNER(A,Z) calcola Y = A(1)*Z^N + A(2)*Z^(N-1) + ... + A(N)*Z + A(N+1) con il metodo di divisione sintetica di Horner. 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. 15> a = [5 -1 7 -4]; 16> horner(a) error: 'z' undefined near line 12 column 23 error: called from: error: C:\cygwin\home\achilles\programmi_matlab/Programmi_CS4a\horner.m at line 12, column 9 16> horner(a, 3) ans = 143 17> help polyval 'polyval' is a function from the file C:\Octave\Octave3.6.4_gcc4.6.2\share\octave\3.6.4\m\polynomial\polyval.m -- Function File: Y = polyval (P, X) -- Function File: Y = polyval (P, X, [], MU) Evaluate the polynomial P at the specified values of X. When MU is present, evaluate the polynomial for (X-MU(1))/MU(2). If X is a vector or matrix, the polynomial is evaluated for each of the elements of X. -- Function File: [Y, DY] = polyval (P, X, S) -- Function File: [Y, DY] = polyval (P, X, S, MU) In addition to evaluating the polynomial, the second output represents the prediction interval, Y +/- DY, which contains at least 50% of the future predictions. To calculate the prediction interval, the structured variable S, originating from `polyfit', must be supplied. See also: polyvalm, polyaffine, polyfit, roots, poly 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. 18> polyval(a, 3) ans = 143 19> [y, b] = horner(a, 3) y = 143 b = 5 14 49 20> conv(b, [1 -3]) ans = 5 -1 7 -147 21> a a = 5 -1 7 -4 22> conv(b, [1 -3]) + [0 0 0 143] ans = 5 5 5 148 -1 -1 -1 142 7 7 7 150 -147 -147 -147 -4 23> conv(b, [1 -3]) ans = 5 -1 7 -147 24> conv(b, [1 -3]) + [0 0 0 143]' ans = 5 -1 7 -4 25> conv(b, [1 -3]) + 143 ans = 148 142 150 -4 26> p = [1 -6 11 -6] p = 1 -6 11 -6 27> [radici, iter] = newtonhorner(p, 4) radici = 3.00000 2.00000 1.00000 iter = 6 6 2 28> [radici, iter] = newtonhorner(p, 0) radici = 1.00000 2.00000 3.00000 iter = 6 6 2 29> quit